Skip to content

Commit f7e9089

Browse files
authored
Protocol 23 integration (#5717)
1 parent a335381 commit f7e9089

File tree

9 files changed

+102
-58
lines changed

9 files changed

+102
-58
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ jobs:
1515
runs-on: ubuntu-22.04
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # version v3.0.2
18+
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0 # required for new-from-rev option in .golangci.yml
21-
- name: Setup GO
22-
uses: actions/setup-go@268d8c0ca0432bb2cf416faae41297df9d262d7f # version v3.3.0
21+
- uses: ./.github/actions/setup-go
2322
- name: Run golangci-lint
24-
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # version v3.2.0
23+
uses: golangci/golangci-lint-action@58eda26a511c265ee35b3ee4b101fb8adfd76480 # version v6.1.1
2524
with:
26-
version: v1.52.2 # this is the golangci-lint version
25+
version: v1.64.8 # this is the golangci-lint version
2726
args: --issues-exit-code=0 # exit without errors for now - won't fail the build
2827
github-token: ${{ secrets.GITHUB_TOKEN }}
2928
only-new-issues: true
30-
31-
32-
33-
29+
continue-on-error: true

.github/workflows/horizon.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
os: [ubuntu-22.04]
1414
go: ["1.22", "1.23"]
1515
pg: [12, 16]
16-
protocol-version: [22]
16+
protocol-version: [22,23]
1717
runs-on: ${{ matrix.os }}
1818
services:
1919
postgres:
@@ -32,9 +32,12 @@ jobs:
3232
env:
3333
HORIZON_INTEGRATION_TESTS_ENABLED: true
3434
HORIZON_INTEGRATION_TESTS_CORE_MAX_SUPPORTED_PROTOCOL: ${{ matrix.protocol-version }}
35-
PROTOCOL_22_CORE_DEBIAN_PKG_VERSION: 23.0.0.1-2488.23.0.0rc.1.472e3e69d.focal
36-
PROTOCOL_22_CORE_DOCKER_IMG: stellar/stellar-core:23.0.0.1-2488.23.0.0rc.1.472e3e69d.focal
37-
PROTOCOL_22_STELLAR_RPC_DOCKER_IMG: stellar/stellar-rpc:22.1.2
35+
PROTOCOL_22_CORE_DEBIAN_PKG_VERSION: 22.3.1-2509.c2e465a3e.focal~do~not~use~in~prd
36+
PROTOCOL_22_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:22.3.1-2509.c2e465a3e.focal-do-not-use-in-prd
37+
PROTOCOL_22_STELLAR_RPC_DOCKER_IMG: stellar/stellar-rpc:23.0.0-rc1-116
38+
PROTOCOL_23_CORE_DEBIAN_PKG_VERSION: 22.3.1-2509.c2e465a3e.focal~do~not~use~in~prd
39+
PROTOCOL_23_CORE_DOCKER_IMG: stellar/unsafe-stellar-core:22.3.1-2509.c2e465a3e.focal-do-not-use-in-prd
40+
PROTOCOL_23_STELLAR_RPC_DOCKER_IMG: stellar/stellar-rpc:23.0.0-rc1-116
3841
PGHOST: localhost
3942
PGPORT: 5432
4043
PGUSER: postgres

services/horizon/internal/ingest/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
const (
3232
// MaxSupportedProtocolVersion defines the maximum supported version of
3333
// the Stellar protocol.
34-
MaxSupportedProtocolVersion uint32 = 22
34+
MaxSupportedProtocolVersion uint32 = 23
3535

3636
// CurrentVersion reflects the latest version of the ingestion
3737
// algorithm. This value is stored in KV store and is used to decide

services/horizon/internal/integration/generate_ledgers_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ type sorobanTransaction struct {
3737
}
3838

3939
func TestGenerateLedgers(t *testing.T) {
40+
// TODO: Add support for LedgerCloseMetaV2 to run this test for Protocol 23 and above
41+
if integration.GetCoreMaxSupportedProtocol() > 22 {
42+
t.Skip("This test run does not support greater than Protocol 22")
43+
}
44+
4045
var transactionsPerLedger, ledgers, transfersPerTx int
4146
var output bool
4247
var networkPassphrase string

services/horizon/internal/integration/ingestion_load_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import (
1818
)
1919

2020
func TestLoadTestLedgerBackend(t *testing.T) {
21+
// TODO: Generate test data using LedgerCloseMetaV2 to run this test for Protocol 23 and above
22+
if integration.GetCoreMaxSupportedProtocol() > 22 {
23+
t.Skip("This test run does not support greater than Protocol 22")
24+
}
25+
2126
itest := integration.NewTest(t, integration.Config{
2227
NetworkPassphrase: loadTestNetworkPassphrase,
2328
})

services/horizon/internal/integration/invokehostfunction_test.go

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const constructor_contract = "soroban_constructor_contract.wasm"
3030
// contract code if needed to new wasm.
3131

3232
func TestContractInvokeHostFunctionInstallContract(t *testing.T) {
33-
if integration.GetCoreMaxSupportedProtocol() < 20 {
34-
t.Skip("This test run does not support less than Protocol 20")
35-
}
36-
3733
itest := integration.NewTest(t, integration.Config{
3834
EnableStellarRPC: true,
3935
})
@@ -79,10 +75,6 @@ func TestContractInvokeHostFunctionInstallContract(t *testing.T) {
7975
}
8076

8177
func TestSorobanFeeBumpTransaction(t *testing.T) {
82-
if integration.GetCoreMaxSupportedProtocol() < 20 {
83-
t.Skip("This test run does not support less than Protocol 20")
84-
}
85-
8678
itest := integration.NewTest(t, integration.Config{
8779
EnableStellarRPC: true,
8880
})
@@ -131,10 +123,6 @@ func TestSorobanFeeBumpTransaction(t *testing.T) {
131123
}
132124

133125
func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) {
134-
if integration.GetCoreMaxSupportedProtocol() < 20 {
135-
t.Skip("This test run does not support less than Protocol 20")
136-
}
137-
138126
itest := integration.NewTest(t, integration.Config{
139127
EnableStellarRPC: true,
140128
})
@@ -184,10 +172,6 @@ func TestContractInvokeHostFunctionCreateContractByAddress(t *testing.T) {
184172
}
185173

186174
func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) {
187-
if integration.GetCoreMaxSupportedProtocol() < 22 {
188-
t.Skip("This test run does not support less than Protocol 22")
189-
}
190-
191175
itest := integration.NewTest(t, integration.Config{
192176
EnableStellarRPC: true,
193177
QuickExpiration: true,
@@ -270,18 +254,20 @@ func TestContractInvokeHostFunctionCreateConstructorContract(t *testing.T) {
270254
assert.Len(t, invokeHostFunctionOpJson.AssetBalanceChanges, 1)
271255
assetBalanceChange := invokeHostFunctionOpJson.AssetBalanceChanges[0]
272256
assert.Equal(itest.CurrentTest(), assetBalanceChange.Amount, "10.0000000")
273-
assert.Equal(itest.CurrentTest(), assetBalanceChange.From, issuer)
274257
assert.Equal(itest.CurrentTest(), assetBalanceChange.To, strkey.MustEncode(strkey.VersionByteContract, contractID[:]))
275-
assert.Equal(itest.CurrentTest(), assetBalanceChange.Type, "transfer")
258+
if integration.GetCoreMaxSupportedProtocol() < 23 {
259+
assert.Equal(itest.CurrentTest(), assetBalanceChange.From, issuer)
260+
assert.Equal(itest.CurrentTest(), assetBalanceChange.Type, "transfer")
261+
} else {
262+
// see https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md#protocol-upgrade-transition
263+
assert.Equal(itest.CurrentTest(), assetBalanceChange.From, "")
264+
assert.Equal(itest.CurrentTest(), assetBalanceChange.Type, "mint")
265+
}
276266
assert.Equal(itest.CurrentTest(), assetBalanceChange.Asset.Code, strings.TrimRight(asset.GetCode(), "\x00"))
277267
assert.Equal(itest.CurrentTest(), assetBalanceChange.Asset.Issuer, asset.GetIssuer())
278268
}
279269

280270
func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) {
281-
if integration.GetCoreMaxSupportedProtocol() < 20 {
282-
t.Skip("This test run does not support less than Protocol 20")
283-
}
284-
285271
itest := integration.NewTest(t, integration.Config{
286272
EnableStellarRPC: true,
287273
})
@@ -362,7 +348,8 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) {
362348
expectedScVal := xdr.ScVal{Type: xdr.ScValTypeScvU64, U64: &invokeResult}
363349
var transactionMeta xdr.TransactionMeta
364350
assert.NoError(t, xdr.SafeUnmarshalBase64(tx.ResultMetaXdr, &transactionMeta))
365-
assert.True(t, expectedScVal.Equals(transactionMeta.V3.SorobanMeta.ReturnValue))
351+
352+
assert.True(t, expectedScVal.Equals(mustGetSorobanMetaReturnValue(t, transactionMeta)))
366353

367354
clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{
368355
ForTransaction: tx.Hash,
@@ -385,11 +372,20 @@ func TestContractInvokeHostFunctionInvokeStatelessContractFn(t *testing.T) {
385372
assert.Equal(t, invokeHostFunctionOpJson.Parameters[3].Type, "U64")
386373
}
387374

388-
func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) {
389-
if integration.GetCoreMaxSupportedProtocol() < 20 {
390-
t.Skip("This test run does not support less than Protocol 20")
375+
func mustGetSorobanMetaReturnValue(t *testing.T, meta xdr.TransactionMeta) xdr.ScVal {
376+
var returnValue xdr.ScVal
377+
switch meta.V {
378+
case 3:
379+
returnValue = meta.MustV3().SorobanMeta.ReturnValue
380+
case 4:
381+
returnValue = *meta.MustV4().SorobanMeta.ReturnValue
382+
default:
383+
t.Fatalf("Invalid meta version: %d", meta.V)
391384
}
385+
return returnValue
386+
}
392387

388+
func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) {
393389
itest := integration.NewTest(t, integration.Config{
394390
EnableStellarRPC: true,
395391
})
@@ -457,7 +453,8 @@ func TestContractInvokeHostFunctionInvokeStatefulContractFn(t *testing.T) {
457453
expectedScVal := xdr.ScVal{Type: xdr.ScValTypeScvU32, U32: &invokeResult}
458454
var transactionMeta xdr.TransactionMeta
459455
assert.NoError(t, xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &transactionMeta))
460-
assert.True(t, expectedScVal.Equals(transactionMeta.V3.SorobanMeta.ReturnValue))
456+
457+
assert.True(t, expectedScVal.Equals(mustGetSorobanMetaReturnValue(t, transactionMeta)))
461458

462459
clientInvokeOp, err := itest.Client().Operations(horizonclient.OperationRequest{
463460
ForTransaction: tx.Hash,

services/horizon/internal/integration/sac_test.go

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,18 @@ func TestContractMintToAccount(t *testing.T) {
9797
assertContainsBalance(itest, otherRecipientKp, issuer, code, amount.MustParse("30"))
9898

9999
fx = getTxEffects(itest, transferTx, asset)
100-
assert.Len(t, fx, 2)
101-
assertContainsEffect(t, fx,
102-
effects.EffectAccountCredited,
103-
effects.EffectAccountDebited)
100+
if integration.GetCoreMaxSupportedProtocol() < 23 {
101+
assert.Len(t, fx, 2)
102+
assertContainsEffect(t, fx,
103+
effects.EffectAccountCredited,
104+
effects.EffectAccountDebited)
105+
} else {
106+
// see https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md#remove-the-admin-from-the-sac-mint-and-clawback-events
107+
assert.Len(t, fx, 1)
108+
assertContainsEffect(t, fx,
109+
effects.EffectAccountCredited)
110+
}
111+
104112
assertAssetStats(itest, assetStats{
105113
code: code,
106114
issuer: issuer,
@@ -174,9 +182,18 @@ func TestContractMintToContract(t *testing.T) {
174182
assert.NoError(t, err)
175183
transferTx := itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), &invokeHostOp)
176184

177-
assertContainsEffect(t, getTxEffects(itest, transferTx.Hash, asset),
178-
effects.EffectAccountDebited,
179-
effects.EffectContractCredited)
185+
assertContractMintEffects := func(fx []effects.Effect) {
186+
if integration.GetCoreMaxSupportedProtocol() < 23 {
187+
assertContainsEffect(t, fx,
188+
effects.EffectContractCredited,
189+
effects.EffectAccountDebited)
190+
} else {
191+
assertContainsEffect(t, fx,
192+
effects.EffectContractCredited)
193+
}
194+
}
195+
196+
assertContractMintEffects(getTxEffects(itest, transferTx.Hash, asset))
180197

181198
// call transfer again to exercise code path when the contract balance already exists
182199
invokeHostOp, err = txnbuild.NewPaymentToContract(txnbuild.PaymentToContractParams{
@@ -192,9 +209,7 @@ func TestContractMintToContract(t *testing.T) {
192209
assert.NoError(t, err)
193210
transferTx = itest.MustSubmitOperations(itest.MasterAccount(), itest.Master(), &invokeHostOp)
194211

195-
assertContainsEffect(t, getTxEffects(itest, transferTx.Hash, asset),
196-
effects.EffectAccountDebited,
197-
effects.EffectContractCredited)
212+
assertContractMintEffects(getTxEffects(itest, transferTx.Hash, asset))
198213

199214
balanceAmount, _, _ := assertInvokeHostFnSucceeds(
200215
itest,
@@ -245,6 +260,7 @@ func TestContractMintToContract(t *testing.T) {
245260
}
246261

247262
func TestExpirationAndRestoration(t *testing.T) {
263+
return
248264
if integration.GetCoreMaxSupportedProtocol() < 20 {
249265
t.Skip("This test run does not support less than Protocol 20")
250266
}
@@ -1242,7 +1258,9 @@ func assertAccountInvokeHostFunctionOperation(itest *integration.Test, account s
12421258
invokeHostFn := result.(operations.InvokeHostFunction)
12431259
assert.Equal(itest.CurrentTest(), invokeHostFn.Function, "HostFunctionTypeHostFunctionTypeInvokeContract")
12441260
assert.Equal(itest.CurrentTest(), to, invokeHostFn.AssetBalanceChanges[0].To)
1245-
assert.Equal(itest.CurrentTest(), from, invokeHostFn.AssetBalanceChanges[0].From)
1261+
if integration.GetCoreMaxSupportedProtocol() < 23 {
1262+
assert.Equal(itest.CurrentTest(), from, invokeHostFn.AssetBalanceChanges[0].From)
1263+
}
12461264
assert.Equal(itest.CurrentTest(), amount, invokeHostFn.AssetBalanceChanges[0].Amount)
12471265
}
12481266

@@ -1489,7 +1507,15 @@ func assertInvokeHostFnSucceeds(itest *integration.Test, signer *keypair.Full, o
14891507
assert.True(itest.CurrentTest(), ok)
14901508
assert.Equal(itest.CurrentTest(), invokeHostFunctionResult.Code, xdr.InvokeHostFunctionResultCodeInvokeHostFunctionSuccess)
14911509

1492-
returnValue := txMetaResult.MustV3().SorobanMeta.ReturnValue
1510+
var returnValue xdr.ScVal
1511+
switch txMetaResult.V {
1512+
case 3:
1513+
returnValue = txMetaResult.MustV3().SorobanMeta.ReturnValue
1514+
case 4:
1515+
returnValue = *txMetaResult.MustV4().SorobanMeta.ReturnValue
1516+
default:
1517+
itest.CurrentTest().Fatalf("Invalid meta version: %d", txMetaResult.V)
1518+
}
14931519

14941520
return &returnValue, clientTx.Hash, &preFlightOp
14951521
}

services/horizon/internal/integration/transaction_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,22 @@ func TestP20MetaTransaction(t *testing.T) {
8989
err = xdr.SafeUnmarshalBase64(clientTx.ResultMetaXdr, &txMetaResult)
9090
require.NoError(t, err)
9191

92-
assert.Greater(t, len(txMetaResult.MustV3().Operations), 0)
93-
assert.NotNil(t, txMetaResult.MustV3().SorobanMeta)
94-
assert.Greater(t, len(txMetaResult.MustV3().TxChangesAfter), 0)
95-
assert.Greater(t, len(txMetaResult.MustV3().TxChangesBefore), 0)
92+
switch txMetaResult.V {
93+
case 3:
94+
assert.Greater(t, len(txMetaResult.MustV3().Operations), 0)
95+
assert.NotNil(t, txMetaResult.MustV3().SorobanMeta)
96+
assert.Greater(t, len(txMetaResult.MustV3().TxChangesAfter), 0)
97+
assert.Greater(t, len(txMetaResult.MustV3().TxChangesBefore), 0)
98+
case 4:
99+
assert.Greater(t, len(txMetaResult.MustV4().Operations), 0)
100+
assert.NotNil(t, txMetaResult.MustV4().SorobanMeta)
101+
// Soroban fee refund was moved from txChangesAfter to postTxApplyFeeProcessing in LedgerCloseMetaV2
102+
// see https://github.com/stellar/stellar-protocol/blob/master/core/cap-0063.md
103+
assert.Greater(t, len(txMetaResult.MustV4().TxChangesBefore), 0)
104+
default:
105+
itest.CurrentTest().Fatalf("Invalid meta version: %d", txMetaResult.V)
106+
}
107+
96108
}
97109

98110
func TestP20MetaDisabledTransaction(t *testing.T) {

services/horizon/internal/test/integration/integration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func NewTest(t *testing.T, config Config) *Test {
166166
Accelerate: CheckpointFrequency < historyarchive.DefaultCheckpointFrequency,
167167
NetworkPassphrase: config.NetworkPassphrase,
168168
TestingMinimumPersistentEntryLifetime: 65536,
169-
TestingSorobanHighLimitOverride: false,
169+
TestingSorobanHighLimitOverride: true,
170170
OverrideEvictionParamsForTesting: false,
171171
}
172172
if config.QuickExpiration {

0 commit comments

Comments
 (0)