Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update soroban xdr #4704

Merged
merged 28 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e1409b6
Update xdr to 026c9cd074bdb28ddde8ee52f2a4502d9e518a09
Nov 29, 2022
4c615cc
gofmt
Nov 29, 2022
6ed69ef
updating soroban-rpc and horizon for new xdr
Nov 29, 2022
4e84d77
updating horizon operations processor for invoke host function op cha…
Nov 29, 2022
6df9f48
Calculate hash for install contract call
Nov 29, 2022
9f58c4c
Adding tests for new InvokeHostFuncionOp operations processor
Nov 29, 2022
8b00ced
Updating integration test
Nov 29, 2022
6844013
WIP -- trying to fix up horizon's integration tests for new xdr
Nov 29, 2022
1ce8e8c
Fix passphrase obtention in integration test
2opremio Nov 30, 2022
4893dcc
Update core version (with new XDR support)
2opremio Nov 30, 2022
00f8dde
Remove comment
2opremio Nov 30, 2022
670dfe8
Fix formatting
2opremio Nov 30, 2022
04d6cd4
Fix ledger key test
2opremio Nov 30, 2022
3884a81
Fix yet another ledger key test
2opremio Nov 30, 2022
4e17006
Fix yet more ledger key tests
2opremio Nov 30, 2022
ba70465
Fix state verifier test
2opremio Nov 30, 2022
9b7c284
Update stats processor
2opremio Nov 30, 2022
4f53164
(finally) Fix state verifier code
2opremio Nov 30, 2022
d4744d6
Update Core package/docker image
2opremio Nov 30, 2022
0ad5021
Fix soroban integration tests
2opremio Dec 1, 2022
01caf8a
Stop testing Soroban RPC here since it moved to https://github.com/st…
2opremio Dec 1, 2022
e2b9eb6
Bump test_add_u64 example
2opremio Dec 1, 2022
82f5564
empty commit to trigger GitHub actions
2opremio Dec 1, 2022
f97d2c5
Merge remote-tracking branch 'origin/soroban-xdr-next' into soroban-x…
2opremio Dec 1, 2022
eeec948
Regenerate XDR files
2opremio Dec 1, 2022
ef0280b
empty commit to trigger GitHub actions
2opremio Dec 1, 2022
7ec0cfd
Remove and regenerate the xdr/xdr_commit_generated.txt file
2opremio Dec 1, 2022
261f77f
Fix formatting
2opremio Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/horizon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
env:
HORIZON_INTEGRATION_TESTS_ENABLED: true
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.4.1-1097.4e813f20e.focal~soroban
PROTOCOL_20_CORE_DOCKER_IMG: sreuland/stellar-core:19.4.1-1097.4e813f20e.focal-soroban
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.5.1-1131.f55f88376.focal~soroban
PROTOCOL_20_CORE_DOCKER_IMG: 2opremio/stellar-core:19.5.1-1131.f55f88376.focal-soroban
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have these built somewhere official, not on just our personal dockerhubs... But that's not really an issue with this PR.

Copy link
Contributor

@2opremio 2opremio Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I didn't find a better way since the docker repo where builds are put is internal.

PROTOCOL_19_CORE_DEBIAN_PKG_VERSION: 19.4.0-1075.39bee1a2b.focal
PROTOCOL_19_CORE_DOCKER_IMG: stellar/stellar-core:19.4.0-1075.39bee1a2b.focal
PROTOCOL_18_CORE_DEBIAN_PKG_VERSION: 19.4.0-1075.39bee1a2b.focal
Expand Down
52 changes: 0 additions & 52 deletions .github/workflows/soroban-rpc.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ xdr/Stellar-contract.x \
xdr/Stellar-internal.x

XDRGEN_COMMIT=2864dda63ad8a5d3b0e33430fcd6093633ce8fac
XDRNEXT_COMMIT=d194cc6cd79e3b368c43477556b0084e81b9dcbc
XDRNEXT_COMMIT=026c9cd074bdb28ddde8ee52f2a4502d9e518a09

.PHONY: xdr xdr-clean xdr-update

Expand All @@ -40,7 +40,7 @@ gxdr/xdr_generated.go: $(XDRS)
go fmt $@

xdr/%.x:
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr-next/$(XDRNEXT_COMMIT)/$(@F)
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDRNEXT_COMMIT)/$(@F)

xdr/xdr_commit_generated.txt:
printf "%s" ${XDRNEXT_COMMIT} > xdr/xdr_commit_generated.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ func TestGetContractDataSucceeds(t *testing.T) {
assert.GreaterOrEqual(t, result.LatestLedger, result.LastModifiedLedger)
var scVal xdr.ScVal
assert.NoError(t, xdr.SafeUnmarshalBase64(result.XDR, &scVal))
assert.Equal(t, testContract, scVal.MustObj().MustContractCode().MustWasm())
assert.Equal(t, testContract, scVal.MustObj().MustContractCode().MustWasmId())
}
84 changes: 59 additions & 25 deletions exp/services/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,47 @@ var (
testSalt = sha256.Sum256([]byte("a1"))
)

