diff --git a/.github/actions/setup-sui/action.yml b/.github/actions/setup-sui/action.yml index edfb96b6c..117134031 100644 --- a/.github/actions/setup-sui/action.yml +++ b/.github/actions/setup-sui/action.yml @@ -2,9 +2,9 @@ name: Setup Sui CLI description: Install and cache Sui CLI using suiup inputs: version: - description: Sui CLI version to install (e.g., mainnet-v1.67.3) + description: Sui CLI version to install (e.g., mainnet-v1.69.2) required: false - default: mainnet-v1.67.3 + default: mainnet-v1.69.2 runs: using: composite diff --git a/.github/workflows/sui-ccip-test.yml b/.github/workflows/sui-ccip-test.yml index adecf078f..23b133f03 100644 --- a/.github/workflows/sui-ccip-test.yml +++ b/.github/workflows/sui-ccip-test.yml @@ -20,41 +20,41 @@ jobs: matrix: include: - test_name: Test_CCIP_Messaging_Sui2EVM - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_Messaging_EVM2Sui - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_EVM2Sui_ZeroReceiver - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_LockReleaseTokenPool - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_WithRateLimit - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_WithAllowlist - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_BurnMintTokenPool_ThenGloballyCursedUncursed - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIPTokenTransfer_Sui2EVM_ManagedTokenPool_ThenCurseUncurse - sui_version: mainnet-v1.67.3 - - test_name: Test_CCIPTokenTransfer_SUI2EVM_ManagedTokenPool_WithRateLimit - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 + - test_name: Test_CCIPTokenTransfer_Sui2EVM_ManagedTokenPool_WithRateLimit + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_Upgrade_Sui2EVM - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_Upgrade_EVM2Sui - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_Upgrade_CommonPkg_EVM2Sui - sui_version: mainnet-v1.67.3 + sui_version: mainnet-v1.69.2 - test_name: Test_CCIP_Upgrade_NoBlock_EVM2Sui - sui_version: mainnet-v1.67.3 - # - test_name: Test_CCIPTokenTransfer_EVM2SUI_BurnMintTokenPool - # sui_version: mainnet-v1.57.2 - # - test_name: Test_CCIPPureTokenTransfer_EVM2SUI_BurnMintTokenPool - # sui_version: mainnet-v1.57.2 - # - test_name: Test_CCIPProgrammableTokenTransfer_EVM2SUI_BurnMintTokenPool - # sui_version: mainnet-v1.57.2 - # - test_name: Test_CCIPZeroGasLimitTokenTransfer_EVM2SUI_BurnMintTokenPool - # sui_version: mainnet-v1.57.2 + sui_version: mainnet-v1.69.2 + - test_name: Test_CCIPTokenTransfer_EVM2Sui_BurnMintTokenPool + sui_version: mainnet-v1.69.2 + - test_name: Test_CCIPPureTokenTransfer_EVM2Sui_BurnMintTokenPool + sui_version: mainnet-v1.69.2 + - test_name: Test_CCIPProgrammableTokenTransfer_EVM2Sui_BurnMintTokenPool + sui_version: mainnet-v1.69.2 + - test_name: Test_CCIPZeroGasLimitTokenTransfer_EVM2Sui_BurnMintTokenPool + sui_version: mainnet-v1.69.2 env: DEFAULT_CORE_REF: develop diff --git a/contracts/test/Move.lock b/contracts/test/Move.lock new file mode 100644 index 000000000..87a9b8bc6 --- /dev/null +++ b/contracts/test/Move.lock @@ -0,0 +1,77 @@ +# Generated by move; do not edit +# This file should be checked in. + +[move] +version = 4 + +[pinned.local.MoveStdlib] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "local" +manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363" +deps = {} + +[pinned.local.Sui] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "local" +manifest_digest = "98EF265044695258DF77084171BC5CCC94248AEEC2463AF6274326433A1512BA" +deps = { MoveStdlib = "MoveStdlib" } + +[pinned.local.test] +source = { root = true } +use_environment = "local" +manifest_digest = "4ED73376CE4715AD6C0F6AF3CC7AB9E26B4759A5F31352D0716A5FD6EC6E61F5" +deps = { std = "MoveStdlib", sui = "Sui", test_secondary = "test_secondary" } + +[pinned.local.test_secondary] +source = { local = "../test_secondary" } +use_environment = "local" +manifest_digest = "5F75228E403340DD70556AFD567899C8C2E4BB556771AF4C11F408D875984A08" +deps = { std = "MoveStdlib", sui = "Sui" } + +[pinned.local_9a32b313.MoveStdlib] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "local_9a32b313" +manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363" +deps = {} + +[pinned.local_9a32b313.Sui] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "local_9a32b313" +manifest_digest = "1351CA615D5B149A79F70C9B1A81F81C63785726AD1407C3909489451B7B6511" +deps = { MoveStdlib = "MoveStdlib" } + +[pinned.local_9a32b313.test] +source = { root = true } +use_environment = "local_9a32b313" +manifest_digest = "A7B8056EE3CFE149AD5B199BDDAF988579BADD2A8E134BA38CD11D019B21A3B7" +deps = { std = "MoveStdlib", sui = "Sui", test_secondary = "test_secondary" } + +[pinned.local_9a32b313.test_secondary] +source = { local = "../test_secondary" } +use_environment = "local_9a32b313" +manifest_digest = "EB78069460D8F989E2D61A6E191C1620B8E678A580A6D038670FD08D974DA704" +deps = { std = "MoveStdlib", sui = "Sui" } + +[pinned.testnet.MoveStdlib] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "testnet" +manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363" +deps = {} + +[pinned.testnet.Sui] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "c2428b3aaf9c24270b609001e56d96cb10c76d28" } +use_environment = "testnet" +manifest_digest = "7AFB66695545775FBFBB2D3078ADFD084244D5002392E837FDE21D9EA1C6D01C" +deps = { MoveStdlib = "MoveStdlib" } + +[pinned.testnet.test] +source = { root = true } +use_environment = "testnet" +manifest_digest = "5B34CE8FD6BAA0524CBA26CBF0BB0A655056EF6526BE5AC719B80ECB56AD43A5" +deps = { std = "MoveStdlib", sui = "Sui", test_secondary = "test_secondary" } + +[pinned.testnet.test_secondary] +source = { local = "../test_secondary" } +use_environment = "testnet" +manifest_digest = "5745706258F61D6CE210904B3E6AE87A73CE9D31A6F93BE4718C442529332A87" +deps = { std = "MoveStdlib", sui = "Sui" } diff --git a/contracts/test/Move.toml b/contracts/test/Move.toml index 9383fe257..134943e37 100644 --- a/contracts/test/Move.toml +++ b/contracts/test/Move.toml @@ -3,8 +3,9 @@ local = '../test_secondary' [environments] + local_9a32b313 = '9a32b313' devnet = 'a9149565' - local = '92d92e5c' + local = '9a32b313' [package] edition = '2024' diff --git a/contracts/test/Published.toml b/contracts/test/Published.toml index ca6bc0320..e69de29bb 100644 --- a/contracts/test/Published.toml +++ b/contracts/test/Published.toml @@ -1 +0,0 @@ -[published] diff --git a/contracts/test_secondary/Move.lock b/contracts/test_secondary/Move.lock new file mode 100644 index 000000000..d434a93ee --- /dev/null +++ b/contracts/test_secondary/Move.lock @@ -0,0 +1,23 @@ +# Generated by move; do not edit +# This file should be checked in. + +[move] +version = 4 + +[pinned.local.MoveStdlib] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "85400e2bd37b490fcd057776e700d3fdca643396" } +use_environment = "local" +manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363" +deps = {} + +[pinned.local.Sui] +source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "85400e2bd37b490fcd057776e700d3fdca643396" } +use_environment = "local" +manifest_digest = "98EF265044695258DF77084171BC5CCC94248AEEC2463AF6274326433A1512BA" +deps = { MoveStdlib = "MoveStdlib" } + +[pinned.local.test_secondary] +source = { root = true } +use_environment = "local" +manifest_digest = "5F75228E403340DD70556AFD567899C8C2E4BB556771AF4C11F408D875984A08" +deps = { std = "MoveStdlib", sui = "Sui" } diff --git a/contracts/test_secondary/Move.toml b/contracts/test_secondary/Move.toml index 5cf208dac..c4c95835b 100644 --- a/contracts/test_secondary/Move.toml +++ b/contracts/test_secondary/Move.toml @@ -1,6 +1,7 @@ [environments] + local_9a32b313 = '9a32b313' devnet = 'a9149565' - local = '92d92e5c' + local = '9a32b313' [package] edition = '2024' diff --git a/contracts/test_secondary/Published.toml b/contracts/test_secondary/Published.toml index ca6bc0320..e69de29bb 100644 --- a/contracts/test_secondary/Published.toml +++ b/contracts/test_secondary/Published.toml @@ -1 +0,0 @@ -[published] diff --git a/deployment/go.mod b/deployment/go.mod index ff66ec1b9..ce4c7136f 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -9,7 +9,7 @@ replace github.com/smartcontractkit/chainlink-sui => ../ require ( github.com/Masterminds/semver/v3 v3.4.0 - github.com/block-vision/sui-go-sdk v1.1.4 + github.com/block-vision/sui-go-sdk v1.2.1 github.com/ethereum/go-ethereum v1.17.1 github.com/google/go-cmp v0.7.0 github.com/smartcontractkit/chain-selectors v1.0.97 diff --git a/deployment/go.sum b/deployment/go.sum index b255033c6..0562c1305 100644 --- a/deployment/go.sum +++ b/deployment/go.sum @@ -72,8 +72,8 @@ github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3M github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= -github.com/block-vision/sui-go-sdk v1.1.4 h1:1PPgYxQjo1P9UCgFOPTvDCuGEglRL32NwjKPulR4FQk= -github.com/block-vision/sui-go-sdk v1.1.4/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= +github.com/block-vision/sui-go-sdk v1.2.1 h1:uwvGbzfcrS4SsIaakclYxy0qgEF1XWIUtTYWXB4PoAw= +github.com/block-vision/sui-go-sdk v1.2.1/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= diff --git a/docker-compose.yml b/docker-compose.yml index 67257a88d..c0724b84e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: sui: - image: mysten/sui-tools:mainnet-v1.67.3 + image: mysten/sui-tools:mainnet-v1.69.2 ports: - "9000:9000" command: ["sui", "start"] diff --git a/go.mod b/go.mod index c81b67a25..c76bf7b54 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ replace github.com/fbsobreira/gotron-sdk => github.com/smartcontractkit/chainlin require ( github.com/aptos-labs/aptos-go-sdk v1.7.1-0.20250602153733-bb1facae1d43 github.com/aptos-labs/tree-sitter-move-on-aptos v0.0.0-20250321090037-c820eb4716e1 - github.com/block-vision/sui-go-sdk v1.1.3 + github.com/block-vision/sui-go-sdk v1.2.1 github.com/ethereum/go-ethereum v1.16.2 github.com/google/uuid v1.6.0 github.com/hashicorp/go-plugin v1.7.0 diff --git a/go.sum b/go.sum index 24a512320..370fd9345 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/block-vision/sui-go-sdk v1.1.3 h1:aqB9EYAccy5x3SN3gTxfSwQSJ0HnQDLlhRCi9PzBLyM= -github.com/block-vision/sui-go-sdk v1.1.3/go.mod h1:dhKcdEPKH6PyzWY16XlrTgTbC3gL8/zd1FPIj2rdRBg= +github.com/block-vision/sui-go-sdk v1.2.1 h1:uwvGbzfcrS4SsIaakclYxy0qgEF1XWIUtTYWXB4PoAw= +github.com/block-vision/sui-go-sdk v1.2.1/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 19801a418..75b6530ee 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -3,7 +3,7 @@ module github.com/smartcontractkit/chainlink-sui/integration-tests go 1.25.5 require ( - github.com/block-vision/sui-go-sdk v1.1.4 + github.com/block-vision/sui-go-sdk v1.2.1 github.com/ethereum/go-ethereum v1.17.1 github.com/holiman/uint256 v1.3.2 github.com/smartcontractkit/chain-selectors v1.0.97 diff --git a/integration-tests/go.sum b/integration-tests/go.sum index f89b19983..8eae0d4a2 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -72,8 +72,8 @@ github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3M github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= -github.com/block-vision/sui-go-sdk v1.1.4 h1:1PPgYxQjo1P9UCgFOPTvDCuGEglRL32NwjKPulR4FQk= -github.com/block-vision/sui-go-sdk v1.1.4/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= +github.com/block-vision/sui-go-sdk v1.2.1 h1:uwvGbzfcrS4SsIaakclYxy0qgEF1XWIUtTYWXB4PoAw= +github.com/block-vision/sui-go-sdk v1.2.1/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= diff --git a/relayer/chainreader/indexer/events_indexer_test.go b/relayer/chainreader/indexer/events_indexer_test.go index b3bdb7637..20acbe7cc 100644 --- a/relayer/chainreader/indexer/events_indexer_test.go +++ b/relayer/chainreader/indexer/events_indexer_test.go @@ -80,8 +80,7 @@ func TestEventsIndexer(t *testing.T) { chainID, err := testutils.GetChainIdentifier(testutils.LocalUrl) require.NoError(t, err) testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) - - // testutils.PatchContractAddressTOML(t, "contracts/test", "test_secondary", "_") + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) contractPath := testutils.BuildSetup(t, "contracts/test") gasBudget := int(2000000000) diff --git a/relayer/chainreader/indexer/transactions_indexer_test.go b/relayer/chainreader/indexer/transactions_indexer_test.go index 05ec668d9..5d8aba87e 100644 --- a/relayer/chainreader/indexer/transactions_indexer_test.go +++ b/relayer/chainreader/indexer/transactions_indexer_test.go @@ -90,6 +90,11 @@ func TestTransactionsIndexer(t *testing.T) { relayerClient, err := client.NewPTBClient(log, testutils.LocalUrl, nil, 10*time.Second, keystoreInstance, 5, "WaitForLocalExecution") require.NoError(t, err) + chainID, chainIDErr := testutils.GetChainIdentifier(testutils.LocalUrl) + require.NoError(t, chainIDErr) + testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) + contractPath := testutils.BuildSetup(t, "contracts/test") gasBudget := int(2000000000) packageId, tx, err := testutils.PublishContract(t, "counter", contractPath, accountAddress, &gasBudget) diff --git a/relayer/chainreader/loop/loop_reader_test.go b/relayer/chainreader/loop/loop_reader_test.go index 71f1fe22c..a1d0e35ab 100644 --- a/relayer/chainreader/loop/loop_reader_test.go +++ b/relayer/chainreader/loop/loop_reader_test.go @@ -67,6 +67,11 @@ func runLoopChainReaderEchoTest(t *testing.T, log logger.Logger, rpcUrl string) faucetFundErr := testutils.FundWithFaucet(log, testutils.SuiLocalnet, accountAddress) require.NoError(t, faucetFundErr) + chainID, err := testutils.GetChainIdentifier(rpcUrl) + require.NoError(t, err) + testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) + contractPath := testutils.BuildSetup(t, "contracts/test") gasBudget := int(2000000000) packageId, tx, err := testutils.PublishContract(t, "counter", contractPath, accountAddress, &gasBudget) diff --git a/relayer/chainreader/reader/chainreader_local_test.go b/relayer/chainreader/reader/chainreader_local_test.go index e5e636cd4..a74b0ae62 100644 --- a/relayer/chainreader/reader/chainreader_local_test.go +++ b/relayer/chainreader/reader/chainreader_local_test.go @@ -81,6 +81,11 @@ func runChainReaderCounterTest(t *testing.T, log logger.Logger, rpcUrl string) { faucetFundErr := testutils.FundWithFaucet(log, testutils.SuiLocalnet, accountAddress) require.NoError(t, faucetFundErr) + chainID, chainIDErr := testutils.GetChainIdentifier(rpcUrl) + require.NoError(t, chainIDErr) + testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) + // Publish test_secondary first (before counter, since counter depends on it) gasBudget := int(2000000000) contractPath := testutils.BuildSetup(t, "contracts/test_secondary") diff --git a/relayer/chainwriter/ptb/ptb_constructor_test.go b/relayer/chainwriter/ptb/ptb_constructor_test.go index 63b9f7caf..e77c3837e 100644 --- a/relayer/chainwriter/ptb/ptb_constructor_test.go +++ b/relayer/chainwriter/ptb/ptb_constructor_test.go @@ -71,6 +71,11 @@ func setupTestEnvironment(t *testing.T) ( relayerClient, err = client.NewPTBClient(log, testutils.LocalUrl, nil, 10*time.Second, keystoreInstance, 5, "WaitForLocalExecution") require.NoError(t, err) + chainID, chainIDErr := testutils.GetChainIdentifier(testutils.LocalUrl) + require.NoError(t, chainIDErr) + testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) + contractPath := testutils.BuildSetup(t, "contracts/test") gasBudget := int(2000000000) packageId, tx, err := testutils.PublishContract(t, "counter", contractPath, accountAddress, &gasBudget) diff --git a/relayer/client/ptb_client_test.go b/relayer/client/ptb_client_test.go index b567f4864..258c7bda9 100644 --- a/relayer/client/ptb_client_test.go +++ b/relayer/client/ptb_client_test.go @@ -48,6 +48,11 @@ func TestPTBClient(t *testing.T) { err = testutils.FundWithFaucet(log, testutils.SuiLocalnet, accountAddress) require.NoError(t, err) + chainID, err := testutils.GetChainIdentifier(testutils.LocalUrl) + require.NoError(t, err) + testutils.PatchEnvironmentTOML("contracts/test", "local", chainID) + testutils.PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) + contractPath := testutils.BuildSetup(t, "contracts/test") gasBudget := int(2000000000) packageId, tx, err := testutils.PublishContract(t, "counter", contractPath, accountAddress, &gasBudget) @@ -497,11 +502,12 @@ func TestPTBClient(t *testing.T) { // create another failed transaction and use the cursor to ignore the previously fetched ones CreateFailedTransaction(t, relayerClient, packageId, counterObjectId, accountAddress, publicKeyBytes) cursor := &values.NextCursor + queryLimit := uint64(1) values, err = relayerClient.QueryTransactions( context.Background(), accountAddress, cursor, - nil, + &queryLimit, ) require.NoError(t, err) require.NotNil(t, values) diff --git a/relayer/testutils/bootstrap.go b/relayer/testutils/bootstrap.go index 9f9ebe259..11b484ef8 100644 --- a/relayer/testutils/bootstrap.go +++ b/relayer/testutils/bootstrap.go @@ -129,7 +129,7 @@ func SetupTestEnv( PatchEnvironmentTOML("contracts/test_secondary", "local", chainID) contractPath := BuildSetup(t, "contracts/test") - gasBudget := int(8000000000) + gasBudget := int(2000000000) packageId, tx, err := PublishContract(t, "counter", contractPath, accountAddress, &gasBudget) require.NoError(t, err) require.NotNil(t, packageId) diff --git a/relayer/testutils/contract.go b/relayer/testutils/contract.go index 8cb6605c0..8252fa0a9 100644 --- a/relayer/testutils/contract.go +++ b/relayer/testutils/contract.go @@ -6,7 +6,6 @@ import ( "encoding/base64" "encoding/json" "fmt" - "log" "os" "os/exec" "path/filepath" @@ -14,6 +13,7 @@ import ( "strconv" "strings" "testing" + "time" "github.com/pelletier/go-toml/v2" @@ -197,16 +197,119 @@ func PublishContract(t *testing.T, packageName string, contractPath string, acco gasBudgetArg = strconv.Itoa(*gasBudget) } + // Collect contract dirs that need Published.toml cleanup: the package itself + // and any local dependencies declared in Move.toml (e.g. test_secondary). + dirsToClean := []string{contractPath} + if moveToml, err := os.ReadFile(filepath.Join(contractPath, "Move.toml")); err == nil { + for _, line := range strings.Split(string(moveToml), "\n") { + line = strings.TrimSpace(line) + if !strings.HasPrefix(line, "local") { + continue + } + for _, q := range []string{`"`, `'`} { + prefix := "local = " + q + if idx := strings.Index(line, prefix); idx != -1 { + relPath := line[idx+len(prefix):] + if end := strings.Index(relPath, q); end != -1 { + p := relPath[:end] + if strings.HasPrefix(p, ".") || strings.HasPrefix(p, "/") { + dirsToClean = append(dirsToClean, filepath.Join(contractPath, p)) + } + } + } + } + } + } + + // Remove Published.toml and ephemeral pubfiles for the MAIN package only. + // Dependency dirs (e.g. test_secondary) keep their Published.toml so that + // --with-unpublished-dependencies can detect packages that were already + // published by a prior PublishContract call in the same test. Without this, + // the dependency gets re-published as a separate on-chain package, causing + // TypeMismatch errors when objects from the original publish are used. + os.Remove(filepath.Join(contractPath, "Published.toml")) + if pubGlob, err := filepath.Glob(filepath.Join(contractPath, "Pub.*.toml")); err == nil { + for _, f := range pubGlob { + os.Remove(f) + } + } + + // Snapshot Move.toml and Move.lock for each dir so we can restore them + // after the test. This prevents patchMoveTomlEnvironment and the Sui CLI + // from permanently dirtying the source tree. + type fileSnapshot struct { + path string + data []byte + } + var snapshots []fileSnapshot + for _, dir := range dirsToClean { + for _, name := range []string{"Move.toml", "Move.lock"} { + p := filepath.Join(dir, name) + if data, err := os.ReadFile(p); err == nil { + snapshots = append(snapshots, fileSnapshot{p, data}) + } + } + } + + // Register cleanup to restore source tree files after the test. + t.Cleanup(func() { + for _, dir := range dirsToClean { + os.WriteFile(filepath.Join(dir, "Published.toml"), []byte{}, 0644) //nolint:errcheck + pubGlob, _ := filepath.Glob(filepath.Join(dir, "Pub.*.toml")) + for _, f := range pubGlob { + os.Remove(f) + } + } + for _, s := range snapshots { + os.WriteFile(s.path, s.data, 0644) //nolint:errcheck + } + }) + + // Create a CLI environment with a unique name derived from the current + // node's chain ID, then switch to it. This avoids stale chain ID caching + // that occurs when "sui client new-env" is called with an alias that + // already exists from a previous node (with a different chain ID). + chainID, err := GetChainIdentifier(LocalUrl) + require.NoError(t, err, "failed to get chain identifier before publish") + + envName := ensureCLIEnvForChainID(chainID) + + // Patch Move.toml [environments] with a matching entry so the CLI's + // chain ID check passes. + for _, dir := range dirsToClean { + patchMoveTomlEnvironment(filepath.Join(dir, "Move.toml"), envName, chainID) + } + + // #region agent log + logFile, _ := os.OpenFile("/Users/felix/dev/chainlink/.cursor/debug-7c7360.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if logFile != nil { + fmt.Fprintf(logFile, "{\"sessionId\":\"7c7360\",\"hypothesisId\":\"A\",\"location\":\"contract.go:PublishContract\",\"message\":\"pre-publish state\",\"data\":{\"chainID\":%q,\"envName\":%q,\"contractPath\":%q,\"dirsToClean\":%q},\"timestamp\":%d}\n", chainID, envName, contractPath, dirsToClean, time.Now().UnixMilli()) + logFile.Close() + } + // #endregion + publishCmd := exec.Command("sui", "client", "publish", "--gas-budget", gasBudgetArg, "--json", "--silence-warnings", "--with-unpublished-dependencies", - "-e", "local", // Explicitly use local environment from Move.toml contractPath, ) publishOutput, err := publishCmd.CombinedOutput() + + // #region agent log + logFile2, _ := os.OpenFile("/Users/felix/dev/chainlink/.cursor/debug-7c7360.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if logFile2 != nil { + outSnippet := string(publishOutput) + if len(outSnippet) > 500 { + outSnippet = outSnippet[:500] + } + fmt.Fprintf(logFile2, "{\"sessionId\":\"7c7360\",\"hypothesisId\":\"A\",\"location\":\"contract.go:PublishContract:post\",\"message\":\"publish result\",\"data\":{\"err\":%q,\"outputSnippet\":%q},\"timestamp\":%d}\n", fmt.Sprint(err), outSnippet, time.Now().UnixMilli()) + logFile2.Close() + } + // #endregion + require.NoError(t, err, "Failed to publish contract: %s", string(publishOutput)) cleanedOutput, err := extractJSONOutput(string(publishOutput)) @@ -243,6 +346,7 @@ func PublishContract(t *testing.T, packageName string, contractPath string, acco break } } + require.NotEmpty(t, packageId, "Package ID not found") return packageId, parsedPublishTxn, nil @@ -420,11 +524,94 @@ func patchContractTOMLSectionNoTest(contractPath, addresses, name, address strin // require.NoError(t, err, "write Move.toml") } } +} - // Log resulting TOML contents for debugging. - finalToml, _ := os.ReadFile(moveToml) - // require.NoError(t, err, "read patched Move.toml") - log.Printf("Patched Move.toml (%s):\n%s\n", moveToml, string(finalToml)) +// patchMoveTomlEnvironment does a targeted text replacement of a chain ID value +// in Move.toml's [environments] section. Unlike PatchEnvironmentTOML, this avoids +// full TOML parse/re-encode which can silently corrupt the file format. +func patchMoveTomlEnvironment(moveTomlPath, envName, newChainID string) { + content, err := os.ReadFile(moveTomlPath) + if err != nil { + return + } + + lines := strings.Split(string(content), "\n") + inEnvSection := false + envSectionIdx := -1 + patched := false + + for i, line := range lines { + trimmed := strings.TrimSpace(line) + + if trimmed == "[environments]" { + inEnvSection = true + envSectionIdx = i + continue + } + if inEnvSection && strings.HasPrefix(trimmed, "[") { + inEnvSection = false + break + } + + if !inEnvSection { + continue + } + + // Match envName = 'value' or envName = "value" with optional indentation + for _, q := range []string{`'`, `"`} { + prefix := envName + " = " + q + altPrefix := envName + "= " + q + altPrefix2 := envName + " =" + q + if strings.HasPrefix(trimmed, prefix) || strings.HasPrefix(trimmed, altPrefix) || strings.HasPrefix(trimmed, altPrefix2) { + leading := line[:len(line)-len(strings.TrimLeft(line, " \t"))] + lines[i] = fmt.Sprintf("%s%s = %s%s%s", leading, envName, q, newChainID, q) + patched = true + break + } + } + if patched { + break + } + } + + if !patched && envSectionIdx >= 0 { + // Entry doesn't exist in [environments]; insert it after the section header. + newLine := fmt.Sprintf(" %s = '%s'", envName, newChainID) + lines = append(lines[:envSectionIdx+1], append([]string{newLine}, lines[envSectionIdx+1:]...)...) + patched = true + } + + if !patched { + return + } + + os.WriteFile(moveTomlPath, []byte(strings.Join(lines, "\n")), 0644) //nolint:errcheck +} + +// ensureCLIEnvForChainID creates a CLI environment alias unique to the given +// chain ID, then switches to it. Using a chain-ID-derived name avoids stale +// chain ID caching: "sui client new-env" silently fails when the alias already +// exists, so reusing a fixed "local" alias across node restarts (each with a +// different chain ID from --force-regenesis) leaves the CLI with an outdated +// chain ID that causes "Move.toml expects local to have chain ID …" errors. +func ensureCLIEnvForChainID(chainID string) string { + envName := "local_" + chainID + + createCmd := exec.Command("sui", "client", "new-env", "--rpc", LocalUrl, "--alias", envName) + createCmd.CombinedOutput() //nolint:errcheck + + switchCmd := exec.Command("sui", "client", "switch", "--env", envName) + switchCmd.CombinedOutput() //nolint:errcheck + + // #region agent log + logFile, _ := os.OpenFile("/Users/felix/dev/chainlink/.cursor/debug-7c7360.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if logFile != nil { + fmt.Fprintf(logFile, "{\"sessionId\":\"7c7360\",\"hypothesisId\":\"B\",\"location\":\"contract.go:ensureCLIEnvForChainID\",\"message\":\"CLI env created\",\"data\":{\"envName\":%q,\"chainID\":%q},\"timestamp\":%d}\n", envName, chainID, time.Now().UnixMilli()) + logFile.Close() + } + // #endregion + + return envName } // CleanupTestContracts removes the [published.local] entries from Published.toml files diff --git a/scripts/go.mod b/scripts/go.mod index a2b75c80b..ca75148da 100644 --- a/scripts/go.mod +++ b/scripts/go.mod @@ -24,7 +24,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.20.0 // indirect github.com/blendle/zapdriver v1.3.1 // indirect - github.com/block-vision/sui-go-sdk v1.1.4 // indirect + github.com/block-vision/sui-go-sdk v1.2.1 // indirect github.com/btcsuite/btcd v0.24.2 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/btcsuite/btcd/btcutil v1.1.6 // indirect diff --git a/scripts/go.sum b/scripts/go.sum index b255033c6..0562c1305 100644 --- a/scripts/go.sum +++ b/scripts/go.sum @@ -72,8 +72,8 @@ github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3M github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= -github.com/block-vision/sui-go-sdk v1.1.4 h1:1PPgYxQjo1P9UCgFOPTvDCuGEglRL32NwjKPulR4FQk= -github.com/block-vision/sui-go-sdk v1.1.4/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= +github.com/block-vision/sui-go-sdk v1.2.1 h1:uwvGbzfcrS4SsIaakclYxy0qgEF1XWIUtTYWXB4PoAw= +github.com/block-vision/sui-go-sdk v1.2.1/go.mod h1:t8mWASwfyv+EyqHGO9ZrcDiCJWGOFEXqq50TMJ8GQco= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= diff --git a/sui.nix b/sui.nix index e9cc136fe..74002ec16 100644 --- a/sui.nix +++ b/sui.nix @@ -4,18 +4,18 @@ }: stdenv.mkDerivation rec { name = "sui-cli-${version}"; - version = "1.67.3"; # Update as needed. Should be a mainnet release version from https://github.com/MystenLabs/sui/releases + version = "1.69.2"; # Update as needed. Should be a mainnet release version from https://github.com/MystenLabs/sui/releases src = if stdenv.hostPlatform.isDarwin then pkgs.fetchzip { url = "https://github.com/MystenLabs/sui/releases/download/mainnet-v${version}/sui-mainnet-v${version}-macos-arm64.tgz"; # Assume is a M1 Mac - sha256 = "sha256-bnrLaWx7IWNoI0Ou9oQrfprBx/nKv282OGyrlUHcdFY="; # Should be replaced when bumping versions + sha256 = "sha256-20O1Lp9qJdT+bnbgqLsQa+fe8TbrqGuOwXxVocLv3sY="; # Should be replaced when bumping versions stripRoot = false; } else if stdenv.isLinux then pkgs.fetchzip { url = "https://github.com/MystenLabs/sui/releases/download/mainnet-v${version}/sui-mainnet-v${version}-ubuntu-x86_64.tgz"; - sha256 = "sha256-xAWUigROvAVVLIut/HlZJjx4MB7T1k0b6X5SGRIO+cw="; # Should be replaced when bumping versions + sha256 = "sha256-ZREF0yArM/qdxXYBFgb6/hGDGkZPDBzr2qZSt7mOkYk="; # Should be replaced when bumping versions stripRoot = false; } else