// createInvokeHostOperation creates a dummy InvokeHostFunctionOp. In this case by installing a contract code.
func createInvokeHostOperation(t *testing.T, sourceAccount string, includeFootprint bool) *txnbuild.InvokeHostFunction {
contractNameParameterAddr := &xdr.ScObject{
Type: xdr.ScObjectTypeScoBytes,
Bin: &testContract,
}
contractNameParameter := xdr.ScVal{
Type: xdr.ScValTypeScvObject,
Obj: &contractNameParameterAddr,
}
return createInstallContractCodeOperation(t, sourceAccount, testContract, includeFootprint)
}

saltySlice := testSalt[:]
saltParameterAddr := &xdr.ScObject{
Type: xdr.ScObjectTypeScoBytes,
Bin: &saltySlice,
func createInstallContractCodeOperation(t *testing.T, sourceAccount string, contractCode []byte, includeFootprint bool) *txnbuild.InvokeHostFunction {
var footprint xdr.LedgerFootprint
if includeFootprint {
// TODO: Check this is still right
ledgerKey := xdr.LedgerKeyContractData{
ContractId: xdr.Hash(getContractID(t, sourceAccount, testSalt)),
Key: getContractCodeLedgerKey(),
}
footprint = xdr.LedgerFootprint{
ReadWrite: []xdr.LedgerKey{
{
Type: xdr.LedgerEntryTypeContractData,
ContractData: &ledgerKey,
},
},
}
}
saltParameter := xdr.ScVal{
Type: xdr.ScValTypeScvObject,
Obj: &saltParameterAddr,

return &txnbuild.InvokeHostFunction{
Footprint: footprint,
Function: xdr.HostFunction{
Type: xdr.HostFunctionTypeHostFunctionTypeInstallContractCode,
InstallContractCodeArgs: &xdr.InstallContractCodeArgs{
Code: contractCode,
},
},
SourceAccount: sourceAccount,
}
}

func createCreateContractOperation(t *testing.T, sourceAccount string, contractCode []byte, includeFootprint bool) *txnbuild.InvokeHostFunction {
saltParam := xdr.Uint256(testSalt)

var footprint xdr.LedgerFootprint
if includeFootprint {
// TODO: Check this is still right
ledgerKey := xdr.LedgerKeyContractData{
ContractId: xdr.Hash(getContractID(t, sourceAccount, testSalt)),
Key: getContractCodeLedgerKey(),
Expand All @@ -59,12 +78,25 @@ func createInvokeHostOperation(t *testing.T, sourceAccount string, includeFootpr
}
}

installContractCodeArgs, err := xdr.InstallContractCodeArgs{Code: contractCode}.MarshalBinary()
assert.NoError(t, err)
contractHash := xdr.Hash(sha256.Sum256(installContractCodeArgs))

// two operations, install, then create.
return &txnbuild.InvokeHostFunction{
Footprint: footprint,
Function: xdr.HostFunctionHostFnCreateContractWithSourceAccount,
Parameters: xdr.ScVec{
contractNameParameter,
saltParameter,
Function: xdr.HostFunction{
Type: xdr.HostFunctionTypeHostFunctionTypeCreateContract,
CreateContractArgs: &xdr.CreateContractArgs{
ContractId: xdr.ContractId{
Type: xdr.ContractIdTypeContractIdFromSourceAccount,
Salt: &saltParam,
},
Source: xdr.ScContractCode{
Type: xdr.ScContractCodeTypeSccontractCodeWasmRef,
WasmId: &contractHash,
},
},
},
SourceAccount: sourceAccount,
}
Expand Down Expand Up @@ -106,9 +138,11 @@ func TestSimulateTransactionSucceeds(t *testing.T) {
Sequence: 0,
},
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{createInvokeHostOperation(t, sourceAccount, false)},
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Operations: []txnbuild.Operation{
createInvokeHostOperation(t, sourceAccount, false),
},
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Preconditions: txnbuild.Preconditions{
TimeBounds: txnbuild.NewInfiniteTimeout(),
},
Expand Down Expand Up @@ -201,7 +235,7 @@ func TestSimulateTransactionError(t *testing.T) {

sourceAccount := keypair.Root(StandaloneNetworkPassphrase).Address()
invokeHostOp := createInvokeHostOperation(t, sourceAccount, false)
invokeHostOp.Parameters = invokeHostOp.Parameters[:len(invokeHostOp.Parameters)-1]
invokeHostOp.Function.InstallContractCodeArgs = nil
tx, err := txnbuild.NewTransaction(txnbuild.TransactionParams{
SourceAccount: &txnbuild.SimpleAccount{
AccountID: keypair.Root(StandaloneNetworkPassphrase).Address(),
Expand Down Expand Up @@ -242,8 +276,8 @@ func TestSimulateTransactionMultipleOperations(t *testing.T) {
},
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{
createInvokeHostOperation(t, sourceAccount, false),
createInvokeHostOperation(t, sourceAccount, false),
createInstallContractCodeOperation(t, sourceAccount, testContract, false),
createCreateContractOperation(t, sourceAccount, testContract, false),
},
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Expand Down
Loading