diff --git a/.github/integration-in-memory-tests.yml b/.github/integration-in-memory-tests.yml index 7fd33be85e7..2e4530efea2 100644 --- a/.github/integration-in-memory-tests.yml +++ b/.github/integration-in-memory-tests.yml @@ -427,7 +427,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "^TestRMNCurseUncurseAptos$" -timeout 20m -count=1 -parallel=4 smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 - id: smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go:TestRMNCurseMCMS path: integration-tests/smoke/ccip/ccip_cs_rmn_curse_uncurse_test.go @@ -722,7 +722,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_Messaging_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -740,7 +740,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_Messaging_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -758,7 +758,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -776,7 +776,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -794,7 +794,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_BnM_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -812,7 +812,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_BnM_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -830,7 +830,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -848,7 +848,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -867,7 +867,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -885,7 +885,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -903,7 +903,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_AptosMessageHasher" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -921,7 +921,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_RegulatedTokenTransfer_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -939,7 +939,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_RegulatedTokenTransfer_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -957,7 +957,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_BnM_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -975,7 +975,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_BnM_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -993,7 +993,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -1011,7 +1011,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -1029,7 +1029,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_without_TransferRef_EVM2Aptos" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true @@ -1047,7 +1047,7 @@ runner-test-matrix: --format=github-actions \ -- -v -run "Test_CCIP_TokenTransfer_LnR_without_TransferRef_Aptos2EVM" -timeout 20m -count=1 -parallel=1 ./smoke/ccip test_go_project_path: integration-tests - aptos_cli_version: 8.1.0 + aptos_cli_version: 9.1.0 install_plugins_public: true free_disk_space: true diff --git a/core/scripts/go.mod b/core/scripts/go.mod index 711632da375..2bbbb7c43fd 100644 --- a/core/scripts/go.mod +++ b/core/scripts/go.mod @@ -85,8 +85,8 @@ require ( github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.59.1 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect ) @@ -148,7 +148,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.112.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beevik/ntp v1.5.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect @@ -487,7 +487,7 @@ require ( github.com/sirupsen/logrus v1.9.4 // indirect github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 // indirect + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 // indirect github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee // indirect github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260506144252-c100eabfda74 // indirect github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260511195239-0f6e1b177fc7 // indirect diff --git a/core/scripts/go.sum b/core/scripts/go.sum index b51f0e50b3a..de2211188d4 100644 --- a/core/scripts/go.sum +++ b/core/scripts/go.sum @@ -218,8 +218,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.112.0 h1:7jusWZUgSTuSPLa2ZRv+siGuyoFSzFNk/TaHqlcFe6Y= github.com/aws/jsii-runtime-go v1.112.0/go.mod h1:jiAbLN2Hz+7At3C59LsQyv8gK3HvfNYF2YFPkWLHll8= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= @@ -1564,12 +1564,12 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1674,8 +1674,8 @@ github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57 github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57cf3c/go.mod h1:gL4GT6WUvna7MYGJXAqOq65xpQpG9bnQcdAfqCbKgH4= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g= diff --git a/deployment/ccip/changeset/aptos/adapters/fastcurse.go b/deployment/ccip/changeset/aptos/adapters/fastcurse.go deleted file mode 100644 index cb3b717fc19..00000000000 --- a/deployment/ccip/changeset/aptos/adapters/fastcurse.go +++ /dev/null @@ -1,153 +0,0 @@ -package adapters - -import ( - "fmt" - - "github.com/Masterminds/semver/v3" - "github.com/aptos-labs/aptos-go-sdk" - chainsel "github.com/smartcontractkit/chain-selectors" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - "github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse" - "github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - aptosseq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - aptosops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" - aptosstateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -type CurseAdapter struct { - CCIPAddress aptos.AccountAddress -} - -func NewCurseAdapter() *CurseAdapter { - return &CurseAdapter{} -} - -func (c *CurseAdapter) Initialize(e cldf.Environment, selector uint64) error { - stateMap, err := aptosstateview.LoadOnchainStateAptos(e) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - state, ok := stateMap[selector] - if !ok { - return fmt.Errorf("aptos chain %d not found in state", selector) - } - c.CCIPAddress = state.CCIPAddress - return nil -} - -// IsSubjectCursedOnChain checks if the subject is cursed on Aptos chain -func (c *CurseAdapter) IsSubjectCursedOnChain(e cldf.Environment, selector uint64, subject fastcurse.Subject) (bool, error) { - chain, ok := e.BlockChains.AptosChains()[selector] - if !ok { - return false, fmt.Errorf("aptos chain %d not found in environment", selector) - } - deps := dependency.AptosDeps{ - AptosChain: chain, - } - return aptosops.IsSubjectCursed(deps, c.CCIPAddress, subject[:]) -} - -// IsChainConnectedToTargetChain checks if the target chain is supported on Aptos chain -func (c *CurseAdapter) IsChainConnectedToTargetChain(e cldf.Environment, selector uint64, targetSelector uint64) (bool, error) { - chain, ok := e.BlockChains.AptosChains()[selector] - if !ok { - return false, fmt.Errorf("aptos chain %d not found in environment", selector) - } - routerBind := ccip_router.Bind(c.CCIPAddress, chain.Client) - callOpts := &bind.CallOpts{} - connected, err := routerBind.Router().IsChainSupported(callOpts, targetSelector) - if err != nil { - return false, fmt.Errorf("failed to check if chain %d is connected to chain %d: %w", selector, targetSelector, err) - } - return connected, nil -} - -// IsCurseEnabledForChain returns true because Aptos is live on CCIP 1.6 -func (c *CurseAdapter) IsCurseEnabledForChain(cldf.Environment, uint64) (bool, error) { - return true, nil -} - -// SubjectToSelector converts subject to chainselector -func (c *CurseAdapter) SubjectToSelector(subject fastcurse.Subject) (uint64, error) { - return fastcurse.GenericSubjectToSelector(subject) -} - -// Curse returns the sequence to curse multiple subjects on Aptos chain -func (c *CurseAdapter) Curse() *cldf_ops.Sequence[fastcurse.CurseInput, sequences.OnChainOutput, cldf_chain.BlockChains] { - return cldf_ops.NewSequence( - aptosseq.AptosCurseSequence.ID(), - operation.Version1_0_0, - aptosseq.AptosCurseSequence.Description(), - func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in fastcurse.CurseInput) (output sequences.OnChainOutput, err error) { - aptosInput := aptosseq.AptosCurseUncurseInput{ - CCIPAddress: c.CCIPAddress, - ChainSelector: in.ChainSelector, - Subjects: in.Subjects, - } - seqReport, err := cldf_ops.ExecuteSequence(b, aptosseq.AptosCurseSequence, chains, aptosInput) - if err != nil { - return sequences.OnChainOutput{}, fmt.Errorf("failed to execute curse sequence on Aptos chain %d: %w", in.ChainSelector, err) - } - return seqReport.Output, nil - }, - ) -} - -// Uncurse returns the sequence to uncurse multiple subjects on Aptos chain -func (c *CurseAdapter) Uncurse() *cldf_ops.Sequence[fastcurse.CurseInput, sequences.OnChainOutput, cldf_chain.BlockChains] { - return cldf_ops.NewSequence( - aptosseq.AptosUncurseSequence.ID(), - operation.Version1_0_0, - aptosseq.AptosUncurseSequence.Description(), - func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in fastcurse.CurseInput) (output sequences.OnChainOutput, err error) { - aptosInput := aptosseq.AptosCurseUncurseInput{ - CCIPAddress: c.CCIPAddress, - ChainSelector: in.ChainSelector, - Subjects: in.Subjects, - } - seqReport, err := cldf_ops.ExecuteSequence(b, aptosseq.AptosUncurseSequence, chains, aptosInput) - if err != nil { - return sequences.OnChainOutput{}, fmt.Errorf("failed to execute uncurse sequence on Aptos chain %d: %w", in.ChainSelector, err) - } - return seqReport.Output, nil - }, - ) -} - -func (c *CurseAdapter) ListConnectedChains(e cldf.Environment, selector uint64) ([]uint64, error) { - chain, ok := e.BlockChains.AptosChains()[selector] - if !ok { - return nil, fmt.Errorf("aptos chain %d not found in environment", selector) - } - routerBind := ccip_router.Bind(c.CCIPAddress, chain.Client) - callOpts := &bind.CallOpts{} - connectedChains, err := routerBind.Router().GetDestChains(callOpts) - if err != nil { - return nil, fmt.Errorf("failed to get connected chains for chain %d: %w", selector, err) - } - return connectedChains, nil -} - -// SelectorToSubject converts selector to Subject. -func (c *CurseAdapter) SelectorToSubject(selector uint64) fastcurse.Subject { - return globals.FamilyAwareSelectorToSubject(selector, chainsel.FamilyAptos) -} - -func (c *CurseAdapter) DeriveCurseAdapterVersion(e cldf.Environment, selector uint64) (*semver.Version, error) { - return semver.MustParse("1.6.0"), nil -} - -var ( - _ fastcurse.CurseAdapter = (*CurseAdapter)(nil) - _ fastcurse.CurseSubjectAdapter = (*CurseAdapter)(nil) -) diff --git a/deployment/ccip/changeset/aptos/adapters/fastcurse_test.go b/deployment/ccip/changeset/aptos/adapters/fastcurse_test.go deleted file mode 100644 index 0b636980f8f..00000000000 --- a/deployment/ccip/changeset/aptos/adapters/fastcurse_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package adapters - -import ( - "testing" - - "github.com/Masterminds/semver/v3" - "github.com/aptos-labs/aptos-go-sdk" - "github.com/stretchr/testify/require" - - chainsel "github.com/smartcontractkit/chain-selectors" - - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -func TestInitializeSetsCCIPAddress(t *testing.T) { - selector := uint64(123) - ccipAddrStr := "0x1" - ccipAddr := aptos.AccountAddress{} - require.NoError(t, ccipAddr.ParseStringRelaxed(ccipAddrStr)) - - ab := stubAddressBook{ - data: map[uint64]map[string]cldf.TypeAndVersion{ - selector: { - ccipAddrStr: cldf.NewTypeAndVersion(shared.AptosCCIPType, *semver.MustParse("1.0.0")), - }, - }, - } - - chain := cldf_aptos.Chain{Selector: selector} - env := cldf.Environment{ - ExistingAddresses: ab, - BlockChains: cldf_chain.NewBlockChainsFromSlice([]cldf_chain.BlockChain{chain}), - } - - adapter := &CurseAdapter{} - err := adapter.Initialize(env, selector) - require.NoError(t, err) - require.Equal(t, ccipAddr, adapter.CCIPAddress) -} - -func TestSelectorSubjectConversions(t *testing.T) { - adapter := &CurseAdapter{} - selector := uint64(789) - subject := adapter.SelectorToSubject(selector) - outSelector, err := adapter.SubjectToSelector(subject) - require.NoError(t, err) - require.Equal(t, selector, outSelector) - require.Equal(t, globals.FamilyAwareSelectorToSubject(selector, chainsel.FamilyAptos), subject) -} - -type stubAddressBook struct { - data map[uint64]map[string]cldf.TypeAndVersion -} - -func (s stubAddressBook) Save(uint64, string, cldf.TypeAndVersion) error { return nil } -func (s stubAddressBook) Addresses() (map[uint64]map[string]cldf.TypeAndVersion, error) { - return s.data, nil -} -func (s stubAddressBook) AddressesForChain(chain uint64) (map[string]cldf.TypeAndVersion, error) { - return s.data[chain], nil -} -func (s stubAddressBook) Merge(cldf.AddressBook) error { return nil } -func (s stubAddressBook) Remove(cldf.AddressBook) error { return nil } diff --git a/deployment/ccip/changeset/aptos/adapters/init.go b/deployment/ccip/changeset/aptos/adapters/init.go deleted file mode 100644 index ebf84f44a93..00000000000 --- a/deployment/ccip/changeset/aptos/adapters/init.go +++ /dev/null @@ -1,22 +0,0 @@ -package adapters - -import ( - "github.com/Masterminds/semver/v3" - chainsel "github.com/smartcontractkit/chain-selectors" - - "github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse" - "github.com/smartcontractkit/chainlink-ccip/deployment/utils/changesets" -) - -func init() { - curseRegistry := fastcurse.GetCurseRegistry() - curseRegistry.RegisterNewCurse(fastcurse.CurseRegistryInput{ - CursingFamily: chainsel.FamilyAptos, - CursingVersion: semver.MustParse("1.6.0"), - CurseAdapter: NewCurseAdapter(), - CurseSubjectAdapter: NewCurseAdapter(), - }) - - mcmsRegistry := changesets.GetRegistry() - mcmsRegistry.RegisterMCMSReader(chainsel.FamilyAptos, &AptosCurseMCMSReader{}) -} diff --git a/deployment/ccip/changeset/aptos/adapters/mcmsreader.go b/deployment/ccip/changeset/aptos/adapters/mcmsreader.go deleted file mode 100644 index de2216b760a..00000000000 --- a/deployment/ccip/changeset/aptos/adapters/mcmsreader.go +++ /dev/null @@ -1,95 +0,0 @@ -package adapters - -import ( - "encoding/json" - "fmt" - - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - mcms_utils "github.com/smartcontractkit/chainlink-ccip/deployment/utils/mcms" - "github.com/smartcontractkit/chainlink-deployments-framework/datastore" - "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -// AptosCurseMCMSReader implements changesets.MCMSReader for the Aptos family, -// targeting the CurseMCMS contract rather than the regular MCMS contract. -// It is registered for FamilyAptos so that the fastcurse framework's -// OutputBuilder produces proposals against CurseMCMS. -type AptosCurseMCMSReader struct{} - -func (r *AptosCurseMCMSReader) GetChainMetadata(e deployment.Environment, chainSelector uint64, input mcms_utils.Input) (mcmstypes.ChainMetadata, error) { - chain, ok := e.BlockChains.AptosChains()[chainSelector] - if !ok { - return mcmstypes.ChainMetadata{}, fmt.Errorf("aptos chain with selector %d not found", chainSelector) - } - - stateMap, err := aptos.LoadOnchainStateAptos(e) - if err != nil { - return mcmstypes.ChainMetadata{}, fmt.Errorf("failed to load aptos onchain state: %w", err) - } - state, ok := stateMap[chainSelector] - if !ok { - return mcmstypes.ChainMetadata{}, fmt.Errorf("aptos chain %d not found in state", chainSelector) - } - curseMCMSAddr := state.CurseMCMSAddress - - role, err := cldfproposalutils.GetAptosRoleFromAction(input.TimelockAction) - if err != nil { - return mcmstypes.ChainMetadata{}, fmt.Errorf("failed to get role from action: %w", err) - } - inspector := aptosmcms.NewInspectorWithMCMSType(chain.Client, role, aptosmcms.MCMSTypeCurse) - - opCount, err := inspector.GetOpCount(e.GetContext(), curseMCMSAddr.StringLong()) - if err != nil { - return mcmstypes.ChainMetadata{}, fmt.Errorf("failed to get opCount for CurseMCMS at %s on chain %d: %w", curseMCMSAddr.StringLong(), chainSelector, err) - } - - afm := aptosmcms.AdditionalFieldsMetadata{ - MCMSType: aptosmcms.MCMSTypeCurse, - } - afBytes, err := json.Marshal(afm) - if err != nil { - return mcmstypes.ChainMetadata{}, fmt.Errorf("failed to marshal additional fields metadata: %w", err) - } - - return mcmstypes.ChainMetadata{ - StartingOpCount: opCount, - MCMAddress: curseMCMSAddr.StringLong(), - AdditionalFields: afBytes, - }, nil -} - -func (r *AptosCurseMCMSReader) GetTimelockRef(e deployment.Environment, chainSelector uint64, input mcms_utils.Input) (datastore.AddressRef, error) { - stateMap, err := aptos.LoadOnchainStateAptos(e) - if err != nil { - return datastore.AddressRef{}, fmt.Errorf("failed to load aptos onchain state: %w", err) - } - state, ok := stateMap[chainSelector] - if !ok { - return datastore.AddressRef{}, fmt.Errorf("aptos chain %d not found in state", chainSelector) - } - return datastore.AddressRef{ - Address: state.CurseMCMSAddress.StringLong(), - ChainSelector: chainSelector, - }, nil -} - -func (r *AptosCurseMCMSReader) GetMCMSRef(e deployment.Environment, chainSelector uint64, input mcms_utils.Input) (datastore.AddressRef, error) { - stateMap, err := aptos.LoadOnchainStateAptos(e) - if err != nil { - return datastore.AddressRef{}, fmt.Errorf("failed to load aptos onchain state: %w", err) - } - state, ok := stateMap[chainSelector] - if !ok { - return datastore.AddressRef{}, fmt.Errorf("aptos chain %d not found in state", chainSelector) - } - return datastore.AddressRef{ - Address: state.CurseMCMSAddress.StringLong(), - ChainSelector: chainSelector, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/config/chain.go b/deployment/ccip/changeset/aptos/config/chain.go deleted file mode 100644 index 6f97f1db47f..00000000000 --- a/deployment/ccip/changeset/aptos/config/chain.go +++ /dev/null @@ -1,140 +0,0 @@ -package config - -import ( - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - chainsel "github.com/smartcontractkit/chain-selectors" - - aptos_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - evm_fee_quoter "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -// ChainDefinition is an interface that defines a chain config for lane deployment -// It is used to convert between Aptos and EVM fee quoter configs. -type ChainDefinition interface { - GetChainFamily() string - GetSelector() uint64 -} - -type EVMChainDefinition struct { - v1_6.ChainDefinition - OnRampVersion []byte -} - -func (c EVMChainDefinition) GetChainFamily() string { - return chainsel.FamilyEVM -} - -func (c EVMChainDefinition) GetSelector() uint64 { - return c.Selector -} - -func (c EVMChainDefinition) GetConvertedAptosFeeQuoterConfig() aptos_fee_quoter.DestChainConfig { - efqc := c.FeeQuoterDestChainConfig - // Handle the byte slice to fixed-size array conversion - return aptos_fee_quoter.DestChainConfig{ - IsEnabled: efqc.IsEnabled, - MaxNumberOfTokensPerMsg: efqc.MaxNumberOfTokensPerMsg, - MaxDataBytes: efqc.MaxDataBytes, - MaxPerMsgGasLimit: efqc.MaxPerMsgGasLimit, - DestGasOverhead: efqc.DestGasOverhead, - DestGasPerPayloadByteBase: efqc.DestGasPerPayloadByteBase, - DestGasPerPayloadByteHigh: efqc.DestGasPerPayloadByteHigh, - DestGasPerPayloadByteThreshold: efqc.DestGasPerPayloadByteThreshold, - DestDataAvailabilityOverheadGas: efqc.DestDataAvailabilityOverheadGas, - DestGasPerDataAvailabilityByte: efqc.DestGasPerDataAvailabilityByte, - DestDataAvailabilityMultiplierBps: efqc.DestDataAvailabilityMultiplierBps, - ChainFamilySelector: efqc.ChainFamilySelector[:], - EnforceOutOfOrder: efqc.EnforceOutOfOrder, - DefaultTokenFeeUsdCents: efqc.DefaultTokenFeeUSDCents, - DefaultTokenDestGasOverhead: efqc.DefaultTokenDestGasOverhead, - DefaultTxGasLimit: efqc.DefaultTxGasLimit, - GasMultiplierWeiPerEth: efqc.GasMultiplierWeiPerEth, - GasPriceStalenessThreshold: efqc.GasPriceStalenessThreshold, - NetworkFeeUsdCents: efqc.NetworkFeeUSDCents, - } -} - -type AptosChainDefinition struct { - // ConnectionConfig holds configuration for connection. - v1_6.ConnectionConfig `json:"connectionConfig"` - // Selector is the chain selector of this chain. - Selector uint64 `json:"selector"` - // GasPrice defines the USD price (18 decimals) per unit gas for this chain as a destination. - GasPrice *big.Int `json:"gasPrice"` - // TokenPrices defines USD price for a token address (28 decimals) - TokenPrices map[aptos.AccountAddress]*big.Int - // FeeQuoterDestChainConfig is the configuration on a fee quoter for this chain as a destination. - FeeQuoterDestChainConfig aptos_fee_quoter.DestChainConfig `json:"feeQuoterDestChainConfig"` - // AddTokenTransferFeeConfigs is the configuration for token transfer fees to be added to fee quoter - AddTokenTransferFeeConfigs []aptos_fee_quoter.TokenTransferFeeConfigAdded - // RemoveTokenTransferFeeConfigs holds token transfer fees to be removed from fee quoter - RemoveTokenTransferFeeConfigs []aptos_fee_quoter.TokenTransferFeeConfigRemoved -} - -func (c AptosChainDefinition) GetChainFamily() string { - return chainsel.FamilyAptos -} - -func (c AptosChainDefinition) GetSelector() uint64 { - return c.Selector -} - -func (c AptosChainDefinition) GetConvertedEVMFeeQuoterConfig() evm_fee_quoter.FeeQuoterDestChainConfig { - afqc := c.FeeQuoterDestChainConfig - // Handle the byte slice to fixed-size array conversion - var chainFamilySelector [4]byte - // Copy up to 4 bytes, zero-padding if source is shorter - copy(chainFamilySelector[:], afqc.ChainFamilySelector) - - return evm_fee_quoter.FeeQuoterDestChainConfig{ - IsEnabled: afqc.IsEnabled, - MaxNumberOfTokensPerMsg: afqc.MaxNumberOfTokensPerMsg, - MaxDataBytes: afqc.MaxDataBytes, - MaxPerMsgGasLimit: afqc.MaxPerMsgGasLimit, - DestGasOverhead: afqc.DestGasOverhead, - DestGasPerPayloadByteBase: afqc.DestGasPerPayloadByteBase, - DestGasPerPayloadByteHigh: afqc.DestGasPerPayloadByteHigh, - DestGasPerPayloadByteThreshold: afqc.DestGasPerPayloadByteThreshold, - DestDataAvailabilityOverheadGas: afqc.DestDataAvailabilityOverheadGas, - DestGasPerDataAvailabilityByte: afqc.DestGasPerDataAvailabilityByte, - DestDataAvailabilityMultiplierBps: afqc.DestDataAvailabilityMultiplierBps, - ChainFamilySelector: chainFamilySelector, - EnforceOutOfOrder: afqc.EnforceOutOfOrder, - DefaultTokenFeeUSDCents: afqc.DefaultTokenFeeUsdCents, - DefaultTokenDestGasOverhead: afqc.DefaultTokenDestGasOverhead, - DefaultTxGasLimit: afqc.DefaultTxGasLimit, - GasMultiplierWeiPerEth: afqc.GasMultiplierWeiPerEth, - GasPriceStalenessThreshold: afqc.GasPriceStalenessThreshold, - NetworkFeeUSDCents: afqc.NetworkFeeUsdCents, - } -} - -func (c AptosChainDefinition) Validate(client aptos.AptosRpcClient, state aptosstate.CCIPChainState) error { - // Check CCIP Package - if state.CCIPAddress == (aptos.AccountAddress{}) { - return fmt.Errorf("package CCIP is not deployed on Aptos chain %d", c.Selector) - } - // Check OnRamp module - hasOnramp, err := utils.IsModuleDeployed(client, state.CCIPAddress, "onramp") - if err != nil || !hasOnramp { - return fmt.Errorf("onRamp module is not deployed on Aptos chain %d: %w", c.Selector, err) - } - // Check OffRamp module - hasOfframp, err := utils.IsModuleDeployed(client, state.CCIPAddress, "offramp") - if err != nil || !hasOfframp { - return fmt.Errorf("offRamp module is not deployed on Aptos chain %d: %w", c.Selector, err) - } - // Check Router module - hasRouter, err := utils.IsModuleDeployed(client, state.CCIPAddress, "router") - if err != nil || !hasRouter { - return fmt.Errorf("router module is not deployed on Aptos chain %d: %w", c.Selector, err) - } - - return nil -} diff --git a/deployment/ccip/changeset/aptos/config/deploy_aptos_chain.go b/deployment/ccip/changeset/aptos/config/deploy_aptos_chain.go deleted file mode 100644 index 124dffb93c8..00000000000 --- a/deployment/ccip/changeset/aptos/config/deploy_aptos_chain.go +++ /dev/null @@ -1,109 +0,0 @@ -package config - -import ( - "errors" - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -// DeployAptosChainConfig is a configuration for deploying CCIP Package for Aptos chains -type DeployAptosChainConfig struct { - MCMSDeployConfigPerChain map[uint64]cldfproposalutils.MCMSWithTimelockConfig - MCMSTimelockConfigPerChain map[uint64]cldfproposalutils.TimelockConfig - ContractParamsPerChain map[uint64]ChainContractParams -} - -func (c DeployAptosChainConfig) Validate() error { - for cs, args := range c.ContractParamsPerChain { - if err := cldf.IsValidChainSelector(cs); err != nil { - return fmt.Errorf("invalid chain selector: %d - %w", cs, err) - } - if err := args.Validate(); err != nil { - return fmt.Errorf("invalid contract args for chain %d: %w", cs, err) - } - } - return nil -} - -// ChainContractParams stores configuration to call initialize in CCIP contracts -type ChainContractParams struct { - FeeQuoterParams FeeQuoterParams - OffRampParams OffRampParams - OnRampParams OnRampParams -} - -func (c ChainContractParams) Validate() error { - // Validate every field - if err := c.FeeQuoterParams.Validate(); err != nil { - return fmt.Errorf("invalid FeeQuoterParams: %w", err) - } - if err := c.OffRampParams.Validate(); err != nil { - return fmt.Errorf("invalid OffRampParams: %w", err) - } - if err := c.OnRampParams.Validate(); err != nil { - return fmt.Errorf("invalid OnRampParams: %w", err) - } - return nil -} - -type FeeQuoterParams struct { - MaxFeeJuelsPerMsg *big.Int - TokenPriceStalenessThreshold uint64 - FeeTokens []aptos.AccountAddress - PremiumMultiplierWeiPerEthByFeeToken map[shared.TokenSymbol]uint64 -} - -func (f FeeQuoterParams) Validate() error { - if f.TokenPriceStalenessThreshold == 0 { - return errors.New("TokenPriceStalenessThreshold can't be 0") - } - if len(f.PremiumMultiplierWeiPerEthByFeeToken) == 0 { - return errors.New("PremiumMultiplierWeiPerEthByFeeToken is nil or empty, at least one token must be configured") - } - if f.MaxFeeJuelsPerMsg == nil { - return errors.New("MaxFeeJuelsPerMsg is nil, it must be set") - } - return nil -} - -type OffRampParams struct { - ChainSelector uint64 - PermissionlessExecutionThreshold uint32 - IsRMNVerificationDisabled []bool - SourceChainSelectors []uint64 - SourceChainIsEnabled []bool - SourceChainsOnRamp [][]byte -} - -func (o OffRampParams) Validate() error { - if err := cldf.IsValidChainSelector(o.ChainSelector); err != nil { - return fmt.Errorf("invalid chain selector: %d - %w", o.ChainSelector, err) - } - if o.PermissionlessExecutionThreshold == 0 { - return errors.New("PermissionlessExecutionThreshold can't be 0") - } - if len(o.SourceChainSelectors) != len(o.SourceChainIsEnabled) { - return errors.New("SourceChainSelectors and SourceChainIsEnabled must have the same length") - } - return nil -} - -type OnRampParams struct { - ChainSelector uint64 - AllowlistAdmin aptos.AccountAddress - FeeAggregator aptos.AccountAddress -} - -func (o OnRampParams) Validate() error { - if err := cldf.IsValidChainSelector(o.ChainSelector); err != nil { - return fmt.Errorf("invalid chain selector: %d - %w", o.ChainSelector, err) - } - return nil -} diff --git a/deployment/ccip/changeset/aptos/config/deploy_curse_mcms.go b/deployment/ccip/changeset/aptos/config/deploy_curse_mcms.go deleted file mode 100644 index f82870dff47..00000000000 --- a/deployment/ccip/changeset/aptos/config/deploy_curse_mcms.go +++ /dev/null @@ -1,31 +0,0 @@ -package config - -import ( - "fmt" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" -) - -// DeployCurseMCMSConfig holds per-chain configuration for deploying and -// configuring a CurseMCMS contract on Aptos chains. -type DeployCurseMCMSConfig struct { - CurseMCMSConfigPerChain map[uint64]cldfproposalutils.MCMSWithTimelockConfig - MCMSTimelockConfigPerChain map[uint64]cldfproposalutils.TimelockConfig -} - -func (c DeployCurseMCMSConfig) Validate() error { - for cs, cfg := range c.CurseMCMSConfigPerChain { - if err := cldf.IsValidChainSelector(cs); err != nil { - return fmt.Errorf("invalid chain selector: %d - %w", cs, err) - } - for _, mcmsCfg := range []mcmstypes.Config{cfg.Bypasser, cfg.Canceller, cfg.Proposer} { - if err := mcmsCfg.Validate(); err != nil { - return fmt.Errorf("invalid MCMS config for chain %d: %w", cs, err) - } - } - } - return nil -} diff --git a/deployment/ccip/changeset/aptos/config/deploy_regulated_token.go b/deployment/ccip/changeset/aptos/config/deploy_regulated_token.go deleted file mode 100644 index 1920f9743ef..00000000000 --- a/deployment/ccip/changeset/aptos/config/deploy_regulated_token.go +++ /dev/null @@ -1,53 +0,0 @@ -package config - -import ( - "errors" - - "github.com/aptos-labs/aptos-go-sdk" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" -) - -// DeployRegulatedTokenConfig drives the regulated token publish + initialize + -// transfer_ownership + transfer_admin to the MCMS registry owner, and emits an MCMS -// proposal with accept_ownership and accept_admin. Note: regulated_token cannot be -// deployed via MCMS due to DFA re-entrancy; those steps are signed directly by the -// deployer. -type DeployRegulatedTokenConfig struct { - ChainSelector uint64 - TokenParams TokenParams - TokenMint *TokenMint - // RegistrarPreregister is passed to DeployMCMSRegistrarToExistingObject (default true). - RegistrarPreregister *bool - MCMSConfig *cldfproposalutils.TimelockConfig -} - -func (c DeployRegulatedTokenConfig) Validate() error { - var errs []error - if c.MCMSConfig == nil { - errs = append(errs, errors.New("MCMSConfig is required")) - } - if err := c.TokenParams.Validate(); err != nil { - errs = append(errs, err) - } - // The deploy sequence grants MINTER_ROLE to the deployer and calls Mint via direct EOA - // transactions before the MCMS proposal is built; reject invalid TokenMint up front so - // we don't fail after partial on-chain side effects. - if c.TokenMint != nil { - if (c.TokenMint.To == aptos.AccountAddress{}) { - errs = append(errs, errors.New("TokenMint.To address is empty")) - } - if c.TokenMint.Amount == 0 { - errs = append(errs, errors.New("TokenMint.Amount is 0")) - } - } - return errors.Join(errs...) -} - -// RegistrarPreregisterOrDefault returns true when unset (matches test helper default). -func (c DeployRegulatedTokenConfig) RegistrarPreregisterOrDefault() bool { - if c.RegistrarPreregister == nil { - return true - } - return *c.RegistrarPreregister -} diff --git a/deployment/ccip/changeset/aptos/config/dynamic.go b/deployment/ccip/changeset/aptos/config/dynamic.go deleted file mode 100644 index 2c238cd4acc..00000000000 --- a/deployment/ccip/changeset/aptos/config/dynamic.go +++ /dev/null @@ -1,14 +0,0 @@ -package config - -import ( - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" -) - -type DynamicConfig struct { - Defs []operations.Definition - Inputs []any // Each element should be the corresponding input type for its operation - ChainSelector uint64 - Description string - MCMSConfig *cldfproposalutils.TimelockConfig -} diff --git a/deployment/ccip/changeset/aptos/config/lane.go b/deployment/ccip/changeset/aptos/config/lane.go deleted file mode 100644 index 2e4faf8af09..00000000000 --- a/deployment/ccip/changeset/aptos/config/lane.go +++ /dev/null @@ -1,175 +0,0 @@ -package config - -import ( - "maps" - "math/big" - - "github.com/ethereum/go-ethereum/common" - chainsel "github.com/smartcontractkit/chain-selectors" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" -) - -type LaneConfig struct { - Source ChainDefinition - Dest ChainDefinition - IsDisabled bool -} - -// UpdateAptosLanesConfig is a configuration struct for AddAptosLanesChangeset -// Lanes accept different chain families -type UpdateAptosLanesConfig struct { - // EVMMCMSConfig defines the MCMS configuration for EVM chains. - EVMMCMSConfig *cldfproposalutils.TimelockConfig - // MCMSConfig defines the MCMS configuration for Aptos chains. - AptosMCMSConfig *cldfproposalutils.TimelockConfig - // Lanes describes the lanes that we want to create. - Lanes []LaneConfig - // TestRouter indicates if we want to enable these lanes on the test router. - TestRouter bool -} - -// ToEVMUpdateLanesConfig adapts the Aptos Add Lanes config to EVM Update Lanes Config -// It adapts all Aptos <> EVM lanes to v1_6.UpdateBidirectionalLanesChangesetConfigs type to be used in UpdateLanesLogic "sequence" -func ToEVMUpdateLanesConfig(aptosAddCfg UpdateAptosLanesConfig) v1_6.UpdateBidirectionalLanesChangesetConfigs { - onRampUpdatesByChain := make(map[uint64]map[uint64]v1_6.OnRampDestinationUpdate) - offRampUpdatesByChain := make(map[uint64]map[uint64]v1_6.OffRampSourceUpdate) - routerUpdatesByChain := make(map[uint64]v1_6.RouterUpdates) - feeQuoterDestUpdatesByChain := make(map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig) - feeQuoterPriceUpdatesByChain := make(map[uint64]v1_6.FeeQuoterPriceUpdatePerSource) - - for _, lane := range aptosAddCfg.Lanes { - if lane.Source.GetChainFamily() == chainsel.FamilyEVM { - setEVMSourceUpdates( - lane, - onRampUpdatesByChain, - routerUpdatesByChain, - feeQuoterDestUpdatesByChain, - feeQuoterPriceUpdatesByChain, - aptosAddCfg.TestRouter, - ) - } - if lane.Dest.GetChainFamily() == chainsel.FamilyEVM { - setEVMDestUpdates( - lane, - routerUpdatesByChain, - offRampUpdatesByChain, - aptosAddCfg.TestRouter, - ) - } - } - - routerMCMSConfig := aptosAddCfg.EVMMCMSConfig - if aptosAddCfg.TestRouter { - routerMCMSConfig = nil // Test router is never owned by MCMS - } - - return v1_6.UpdateBidirectionalLanesChangesetConfigs{ - UpdateFeeQuoterDestsConfig: v1_6.UpdateFeeQuoterDestsConfig{ - MCMS: aptosAddCfg.EVMMCMSConfig, - UpdatesByChain: feeQuoterDestUpdatesByChain, - }, - UpdateFeeQuoterPricesConfig: v1_6.UpdateFeeQuoterPricesConfig{ - MCMS: aptosAddCfg.EVMMCMSConfig, - PricesByChain: feeQuoterPriceUpdatesByChain, - }, - UpdateOnRampDestsConfig: v1_6.UpdateOnRampDestsConfig{ - MCMS: aptosAddCfg.EVMMCMSConfig, - UpdatesByChain: onRampUpdatesByChain, - }, - UpdateOffRampSourcesConfig: v1_6.UpdateOffRampSourcesConfig{ - MCMS: aptosAddCfg.EVMMCMSConfig, - UpdatesByChain: offRampUpdatesByChain, - }, - UpdateRouterRampsConfig: v1_6.UpdateRouterRampsConfig{ - TestRouter: aptosAddCfg.TestRouter, - MCMS: routerMCMSConfig, - UpdatesByChain: routerUpdatesByChain, - }, - } -} - -// setEVMSourceUpdates requires Source: EVM -> Destination: Aptos -func setEVMSourceUpdates( - lane LaneConfig, - onRampUpdatesByChain map[uint64]map[uint64]v1_6.OnRampDestinationUpdate, - routerUpdatesByChain map[uint64]v1_6.RouterUpdates, - feeQuoterDestUpdatesByChain map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig, - feeQuoterPriceUpdatesByChain map[uint64]v1_6.FeeQuoterPriceUpdatePerSource, - isTestRouter bool, -) { - source := lane.Source.(EVMChainDefinition) - dest := lane.Dest.(AptosChainDefinition) - isEnabled := !lane.IsDisabled - - // Setting the destination on the on ramp - if onRampUpdatesByChain[source.Selector] == nil { - onRampUpdatesByChain[source.Selector] = make(map[uint64]v1_6.OnRampDestinationUpdate) - } - onRampUpdatesByChain[source.Selector][dest.Selector] = v1_6.OnRampDestinationUpdate{ - IsEnabled: isEnabled, - TestRouter: isTestRouter, - AllowListEnabled: dest.AllowListEnabled, - } - - // Setting the on ramp on the source router - routerUpdatesOnSource := routerUpdatesByChain[source.Selector] - if routerUpdatesByChain[source.Selector].OnRampUpdates == nil { - routerUpdatesOnSource.OnRampUpdates = make(map[uint64]bool) - } - routerUpdatesOnSource.OnRampUpdates[dest.Selector] = isEnabled - routerUpdatesByChain[source.Selector] = routerUpdatesOnSource - - // Setting the fee quoter destination on the source chain - if feeQuoterDestUpdatesByChain[source.Selector] == nil { - feeQuoterDestUpdatesByChain[source.Selector] = make(map[uint64]fee_quoter.FeeQuoterDestChainConfig) - } - feeQuoterDestUpdatesByChain[source.Selector][dest.Selector] = dest.GetConvertedEVMFeeQuoterConfig() - - // Setting the destination gas prices on the source chain - feeQuoterPriceUpdatesOnSource := feeQuoterPriceUpdatesByChain[source.Selector] - if feeQuoterPriceUpdatesOnSource.GasPrices == nil { - feeQuoterPriceUpdatesOnSource.GasPrices = make(map[uint64]*big.Int) - } - feeQuoterPriceUpdatesOnSource.GasPrices[dest.Selector] = dest.GasPrice - feeQuoterPriceUpdatesByChain[source.Selector] = feeQuoterPriceUpdatesOnSource - - // Setting the destination token prices on the source chain - if feeQuoterPriceUpdatesOnSource.TokenPrices == nil { - feeQuoterPriceUpdatesOnSource.TokenPrices = make(map[common.Address]*big.Int) - } - maps.Copy(feeQuoterPriceUpdatesOnSource.TokenPrices, source.TokenPrices) -} - -// setEVMSourceUpdates requires Source: Aptos -> Destination: EVM -func setEVMDestUpdates( - lane LaneConfig, - routerUpdatesByChain map[uint64]v1_6.RouterUpdates, - offRampUpdatesByChain map[uint64]map[uint64]v1_6.OffRampSourceUpdate, - isTestRouter bool, -) { - source := lane.Source.(AptosChainDefinition) - dest := lane.Dest.(EVMChainDefinition) - isEnabled := !lane.IsDisabled - - // Setting the source on the off ramp - if offRampUpdatesByChain[dest.Selector] == nil { - offRampUpdatesByChain[dest.Selector] = make(map[uint64]v1_6.OffRampSourceUpdate) - } - offRampUpdatesByChain[dest.Selector][source.Selector] = v1_6.OffRampSourceUpdate{ - IsEnabled: isEnabled, - TestRouter: isTestRouter, - IsRMNVerificationDisabled: source.RMNVerificationDisabled, - } - - // Setting the off ramp on the dest router - routerUpdatesOnDest := routerUpdatesByChain[dest.Selector] - if routerUpdatesByChain[dest.Selector].OffRampUpdates == nil { - routerUpdatesOnDest.OffRampUpdates = make(map[uint64]bool) - } - routerUpdatesOnDest.OffRampUpdates[source.Selector] = isEnabled - routerUpdatesByChain[dest.Selector] = routerUpdatesOnDest -} diff --git a/deployment/ccip/changeset/aptos/config/lane_test.go b/deployment/ccip/changeset/aptos/config/lane_test.go deleted file mode 100644 index 0f0c9b47548..00000000000 --- a/deployment/ccip/changeset/aptos/config/lane_test.go +++ /dev/null @@ -1,181 +0,0 @@ -package config - -import ( - "encoding/hex" - "math/big" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - aptos_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" -) - -func TestToEVMUpdateLanesConfig(t *testing.T) { - t.Parallel() - tests := []struct { - name string - input UpdateAptosLanesConfig - expected v1_6.UpdateBidirectionalLanesChangesetConfigs - }{ - { - name: "EVM <> Aptos Biderectional Lane", - input: UpdateAptosLanesConfig{ - EVMMCMSConfig: &cldfproposalutils.TimelockConfig{}, - Lanes: []LaneConfig{ - { - Source: getEVMDef(), - Dest: getAptosDef(t), - IsDisabled: false, - }, - { - Source: getAptosDef(t), - Dest: getEVMDef(), - IsDisabled: false, - }, - }, - TestRouter: false, - }, - expected: v1_6.UpdateBidirectionalLanesChangesetConfigs{ - UpdateFeeQuoterDestsConfig: v1_6.UpdateFeeQuoterDestsConfig{ - MCMS: &cldfproposalutils.TimelockConfig{}, - UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{ - 1881: { - 4457093679053095497: fee_quoter.FeeQuoterDestChainConfig{ - IsEnabled: true, - MaxNumberOfTokensPerMsg: 11, - MaxDataBytes: 40_000, - MaxPerMsgGasLimit: 4_000_000, - DestGasOverhead: ccipevm.DestGasOverhead, - DefaultTokenFeeUSDCents: 30, - DestGasPerPayloadByteBase: ccipevm.CalldataGasPerByteBase, - DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, - DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, - DestDataAvailabilityOverheadGas: 700, - DestGasPerDataAvailabilityByte: 17, - DestDataAvailabilityMultiplierBps: 2, - DefaultTokenDestGasOverhead: 100_000, - DefaultTxGasLimit: 100_000, - GasMultiplierWeiPerEth: 12e17, - NetworkFeeUSDCents: 20, - EnforceOutOfOrder: false, - GasPriceStalenessThreshold: 2, - ChainFamilySelector: [4]byte{0xac, 0x77, 0xff, 0xec}, // From AptosFamilySelector "ac77ffec" - }, - }, - }, - }, - UpdateFeeQuoterPricesConfig: v1_6.UpdateFeeQuoterPricesConfig{ - MCMS: &cldfproposalutils.TimelockConfig{}, - PricesByChain: map[uint64]v1_6.FeeQuoterPriceUpdatePerSource{ - 1881: { - GasPrices: map[uint64]*big.Int{ - 4457093679053095497: big.NewInt(100), - }, - }, - }, - }, - UpdateOnRampDestsConfig: v1_6.UpdateOnRampDestsConfig{ - MCMS: &cldfproposalutils.TimelockConfig{}, - UpdatesByChain: map[uint64]map[uint64]v1_6.OnRampDestinationUpdate{ - 1881: { - 4457093679053095497: v1_6.OnRampDestinationUpdate{ - IsEnabled: true, - TestRouter: false, - AllowListEnabled: true, - }, - }, - }, - }, - UpdateOffRampSourcesConfig: v1_6.UpdateOffRampSourcesConfig{ - MCMS: &cldfproposalutils.TimelockConfig{}, - UpdatesByChain: map[uint64]map[uint64]v1_6.OffRampSourceUpdate{ - 1881: { - 4457093679053095497: v1_6.OffRampSourceUpdate{ - IsEnabled: true, - TestRouter: false, - IsRMNVerificationDisabled: false, - }, - }, - }, - }, - UpdateRouterRampsConfig: v1_6.UpdateRouterRampsConfig{ - TestRouter: false, - MCMS: &cldfproposalutils.TimelockConfig{}, - UpdatesByChain: map[uint64]v1_6.RouterUpdates{ - 1881: { - OnRampUpdates: map[uint64]bool{ - 4457093679053095497: true, - }, - OffRampUpdates: map[uint64]bool{ - 4457093679053095497: true, - }, - }, - }, - }, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - result := ToEVMUpdateLanesConfig(tt.input) - assert.Equal(t, tt.expected, result) - }) - } -} - -func getEVMDef() EVMChainDefinition { - return EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, - Selector: 1881, - GasPrice: big.NewInt(1e17), - FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), - }, - OnRampVersion: []byte{1, 6, 0}, - } -} - -func getAptosDef(t *testing.T) AptosChainDefinition { - return AptosChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{AllowListEnabled: true}, - Selector: 4457093679053095497, - GasPrice: big.NewInt(100), - FeeQuoterDestChainConfig: aptos_fee_quoter.DestChainConfig{ - IsEnabled: true, - MaxNumberOfTokensPerMsg: 11, - MaxDataBytes: 40_000, - MaxPerMsgGasLimit: 4_000_000, - DestGasOverhead: ccipevm.DestGasOverhead, - DefaultTokenFeeUsdCents: 30, - DestGasPerPayloadByteBase: ccipevm.CalldataGasPerByteBase, - DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, - DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, - DestDataAvailabilityOverheadGas: 700, - DestGasPerDataAvailabilityByte: 17, - DestDataAvailabilityMultiplierBps: 2, - DefaultTokenDestGasOverhead: 100_000, - DefaultTxGasLimit: 100_000, - GasMultiplierWeiPerEth: 12e17, - NetworkFeeUsdCents: 20, - ChainFamilySelector: hexMustDecode(t, v1_6.AptosFamilySelector), - EnforceOutOfOrder: false, - GasPriceStalenessThreshold: 2, - }, - } -} - -func hexMustDecode(t *testing.T, s string) []byte { - b, err := hex.DecodeString(s) - require.NoError(t, err) - return b -} diff --git a/deployment/ccip/changeset/aptos/config/migrate_onramp.go b/deployment/ccip/changeset/aptos/config/migrate_onramp.go deleted file mode 100644 index 04a039e3ae1..00000000000 --- a/deployment/ccip/changeset/aptos/config/migrate_onramp.go +++ /dev/null @@ -1,14 +0,0 @@ -package config - -import ( - "github.com/aptos-labs/aptos-go-sdk" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" -) - -type MigrateOnRampDestChainConfigsToV2Config struct { - ChainSelector uint64 - DestChainSelectors []uint64 - RouterModuleAddresses []aptos.AccountAddress - MCMS *cldfproposalutils.TimelockConfig -} diff --git a/deployment/ccip/changeset/aptos/config/token.go b/deployment/ccip/changeset/aptos/config/token.go deleted file mode 100644 index 363e8d28430..00000000000 --- a/deployment/ccip/changeset/aptos/config/token.go +++ /dev/null @@ -1,100 +0,0 @@ -package config - -import ( - "errors" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -type TokenParams struct { - MaxSupply *big.Int - Name string - Symbol shared.TokenSymbol - Decimals byte - Icon string - Project string -} - -func (tp TokenParams) Validate() error { - if tp.MaxSupply != nil && tp.MaxSupply.Sign() <= 0 { - return errors.New("maxSupply must be a positive integer or nil") - } - if tp.Name == "" { - return errors.New("name cannot be empty") - } - if tp.Symbol == "" { - return errors.New("symbol cannot be empty") - } - if tp.Decimals < 1 || tp.Decimals > 8 { - return errors.New("decimals must be between 1 and 8") - } - return nil -} - -type TokenMint struct { - Amount uint64 - To aptos.AccountAddress -} - -type DeployTokenFaucetInput struct { - ChainSelector uint64 - TokenCodeObjectAddress aptos.AccountAddress - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type MintTokenInput struct { - ChainSelector uint64 - TokenCodeObjectAddress aptos.AccountAddress - MCMSConfig *cldfproposalutils.TimelockConfig - TokenMint -} - -// ################### -// # Token Ownership # -// ################### - -type TokenTransferInput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenType deployment.ContractType - To aptos.AccountAddress -} - -type TransferTokenOwnershipInput struct { - ChainSelector uint64 - Transfers []TokenTransferInput - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type TokenAcceptInput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenType deployment.ContractType -} - -type AcceptTokenOwnershipInput struct { - ChainSelector uint64 - Accepts []TokenAcceptInput - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type ExecuteTokenOwnershipTransferInput struct { - ChainSelector uint64 - Transfers []TokenTransferInput - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type TransferTokenAdminInput struct { - ChainSelector uint64 - Transfers []TokenTransferInput - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type AcceptTokenAdminInput struct { - ChainSelector uint64 - Accepts []TokenAcceptInput - MCMSConfig *cldfproposalutils.TimelockConfig -} diff --git a/deployment/ccip/changeset/aptos/config/token_pool.go b/deployment/ccip/changeset/aptos/config/token_pool.go deleted file mode 100644 index 1f972d5bd99..00000000000 --- a/deployment/ccip/changeset/aptos/config/token_pool.go +++ /dev/null @@ -1,87 +0,0 @@ -package config - -import ( - "errors" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/ethereum/go-ethereum/common" - - fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" -) - -type AddTokenPoolConfig struct { - // DeployAptosTokenConfig - ChainSelector uint64 - TokenAddress aptos.AccountAddress // if empty, token will be deployed - TokenCodeObjAddress aptos.AccountAddress // if empty, token will be deployed - TokenPoolAddress aptos.AccountAddress // if empty, token pool will be deployed - PoolType cldf.ContractType - TokenTransferFeeByRemoteChainConfig map[uint64]fee_quoter.TokenTransferFeeConfig - EVMRemoteConfigs map[uint64]EVMRemoteConfig - TokenParams TokenParams - MCMSConfig *cldfproposalutils.TimelockConfig - TokenMint *TokenMint -} - -type EVMRemoteConfig struct { - TokenAddress common.Address - // TODO: EVM has a way of picking up Pool by token address and type, use this instead of passing PoolAddress - TokenPoolAddress common.Address - RateLimiterConfig -} - -func (erc EVMRemoteConfig) Validate() error { - if erc.TokenAddress == (common.Address{}) { - return errors.New("TokenAddress cannot be empty") - } - if erc.TokenPoolAddress == (common.Address{}) { - return errors.New("TokenPoolAddress cannot be empty") - } - - return nil -} - -type RateLimiterConfig struct { - RemoteChainSelector uint64 - OutboundIsEnabled bool - OutboundCapacity uint64 - OutboundRate uint64 - InboundIsEnabled bool - InboundCapacity uint64 - InboundRate uint64 -} - -// ######################## -// # Token Pool Ownership # -// ######################## - -type TokenPoolTransfer struct { - TokenPoolAddress aptos.AccountAddress - To aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -type TransferTokenPoolOwnershipInput struct { - ChainSelector uint64 - Transfers []TokenPoolTransfer - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type TokenPoolAccept struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -type AcceptTokenPoolOwnershipInput struct { - ChainSelector uint64 - Accepts []TokenPoolAccept - MCMSConfig *cldfproposalutils.TimelockConfig -} - -type ExecuteTokenPoolOwnershipTransferInput struct { - ChainSelector uint64 - Transfers []TokenPoolTransfer - MCMSConfig *cldfproposalutils.TimelockConfig -} diff --git a/deployment/ccip/changeset/aptos/config/upgrade.go b/deployment/ccip/changeset/aptos/config/upgrade.go deleted file mode 100644 index 4717e7be4be..00000000000 --- a/deployment/ccip/changeset/aptos/config/upgrade.go +++ /dev/null @@ -1,12 +0,0 @@ -package config - -import cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - -type UpgradeAptosChainConfig struct { - ChainSelector uint64 - UpgradeCCIP bool - UpgradeOffRamp bool - UpgradeOnRamp bool - UpgradeRouter bool - MCMS *cldfproposalutils.TimelockConfig -} diff --git a/deployment/ccip/changeset/aptos/cs_add_token_pool.go b/deployment/ccip/changeset/aptos/cs_add_token_pool.go deleted file mode 100644 index 6fcfcd209e7..00000000000 --- a/deployment/ccip/changeset/aptos/cs_add_token_pool.go +++ /dev/null @@ -1,287 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - "strings" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/ethereum/go-ethereum/common" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" -) - -var _ cldf.ChangeSetV2[config.AddTokenPoolConfig] = AddTokenPool{} - -// AddTokenPool deploys token pools and sets up tokens on lanes -type AddTokenPool struct{} - -func (cs AddTokenPool) VerifyPreconditions(env cldf.Environment, cfg config.AddTokenPoolConfig) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - // Validate supported chain - supportedChains := state.SupportedChains() - if _, ok := supportedChains[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - // Validate CCIP deployed - if state.AptosChains[cfg.ChainSelector].CCIPAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("CCIP is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - // Validate MCMS config - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required for AddTokenPool changeset")) - } - // Validate config.TokenParams - if cfg.TokenCodeObjAddress == (aptos.AccountAddress{}) { - err = cfg.TokenParams.Validate() - if err != nil { - errs = append(errs, fmt.Errorf("invalid token parameters: %w", err)) - } - } - // Validate config.EVMRemoteConfigs - for chainSelector, remoteConfig := range cfg.EVMRemoteConfigs { - if err := remoteConfig.Validate(); err != nil { - errs = append(errs, fmt.Errorf("invalid EVM remote config for chain %d: %w", chainSelector, err)) - } - } - // Validate if token address is provided if pool address is specified - if cfg.TokenCodeObjAddress == (aptos.AccountAddress{}) && cfg.TokenPoolAddress != (aptos.AccountAddress{}) { - errs = append(errs, errors.New("token object address must be provided if token pool address is specified")) - } - // No token pool address provided, so no need to validate token address - if cfg.TokenCodeObjAddress == (aptos.AccountAddress{}) && cfg.TokenPoolAddress == (aptos.AccountAddress{}) { - return errors.Join(errs...) - } - // Validate if token already exists with different pool address - for token, pool := range state.AptosChains[cfg.ChainSelector].AptosManagedTokenPools { - if (token == cfg.TokenAddress) && (pool != cfg.TokenPoolAddress) { - errs = append(errs, fmt.Errorf("token %s already exists with a different pool address %s", token.StringLong(), pool.StringLong())) - } - if (pool == cfg.TokenPoolAddress) && (token != cfg.TokenAddress) { - errs = append(errs, fmt.Errorf("pool %s already exists with a different token address %s", pool.StringLong(), token.StringLong())) - } - } - for token, pool := range state.AptosChains[cfg.ChainSelector].RegulatedTokenPools { - if (token == cfg.TokenAddress) && (pool != cfg.TokenPoolAddress) { - errs = append(errs, fmt.Errorf("token %s already exists with a different pool address %s", token.StringLong(), pool.StringLong())) - } - if (pool == cfg.TokenPoolAddress) && (token != cfg.TokenAddress) { - errs = append(errs, fmt.Errorf("pool %s already exists with a different token address %s", pool.StringLong(), token.StringLong())) - } - } - for token, pool := range state.AptosChains[cfg.ChainSelector].BurnMintTokenPools { - if (token == cfg.TokenAddress) && (pool != cfg.TokenPoolAddress) { - errs = append(errs, fmt.Errorf("token %s already exists with a different pool address %s", token.StringLong(), pool.StringLong())) - } - if (pool == cfg.TokenPoolAddress) && (token != cfg.TokenAddress) { - errs = append(errs, fmt.Errorf("pool %s already exists with a different token address %s", pool.StringLong(), token.StringLong())) - } - } - for token, pool := range state.AptosChains[cfg.ChainSelector].LockReleaseTokenPools { - if (token == cfg.TokenAddress) && (pool != cfg.TokenPoolAddress) { - errs = append(errs, fmt.Errorf("token %s already exists with a different pool address %s", token.StringLong(), pool.StringLong())) - } - if (pool == cfg.TokenPoolAddress) && (token != cfg.TokenAddress) { - errs = append(errs, fmt.Errorf("pool %s already exists with a different token address %s", pool.StringLong(), token.StringLong())) - } - } - // Validate regulated token ownership finalization preconditions: when adding a regulated - // token pool against a pre-existing regulated token, a pending ownership transfer to MCMS - // (if any) must be in a state where the deployer EOA can finalize it. - if cfg.PoolType == shared.AptosRegulatedTokenPoolType && cfg.TokenCodeObjAddress != (aptos.AccountAddress{}) { - deps := dependency.AptosDeps{ - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - mcmsAddress := state.AptosChains[cfg.ChainSelector].MCMSAddress - if err := seq.VerifyFinalizeRegulatedTokenOwnership(deps, cfg.TokenCodeObjAddress, mcmsAddress); err != nil { - errs = append(errs, fmt.Errorf("regulated token ownership finalize precondition: %w", err)) - } - } - return errors.Join(errs...) -} - -func (cs AddTokenPool) Apply(env cldf.Environment, cfg config.AddTokenPoolConfig) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - aptosChain := env.BlockChains.AptosChains()[cfg.ChainSelector] - ab := cldf.NewMemoryAddressBook() - seqReports := make([]operations.Report[any, any], 0) - proposals := make([]mcms.TimelockProposal, 0) - var mcmsOperations []mcmstypes.BatchOperation - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - // Finalize the regulated_token 3-step ownership handoff if needed: when MCMS has accepted - // ownership but the original deployer hasn't called execute_ownership_transfer yet, the - // token object still belongs to the deployer and isTokenOwnedByMCMS would return false. - if cfg.PoolType == shared.AptosRegulatedTokenPoolType && cfg.TokenCodeObjAddress != (aptos.AccountAddress{}) { - finalizeReport, err := operations.ExecuteSequence( - env.OperationsBundle, - seq.FinalizeRegulatedTokenOwnershipSequence, - deps, - cfg.TokenCodeObjAddress, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to finalize regulated token ownership: %w", err) - } - seqReports = append(seqReports, finalizeReport.ExecutionReports...) - } - - // Deploy Aptos Token - tokenCodeObjAddress := cfg.TokenCodeObjAddress - tokenAddress := cfg.TokenAddress - if cfg.TokenCodeObjAddress == (aptos.AccountAddress{}) { - deployTokenIn := seq.DeployTokenSeqInput{ - TokenParams: cfg.TokenParams, - MCMSAddress: state.AptosChains[cfg.ChainSelector].MCMSAddress, - TokenMint: cfg.TokenMint, - } - deploySeq, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployAptosTokenSequence, deps, deployTokenIn) - if err != nil { - return cldf.ChangesetOutput{}, err - } - tokenCodeObjAddress = deploySeq.Output.TokenCodeObjAddress - tokenAddress = deploySeq.Output.TokenAddress - seqReports = append(seqReports, deploySeq.ExecutionReports...) - mcmsOperations = append(mcmsOperations, deploySeq.Output.MCMSOperations...) - // Save token object address in address book - typeAndVersion := cldf.NewTypeAndVersion(shared.AptosManagedTokenType, deployment.Version1_6_0) - typeAndVersion.AddLabel(string(cfg.TokenParams.Symbol)) - err = deps.AB.Save(deps.AptosChain.Selector, deploySeq.Output.TokenCodeObjAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save token object address %s: %w", deploySeq.Output.TokenCodeObjAddress, err) - } - // Save token address in address book - typeAndVersion = cldf.NewTypeAndVersion(cldf.ContractType(cfg.TokenParams.Symbol), deployment.Version1_6_0) - err = deps.AB.Save(deps.AptosChain.Selector, deploySeq.Output.TokenAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save token address %s: %w", deploySeq.Output.TokenAddress, err) - } - } - - // Deploy Aptos token pool - tokenPoolAddress := cfg.TokenPoolAddress - if cfg.TokenPoolAddress == (aptos.AccountAddress{}) { - isOwned, err := isTokenOwnedByMCMS(deps, cfg.TokenCodeObjAddress) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to check if token is owned by MCMS: %w", err) - } - depInput := seq.DeployTokenPoolSeqInput{ - TokenCodeObjAddress: tokenCodeObjAddress, - TokenAddress: tokenAddress, - PoolType: cfg.PoolType, - IsTokenOwnedByMCMS: isOwned, - } - deploySeq, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployAptosTokenPoolSequence, deps, depInput) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, deploySeq.ExecutionReports...) - mcmsOperations = append(mcmsOperations, deploySeq.Output.MCMSOps...) - tokenPoolAddress = deploySeq.Output.TokenPoolAddress - // Save token pool address in address book - typeAndVersion := cldf.NewTypeAndVersion(cfg.PoolType, deployment.Version1_6_0) - typeAndVersion.AddLabel(tokenAddress.StringLong()) - err = deps.AB.Save(deps.AptosChain.Selector, deploySeq.Output.TokenPoolAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save token pool address %s: %w", deploySeq.Output.TokenPoolAddress, err) - } - } - - // Connect token pools EVM -> Aptos - connInput := seq.ConnectTokenPoolSeqInput{ - TokenPoolAddress: tokenPoolAddress, - TokenPoolType: cfg.PoolType, - RemotePools: toRemotePools(cfg.EVMRemoteConfigs), - TokenAddress: tokenAddress, - TokenTransferFeeByRemoteChainConfig: cfg.TokenTransferFeeByRemoteChainConfig, - } - connectSeq, err := operations.ExecuteSequence(env.OperationsBundle, seq.ConnectTokenPoolSequence, deps, connInput) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, connectSeq.ExecutionReports...) - mcmsOperations = append(mcmsOperations, connectSeq.Output) - - // Generate Aptos MCMS proposals - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - mcmsOperations, - "Deploy and configure token pool on Aptos chain", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - proposals = append(proposals, *proposal) - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate in-memory DataStore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: proposals, - Reports: seqReports, - }, nil -} - -func isTokenOwnedByMCMS(deps dependency.AptosDeps, cfgTokenAddress aptos.AccountAddress) (bool, error) { - if cfgTokenAddress == (aptos.AccountAddress{}) { - // Token cfg not provided, so token is newly deployed and owned by MCMS - return true, nil - } - mcmsAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].MCMSAddress - mcmsContract := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - isOwned, err := mcmsContract.MCMSRegistry().IsOwnedCodeObject(nil, cfgTokenAddress) - if err != nil { - eMsg := err.Error() - if strings.Contains(eMsg, "E_ADDRESS_NOT_REGISTERED") { - // If token is not registered, treat as just not owned by MCMS - // This is not an error per se - return false, nil - } - return false, fmt.Errorf("failed to check if token is owned by MCMS: %w", err) - } - return isOwned, nil -} - -func toRemotePools(evmRemoteCfg map[uint64]config.EVMRemoteConfig) map[uint64]seq.RemotePool { - remotePools := make(map[uint64]seq.RemotePool) - for chainSelector, remoteConfig := range evmRemoteCfg { - remotePools[chainSelector] = seq.RemotePool{ - RemotePoolAddress: remoteConfig.TokenPoolAddress.Bytes(), - RemoteTokenAddress: common.LeftPadBytes(remoteConfig.TokenAddress.Bytes(), 32), - RateLimiterConfig: remoteConfig.RateLimiterConfig, - } - } - return remotePools -} diff --git a/deployment/ccip/changeset/aptos/cs_add_token_pool_test.go b/deployment/ccip/changeset/aptos/cs_add_token_pool_test.go deleted file mode 100644 index 01cd039c6e4..00000000000 --- a/deployment/ccip/changeset/aptos/cs_add_token_pool_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package aptos_test - -import ( - "fmt" - "math/big" - "testing" - "time" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/ethereum/go-ethereum/common" - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/managed_token_pool" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" -) - -var testTokenTransferFeeConfig = fee_quoter.TokenTransferFeeConfig{ - MinFeeUsdCents: 50, - MaxFeeUsdCents: 1600, - DeciBps: 0, - DestGasOverhead: 300_000, - DestBytesOverhead: 100, - IsEnabled: true, -} - -func TestAddTokenPool_Apply(t *testing.T) { - t.Parallel() - // Setup environment and config with 1 Aptos chain - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - // Get chain selectors for Aptos - aptosChainSelectors := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos)) - require.Len(t, aptosChainSelectors, 1, "Expected exactly 1 Aptos chain") - aptosSelector := aptosChainSelectors[0] - - mockEVMPool := "0xbd10ffa3815c010d5cf7d38815a0eaabc959eb84" - // Get EVM chain selectors - emvSelector1 := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM))[0] - emvSelector2 := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM))[1] - - // Configure token pool settings - cfg := config.AddTokenPoolConfig{ - MCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - ChainSelector: aptosSelector, - PoolType: shared.AptosManagedTokenPoolType, - EVMRemoteConfigs: map[uint64]config.EVMRemoteConfig{ - emvSelector1: { - TokenAddress: common.HexToAddress("0xa"), - TokenPoolAddress: common.HexToAddress(mockEVMPool), - RateLimiterConfig: config.RateLimiterConfig{ - RemoteChainSelector: emvSelector1, - OutboundIsEnabled: false, - OutboundCapacity: 0, - OutboundRate: 0, - InboundIsEnabled: true, - InboundCapacity: 110, - InboundRate: 20, - }, - }, - emvSelector2: { - TokenAddress: common.HexToAddress("0xa"), - TokenPoolAddress: common.HexToAddress(mockEVMPool), - RateLimiterConfig: config.RateLimiterConfig{ - RemoteChainSelector: emvSelector2, - OutboundIsEnabled: false, - OutboundCapacity: 0, - OutboundRate: 0, - InboundIsEnabled: true, - InboundCapacity: 110, - InboundRate: 20, - }, - }, - }, - TokenTransferFeeByRemoteChainConfig: map[uint64]fee_quoter.TokenTransferFeeConfig{ - emvSelector2: testTokenTransferFeeConfig, - }, - TokenParams: config.TokenParams{ - MaxSupply: big.NewInt(1000000), - Name: "BnMTest", - Symbol: "BnM", - Decimals: 8, - Icon: "", - Project: "", - }, - } - - // Apply the AddTokenPool changeset - env, output, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.AddTokenPool{}, cfg), - }) - require.NoError(t, err) - - // Load onchain state for assertions - state, err := stateview.LoadOnchainState(env) - require.NoError(t, err, "must load onchain state") - require.NotNil(t, state.AptosChains[aptosSelector].AptosManagedTokenPools) - - client := env.BlockChains.AptosChains()[aptosSelector].Client - aptosCCIPAddr := state.AptosChains[aptosSelector].CCIPAddress - ccipContract := ccip.Bind(aptosCCIPAddr, client) - mcmsAddress := state.AptosChains[aptosSelector].MCMSAddress - mcmsContract := mcmsbind.Bind(mcmsAddress, client) - - expectedAdm, err := mcmsContract.MCMSRegistry().GetRegisteredOwnerAddress(nil, aptosCCIPAddr) - require.NoError(t, err) - - for tokenAddress, pool := range state.AptosChains[aptosSelector].AptosManagedTokenPools { - poolBind := managed_token_pool.Bind(pool, env.BlockChains.AptosChains()[aptosSelector].Client) - - remotePools, err := poolBind.ManagedTokenPool().GetRemotePools(nil, emvSelector1) - require.NoError(t, err) - require.NotEmpty(t, remotePools) - hexString := fmt.Sprintf("0x%x", remotePools[0]) - assert.Equal(t, hexString, mockEVMPool) - - remotePools2, err := poolBind.ManagedTokenPool().GetRemotePools(nil, emvSelector2) - require.NoError(t, err) - require.NotEmpty(t, remotePools2) - hexString = fmt.Sprintf("0x%x", remotePools2[0]) - assert.Equal(t, hexString, mockEVMPool) - - poolAdd, admin, pendingAdm, err := ccipContract.TokenAdminRegistry().GetTokenConfig(nil, tokenAddress) - require.NoError(t, err) - require.Equal(t, pool, poolAdd, "Expected the registered pool to match the deployed pool") - require.Equal(t, expectedAdm, admin, "Admin should match ccipOwnerAddress") - require.Equal(t, aptos.AccountAddress{}, pendingAdm, "Pending admin should be empty") - - ttfcfgs1, err := ccipContract.FeeQuoter().GetTokenTransferFeeConfig(nil, emvSelector1, tokenAddress) - require.NoError(t, err) - require.Equal(t, fee_quoter.TokenTransferFeeConfig{}, ttfcfgs1) - ttfcfgs2, err := ccipContract.FeeQuoter().GetTokenTransferFeeConfig(nil, emvSelector2, tokenAddress) - require.NoError(t, err) - require.Equal(t, testTokenTransferFeeConfig, ttfcfgs2) - } - - // The output should include MCMS proposals - require.Len(t, output[0].MCMSTimelockProposals, 1, "Expected exactly 1 MCMS proposal") - require.Len(t, output[0].MCMSTimelockProposals[0].Operations, 7, "Expected exactly 7 MCMS proposal operations, received:", len(output[0].MCMSTimelockProposals[0].Operations)) -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain.go b/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain.go deleted file mode 100644 index b55c3728460..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain.go +++ /dev/null @@ -1,192 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" - contracttypes "github.com/smartcontractkit/chainlink/deployment/common/types" -) - -var _ cldf.ChangeSetV2[config.DeployAptosChainConfig] = DeployAptosChain{} - -// DeployAptosChain deploys Aptos chain packages and modules -type DeployAptosChain struct{} - -func (cs DeployAptosChain) VerifyPreconditions(env cldf.Environment, config config.DeployAptosChainConfig) error { - // Validate env and prerequisite contracts - state, err := aptosstate.LoadOnchainStateAptos(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - aptosChains := env.BlockChains.AptosChains() - var errs []error - for chainSel := range config.ContractParamsPerChain { - if err := config.Validate(); err != nil { - errs = append(errs, fmt.Errorf("invalid config for Aptos chain %d: %w", chainSel, err)) - continue - } - if _, ok := aptosChains[chainSel]; !ok { - errs = append(errs, fmt.Errorf("aptos chain %d not found in env", chainSel)) - } - chainState, ok := state[chainSel] - if !ok { - errs = append(errs, fmt.Errorf("aptos chain %d not found in state", chainSel)) - continue - } - if chainState.MCMSAddress == (aptos.AccountAddress{}) { - mcmsConfig := config.MCMSDeployConfigPerChain[chainSel] - for _, cfg := range []mcmstypes.Config{mcmsConfig.Bypasser, mcmsConfig.Canceller, mcmsConfig.Proposer} { - if err := cfg.Validate(); err != nil { - errs = append(errs, fmt.Errorf("invalid mcms configs for Aptos chain %d: %w", chainSel, err)) - } - } - if mcmsConfig.TimelockMinDelay == nil { - errs = append(errs, fmt.Errorf("invalid MCMS timelock min delay for Aptos chain %d: %s", chainSel, mcmsConfig.TimelockMinDelay)) - } - } - } - - return errors.Join(errs...) -} - -func (cs DeployAptosChain) Apply(env cldf.Environment, cfg config.DeployAptosChainConfig) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - ab := cldf.NewMemoryAddressBook() - seqReports := make([]operations.Report[any, any], 0) - proposals := make([]mcms.TimelockProposal, 0) - - aptosChains := env.BlockChains.AptosChains() - // Deploy CCIP on each Aptos chain in config - for chainSel := range cfg.ContractParamsPerChain { - var mcmsOperations []mcmstypes.BatchOperation - aptosChain := aptosChains[chainSel] - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - // MCMS Deploy operations - mcmsSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployMCMSSequence, deps, cfg.MCMSDeployConfigPerChain[chainSel]) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, mcmsSeqReport.ExecutionReports...) - mcmsOperations = append(mcmsOperations, mcmsSeqReport.Output.MCMSOperation) - - // Save MCMS address - typeAndVersion := cldf.NewTypeAndVersion(shared.AptosMCMSType, deployment.Version1_6_0) - err = deps.AB.Save(deps.AptosChain.Selector, mcmsSeqReport.Output.MCMSAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save MCMS address %s for Aptos chain %d: %w", mcmsSeqReport.Output.MCMSAddress.StringLong(), chainSel, err) - } - - // Deploy Link token if not already deployed - linkTokenAddress := state.AptosChains[chainSel].LinkTokenAddress - if linkTokenAddress == (aptos.AccountAddress{}) { - // Deploy Link token - deployTokenIn := seq.DeployTokenSeqInput{ - TokenParams: config.TokenParams{ - MaxSupply: nil, - Name: "ChainLink Token", - Symbol: "LINK", - Decimals: 8, - Icon: "https://raw.githubusercontent.com/smartcontractkit/documentation/main/public/assets/icons/link.svg", - Project: "https://chain.link", - }, - MCMSAddress: mcmsSeqReport.Output.MCMSAddress, - } - linkSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployAptosTokenSequence, deps, deployTokenIn) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy Link token for Aptos chain %d: %w", chainSel, err) - } - seqReports = append(seqReports, linkSeqReport.ExecutionReports...) - mcmsOperations = append(mcmsOperations, linkSeqReport.Output.MCMSOperations...) - - // Save token object address in address book - typeAndVersion = cldf.NewTypeAndVersion(shared.AptosManagedTokenType, deployment.Version1_6_0) - typeAndVersion.AddLabel(string(shared.LinkSymbol)) - err = deps.AB.Save(deps.AptosChain.Selector, linkSeqReport.Output.TokenCodeObjAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save Link token object address %s for Aptos chain %d: %w", linkSeqReport.Output.TokenCodeObjAddress.StringLong(), chainSel, err) - } - // Save Link token address - typeAndVersion = cldf.NewTypeAndVersion(contracttypes.LinkToken, deployment.Version1_6_0) - err = deps.AB.Save(deps.AptosChain.Selector, linkSeqReport.Output.TokenAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save Link token address %s for Aptos chain %d: %w", linkSeqReport.Output.TokenAddress.StringLong(), chainSel, err) - } - linkTokenAddress = linkSeqReport.Output.TokenAddress - - // Add token to config - params := cfg.ContractParamsPerChain[chainSel] - params.FeeQuoterParams.FeeTokens = append(params.FeeQuoterParams.FeeTokens, linkTokenAddress) - cfg.ContractParamsPerChain[chainSel] = params - } - - // CCIP Deploy operations - ccipSeqInput := seq.DeployCCIPSeqInput{ - MCMSAddress: mcmsSeqReport.Output.MCMSAddress, - LinkTokenAddress: linkTokenAddress, - CCIPConfig: cfg.ContractParamsPerChain[chainSel], - } - ccipSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployCCIPSequence, deps, ccipSeqInput) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy CCIP for Aptos chain %d: %w", chainSel, err) - } - seqReports = append(seqReports, ccipSeqReport.ExecutionReports...) - mcmsOperations = append(mcmsOperations, ccipSeqReport.Output.MCMSOperations...) - - // Save the address of the CCIP object - typeAndVersion = cldf.NewTypeAndVersion(shared.AptosCCIPType, deployment.Version1_6_0) - err = deps.AB.Save(deps.AptosChain.Selector, ccipSeqReport.Output.CCIPAddress.StringLong(), typeAndVersion) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save CCIP address %s for Aptos chain %d: %w", ccipSeqReport.Output.CCIPAddress.StringLong(), chainSel, err) - } - - // Generate MCMS proposals - proposal, err := utils.GenerateProposal( - env, - mcmsSeqReport.Output.MCMSAddress, - chainSel, - mcmsOperations, - "Deploy Aptos MCMS and CCIP", - cfg.MCMSTimelockConfigPerChain[chainSel], - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", chainSel, err) - } - proposals = append(proposals, *proposal) - } - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate in-memory DataStore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: proposals, - Reports: seqReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain_test.go b/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain_test.go deleted file mode 100644 index 909c785faae..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_aptos_chain_test.go +++ /dev/null @@ -1,310 +0,0 @@ -package aptos - -import ( - "crypto/ecdsa" - "math/big" - "testing" - "time" - - "github.com/aptos-labs/aptos-go-sdk" - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - "github.com/smartcontractkit/chainlink-common/pkg/logger" - - "github.com/smartcontractkit/chainlink-deployments-framework/chain" - aptoschain "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - cldftesthelpers "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils/testhelpers" - "github.com/smartcontractkit/chainlink-deployments-framework/engine/test/environment" - "github.com/smartcontractkit/chainlink-deployments-framework/engine/test/runtime" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -func TestDeployAptosChainImp_VerifyPreconditions(t *testing.T) { - t.Parallel() - tests := []struct { - name string - env cldf.Environment - config config.DeployAptosChainConfig - wantErrRe string - wantErr bool - }{ - { - name: "success - valid configs", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: cldf.NewMemoryAddressBook(), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 743186221051783445: aptoschain.Chain{}, - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: GetMockChainContractParams(t, 4457093679053095497), - 743186221051783445: GetMockChainContractParams(t, 743186221051783445), - }, - MCMSDeployConfigPerChain: map[uint64]cldfproposalutils.MCMSWithTimelockConfig{ - 4457093679053095497: getMockMCMSConfig(t), - 743186221051783445: getMockMCMSConfig(t), - }, - }, - wantErr: false, - }, - { - name: "success - valid config w MCMS deployed", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: getTestAddressBook( - t, - map[uint64]map[string]cldf.TypeAndVersion{ - 4457093679053095497: { - mockMCMSAddress: {Type: shared.AptosMCMSType}, - }, - 743186221051783445: { - mockMCMSAddress: {Type: shared.AptosMCMSType}, - }, - }, - ), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 743186221051783445: aptoschain.Chain{}, - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: GetMockChainContractParams(t, 4457093679053095497), - 743186221051783445: GetMockChainContractParams(t, 743186221051783445), - }, - }, - wantErr: false, - }, - { - name: "error - invalid min delay", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: cldf.NewMemoryAddressBook(), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: GetMockChainContractParams(t, 4457093679053095497), - }, - MCMSDeployConfigPerChain: map[uint64]cldfproposalutils.MCMSWithTimelockConfig{ - 4457093679053095497: { - Canceller: cldftesthelpers.SingleGroupMCMS(t), - Proposer: cldftesthelpers.SingleGroupMCMS(t), - Bypasser: cldftesthelpers.SingleGroupMCMS(t), - TimelockMinDelay: nil, // Invalid min delay - }, - }, - }, - wantErr: true, - wantErrRe: `invalid MCMS timelock min delay for Aptos chain 4457093679053095497`, - }, - { - name: "error - chain has no env", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: getTestAddressBook( - t, - map[uint64]map[string]cldf.TypeAndVersion{ - 4457093679053095497: { - mockMCMSAddress: {Type: shared.AptosMCMSType}, - }, - 743186221051783445: { - mockMCMSAddress: {Type: shared.AptosMCMSType}, - }, - }, - ), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: GetMockChainContractParams(t, 4457093679053095497), - 743186221051783445: GetMockChainContractParams(t, 743186221051783445), - }, - }, - wantErrRe: `chain 743186221051783445 not found in env`, - wantErr: true, - }, - { - name: "error - invalid config - chainSelector", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: cldf.NewMemoryAddressBook(), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 1: {}, - }, - }, - wantErrRe: "invalid chain selector:", - wantErr: true, - }, - { - name: "error - missing MCMS config for chain without MCMS deployed", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: getTestAddressBook( - t, - map[uint64]map[string]cldf.TypeAndVersion{ - 4457093679053095497: {}, // No MCMS address in state - }, - ), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: GetMockChainContractParams(t, 4457093679053095497), - }, - // MCMSDeployConfigPerChain is missing needed configs - }, - wantErrRe: `invalid mcms configs for Aptos chain 4457093679053095497`, - wantErr: true, - }, - { - name: "error - invalid config for chain", - env: cldf.Environment{ - Name: "test", - Logger: logger.Test(t), - ExistingAddresses: getTestAddressBook( - t, - map[uint64]map[string]cldf.TypeAndVersion{ - 4457093679053095497: { - mockMCMSAddress: {Type: shared.AptosMCMSType}, // MCMS already deployed - }, - }, - ), - BlockChains: chain.NewBlockChains( - map[uint64]chain.BlockChain{ - 4457093679053095497: aptoschain.Chain{}, - }), - }, - config: config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - 4457093679053095497: { - FeeQuoterParams: config.FeeQuoterParams{ - TokenPriceStalenessThreshold: 0, // Invalid gas limit (assuming 0 is invalid) - }, - }, - }, - }, - wantErrRe: `invalid config for Aptos chain 4457093679053095497`, - wantErr: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - cs := DeployAptosChain{} - err := cs.VerifyPreconditions(tt.env, tt.config) - if tt.wantErr { - require.Error(t, err) - errStr := err.Error() - assert.Regexp(t, tt.wantErrRe, errStr) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestDeployAptosChain_Apply(t *testing.T) { - t.Parallel() - - // Setup environment with 1 Aptos chain - selector := chain_selectors.APTOS_LOCALNET.Selector - rt, err := runtime.New(t.Context(), runtime.WithEnvOpts( - environment.WithAptosContainer(t, []uint64{selector}), - environment.WithLogger(logger.Test(t)), - )) - require.NoError(t, err) - - chain := rt.Environment().BlockChains.AptosChains()[selector] - - t.Log("Deployer: ", chain.DeployerSigner) - - // Deploy CCIP to Aptos chain - mockCCIPParams := GetMockChainContractParams(t, selector) - ccipConfig := config.DeployAptosChainConfig{ - ContractParamsPerChain: map[uint64]config.ChainContractParams{ - selector: mockCCIPParams, - }, - MCMSDeployConfigPerChain: map[uint64]cldfproposalutils.MCMSWithTimelockConfig{ - selector: { - Canceller: cldftesthelpers.SingleGroupMCMS(t), - Proposer: cldftesthelpers.SingleGroupMCMS(t), - Bypasser: cldftesthelpers.SingleGroupMCMS(t), - TimelockMinDelay: big.NewInt(1), - }, - }, - MCMSTimelockConfigPerChain: map[uint64]cldfproposalutils.TimelockConfig{ - selector: { - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - }, - } - - err = rt.Exec( - runtime.ChangesetTask(DeployAptosChain{}, ccipConfig), - runtime.SignAndExecuteProposalsTask([]*ecdsa.PrivateKey{cldftesthelpers.TestXXXMCMSSigner}), - ) - require.NoError(t, err) - - // Verify CCIP deployment state by binding ccip contract and checking if it's deployed - states, err := aptosstate.LoadOnchainStateAptos(rt.Environment()) - require.NoError(t, err) - require.NotNil(t, states[selector], "No state found for chain") - state := states[selector] - - ccipAddr := state.CCIPAddress - require.NotEmpty(t, ccipAddr, "CCIP address should not be empty") - - // Bind CCIP offramp contract - offrampBind := ccip_offramp.Bind(ccipAddr, chain.Client) - offRampSourceConfig, err := offrampBind.Offramp().GetSourceChainConfig(nil, mockCCIPParams.OffRampParams.SourceChainSelectors[0]) - require.NoError(t, err) - require.True(t, offRampSourceConfig.IsEnabled, "contracts were not initialized correctly") - - // Check premium multiplier - ccipBind := ccip.Bind(ccipAddr, chain.Client) - require.NotEqual(t, aptos.AccountAddress{}, state.LinkTokenAddress, "Link token address should not be empty") - mult, err := ccipBind.FeeQuoter().GetPremiumMultiplierWeiPerEth(nil, state.LinkTokenAddress) - require.NoError(t, err) - require.Equal(t, mockCCIPParams.FeeQuoterParams.PremiumMultiplierWeiPerEthByFeeToken[shared.LinkSymbol], mult) - - aptTokenAdd := MustParseAddress(t, "0xa") - mult, err = ccipBind.FeeQuoter().GetPremiumMultiplierWeiPerEth(nil, aptTokenAdd) - require.NoError(t, err) - require.Equal(t, mockCCIPParams.FeeQuoterParams.PremiumMultiplierWeiPerEthByFeeToken[shared.APTSymbol], mult) -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_curse_mcms.go b/deployment/ccip/changeset/aptos/cs_deploy_curse_mcms.go deleted file mode 100644 index 900bb34e89b..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_curse_mcms.go +++ /dev/null @@ -1,130 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -var _ cldf.ChangeSetV2[config.DeployCurseMCMSConfig] = DeployCurseMCMS{} - -// DeployCurseMCMS deploys and configures the CurseMCMS contract on Aptos chains. -type DeployCurseMCMS struct{} - -func (cs DeployCurseMCMS) VerifyPreconditions(env cldf.Environment, cfg config.DeployCurseMCMSConfig) error { - if err := cfg.Validate(); err != nil { - return fmt.Errorf("invalid config: %w", err) - } - - state, err := aptosstate.LoadOnchainStateAptos(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - aptosChains := env.BlockChains.AptosChains() - var errs []error - for chainSel := range cfg.CurseMCMSConfigPerChain { - if _, ok := aptosChains[chainSel]; !ok { - errs = append(errs, fmt.Errorf("aptos chain %d not found in env", chainSel)) - continue - } - chainState, ok := state[chainSel] - if !ok { - errs = append(errs, fmt.Errorf("aptos chain %d not found in state", chainSel)) - continue - } - if chainState.MCMSAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS not deployed for Aptos chain %d", chainSel)) - } - if chainState.CCIPAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("CCIP not deployed for Aptos chain %d", chainSel)) - } - } - - return errors.Join(errs...) -} - -func (cs DeployCurseMCMS) Apply(env cldf.Environment, cfg config.DeployCurseMCMSConfig) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load onchain state: %w", err) - } - - ab := cldf.NewMemoryAddressBook() - seqReports := make([]operations.Report[any, any], 0) - proposals := make([]mcms.TimelockProposal, 0) - - aptosChains := env.BlockChains.AptosChains() - for chainSel, curseMCMSConfig := range cfg.CurseMCMSConfigPerChain { - aptosChain := aptosChains[chainSel] - chainState := state.AptosChains[chainSel] - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - seqInput := seq.DeployCurseMCMSSeqInput{ - MCMSAddress: chainState.MCMSAddress, - CCIPAddress: chainState.CCIPAddress, - CurseMCMS: curseMCMSConfig, - } - - curseMCMSSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployCurseMCMSSequence, deps, seqInput) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to deploy CurseMCMS for Aptos chain %d: %w", chainSel, err) - } - seqReports = append(seqReports, curseMCMSSeqReport.ExecutionReports...) - - // Skip address saving and proposal generation when sequence was a no-op (already deployed). - if curseMCMSSeqReport.Output.CurseMCMSAddress == (aptos.AccountAddress{}) { - continue - } - - typeAndVersion := cldf.NewTypeAndVersion(shared.AptosCurseMCMSType, deployment.Version1_6_0) - if err := ab.Save(chainSel, curseMCMSSeqReport.Output.CurseMCMSAddress.StringLong(), typeAndVersion); err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to save CurseMCMS address for Aptos chain %d: %w", chainSel, err) - } - - // Generate a CurseMCMS proposal for self-governance operations (AcceptOwnership + SetMinDelay). - proposal, err := utils.GenerateCurseMCMSProposal( - env, - curseMCMSSeqReport.Output.CurseMCMSAddress, - chainSel, - []mcmstypes.BatchOperation{curseMCMSSeqReport.Output.CurseMCMSOperation}, - "CurseMCMS accept ownership and set timelock min delay", - cfg.MCMSTimelockConfigPerChain[chainSel], - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate CurseMCMS proposal for Aptos chain %d: %w", chainSel, err) - } - proposals = append(proposals, *proposal) - } - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate DataStore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: proposals, - Reports: seqReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_regulated_token.go b/deployment/ccip/changeset/aptos/cs_deploy_regulated_token.go deleted file mode 100644 index cebabf36c68..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_regulated_token.go +++ /dev/null @@ -1,121 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/smartcontractkit/mcms" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - - "github.com/aptos-labs/aptos-go-sdk" -) - -var _ cldf.ChangeSetV2[config.DeployRegulatedTokenConfig] = DeployRegulatedToken{} - -// DeployRegulatedToken deploys and initializes a regulated token directly with the -// deployer signer (regulated_token cannot be deployed via MCMS due to DFA re-entrancy), -// transfers ownership and admin role to the MCMS registry owner, and returns a -// timelock proposal containing accept_ownership and accept_admin. -type DeployRegulatedToken struct{} - -func (cs DeployRegulatedToken) VerifyPreconditions(env cldf.Environment, cfg config.DeployRegulatedTokenConfig) error { - if err := cfg.Validate(); err != nil { - return err - } - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - aptosState, ok := state.AptosChains[cfg.ChainSelector] - if !ok { - errs = append(errs, fmt.Errorf("aptos chain %d not in state", cfg.ChainSelector)) - } else { - if aptosState.CCIPAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("CCIP is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - if aptosState.MCMSAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - } - return errors.Join(errs...) -} - -func (cs DeployRegulatedToken) Apply(env cldf.Environment, cfg config.DeployRegulatedTokenConfig) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load onchain state: %w", err) - } - - aptosChain := env.BlockChains.AptosChains()[cfg.ChainSelector] - mcmsAddress := state.AptosChains[cfg.ChainSelector].MCMSAddress - - ab := cldf.NewMemoryAddressBook() - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - seqReport, err := operations.ExecuteSequence( - env.OperationsBundle, - seq.DeployRegulatedTokenSequence, - deps, - seq.DeployRegulatedTokenSeqInput{ - MCMSAddress: mcmsAddress, - TokenParams: cfg.TokenParams, - TokenMint: cfg.TokenMint, - RegistrarPreregister: cfg.RegistrarPreregisterOrDefault(), - }, - ) - if err != nil { - return cldf.ChangesetOutput{}, err - } - - out := seqReport.Output - typeAndVersion := cldf.NewTypeAndVersion(shared.AptosRegulatedTokenType, deployment.Version1_6_0) - typeAndVersion.AddLabel(string(cfg.TokenParams.Symbol)) - if err := ab.Save(aptosChain.Selector, out.TokenCodeObjectAddress.StringLong(), typeAndVersion); err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("save regulated token code object: %w", err) - } - typeAndVersion = cldf.NewTypeAndVersion(cldf.ContractType(cfg.TokenParams.Symbol), deployment.Version1_6_0) - if err := ab.Save(aptosChain.Selector, out.TokenMetadataAddress.StringLong(), typeAndVersion); err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("save token metadata address: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - mcmsAddress, - cfg.ChainSelector, - out.MCMSOperations, - "Accept regulated token ownership and admin role (after direct deploy)", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("generate MCMS proposal: %w", err) - } - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("populate datastore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: seqReport.ExecutionReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_regulated_token_test.go b/deployment/ccip/changeset/aptos/cs_deploy_regulated_token_test.go deleted file mode 100644 index c95d4c8686f..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_regulated_token_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package aptos_test - -import ( - "math/big" - "testing" - "time" - - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" -) - -func TestDeployRegulatedToken_Apply(t *testing.T) { - t.Parallel() - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithAptosChains(1)) - env := deployedEnvironment.Env - - aptosSelectors := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos)) - require.Len(t, aptosSelectors, 1) - aptosSelector := aptosSelectors[0] - - cfg := config.DeployRegulatedTokenConfig{ - ChainSelector: aptosSelector, - TokenParams: config.TokenParams{ - MaxSupply: big.NewInt(1_000_000), - Name: "RegDeploy", - Symbol: "RDT", - Decimals: 8, - Icon: "", - Project: "", - }, - MCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - } - - _, outputs, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.DeployRegulatedToken{}, cfg), - }) - require.NoError(t, err) - require.Len(t, outputs, 1) - output := outputs[0] - require.Len(t, output.MCMSTimelockProposals, 1) - require.NotEmpty(t, output.Reports) - ops := output.MCMSTimelockProposals[0].Operations - require.NotEmpty(t, ops) - require.Len(t, ops[0].Transactions, 2) -} diff --git a/deployment/ccip/changeset/aptos/cs_deploy_token_faucet.go b/deployment/ccip/changeset/aptos/cs_deploy_token_faucet.go deleted file mode 100644 index c122e2f7e32..00000000000 --- a/deployment/ccip/changeset/aptos/cs_deploy_token_faucet.go +++ /dev/null @@ -1,93 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.DeployTokenFaucetInput] = DeployTokenFaucet{} - -type DeployTokenFaucet struct{} - -func (d DeployTokenFaucet) VerifyPreconditions(env cldf.Environment, cfg config.DeployTokenFaucetInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - if (cfg.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, errors.New("managed token object address is empty")) - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (d DeployTokenFaucet) Apply(env cldf.Environment, cfg config.DeployTokenFaucetInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - aptosChain := env.BlockChains.AptosChains()[cfg.ChainSelector] - ab := cldf.NewMemoryAddressBook() - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - input := seq.DeployTokenFaucetSeqInput{ - MCMSAddress: state.AptosChains[cfg.ChainSelector].MCMSAddress, - TokenCodeObjAddress: cfg.TokenCodeObjectAddress, - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.DeployTokenFaucetSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute DeployTokenFaucetSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - report.Output, - "Deploy Managed Token Faucet and grant mint rights to it", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate in-memory DataStore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_dynamic.go b/deployment/ccip/changeset/aptos/cs_dynamic.go deleted file mode 100644 index 2be270d879c..00000000000 --- a/deployment/ccip/changeset/aptos/cs_dynamic.go +++ /dev/null @@ -1,79 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/smartcontractkit/mcms" - "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.DynamicConfig] = DynamicCS{} - -// DynamicCS enables dynamic execution of multiple Aptos operations at runtime -// without requiring dedicated changesets. It allows for flexible, configurable -// operation sequences to be applied based on runtime input, streamlining the -// process of managing Aptos chain changes. -type DynamicCS struct{} - -func (cs DynamicCS) VerifyPreconditions(env cldf.Environment, cfg config.DynamicConfig) error { - if len(cfg.Defs) != len(cfg.Inputs) { - return fmt.Errorf("precondition failed: cfg.Defs and cfg.Inputs must have matching lengths (got %d and %d)", len(cfg.Defs), len(cfg.Inputs)) - } - if cfg.MCMSConfig == nil { - return errors.New("precondition failed: cfg.MCMSConfig must not be nil") - } - return nil -} - -func (cs DynamicCS) Apply(env cldf.Environment, cfg config.DynamicConfig) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - aptosChain := env.BlockChains.AptosChains()[cfg.ChainSelector] - ab := cldf.NewMemoryAddressBook() - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - in := seq.DynamicSeqInput{ - Defs: cfg.Defs, - Inputs: cfg.Inputs, - ChainSelector: cfg.ChainSelector, - } - result, err := operations.ExecuteSequence(env.OperationsBundle, seq.DynamicSequence, deps, in) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute sequence: %w", err) - } - - // Generate Aptos MCMS proposals - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []types.BatchOperation{result.Output}, - cfg.Description, - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: result.ExecutionReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_dynamic_test.go b/deployment/ccip/changeset/aptos/cs_dynamic_test.go deleted file mode 100644 index bb265136e74..00000000000 --- a/deployment/ccip/changeset/aptos/cs_dynamic_test.go +++ /dev/null @@ -1,259 +0,0 @@ -package aptos_test - -import ( - "math/big" - "testing" - "time" - - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - module_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - aptosconfig "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" -) - -func TestDynamicCS_Apply(t *testing.T) { - t.Parallel() - - // Setup environment with Aptos chain and deployed contracts - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - // Load onchain state to get deployed contract addresses - state, err := stateview.LoadOnchainState(env) - require.NoError(t, err, "must load onchain state") - - aptosChainSel := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos))[0] - aptosState := state.AptosChains[aptosChainSel] - aptosChain := env.BlockChains.AptosChains()[aptosChainSel] - - // Get a token address for price update (use any deployed token or a mock address) - // For this test, we'll use the CCIP address as a mock token address - mockTokenAddr := aptosState.CCIPAddress.StringLong() - - registry := operations.NewOperationRegistry(operation.GetAptosOperations()...) - env.OperationsBundle.OperationRegistry = registry - - // Define the operations to execute - defs := []operations.Definition{ - operation.ApplyAllowedOfframpUpdatesOp.Def(), - operation.UpdateFeeQuoterDestsOp.Def(), - operation.UpdateFeeQuoterPricesOp.Def(), - aptos.CurseMultipleOp.Def(), - } - - arbSubject := globals.FamilyAwareSelectorToSubject( - chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.Selector, - chain_selectors.FamilyEVM, - ) - bscSubject := globals.FamilyAwareSelectorToSubject( - chain_selectors.BINANCE_SMART_CHAIN_MAINNET.Selector, - chain_selectors.FamilyEVM, - ) - - // Define the inputs for each operation - inputs := []any{ - // Input for ApplyAllowedOfframpUpdatesOp - operations.EmptyInput{}, - // Input for UpdateFeeQuoterDestsOp - operation.UpdateFeeQuoterDestsInput{ - Updates: map[uint64]module_fee_quoter.DestChainConfig{ - chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.EvmChainID: aptosTestDestFeeQuoterConfig(t), - }, - }, - // Input for UpdateFeeQuoterPricesOp - operation.UpdateFeeQuoterPricesInput{ - TokenPrices: map[string]*big.Int{ - mockTokenAddr: big.NewInt(1000001), - }, - GasPrices: map[uint64]*big.Int{ - chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.EvmChainID: big.NewInt(500000), // Mock gas price - }, - }, - // Input for CurseSubjectsOp - aptos.CurseMultipleInput{ - CCIPAddress: aptosState.CCIPAddress, - Subjects: [][]byte{ - arbSubject[:], - bscSubject[:], - }, - }, - } - - // Configure the dynamic changeset - cfg := aptosconfig.DynamicConfig{ - Defs: defs, - Inputs: inputs, - ChainSelector: aptosChainSel, - Description: "Test dynamic changeset with multiple operations", - MCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - } - - // Apply the dynamic changeset - env, _, err = commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.DynamicCS{}, cfg), - }) - require.NoError(t, err, "dynamic changeset should apply successfully") - // Re-register operations after ApplyChangesets (bundle may be rebuilt) - env.OperationsBundle.OperationRegistry = operations.NewOperationRegistry(operation.GetAptosOperations()...) - - // Verify the operations were executed successfully by checking the state - // 1. Verify FeeQuoter prices were updated - ccipBind := ccip.Bind(aptosState.CCIPAddress, aptosChain.Client) - - // Check token price - tokenPrice, err := ccipBind.FeeQuoter().GetTokenPrice(nil, aptosState.CCIPAddress) - require.NoError(t, err) - require.NotNil(t, tokenPrice) - require.Equal(t, big.NewInt(1000001), tokenPrice.Value, "token price should be updated") - - // 2. Verify allowed offramp updates were applied - // The ApplyAllowedOfframpUpdatesOp adds the CCIP owner to the allowlist - // Bind MCMS to get the owner address - mcmsBind := mcmsbind.Bind(aptosState.MCMSAddress, aptosChain.Client) - - // Get CCIP owner address - ccipOwnerAddress, err := mcmsBind.MCMSRegistry().GetRegisteredOwnerAddress(nil, aptosState.CCIPAddress) - require.NoError(t, err) - - // Get the list of allowed offramps - allowedOfframps, err := ccipBind.Auth().GetAllowedOfframps(nil) - require.NoError(t, err) - - // Verify CCIP owner is in the allowlist - found := false - for _, addr := range allowedOfframps { - if addr == ccipOwnerAddress { - found = true - break - } - } - require.True(t, found, "CCIP owner should be in the allowlist after ApplyAllowedOfframpUpdatesOp") - - // 3. Verify subjects were cursed - arbU128Selector := new(big.Int).SetUint64(chain_selectors.ETHEREUM_MAINNET_ARBITRUM_1.Selector) - bscU128Selector := new(big.Int).SetUint64(chain_selectors.BINANCE_SMART_CHAIN_MAINNET.Selector) - isCursedU128, err := ccipBind.RMNRemote().IsCursedU128(nil, arbU128Selector) - require.NoError(t, err) - require.True(t, isCursedU128, "should be cursed") - - isCursed, err := ccipBind.RMNRemote().IsCursed(nil, bscSubject[:]) - require.NoError(t, err) - require.True(t, isCursed, "should be cursed") - - // define the operations to execute - defs = []operations.Definition{ - aptos.UncurseMultipleOp.Def(), - } - - inputs = []any{ - aptos.UncurseMultipleInput{ - CCIPAddress: aptosState.CCIPAddress, - Subjects: [][]byte{ - arbSubject[:], - }, - }, - } - - cfg = aptosconfig.DynamicConfig{ - Defs: defs, - Inputs: inputs, - ChainSelector: aptosChainSel, - Description: "Test dynamic changeset with uncurse subjects operation", - MCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - } - - env, _, err = commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.DynamicCS{}, cfg), - }) - require.NoError(t, err, "dynamic changeset should apply successfully") - // Re-register operations after ApplyChangesets (bundle may be rebuilt) - env.OperationsBundle.OperationRegistry = operations.NewOperationRegistry(operation.GetAptosOperations()...) - - // Verify the operations were executed successfully by checking the state - isCursedU128, err = ccipBind.RMNRemote().IsCursedU128(nil, arbU128Selector) - require.NoError(t, err) - require.False(t, isCursedU128, "should not be cursed") - - isCursed, err = ccipBind.RMNRemote().IsCursed(nil, arbSubject[:]) - require.NoError(t, err) - require.False(t, isCursed, "should not be cursed") - - isCursedU128, err = ccipBind.RMNRemote().IsCursedU128(nil, bscU128Selector) - require.NoError(t, err) - require.True(t, isCursedU128, "should be cursed") - - isCursed, err = ccipBind.RMNRemote().IsCursed(nil, bscSubject[:]) - require.NoError(t, err) - require.True(t, isCursed, "should be cursed") - - // define the operations to execute - defs = []operations.Definition{ - aptos.CurseMultipleOp.Def(), - } - - globalSubject := globals.GlobalCurseSubject() - - inputs = []any{ - aptos.CurseMultipleInput{ - CCIPAddress: aptosState.CCIPAddress, - Subjects: [][]byte{globalSubject[:]}, - }, - } - - cfg = aptosconfig.DynamicConfig{ - Defs: defs, - Inputs: inputs, - ChainSelector: aptosChainSel, - Description: "Test dynamic changeset with global curse operation", - MCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - } - - env, _, err = commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.DynamicCS{}, cfg), - }) - require.NoError(t, err, "dynamic changeset should apply successfully") - - // Verify the operations were executed successfully by checking the state - isCursedGlobal, err := ccipBind.RMNRemote().IsCursedGlobal(nil) - require.NoError(t, err) - require.True(t, isCursedGlobal, "should be cursed globally") - - optimismSubject := globals.FamilyAwareSelectorToSubject( - chain_selectors.ETHEREUM_MAINNET_OPTIMISM_1.Selector, - chain_selectors.FamilyEVM, - ) - - isCursed, err = ccipBind.RMNRemote().IsCursed(nil, optimismSubject[:]) - require.NoError(t, err) - require.True(t, isCursed, "should be cursed") -} diff --git a/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs.go b/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs.go deleted file mode 100644 index 4e9d9fe8d6a..00000000000 --- a/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs.go +++ /dev/null @@ -1,101 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - operation "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.MigrateOnRampDestChainConfigsToV2Config] = MigrateOnRampDestChainConfigsToV2{} - -type MigrateOnRampDestChainConfigsToV2 struct{} - -func (cs MigrateOnRampDestChainConfigsToV2) VerifyPreconditions(env cldf.Environment, cfg config.MigrateOnRampDestChainConfigsToV2Config) error { - var errs []error - - if cfg.MCMS == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if len(cfg.DestChainSelectors) == 0 { - errs = append(errs, errors.New("DestChainSelectors must not be empty")) - } - if len(cfg.DestChainSelectors) != len(cfg.RouterModuleAddresses) { - errs = append(errs, fmt.Errorf("DestChainSelectors length (%d) must match RouterModuleAddresses length (%d)", - len(cfg.DestChainSelectors), len(cfg.RouterModuleAddresses))) - } - - state, err := stateview.LoadOnchainState(env) - if err != nil { - errs = append(errs, fmt.Errorf("failed to load onchain state: %w", err)) - return errors.Join(errs...) - } - - supportedChains := state.SupportedChains() - if _, ok := supportedChains[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - - ccipAddress := state.AptosChains[cfg.ChainSelector].CCIPAddress - if ccipAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("CCIP package is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - client := env.BlockChains.AptosChains()[cfg.ChainSelector].Client - hasOnramp, err := utils.IsModuleDeployed(client, ccipAddress, "onramp") - if err != nil || !hasOnramp { - errs = append(errs, fmt.Errorf("onRamp module is not deployed on Aptos chain %d: %w", cfg.ChainSelector, err)) - } - - return errors.Join(errs...) -} - -func (cs MigrateOnRampDestChainConfigsToV2) Apply(env cldf.Environment, cfg config.MigrateOnRampDestChainConfigsToV2Config) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - - seqInput := operation.MigrateOnRampDestChainConfigsToV2Input{ - DestChainSelectors: cfg.DestChainSelectors, - RouterModuleAddresses: cfg.RouterModuleAddresses, - } - - seqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.MigrateOnRampDestChainConfigsToV2Sequence, deps, seqInput) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute migrate sequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{seqReport.Output}, - "Migrate OnRamp destination chain configs to V2", - *cfg.MCMS, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: seqReport.ExecutionReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs_test.go b/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs_test.go deleted file mode 100644 index e6d19eb6ef6..00000000000 --- a/deployment/ccip/changeset/aptos/cs_migrate_onramp_dest_chain_configs_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package aptos_test - -import ( - "testing" - "time" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/aptos-labs/aptos-go-sdk" - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" -) - -func TestMigrateOnRampDestChainConfigsToV2_Apply(t *testing.T) { - t.Skip("skipping - no need to run these tests in CI") - t.Parallel() - - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - chainSelector := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos))[0] - - cfg := config.MigrateOnRampDestChainConfigsToV2Config{ - ChainSelector: chainSelector, - DestChainSelectors: []uint64{chain_selectors.ETHEREUM_MAINNET.Selector}, - RouterModuleAddresses: []aptos.AccountAddress{{}}, - MCMS: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - } - - _, out, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.MigrateOnRampDestChainConfigsToV2{}, cfg), - }) - - require.NoError(t, err) - proposals := out[0].MCMSTimelockProposals - require.Len(t, proposals, 1) - require.Len(t, proposals[0].Operations, 1) -} diff --git a/deployment/ccip/changeset/aptos/cs_mint_token.go b/deployment/ccip/changeset/aptos/cs_mint_token.go deleted file mode 100644 index b78a63269bf..00000000000 --- a/deployment/ccip/changeset/aptos/cs_mint_token.go +++ /dev/null @@ -1,106 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.MintTokenInput] = MintToken{} - -type MintToken struct{} - -func (m MintToken) VerifyPreconditions(env cldf.Environment, cfg config.MintTokenInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - if (cfg.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, errors.New("managed token object address is empty")) - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - if (cfg.To == aptos.AccountAddress{}) { - errs = append(errs, errors.New("to address is empty")) - } - if cfg.Amount == 0 { - errs = append(errs, errors.New("token amount is 0")) - } - - return errors.Join(errs...) -} - -func (m MintToken) Apply(env cldf.Environment, cfg config.MintTokenInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - aptosChain := env.BlockChains.AptosChains()[cfg.ChainSelector] - ab := cldf.NewMemoryAddressBook() - - deps := dependency.AptosDeps{ - AB: ab, - AptosChain: aptosChain, - CCIPOnChainState: state, - } - - input := operation.MintTokensInput{ - TokenCodeObjectAddress: cfg.TokenCodeObjectAddress, - To: cfg.To, - Amount: cfg.Amount, - } - report, err := operations.ExecuteOperation(env.OperationsBundle, operation.MintTokensOp, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute MintTokensOp: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{ - { - ChainSelector: mcmstypes.ChainSelector(cfg.ChainSelector), - Transactions: []mcmstypes.Transaction{report.Output}, - }, - }, - "Mint tokens", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - ds, err := shared.PopulateDataStore(ab) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate in-memory DataStore: %w", err) - } - - return cldf.ChangesetOutput{ - AddressBook: ab, - DataStore: ds, - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp.go b/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp.go deleted file mode 100644 index a13a770c27e..00000000000 --- a/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp.go +++ /dev/null @@ -1,82 +0,0 @@ -package aptos - -import ( - "fmt" - - chain_selectors "github.com/smartcontractkit/chain-selectors" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[v1_6.SetOCR3OffRampConfig] = SetOCR3Offramp{} - -// SetOCR3Offramp updates OCR3 Offramp configurations -type SetOCR3Offramp struct{} - -func (cs SetOCR3Offramp) VerifyPreconditions(env cldf.Environment, config v1_6.SetOCR3OffRampConfig) error { - for _, remoteSel := range config.RemoteChainSels { - chainFamily, _ := chain_selectors.GetSelectorFamily(remoteSel) - if chainFamily != chain_selectors.FamilyAptos { - return fmt.Errorf("chain %d is not an Aptos chain", remoteSel) - } - _, exists := env.BlockChains.AptosChains()[remoteSel] - if !exists { - return fmt.Errorf("chain %d is not in Aptos env", remoteSel) - } - } - return nil -} - -func (cs SetOCR3Offramp) Apply(env cldf.Environment, config v1_6.SetOCR3OffRampConfig) (cldf.ChangesetOutput, error) { - seqReports := make([]operations.Report[any, any], 0) - var timeLockProposals []mcms.TimelockProposal - - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - for _, remoteSelector := range config.RemoteChainSels { - deps := dependency.AptosDeps{ - AptosChain: env.BlockChains.AptosChains()[remoteSelector], - CCIPOnChainState: state, - } - in := seq.SetOCR3OfframpSeqInput{ - HomeChainSelector: config.HomeChainSel, - ChainSelector: remoteSelector, - ConfigType: config.CCIPHomeConfigType, - } - setOCR3SeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.SetOCR3OfframpSequence, deps, in) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, setOCR3SeqReport.ExecutionReports...) - - // Generate MCMS proposals - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[remoteSelector].MCMSAddress, - deps.AptosChain.Selector, - []mcmstypes.BatchOperation{setOCR3SeqReport.Output}, - "Set OCR3 Configs", - *config.MCMS, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", remoteSelector, err) - } - timeLockProposals = append(timeLockProposals, *proposal) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: timeLockProposals, - Reports: seqReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp_test.go b/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp_test.go deleted file mode 100644 index a61589669af..00000000000 --- a/deployment/ccip/changeset/aptos/cs_set_ocr3_offramp_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package aptos_test - -import ( - "testing" - "time" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" -) - -func TestSetOCR3Offramp_Apply(t *testing.T) { - t.Parallel() - // Setup environment and config - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - cfg := v1_6.SetOCR3OffRampConfig{ - HomeChainSel: env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM))[0], - RemoteChainSels: env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos)), - MCMS: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - CCIPHomeConfigType: globals.ConfigTypeActive, // TODO: investigate why this is not being used, might be a bug - } - - env, _, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.SetOCR3Offramp{}, cfg), - }) - require.NoError(t, err) - - // Load onchain state - state, err := stateview.LoadOnchainState(env) - require.NoError(t, err, "must load onchain state") - - // bind ccip aptos - aptosCCIPAddr := state.AptosChains[env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos))[0]].CCIPAddress - aptosOffRamp := ccip_offramp.Bind(aptosCCIPAddr, env.BlockChains.AptosChains()[env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos))[0]].Client) - ocr3Commit, err := aptosOffRamp.Offramp().LatestConfigDetails(nil, uint8(types.PluginTypeCCIPCommit)) - require.NoError(t, err) - require.Len(t, ocr3Commit.Signers, 4) - require.NotEmpty(t, ocr3Commit.ConfigInfo.ConfigDigest) - ocr3Exec, err := aptosOffRamp.Offramp().LatestConfigDetails(nil, uint8(types.PluginTypeCCIPExec)) - require.NoError(t, err) - require.Len(t, ocr3Exec.Transmitters, 4) - require.NotEmpty(t, ocr3Exec.ConfigInfo.ConfigDigest) -} diff --git a/deployment/ccip/changeset/aptos/cs_token_ownership.go b/deployment/ccip/changeset/aptos/cs_token_ownership.go deleted file mode 100644 index 6e1d7268f32..00000000000 --- a/deployment/ccip/changeset/aptos/cs_token_ownership.go +++ /dev/null @@ -1,429 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -/* - Aptos uses a three-step ownership transfer: - 1. Initiate ownership transfer to a new address - 2. Accept ownership transfer from the address that's pending from the previous step - 3. Execute the (accepted) ownership transfer from the current owner of the token. - Required in order to transfer the object itself, which requires a &signer of the current object owner. - More details in: https://github.com/smartcontractkit/chainlink-aptos/blob/fa2e60d951574f20497d65b05688d89db6a755cd/contracts/managed_token/sources/ownable.move -*/ - -// Transfer Ownership - -var _ cldf.ChangeSetV2[config.TransferTokenOwnershipInput] = TransferTokenOwnership{} - -type TransferTokenOwnership struct{} - -func (t TransferTokenOwnership) VerifyPreconditions(env cldf.Environment, cfg config.TransferTokenOwnershipInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, transfer := range cfg.Transfers { - if (transfer.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token object address of transfer %d is empty", i)) - } - if (transfer.To == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch transfer.TokenType { - case shared.AptosManagedTokenType, shared.AptosRegulatedTokenType: - default: - errs = append(errs, fmt.Errorf("token type %v of transfer %d is unsupported", transfer.TokenType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t TransferTokenOwnership) Apply(env cldf.Environment, cfg config.TransferTokenOwnershipInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.TransferTokenOwnershipsSeqInput{ - Transfers: make([]seq.TokenTransferInput, 0, len(cfg.Transfers)), - } - for _, transfer := range cfg.Transfers { - input.Transfers = append(input.Transfers, seq.TokenTransferInput{ - TokenCodeObjAddress: transfer.TokenCodeObjectAddress, - To: transfer.To, - TokenType: transfer.TokenType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.TransferTokenOwnershipsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute TransferTokenOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Transfers ownership of one or multiple token instances to new addresses", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -// Accept Ownership - -var _ cldf.ChangeSetV2[config.AcceptTokenOwnershipInput] = AcceptTokenOwnership{} - -type AcceptTokenOwnership struct{} - -func (t AcceptTokenOwnership) VerifyPreconditions(env cldf.Environment, cfg config.AcceptTokenOwnershipInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, accept := range cfg.Accepts { - if (accept.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch accept.TokenType { - case shared.AptosManagedTokenType, shared.AptosRegulatedTokenType: - default: - errs = append(errs, fmt.Errorf("token type %v of transfer %d is unsupported", accept.TokenType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t AcceptTokenOwnership) Apply(env cldf.Environment, cfg config.AcceptTokenOwnershipInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.AcceptTokenOwnershipsSeqInput{ - Accepts: make([]seq.TokenAcceptInput, 0, len(cfg.Accepts)), - } - for _, accept := range cfg.Accepts { - input.Accepts = append(input.Accepts, seq.TokenAcceptInput{ - TokenCodeObjAddress: accept.TokenCodeObjectAddress, - TokenType: accept.TokenType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.AcceptTokenOwnershipsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute AcceptTokenOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Accepts ownership of one or multiple token instances", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -// Execute Ownership Transfer - -var _ cldf.ChangeSetV2[config.ExecuteTokenOwnershipTransferInput] = ExecuteOwnershipTransfer{} - -type ExecuteOwnershipTransfer struct{} - -func (t ExecuteOwnershipTransfer) VerifyPreconditions(env cldf.Environment, cfg config.ExecuteTokenOwnershipTransferInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, transfer := range cfg.Transfers { - if (transfer.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token object address of transfer %d is empty", i)) - } - if (transfer.To == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch transfer.TokenType { - case shared.AptosManagedTokenType, shared.AptosRegulatedTokenType: - default: - errs = append(errs, fmt.Errorf("token type %v of transfer %d is unsupported", transfer.TokenType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t ExecuteOwnershipTransfer) Apply(env cldf.Environment, cfg config.ExecuteTokenOwnershipTransferInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.ExecuteTokenOwnershipTransfersSeqInput{ - Transfers: make([]seq.TokenTransferInput, 0, len(cfg.Transfers)), - } - for _, transfer := range cfg.Transfers { - input.Transfers = append(input.Transfers, seq.TokenTransferInput{ - TokenCodeObjAddress: transfer.TokenCodeObjectAddress, - To: transfer.To, - TokenType: transfer.TokenType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.ExecuteTokenOwnershipTransfersSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute ExecuteTokenOwnershipTransfersSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Executes the pending ownership transfer of one or multiple token instances", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -// Regulated Token - transfer admin - -var _ cldf.ChangeSetV2[config.TransferTokenAdminInput] = TransferTokenAdmin{} - -type TransferTokenAdmin struct{} - -func (t TransferTokenAdmin) VerifyPreconditions(env cldf.Environment, cfg config.TransferTokenAdminInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, transfer := range cfg.Transfers { - if (transfer.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token object address of transfer %d is empty", i)) - } - if (transfer.To == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch transfer.TokenType { - case shared.AptosRegulatedTokenType: - default: - errs = append(errs, fmt.Errorf("token type %v of transfer %d is unsupported", transfer.TokenType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t TransferTokenAdmin) Apply(env cldf.Environment, cfg config.TransferTokenAdminInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.TransferTokenAdminsSeqInput{ - Transfers: make([]seq.TokenTransferInput, 0, len(cfg.Transfers)), - } - for _, transfer := range cfg.Transfers { - input.Transfers = append(input.Transfers, seq.TokenTransferInput{ - TokenCodeObjAddress: transfer.TokenCodeObjectAddress, - To: transfer.To, - TokenType: transfer.TokenType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.TransferTokenAdminsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute TransferTokenOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Transfers the admin role of one or multiple regulated token instances to new addresses", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -// Regulated Token - accept admin - -var _ cldf.ChangeSetV2[config.AcceptTokenAdminInput] = AcceptTokenAdmin{} - -type AcceptTokenAdmin struct{} - -func (t AcceptTokenAdmin) VerifyPreconditions(env cldf.Environment, cfg config.AcceptTokenAdminInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, accept := range cfg.Accepts { - if (accept.TokenCodeObjectAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch accept.TokenType { - case shared.AptosRegulatedTokenType: - default: - errs = append(errs, fmt.Errorf("token type %v of transfer %d is unsupported", accept.TokenType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t AcceptTokenAdmin) Apply(env cldf.Environment, cfg config.AcceptTokenAdminInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.AcceptTokenAdminsSeqInput{ - Accepts: make([]seq.TokenAcceptInput, 0, len(cfg.Accepts)), - } - for _, accept := range cfg.Accepts { - input.Accepts = append(input.Accepts, seq.TokenAcceptInput{ - TokenCodeObjAddress: accept.TokenCodeObjectAddress, - TokenType: accept.TokenType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.AcceptTokenAdminsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute AcceptTokenOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Accepts the admin role of one or multiple regulated token instances", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_token_pool_ownership.go b/deployment/ccip/changeset/aptos/cs_token_pool_ownership.go deleted file mode 100644 index ddae3b03a7a..00000000000 --- a/deployment/ccip/changeset/aptos/cs_token_pool_ownership.go +++ /dev/null @@ -1,255 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.TransferTokenPoolOwnershipInput] = TransferTokenPoolOwnership{} - -type TransferTokenPoolOwnership struct{} - -func (t TransferTokenPoolOwnership) VerifyPreconditions(env cldf.Environment, cfg config.TransferTokenPoolOwnershipInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, transfer := range cfg.Transfers { - if (transfer.TokenPoolAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token pool address of transfer %d is empty", i)) - } - if (transfer.To == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch transfer.TokenPoolType { - case shared.AptosManagedTokenPoolType, shared.BurnMintTokenPool, shared.LockReleaseTokenPool: - default: - errs = append(errs, fmt.Errorf("token pool type %v of transfer %d is unsupported", transfer.TokenPoolType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (t TransferTokenPoolOwnership) Apply(env cldf.Environment, cfg config.TransferTokenPoolOwnershipInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.TransferTokenPoolOwnershipsSeqInput{ - Transfers: make([]seq.TokenPoolTransferInput, 0, len(cfg.Transfers)), - } - for _, transfer := range cfg.Transfers { - input.Transfers = append(input.Transfers, seq.TokenPoolTransferInput{ - TokenPoolAddress: transfer.TokenPoolAddress, - To: transfer.To, - TokenPoolType: transfer.TokenPoolType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.TransferTokenPoolOwnershipsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute TransferTokenPoolOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Transfers ownership of one or multiple token pool instances to new addresses", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -var _ cldf.ChangeSetV2[config.AcceptTokenPoolOwnershipInput] = AcceptTokenPoolOwnership{} - -type AcceptTokenPoolOwnership struct{} - -func (a AcceptTokenPoolOwnership) VerifyPreconditions(env cldf.Environment, cfg config.AcceptTokenPoolOwnershipInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, accept := range cfg.Accepts { - if (accept.TokenPoolAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token pool address of transfer %d is empty", i)) - } - switch accept.TokenPoolType { - case shared.AptosManagedTokenPoolType, shared.BurnMintTokenPool, shared.LockReleaseTokenPool: - default: - errs = append(errs, fmt.Errorf("token pool type %v of transfer %d is unsupported", accept.TokenPoolType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (a AcceptTokenPoolOwnership) Apply(env cldf.Environment, cfg config.AcceptTokenPoolOwnershipInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.AcceptTokenPoolOwnershipsSeqInput{ - Accepts: make([]seq.TokenPoolAcceptInput, 0, len(cfg.Accepts)), - } - for _, transfer := range cfg.Accepts { - input.Accepts = append(input.Accepts, seq.TokenPoolAcceptInput{ - TokenPoolAddress: transfer.TokenPoolAddress, - TokenPoolType: transfer.TokenPoolType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.AcceptTokenPoolOwnershipsSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute AcceptTokenPoolOwnershipsSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Accepts ownership of one or multiple token pool instances", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} - -var _ cldf.ChangeSetV2[config.ExecuteTokenPoolOwnershipTransferInput] = ExecuteTokenPoolOwnershipTransfer{} - -type ExecuteTokenPoolOwnershipTransfer struct{} - -func (e ExecuteTokenPoolOwnershipTransfer) VerifyPreconditions(env cldf.Environment, cfg config.ExecuteTokenPoolOwnershipTransferInput) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - var errs []error - if _, ok := state.SupportedChains()[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - for i, transfer := range cfg.Transfers { - if (transfer.TokenPoolAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("token pool address of transfer %d is empty", i)) - } - if (transfer.To == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("to address of transfer %d is empty", i)) - } - switch transfer.TokenPoolType { - case shared.AptosManagedTokenPoolType, shared.BurnMintTokenPool, shared.LockReleaseTokenPool: - default: - errs = append(errs, fmt.Errorf("token pool type %v of transfer %d is unsupported", transfer.TokenPoolType.String(), i)) - } - } - if cfg.MCMSConfig == nil { - errs = append(errs, errors.New("MCMS config is required")) - } - if (state.AptosChains[cfg.ChainSelector].MCMSAddress == aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("MCMS is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - - return errors.Join(errs...) -} - -func (e ExecuteTokenPoolOwnershipTransfer) Apply(env cldf.Environment, cfg config.ExecuteTokenPoolOwnershipTransferInput) (cldf.ChangesetOutput, error) { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - input := seq.ExecuteTokenPoolOwnershipTransfersSeqInput{ - Transfers: make([]seq.TokenPoolTransferInput, 0, len(cfg.Transfers)), - } - for _, transfer := range cfg.Transfers { - input.Transfers = append(input.Transfers, seq.TokenPoolTransferInput{ - TokenPoolAddress: transfer.TokenPoolAddress, - To: transfer.To, - TokenPoolType: transfer.TokenPoolType, - }) - } - report, err := operations.ExecuteSequence(env.OperationsBundle, seq.ExecuteTokenPoolOwnershipTransfersSequence, deps, input) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to execute ExecuteTokenPoolOwnershipTransfersSequence: %w", err) - } - - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - []mcmstypes.BatchOperation{report.Output}, - "Executed the pending ownership transfer of one or multiple token pool instances to new addresses", - *cfg.MCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: []operations.Report[any, any]{report.ToGenericReport()}, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_update_aptos_lanes.go b/deployment/ccip/changeset/aptos/cs_update_aptos_lanes.go deleted file mode 100644 index 93081add605..00000000000 --- a/deployment/ccip/changeset/aptos/cs_update_aptos_lanes.go +++ /dev/null @@ -1,157 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - chainsel "github.com/smartcontractkit/chain-selectors" - proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" - "github.com/smartcontractkit/mcms" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.UpdateAptosLanesConfig] = AddAptosLanes{} - -// AddAptosLanes implements adding a new lane to an existing Aptos CCIP deployment -type AddAptosLanes struct{} - -func (cs AddAptosLanes) VerifyPreconditions(env cldf.Environment, cfg config.UpdateAptosLanesConfig) error { - state, err := stateview.LoadOnchainState(env) - if err != nil { - return fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - supportedChains := state.SupportedChains() - if cfg.AptosMCMSConfig == nil { - return errors.New("config for Aptos MCMS is required for AddAptosLanes changeset") - } - // For every configured lane validate Aptos source or destination chain definitions - for _, laneCfg := range cfg.Lanes { - // Source cannot be an unknown. - if _, ok := supportedChains[laneCfg.Source.GetSelector()]; !ok { - return fmt.Errorf("unsupported source chain: %d", laneCfg.Source.GetSelector()) - } - // Destination cannot be an unknown. - if _, ok := supportedChains[laneCfg.Dest.GetSelector()]; !ok { - return fmt.Errorf("unsupported destination chain: %d", laneCfg.Dest.GetSelector()) - } - if laneCfg.Source.GetChainFamily() == chainsel.FamilyAptos { - aptosChain, exists := env.BlockChains.AptosChains()[laneCfg.Source.GetSelector()] - if !exists { - return fmt.Errorf("source Aptos chain %d is not in env", laneCfg.Source.GetSelector()) - } - err := laneCfg.Source.(config.AptosChainDefinition).Validate( - aptosChain.Client, - state.AptosChains[laneCfg.Source.GetSelector()], - ) - if err != nil { - return fmt.Errorf("failed to validate Aptos source chain %d: %w", laneCfg.Source.GetSelector(), err) - } - } - if laneCfg.Dest.GetChainFamily() == chainsel.FamilyAptos { - aptosChain, exists := env.BlockChains.AptosChains()[laneCfg.Dest.GetSelector()] - if !exists { - return fmt.Errorf("destination Aptos chain %d is not in env", laneCfg.Dest.GetSelector()) - } - err := laneCfg.Dest.(config.AptosChainDefinition).Validate( - aptosChain.Client, - state.AptosChains[laneCfg.Dest.GetSelector()], - ) - if err != nil { - return fmt.Errorf("failed to validate Aptos destination chain %d: %w", laneCfg.Dest.GetSelector(), err) - } - } - } - - // This EVM specific changeset will be called from within this Aptos changeset, hence, we're verifying it here - // TODO: this is an anti-pattern, change this once EVM changesets are refactored as Operations - evmUpdateCfg := config.ToEVMUpdateLanesConfig(cfg) - err = v1_6.UpdateLanesPrecondition(env, evmUpdateCfg) - if err != nil { - return err - } - return nil -} - -func (cs AddAptosLanes) Apply(env cldf.Environment, cfg config.UpdateAptosLanesConfig) (cldf.ChangesetOutput, error) { - var ( - timeLockProposals []mcms.TimelockProposal - mcmsOperations []mcmstypes.BatchOperation - ) - - seqReports := make([]operations.Report[any, any], 0) - - // Add lane on EVM chains - // TODO: applying a changeset within another changeset is an anti-pattern. Using it here until EVM is refactored into Operations - evmUpdatesInput := config.ToEVMUpdateLanesConfig(cfg) - out, err := v1_6.UpdateLanesLogic(env, cfg.EVMMCMSConfig, true, evmUpdatesInput) // skipNonceManagerUpdates=true for Aptos (no v1.5 EVM contracts) - if err != nil { - return cldf.ChangesetOutput{}, err - } - timeLockProposals = append(timeLockProposals, out.MCMSTimelockProposals...) - - // Add lane on Aptos chains - // Execute UpdateAptosLanesSequence for each aptos chain - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - updateInputsByAptosChain := seq.ToAptosUpdateLanesConfig(state.AptosChains, cfg) - for aptosChainSel, sequenceInput := range updateInputsByAptosChain { - deps := dependency.AptosDeps{ - AB: cldf.NewMemoryAddressBook(), - AptosChain: env.BlockChains.AptosChains()[aptosChainSel], - CCIPOnChainState: state, - } - // Execute the sequence - updateSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.UpdateAptosLanesSequence, deps, sequenceInput) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, updateSeqReport.ExecutionReports...) - mcmsOperations = append(mcmsOperations, updateSeqReport.Output) - - // Generate MCMS proposals - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[aptosChainSel].MCMSAddress, - deps.AptosChain.Selector, - mcmsOperations, - "Update lanes on Aptos chain", - *cfg.AptosMCMSConfig, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", aptosChainSel, err) - } - timeLockProposals = append(timeLockProposals, *proposal) - } - - // Aggregate all Timelock proposals - proposal, err := proposeutils.AggregateProposalsV2( - env, - proposeutils.MCMSStates{ - MCMSEVMState: state.EVMMCMSStateByChain(), - MCMSAptosState: state.AptosMCMSStateByChain(), - }, - timeLockProposals, - "Update lanes Aptos <> EVM", - cfg.AptosMCMSConfig, // Using Aptos MCMS config for the aggregated proposal since it's the required one - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to aggregate proposals: %w", err) - } - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: []mcms.TimelockProposal{*proposal}, - Reports: seqReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_update_aptos_lanes_test.go b/deployment/ccip/changeset/aptos/cs_update_aptos_lanes_test.go deleted file mode 100644 index 44564343680..00000000000 --- a/deployment/ccip/changeset/aptos/cs_update_aptos_lanes_test.go +++ /dev/null @@ -1,243 +0,0 @@ -package aptos_test - -import ( - "encoding/hex" - "math/big" - "testing" - "time" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/ethereum/go-ethereum/common" - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - aptosfeequoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_onramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" -) - -func TestAddAptosLanes_Apply(t *testing.T) { - t.Parallel() - // Setup environment and config - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - emvSelector := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM))[0] - emvSelector2 := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyEVM))[1] - aptosSelector := uint64(4457093679053095497) - - // Get chain selectors - aptosChainSelectors := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos)) - require.Len(t, aptosChainSelectors, 1, "Expected exactly 1 Aptos chain ") - chainSelector := aptosChainSelectors[0] - t.Log("Deployer: ", env.BlockChains.AptosChains()[chainSelector].DeployerSigner) - - // Deploy Lane - cfg := getMockUpdateConfig(t, emvSelector, emvSelector2, aptosSelector) - - // Apply the changeset - env, _, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.AddAptosLanes{}, cfg), - }) - require.NoError(t, err) - - state, err := stateview.LoadOnchainState(env) - require.NoError(t, err, "must load onchain state") - - // bind ccip aptos - aptosCCIPAddr := state.AptosChains[aptosSelector].CCIPAddress - aptosOnRamp := ccip_onramp.Bind(aptosCCIPAddr, env.BlockChains.AptosChains()[aptosSelector].Client) - aptosOffRamp := ccip_offramp.Bind(aptosCCIPAddr, env.BlockChains.AptosChains()[aptosSelector].Client) - aptosRouter := ccip_router.Bind(aptosCCIPAddr, env.BlockChains.AptosChains()[aptosSelector].Client) - - dynCfg, err := aptosOffRamp.Offramp().GetDynamicConfig(&bind.CallOpts{}) - require.NoError(t, err) - require.Positive(t, dynCfg.PermissionlessExecutionThresholdSeconds) - - isSupported, err := aptosOnRamp.Onramp().IsChainSupported(&bind.CallOpts{}, emvSelector) - require.NoError(t, err) - require.True(t, isSupported) - - _, _, router, routerState, err := aptosOnRamp.Onramp().GetDestChainConfigV2(&bind.CallOpts{}, emvSelector) - require.NoError(t, err) - require.NotEqual(t, aptos.AccountAddress{}, router) - require.NotEqual(t, aptos.AccountAddress{}, routerState) - - _, _, router2, routerState2, err := aptosOnRamp.Onramp().GetDestChainConfigV2(&bind.CallOpts{}, emvSelector2) - require.NoError(t, err) - require.NotEqual(t, aptos.AccountAddress{}, router2) - require.NotEqual(t, aptos.AccountAddress{}, routerState2) - - versions, err := aptosRouter.Router().GetOnRampVersions(&bind.CallOpts{}, []uint64{emvSelector, emvSelector2}) - require.NoError(t, err) - require.ElementsMatch(t, versions, [][]byte{{1, 6, 1}, {1, 6, 0}}) - - aptosCCIP := ccip.Bind(aptosCCIPAddr, env.BlockChains.AptosChains()[aptosSelector].Client) - price, err := aptosCCIP.FeeQuoter().GetTokenPrice(&bind.CallOpts{}, aptoscs.MustParseAddress(t, "0xa")) - require.NoError(t, err) - require.Equal(t, big.NewInt(1e18), price.Value) -} - -func getMockUpdateConfig( - t *testing.T, - emvSelector, - emvSelector2, - aptosSelector uint64, -) config.UpdateAptosLanesConfig { - linkToken := aptos.AccountAddress{} - _ = linkToken.ParseStringRelaxed("0x3b17dad1bdd88f337712cc2f6187bb741d56da467320373fd9198262cc93de76") - otherToken := aptos.AccountAddress{} - _ = otherToken.ParseStringRelaxed("0xa") - - return config.UpdateAptosLanesConfig{ - EVMMCMSConfig: nil, - AptosMCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Duration(1) * time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - // Aptos1 <> EVM1 + Aptos1 -> EVM2 - Lanes: []config.LaneConfig{ - { - Source: config.AptosChainDefinition{ - Selector: aptosSelector, - GasPrice: big.NewInt(1e17), - TokenPrices: map[aptos.AccountAddress]*big.Int{aptoscs.MustParseAddress(t, shared.AptosAPTAddress): big.NewInt(1e18)}, - FeeQuoterDestChainConfig: aptosTestDestFeeQuoterConfig(t), - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, - AddTokenTransferFeeConfigs: []aptosfeequoter.TokenTransferFeeConfigAdded{ - { - DestChainSelector: emvSelector, - Token: linkToken, - TokenTransferFeeConfig: aptosfeequoter.TokenTransferFeeConfig{ - MinFeeUsdCents: 1, - MaxFeeUsdCents: 10000, - DeciBps: 0, - DestGasOverhead: 1000, - DestBytesOverhead: 1000, - IsEnabled: true, - }, - }, - { - DestChainSelector: emvSelector, - Token: otherToken, - TokenTransferFeeConfig: aptosfeequoter.TokenTransferFeeConfig{ - MinFeeUsdCents: 1, - MaxFeeUsdCents: 10000, - DeciBps: 0, - DestGasOverhead: 1000, - DestBytesOverhead: 1000, - IsEnabled: true, - }, - }, - }, - }, - Dest: config.EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - Selector: emvSelector, - GasPrice: big.NewInt(1e17), - TokenPrices: map[common.Address]*big.Int{}, - FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, - }, - OnRampVersion: []byte{1, 6, 1}, - }, - IsDisabled: false, - }, - { - Source: config.EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - Selector: emvSelector, - GasPrice: big.NewInt(1e17), - TokenPrices: map[common.Address]*big.Int{}, - FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - AllowListEnabled: false, - }, - }, - }, - Dest: config.AptosChainDefinition{ - Selector: aptosSelector, - GasPrice: big.NewInt(1e17), - TokenPrices: map[aptos.AccountAddress]*big.Int{aptoscs.MustParseAddress(t, shared.AptosAPTAddress): big.NewInt(1e18)}, - FeeQuoterDestChainConfig: aptosTestDestFeeQuoterConfig(t), - }, - IsDisabled: false, - }, - { - Source: config.AptosChainDefinition{ - Selector: aptosSelector, - GasPrice: big.NewInt(1e17), - TokenPrices: map[aptos.AccountAddress]*big.Int{aptoscs.MustParseAddress(t, shared.AptosAPTAddress): big.NewInt(1e18)}, - FeeQuoterDestChainConfig: aptosTestDestFeeQuoterConfig(t), - }, - Dest: config.EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - Selector: emvSelector2, - GasPrice: big.NewInt(1e17), - TokenPrices: map[common.Address]*big.Int{}, - FeeQuoterDestChainConfig: v1_6.DefaultFeeQuoterDestChainConfig(true), - }, - }, - IsDisabled: false, - }, - }, - TestRouter: false, - } -} - -// TODO: Deduplicate these test helpers -func aptosTestDestFeeQuoterConfig(t *testing.T) aptosfeequoter.DestChainConfig { - return aptosfeequoter.DestChainConfig{ - IsEnabled: true, - MaxNumberOfTokensPerMsg: 11, - MaxDataBytes: 40_000, - MaxPerMsgGasLimit: 4_000_000, - DestGasOverhead: ccipevm.DestGasOverhead, - DefaultTokenFeeUsdCents: 30, - DestGasPerPayloadByteBase: ccipevm.CalldataGasPerByteBase, - DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, - DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, - DestDataAvailabilityOverheadGas: 700, - DestGasPerDataAvailabilityByte: 17, - DestDataAvailabilityMultiplierBps: 2, - DefaultTokenDestGasOverhead: 100_000, - DefaultTxGasLimit: 100_000, - GasMultiplierWeiPerEth: 1e7, - NetworkFeeUsdCents: 20, - ChainFamilySelector: hexMustDecode(t, v1_6.AptosFamilySelector), - EnforceOutOfOrder: false, - GasPriceStalenessThreshold: 2, - } -} - -func hexMustDecode(t *testing.T, s string) []byte { - b, err := hex.DecodeString(s) - require.NoError(t, err) - return b -} diff --git a/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip.go b/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip.go deleted file mode 100644 index 97ef08885c9..00000000000 --- a/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip.go +++ /dev/null @@ -1,109 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - "github.com/smartcontractkit/mcms/types" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - seq "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/sequence" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -var _ cldf.ChangeSetV2[config.UpgradeAptosChainConfig] = UpgradeAptosChain{} - -// UpgradeAptosChain upgrades Aptos chain packages and modules -type UpgradeAptosChain struct{} - -func (cs UpgradeAptosChain) VerifyPreconditions(env cldf.Environment, cfg config.UpgradeAptosChainConfig) error { - var errs []error - if !cfg.UpgradeCCIP && !cfg.UpgradeOffRamp && !cfg.UpgradeOnRamp && !cfg.UpgradeRouter { - errs = append(errs, errors.New("no upgrades selected")) - } - state, err := stateview.LoadOnchainState(env) - if err != nil { - errs = append(errs, fmt.Errorf("failed to load Aptos onchain state: %w", err)) - } - // Validate supported chain - supportedChains := state.SupportedChains() - if _, ok := supportedChains[cfg.ChainSelector]; !ok { - errs = append(errs, fmt.Errorf("unsupported chain: %d", cfg.ChainSelector)) - } - // Validate MCMS config - if cfg.MCMS == nil { - errs = append(errs, errors.New("MCMS config is required for UpgradeAptosChain changeset")) - } - // Check CCIP Package - ccipAddress := state.AptosChains[cfg.ChainSelector].CCIPAddress - client := env.BlockChains.AptosChains()[cfg.ChainSelector].Client - if ccipAddress == (aptos.AccountAddress{}) { - errs = append(errs, fmt.Errorf("package CCIP is not deployed on Aptos chain %d", cfg.ChainSelector)) - } - // Check OnRamp module - hasOnramp, err := utils.IsModuleDeployed(client, ccipAddress, "onramp") - if err != nil || !hasOnramp { - errs = append(errs, fmt.Errorf("onRamp module is not deployed on Aptos chain %d: %w", cfg.ChainSelector, err)) - } - // Check OffRamp module - hasOfframp, err := utils.IsModuleDeployed(client, ccipAddress, "offramp") - if err != nil || !hasOfframp { - errs = append(errs, fmt.Errorf("offRamp module is not deployed on Aptos chain %d: %w", cfg.ChainSelector, err)) - } - // Check Router module - hasRouter, err := utils.IsModuleDeployed(client, ccipAddress, "router") - if err != nil || !hasRouter { - errs = append(errs, fmt.Errorf("router module is not deployed on Aptos chain %d: %w", cfg.ChainSelector, err)) - } - - return errors.Join(errs...) -} - -func (cs UpgradeAptosChain) Apply(env cldf.Environment, cfg config.UpgradeAptosChainConfig) (cldf.ChangesetOutput, error) { - timeLockProposals := []mcms.TimelockProposal{} - mcmsOperations := []types.BatchOperation{} - seqReports := make([]operations.Report[any, any], 0) - - state, err := stateview.LoadOnchainState(env) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to load Aptos onchain state: %w", err) - } - - deps := dependency.AptosDeps{ - AptosChain: env.BlockChains.AptosChains()[cfg.ChainSelector], - CCIPOnChainState: state, - } - - // Execute the sequence - upgradeSeqReport, err := operations.ExecuteSequence(env.OperationsBundle, seq.UpgradeCCIPSequence, deps, cfg) - if err != nil { - return cldf.ChangesetOutput{}, err - } - seqReports = append(seqReports, upgradeSeqReport.ExecutionReports...) - mcmsOperations = append(mcmsOperations, upgradeSeqReport.Output...) - - // Generate MCMS proposals - proposal, err := utils.GenerateProposal( - env, - state.AptosChains[cfg.ChainSelector].MCMSAddress, - cfg.ChainSelector, - mcmsOperations, - "Upgrade chain contracts on Aptos chain", - *cfg.MCMS, - ) - if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to generate MCMS proposal for Aptos chain %d: %w", cfg.ChainSelector, err) - } - timeLockProposals = append(timeLockProposals, *proposal) - - return cldf.ChangesetOutput{ - MCMSTimelockProposals: timeLockProposals, - Reports: seqReports, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip_test.go b/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip_test.go deleted file mode 100644 index b9e7e42b669..00000000000 --- a/deployment/ccip/changeset/aptos/cs_upgrade_aptos_ccip_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package aptos_test - -import ( - "testing" - "time" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - chain_selectors "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - "github.com/stretchr/testify/require" - - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" - commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset" -) - -func TestUpgradeAptosChain_Apply(t *testing.T) { - t.Skip("skipping - no need to run these tests in CI") - t.Parallel() - // Setup environment with contracts deployed - deployedEnvironment, _ := testhelpers.NewMemoryEnvironment( - t, - testhelpers.WithAptosChains(1), - ) - env := deployedEnvironment.Env - - chainSelector := env.BlockChains.ListChainSelectors(cldf_chain.WithFamily(chain_selectors.FamilyAptos))[0] - - cfg := config.UpgradeAptosChainConfig{ - ChainSelector: chainSelector, - MCMS: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - UpgradeCCIP: true, - UpgradeOffRamp: true, - UpgradeOnRamp: true, - UpgradeRouter: true, - } - - // Apply the changeset - env, out, err := commonchangeset.ApplyChangesets(t, env, []commonchangeset.ConfiguredChangeSet{ - commonchangeset.Configure(aptoscs.UpgradeAptosChain{}, cfg), - }) - - proposals := out[0].MCMSTimelockProposals - require.Len(t, proposals, 1) - require.Len(t, proposals[0].Operations, 7) - require.NoError(t, err) -} diff --git a/deployment/ccip/changeset/aptos/dependency/dependencies.go b/deployment/ccip/changeset/aptos/dependency/dependencies.go deleted file mode 100644 index 81cb761026e..00000000000 --- a/deployment/ccip/changeset/aptos/dependency/dependencies.go +++ /dev/null @@ -1,14 +0,0 @@ -package dependency - -import ( - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - - "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" -) - -type AptosDeps struct { - AB *cldf.AddressBookMap - AptosChain cldf_aptos.Chain - CCIPOnChainState stateview.CCIPOnChainState -} diff --git a/deployment/ccip/changeset/aptos/operation/ccip.go b/deployment/ccip/changeset/aptos/operation/ccip.go deleted file mode 100644 index f3f5f62e77a..00000000000 --- a/deployment/ccip/changeset/aptos/operation/ccip.go +++ /dev/null @@ -1,305 +0,0 @@ -package operation - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_onramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - aptoscfg "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var CCIPOperations = []*operations.Operation[any, any, any]{ - DeployRouterOp.AsUntypedRelaxed(), - DeployOffRampOp.AsUntypedRelaxed(), - DeployOnRampOp.AsUntypedRelaxed(), - InitializeCCIPOp.AsUntypedRelaxed(), - ApplyAllowedOfframpUpdatesOp.AsUntypedRelaxed(), -} - -// OP: DeployCCIPOp deploys the CCIP package on Aptos chain -type DeployCCIPInput struct { - MCMSAddress aptos.AccountAddress - IsUpgrade bool -} - -type DeployCCIPOutput struct { - CCIPAddress aptos.AccountAddress - MCMSOperations []mcmstypes.Operation -} - -var DeployCCIPOp = operations.NewOperation( - "deploy-ccip-op", - Version1_0_0, - "Deploys CCIP Package for Aptos Chain", - deployCCIP, -) - -func deployCCIP(b operations.Bundle, deps dependency.AptosDeps, in DeployCCIPInput) (DeployCCIPOutput, error) { - onChainState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - // Validate there's no package deployed XOR is update - if (onChainState.CCIPAddress == (aptos.AccountAddress{})) == (in.IsUpgrade) { - if in.IsUpgrade { - b.Logger.Infow("Trying to update a non-deployed package", "addr", onChainState.CCIPAddress.StringLong()) - return DeployCCIPOutput{}, fmt.Errorf("CCIP package not deployed on Aptos chain %d", deps.AptosChain.Selector) - } - b.Logger.Infow("CCIP Package already deployed", "addr", onChainState.CCIPAddress.StringLong()) - return DeployCCIPOutput{CCIPAddress: onChainState.CCIPAddress}, nil - } - - // Compile, chunk and get CCIP deploy operations - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - ccipObjectAddress, operations, err := getCCIPDeployMCMSOps(mcmsContract, deps.AptosChain.Selector, onChainState.CCIPAddress) - if err != nil { - return DeployCCIPOutput{}, fmt.Errorf("failed to compile and create deploy operations: %w", err) - } - if in.IsUpgrade { - return DeployCCIPOutput{ - MCMSOperations: operations, - }, nil - } - - return DeployCCIPOutput{ - CCIPAddress: ccipObjectAddress, - MCMSOperations: operations, - }, nil -} - -func getCCIPDeployMCMSOps(mcmsContract mcmsbind.MCMS, chainSel uint64, ccipAddress aptos.AccountAddress) (aptos.AccountAddress, []mcmstypes.Operation, error) { - // Calculate addresses of the owner and the object - var ccipObjectAddress aptos.AccountAddress - var err error - if ccipAddress != (aptos.AccountAddress{}) { - ccipObjectAddress = ccipAddress - } else { - ccipObjectAddress, err = mcmsContract.MCMSRegistry().GetNewCodeObjectAddress(nil, []byte(ccip.DefaultSeed)) - if err != nil { - return ccipObjectAddress, nil, fmt.Errorf("failed to calculate object address: %w", err) - } - } - - // Compile Package - payload, err := ccip.Compile(ccipObjectAddress, mcmsContract.Address(), ccipAddress == aptos.AccountAddress{}) - if err != nil { - return ccipObjectAddress, nil, fmt.Errorf("failed to compile: %w", err) - } - - // Create chunks and stage operations - var operations []mcmstypes.Operation - if ccipAddress == (aptos.AccountAddress{}) { - operations, err = utils.CreateChunksAndStage(payload, mcmsContract, chainSel, ccip.DefaultSeed, nil) - } else { - operations, err = utils.CreateChunksAndStage(payload, mcmsContract, chainSel, "", &ccipObjectAddress) - } - if err != nil { - return ccipObjectAddress, nil, fmt.Errorf("failed to create chunks and stage for %d: %w", chainSel, err) - } - - return ccipObjectAddress, operations, nil -} - -// DeployModulesInput is the input for every module deployment operation -type DeployModulesInput struct { - MCMSAddress aptos.AccountAddress - CCIPAddress aptos.AccountAddress -} - -// OP: DeployRouterOp generates deployment MCMS operations for the Router module -var DeployRouterOp = operations.NewOperation( - "deploy-router-op", - Version1_0_0, - "Generates MCMS proposals that deploys Router module on CCIP package", - deployRouter, -) - -func deployRouter(b operations.Bundle, deps dependency.AptosDeps, in DeployModulesInput) ([]mcmstypes.Operation, error) { - // TODO: is there a way to check if module exists? - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - // Compile Package - payload, err := ccip_router.Compile(in.CCIPAddress, mcmsContract.Address(), true) - if err != nil { - return nil, fmt.Errorf("failed to compile: %w", err) - } - // Create chunks and stage operations - operations, err := utils.CreateChunksAndStage(payload, mcmsContract, deps.AptosChain.Selector, "", &in.CCIPAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks and stage for %d: %w", deps.AptosChain.Selector, err) - } - - return operations, nil -} - -// OP: DeployOffRampOp generates deployment MCMS operations for the OffRamp module -var DeployOffRampOp = operations.NewOperation( - "deploy-offramp-op", - Version1_0_0, - "Generates MCMS proposals that deploys OffRamp module on CCIP package", - deployOffRamp, -) - -func deployOffRamp(b operations.Bundle, deps dependency.AptosDeps, in DeployModulesInput) ([]mcmstypes.Operation, error) { - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - // Compile Package - payload, err := ccip_offramp.Compile(in.CCIPAddress, mcmsContract.Address(), true) - if err != nil { - return nil, fmt.Errorf("failed to compile: %w", err) - } - // Create chunks and stage operations - operations, err := utils.CreateChunksAndStage(payload, mcmsContract, deps.AptosChain.Selector, "", &in.CCIPAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks and stage for %d: %w", deps.AptosChain.Selector, err) - } - return operations, nil -} - -// OP: DeployOnRampOp generates MCMS proposals for the OnRamp module deployment -var DeployOnRampOp = operations.NewOperation( - "deploy-onramp-op", - Version1_0_0, - "Generates MCMS proposals that deploys OnRamp module on CCIP package", - deployOnRamp, -) - -func deployOnRamp(b operations.Bundle, deps dependency.AptosDeps, in DeployModulesInput) ([]mcmstypes.Operation, error) { - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - // Compile Package - payload, err := ccip_onramp.Compile(in.CCIPAddress, mcmsContract.Address(), true) - if err != nil { - return nil, fmt.Errorf("failed to compile: %w", err) - } - // Create chunks and stage operations - operations, err := utils.CreateChunksAndStage(payload, mcmsContract, deps.AptosChain.Selector, "", &in.CCIPAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks and stage for %d: %w", deps.AptosChain.Selector, err) - } - return operations, nil -} - -// OP: InitializeCCIP Operation -type InitializeCCIPInput struct { - MCMSAddress aptos.AccountAddress - CCIPAddress aptos.AccountAddress - LinkTokenAddress aptos.AccountAddress - CCIPConfig aptoscfg.ChainContractParams -} - -var InitializeCCIPOp = operations.NewOperation( - "initialize-ccip-op", - Version1_0_0, - "Initializes CCIP components with configuration parameters", - initializeCCIP, -) - -func initializeCCIP(b operations.Bundle, deps dependency.AptosDeps, in InitializeCCIPInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - // Config OnRamp with empty lane configs. We're only able to get router state signer address after deploying the router module - onrampBind := ccip_onramp.Bind(in.CCIPAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := onrampBind.Onramp().Encoder().Initialize( - deps.AptosChain.Selector, - in.CCIPConfig.OnRampParams.FeeAggregator, - in.CCIPConfig.OnRampParams.AllowlistAdmin, - []uint64{}, // destChainSelectors - []aptos.AccountAddress{}, // destChainRouters - []bool{}, // destChainAllowlistEnabled - ) - if err != nil { - return nil, fmt.Errorf("failed to encode onramp initialize: %w", err) - } - mcmsTx, err := utils.GenerateMCMSTx(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to generate MCMS operations for OnRamp Initialize: %w", err) - } - txs = append(txs, mcmsTx) - - // Config OffRamp - offrampBind := ccip_offramp.Bind(in.CCIPAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = offrampBind.Offramp().Encoder().Initialize( - deps.AptosChain.Selector, - in.CCIPConfig.OffRampParams.PermissionlessExecutionThreshold, - in.CCIPConfig.OffRampParams.SourceChainSelectors, - in.CCIPConfig.OffRampParams.SourceChainIsEnabled, - in.CCIPConfig.OffRampParams.IsRMNVerificationDisabled, - in.CCIPConfig.OffRampParams.SourceChainsOnRamp, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode offramp initialize: %w", err) - } - mcmsTx, err = utils.GenerateMCMSTx(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to generate MCMS operations for OffRamp Initialize: %w", err) - } - txs = append(txs, mcmsTx) - - // Config FeeQuoter and RMNRemote - ccipBind := ccip.Bind(in.CCIPAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err = ccipBind.FeeQuoter().Encoder().Initialize( - in.CCIPConfig.FeeQuoterParams.MaxFeeJuelsPerMsg, - in.LinkTokenAddress, - in.CCIPConfig.FeeQuoterParams.TokenPriceStalenessThreshold, - in.CCIPConfig.FeeQuoterParams.FeeTokens, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode feequoter initialize: %w", err) - } - mcmsTx, err = utils.GenerateMCMSTx(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to generate MCMS operations for FeeQuoter Initialize: %w", err) - } - txs = append(txs, mcmsTx) - - moduleInfo, function, _, args, err = ccipBind.RMNRemote().Encoder().Initialize(deps.AptosChain.Selector) - if err != nil { - return nil, fmt.Errorf("failed to encode rmnremote initialize: %w", err) - } - mcmsTx, err = utils.GenerateMCMSTx(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to generate MCMS operations for RMNRemote Initialize: %w", err) - } - txs = append(txs, mcmsTx) - - return txs, nil -} - -// OP: ApplyAllowedOfframpUpdates Operation -var ApplyAllowedOfframpUpdatesOp = operations.NewOperation( - "apply-allowed-offramp-updates-op", - Version1_0_0, - "Adds CCIP owner address to OffRamp allow list", - applyAllowedOfframpUpdates, -) - -func applyAllowedOfframpUpdates(b operations.Bundle, deps dependency.AptosDeps, _ operations.EmptyInput) (mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - // Bind MCMS Package - mcmsAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].MCMSAddress - mcmsBind := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - - // Add CCIP Owner address to update token prices allow list - ccipOwnerAddress, err := mcmsBind.MCMSRegistry().GetRegisteredOwnerAddress(nil, ccipAddress) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to get CCIP owner address: %w", err) - } - moduleInfo, function, _, args, err := ccipBind.Auth().Encoder().ApplyAllowedOfframpUpdates(nil, []aptos.AccountAddress{ccipOwnerAddress}) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode ApplyAllowedOfframpUpdates: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - - return tx, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/curse_mcms.go b/deployment/ccip/changeset/aptos/operation/curse_mcms.go deleted file mode 100644 index 0bfe2a47647..00000000000 --- a/deployment/ccip/changeset/aptos/operation/curse_mcms.go +++ /dev/null @@ -1,168 +0,0 @@ -package operation - -import ( - "fmt" - "time" - - "github.com/aptos-labs/aptos-go-sdk" - mcmssdk "github.com/smartcontractkit/mcms/sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - curse_mcms "github.com/smartcontractkit/chainlink-aptos/bindings/curse_mcms" - "github.com/smartcontractkit/chainlink-aptos/contracts" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -// OP: DeployCurseMCMSOp deploys CurseMCMS to a new resource account. -type DeployCurseMCMSInput struct { - MCMSAddress aptos.AccountAddress - CCIPAddress aptos.AccountAddress -} - -var DeployCurseMCMSOp = operations.NewOperation( - "deploy-curse-mcms-op", - Version1_0_0, - "Deploys CurseMCMS Contract to a resource account", - deployCurseMCMS, -) - -func deployCurseMCMS(b operations.Bundle, deps dependency.AptosDeps, in DeployCurseMCMSInput) (aptos.AccountAddress, error) { - seed := curse_mcms.DefaultSeed + time.Now().String() - address, tx, err := bind.DeployPackageToResourceAccount( - deps.AptosChain.DeployerSigner, - deps.AptosChain.Client, - contracts.CurseMCMS, - seed, - map[string]aptos.AccountAddress{ - "curse_mcms_owner": deps.AptosChain.DeployerSigner.AccountAddress(), - "ccip": in.CCIPAddress, - "mcms": in.MCMSAddress, - "mcms_register_entrypoints": aptos.AccountOne, - }, - aptos.MaxGasAmount(1_000_000), - ) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("failed to deploy CurseMCMS: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("failed to confirm CurseMCMS deployment: %w", err) - } - return address, nil -} - -// OP: ConfigureCurseMCMSOp configures a role on the CurseMCMS contract. -// Unlike the main MCMS configurer, this calls curse_mcms::set_config directly. -type ConfigureCurseMCMSInput struct { - CurseMCMSAddress aptos.AccountAddress - MCMSConfigs mcmstypes.Config - MCMSRole aptosmcms.TimelockRole -} - -var ConfigureCurseMCMSOp = operations.NewOperation( - "configure-curse-mcms-op", - Version1_0_0, - "Configure CurseMCMS role (bypasser, canceller, or proposer)", - configureCurseMCMS, -) - -func configureCurseMCMS(b operations.Bundle, deps dependency.AptosDeps, in ConfigureCurseMCMSInput) (any, error) { - curseMcmsBinding := curse_mcms.Bind(in.CurseMCMSAddress, deps.AptosChain.Client) - opts := &bind.TransactOpts{Signer: deps.AptosChain.DeployerSigner} - - groupQuorum, groupParents, signerAddresses, signerGroups, err := mcmssdk.ExtractSetConfigInputs(&in.MCMSConfigs) - if err != nil { - return nil, fmt.Errorf("failed to extract config inputs: %w", err) - } - signers := make([][]byte, len(signerAddresses)) - for i, addr := range signerAddresses { - signers[i] = addr.Bytes() - } - - tx, err := curseMcmsBinding.CurseMCMS().SetConfig( - opts, - in.MCMSRole.Byte(), - signers, - signerGroups, - groupQuorum[:], - groupParents[:], - false, - ) - if err != nil { - return nil, fmt.Errorf("failed to configure CurseMCMS: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return nil, fmt.Errorf("CurseMCMS configure transaction failed: %w", err) - } - return nil, nil -} - -// OP: TransferCurseMCMSOwnershipToSelfOp transfers CurseMCMS ownership to -// the CurseMCMS resource account itself. The deployer is still the owner at -// this point so the call is signed directly. -var TransferCurseMCMSOwnershipToSelfOp = operations.NewOperation( - "transfer-curse-mcms-ownership-to-self-op", - Version1_0_0, - "Transfer CurseMCMS ownership to self", - transferCurseMCMSOwnershipToSelf, -) - -func transferCurseMCMSOwnershipToSelf(b operations.Bundle, deps dependency.AptosDeps, curseMCMSAddress aptos.AccountAddress) (any, error) { - opts := &bind.TransactOpts{Signer: deps.AptosChain.DeployerSigner} - contractCurseMCMS := curse_mcms.Bind(curseMCMSAddress, deps.AptosChain.Client) - tx, err := contractCurseMCMS.CurseMCMSAccount().TransferOwnershipToSelf(opts) - if err != nil { - return nil, fmt.Errorf("failed to TransferOwnershipToSelf in CurseMCMS contract: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return nil, fmt.Errorf("CurseMCMS TransferOwnershipToSelf transaction failed: %w", err) - } - return nil, nil -} - -// OP: AcceptCurseMCMSOwnershipOp encodes an AcceptOwnership transaction for -// the CurseMCMS contract. This must be submitted as a CurseMCMS proposal so -// the CurseMCMS resource account signer can call it. -var AcceptCurseMCMSOwnershipOp = operations.NewOperation( - "accept-curse-mcms-ownership-op", - Version1_0_0, - "Generate Accept Ownership transaction for CurseMCMS", - acceptCurseMCMSOwnership, -) - -func acceptCurseMCMSOwnership(b operations.Bundle, deps dependency.AptosDeps, curseMCMSAddress aptos.AccountAddress) (mcmstypes.Transaction, error) { - contractCurseMCMS := curse_mcms.Bind(curseMCMSAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := contractCurseMCMS.CurseMCMSAccount().Encoder().AcceptOwnership() - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode CurseMCMS AcceptOwnership: %w", err) - } - return utils.GenerateMCMSTx(curseMCMSAddress, moduleInfo, function, args) -} - -// OP: SetCurseMCMSMinDelayOp encodes a CurseMCMS timelock transaction for -// timelock_update_min_delay. This must be submitted as a CurseMCMS proposal -// because the function requires TIMELOCK_ROLE. -type CurseMCMSMinDelayInput struct { - CurseMCMSAddress aptos.AccountAddress - TimelockMinDelay uint64 -} - -var SetCurseMCMSMinDelayOp = operations.NewOperation( - "set-curse-mcms-min-delay-op", - Version1_0_0, - "Generate set timelock min delay transaction for CurseMCMS", - setCurseMCMSMinDelay, -) - -func setCurseMCMSMinDelay(b operations.Bundle, deps dependency.AptosDeps, in CurseMCMSMinDelayInput) (mcmstypes.Transaction, error) { - curseMcmsBinding := curse_mcms.Bind(in.CurseMCMSAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := curseMcmsBinding.CurseMCMS().Encoder().TimelockUpdateMinDelay(in.TimelockMinDelay) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode CurseMCMS TimelockUpdateMinDelay: %w", err) - } - return utils.GenerateMCMSTx(in.CurseMCMSAddress, moduleInfo, function, args) -} diff --git a/deployment/ccip/changeset/aptos/operation/fee_quoter.go b/deployment/ccip/changeset/aptos/operation/fee_quoter.go deleted file mode 100644 index a447e678c7b..00000000000 --- a/deployment/ccip/changeset/aptos/operation/fee_quoter.go +++ /dev/null @@ -1,293 +0,0 @@ -package operation - -import ( - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var FeeQuoterOperations = []*operations.Operation[any, any, any]{ - UpdateFeeQuoterDestsOp.AsUntypedRelaxed(), - UpdateFeeQuoterPricesOp.AsUntypedRelaxed(), - ApplyPremiumMultiplierOp.AsUntypedRelaxed(), - ApplyTokenTransferFeeCfgOp.AsUntypedRelaxed(), -} - -// UpdateFeeQuoterDestsInput contains configuration for updating FeeQuoter destination configs -type UpdateFeeQuoterDestsInput struct { - Updates map[uint64]fee_quoter.DestChainConfig -} - -// UpdateFeeQuoterDestsOp operation to update FeeQuoter destination configurations -var UpdateFeeQuoterDestsOp = operations.NewOperation( - "update-fee-quoter-dests-op", - Version1_0_0, - "Updates FeeQuoter destination chain configurations", - updateFeeQuoterDests, -) - -func updateFeeQuoterDests(b operations.Bundle, deps dependency.AptosDeps, in UpdateFeeQuoterDestsInput) ([]mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - // Process each destination chain config update - var txs []mcmstypes.Transaction - - for destChainSelector, destConfig := range in.Updates { - // Encode the update operation - moduleInfo, function, _, args, err := ccipBind.FeeQuoter().Encoder().ApplyDestChainConfigUpdates( - destChainSelector, - destConfig.IsEnabled, - destConfig.MaxNumberOfTokensPerMsg, - destConfig.MaxDataBytes, - destConfig.MaxPerMsgGasLimit, - destConfig.DestGasOverhead, - destConfig.DestGasPerPayloadByteBase, - destConfig.DestGasPerPayloadByteHigh, - destConfig.DestGasPerPayloadByteThreshold, - destConfig.DestDataAvailabilityOverheadGas, - destConfig.DestGasPerDataAvailabilityByte, - destConfig.DestDataAvailabilityMultiplierBps, - destConfig.ChainFamilySelector, - destConfig.EnforceOutOfOrder, - destConfig.DefaultTokenFeeUsdCents, - destConfig.DefaultTokenDestGasOverhead, - destConfig.DefaultTxGasLimit, - destConfig.GasMultiplierWeiPerEth, - destConfig.GasPriceStalenessThreshold, - destConfig.NetworkFeeUsdCents, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode ApplyDestChainConfigUpdates for chain %d: %w", destChainSelector, err) - } - - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - - txs = append(txs, tx) - - b.Logger.Infow("Adding FeeQuoter destination config update operation", - "destChainSelector", destChainSelector, - "isEnabled", destConfig.IsEnabled) - } - - return txs, nil -} - -// UpdateFeeQuoterPricesInput contains configuration for updating FeeQuoter price configs -type UpdateFeeQuoterPricesInput struct { - TokenPrices map[string]*big.Int // token address (string) -> price - GasPrices map[uint64]*big.Int // dest chain -> gas price -} - -// UpdateFeeQuoterPricesOp operation to update FeeQuoter prices -var UpdateFeeQuoterPricesOp = operations.NewOperation( - "update-fee-quoter-prices-op", - Version1_0_0, - "Updates FeeQuoter token and gas prices", - updateFeeQuoterPrices, -) - -func updateFeeQuoterPrices(b operations.Bundle, deps dependency.AptosDeps, in UpdateFeeQuoterPricesInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - // Convert token prices and gas prices to format expected by Aptos contract - var sourceTokens []aptos.AccountAddress - var sourceUsdPerToken []*big.Int - var gasDestChainSelectors []uint64 - var gasUsdPerUnitGas []*big.Int - - // Process token prices if any - for tokenAddr, price := range in.TokenPrices { - address := aptos.AccountAddress{} - err := address.ParseStringRelaxed(tokenAddr) - if err != nil { - return nil, fmt.Errorf("failed to parse Aptos token address %s: %w", tokenAddr, err) - } - sourceTokens = append(sourceTokens, address) - sourceUsdPerToken = append(sourceUsdPerToken, price) - } - - // Process gas prices if any - for destChainSel, gasPrice := range in.GasPrices { - gasDestChainSelectors = append(gasDestChainSelectors, destChainSel) - gasUsdPerUnitGas = append(gasUsdPerUnitGas, gasPrice) - } - - // Generate MCMS tx to update prices - if len(sourceTokens) == 0 && len(gasDestChainSelectors) == 0 { - b.Logger.Infow("No price updates to apply") - return nil, nil - } - - // Encode the update tx - moduleInfo, function, _, args, err := ccipBind.FeeQuoter().Encoder().UpdatePrices( - sourceTokens, - sourceUsdPerToken, - gasDestChainSelectors, - gasUsdPerUnitGas, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode UpdatePrices: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - txs = append(txs, tx) - - b.Logger.Infow("Adding FeeQuoter price update operation", - "tokenPriceCount", len(sourceTokens), - "gasPriceCount", len(gasDestChainSelectors), - ) - - return txs, nil -} - -// ApplyPremiumMultiplierInput contains configuration for updating FeeQuoter price configs -type ApplyPremiumMultiplierInput struct { - CCIPAddress aptos.AccountAddress - MultiplierBySourceToken map[string]uint64 // source token address (aptos) -> premium wei per eth -} - -// ApplyPremiumMultiplierOp operation to update FeeQuoter prices -var ApplyPremiumMultiplierOp = operations.NewOperation( - "apply-premium-multiplier-op", - Version1_0_0, - "Applies premium multiplier wei per eth updates to FeeQuoter prices", - applyPremiumMultiplier, -) - -func applyPremiumMultiplier(b operations.Bundle, deps dependency.AptosDeps, in ApplyPremiumMultiplierInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - // Bind CCIP Package - ccipBind := ccip.Bind(in.CCIPAddress, deps.AptosChain.Client) - - // Convert token prices and gas prices to format expected by Aptos contract - var sourceTokens []aptos.AccountAddress - var multiplier []uint64 - - // Process token multipliers if any - for tokenAddr, price := range in.MultiplierBySourceToken { - address := aptos.AccountAddress{} - err := address.ParseStringRelaxed(tokenAddr) - if err != nil { - return nil, fmt.Errorf("failed to parse Aptos token address %s: %w", tokenAddr, err) - } - sourceTokens = append(sourceTokens, address) - multiplier = append(multiplier, price) - } - - // Generate MCMS tx to update prices - if len(sourceTokens) == 0 && len(multiplier) == 0 { - b.Logger.Infow("No price updates to apply") - return nil, nil - } - - // Encode the update tx - moduleInfo, function, _, args, err := ccipBind.FeeQuoter().Encoder().ApplyPremiumMultiplierWeiPerEthUpdates( - sourceTokens, - multiplier, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode ApplyPremiumMultiplierWeiPerEthUpdates: %w", err) - } - tx, err := utils.GenerateMCMSTx(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - txs = append(txs, tx) - - b.Logger.Infow("Adding ApplyPremiumMultiplierWeiPerEthUpdates operation", - "tokenCount", len(sourceTokens), - "multiplierCount", len(multiplier), - ) - - return txs, nil -} - -// ApplyTokenTransferFeeCfgInput contains configuration for updating FeeQuoter price configs -type ApplyTokenTransferFeeCfgInput struct { - DestChainSelector uint64 - ConfigsByToken map[string]fee_quoter.TokenTransferFeeConfig // token address (string) -> config - RemoveTokens []aptos.AccountAddress -} - -// ApplyTokenTransferFeeCfgOp operation to apply token transfer fee configuration updates -var ApplyTokenTransferFeeCfgOp = operations.NewOperation( - "apply-token-transfer-fee-cfg-op", - Version1_0_0, - "Applies token transfer fee configuration updates to FeeQuoter prices", - applyTokenTransferFeeCfg, -) - -func applyTokenTransferFeeCfg(b operations.Bundle, deps dependency.AptosDeps, in ApplyTokenTransferFeeCfgInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - var addTokens []aptos.AccountAddress - var addMinFeeUsdCents []uint32 - var addMaxFeeUsdCents []uint32 - var addDeciBps []uint16 - var addDestGasOverhead []uint32 - var addDestBytesOverhead []uint32 - var addIsEnabled []bool - - for token, config := range in.ConfigsByToken { - tokenAddress := aptos.AccountAddress{} - err := tokenAddress.ParseStringRelaxed(token) - if err != nil { - return nil, fmt.Errorf("failed to parse Aptos token address %s: %w", token, err) - } - addTokens = append(addTokens, tokenAddress) - addMinFeeUsdCents = append(addMinFeeUsdCents, config.MinFeeUsdCents) - addMaxFeeUsdCents = append(addMaxFeeUsdCents, config.MaxFeeUsdCents) - addDeciBps = append(addDeciBps, config.DeciBps) - addDestGasOverhead = append(addDestGasOverhead, config.DestGasOverhead) - addDestBytesOverhead = append(addDestBytesOverhead, config.DestBytesOverhead) - addIsEnabled = append(addIsEnabled, config.IsEnabled) - } - - // Encode the update tx - moduleInfo, function, _, args, err := ccipBind.FeeQuoter().Encoder().ApplyTokenTransferFeeConfigUpdates( - in.DestChainSelector, - addTokens, - addMinFeeUsdCents, - addMaxFeeUsdCents, - addDeciBps, - addDestGasOverhead, - addDestBytesOverhead, - addIsEnabled, - in.RemoveTokens, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode ApplyTokenTransferFeeConfigUpdates: %w", err) - } - - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - txs = append(txs, tx) - - return txs, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/mcms.go b/deployment/ccip/changeset/aptos/operation/mcms.go deleted file mode 100644 index 257f1884f0e..00000000000 --- a/deployment/ccip/changeset/aptos/operation/mcms.go +++ /dev/null @@ -1,171 +0,0 @@ -package operation - -import ( - "context" - "fmt" - "time" - - "github.com/aptos-labs/aptos-go-sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var MCMSOperations = []*operations.Operation[any, any, any]{ - AcceptOwnershipOp.AsUntypedRelaxed(), - SetMinDelayOP.AsUntypedRelaxed(), - CleanupStagingAreaOp.AsUntypedRelaxed(), -} - -// OP: Deploy MCMS Contract -var DeployMCMSOp = operations.NewOperation( - "deploy-mcms-op", - Version1_0_0, - "Deploys MCMS Contract Operation for Aptos Chain", - deployMCMS, -) - -func deployMCMS(b operations.Bundle, deps dependency.AptosDeps, _ operations.EmptyInput) (aptos.AccountAddress, error) { - mcmsSeed := mcmsbind.DefaultSeed + time.Now().String() - mcmsAddress, mcmsDeployTx, _, err := mcmsbind.DeployToResourceAccount(deps.AptosChain.DeployerSigner, deps.AptosChain.Client, mcmsSeed) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("failed to deploy MCMS contract: %w", err) - } - if err := deps.AptosChain.Confirm(mcmsDeployTx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("failed to confirm MCMS deployment transaction: %w", err) - } - - return mcmsAddress, nil -} - -// OP: Configure MCMS Contract -type ConfigureMCMSInput struct { - MCMSAddress aptos.AccountAddress - MCMSConfigs mcmstypes.Config - MCMSRole aptosmcms.TimelockRole -} - -var ConfigureMCMSOp = operations.NewOperation( - "configure-mcms-op", - Version1_0_0, - "Configure MCMS Contract Operation for Aptos Chain", - configureMCMS, -) - -func configureMCMS(b operations.Bundle, deps dependency.AptosDeps, in ConfigureMCMSInput) (any, error) { - configurer := aptosmcms.NewConfigurer(deps.AptosChain.Client, deps.AptosChain.DeployerSigner, in.MCMSRole) - setCfgTx, err := configurer.SetConfig(context.Background(), in.MCMSAddress.StringLong(), &in.MCMSConfigs, false) - if err != nil { - return nil, fmt.Errorf("failed to setConfig in MCMS contract: %w", err) - } - if err := deps.AptosChain.Confirm(setCfgTx.Hash); err != nil { - return nil, fmt.Errorf("MCMS setConfig transaction failed: %w", err) - } - return nil, nil -} - -// OP: Transfer Ownership to Self -var TransferOwnershipToSelfOp = operations.NewOperation( - "transfer-ownership-to-self-op", - Version1_0_0, - "Transfer ownership to self", - transferOwnershipToSelf, -) - -func transferOwnershipToSelf(b operations.Bundle, deps dependency.AptosDeps, mcmsAddress aptos.AccountAddress) (any, error) { - opts := &bind.TransactOpts{Signer: deps.AptosChain.DeployerSigner} - contractMCMS := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - tx, err := contractMCMS.MCMSAccount().TransferOwnershipToSelf(opts) - if err != nil { - return nil, fmt.Errorf("failed to TransferOwnershipToSelf in MCMS contract: %w", err) - } - err = deps.AptosChain.Confirm(tx.Hash) - if err != nil { - return nil, fmt.Errorf("MCMS TransferOwnershipToSelf transaction failed: %w", err) - } - return nil, nil -} - -// OP: Accept Ownership -var AcceptOwnershipOp = operations.NewOperation( - "accept-ownership-op", - Version1_0_0, - "Generate Accept Ownership BatchOperations for MCMS Contract", - acceptOwnership, -) - -func acceptOwnership(b operations.Bundle, deps dependency.AptosDeps, mcmsAddress aptos.AccountAddress) (mcmstypes.Transaction, error) { - contractMCMS := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := contractMCMS.MCMSAccount().Encoder().AcceptOwnership() - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode AcceptOwnership: %w", err) - } - - return utils.GenerateMCMSTx(mcmsAddress, moduleInfo, function, args) -} - -// OP: SetMinDelay -type TimelockMinDelayInput struct { - MCMSAddress aptos.AccountAddress - TimelockMinDelay uint64 -} - -var SetMinDelayOP = operations.NewOperation( - "set-timelock-min-delay-op", - Version1_0_0, - "Generate set timelock min delay MCMS BatchOperations", - setMinDelay, -) - -func setMinDelay(b operations.Bundle, deps dependency.AptosDeps, in TimelockMinDelayInput) (mcmstypes.Transaction, error) { - contractMCMS := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := contractMCMS.MCMS().Encoder().TimelockUpdateMinDelay(in.TimelockMinDelay) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode AcceptOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.MCMSAddress, moduleInfo, function, args) -} - -// OP: CleanupStagingAreaOp generates a batch operation to clean up the staging area -var CleanupStagingAreaOp = operations.NewOperation( - "cleanup-staging-area-op", - Version1_0_0, - "Cleans up MCMS staging area if it's not already clean", - cleanupStagingArea, -) - -func cleanupStagingArea(b operations.Bundle, deps dependency.AptosDeps, mcmsAddress aptos.AccountAddress) (mcmstypes.BatchOperation, error) { - // Check resources first to see if staging is clean - IsMCMSStagingAreaClean, err := utils.IsMCMSStagingAreaClean(deps.AptosChain.Client, mcmsAddress) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to check if MCMS staging area is clean: %w", err) - } - if IsMCMSStagingAreaClean { - b.Logger.Infow("MCMS Staging Area already clean", "addr", mcmsAddress.StringLong()) - return mcmstypes.BatchOperation{}, nil - } - - // Bind MCMS contract - mcmsContract := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - - // Get cleanup staging operations - moduleInfo, function, _, args, err := mcmsContract.MCMSDeployer().Encoder().CleanupStagingArea() - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to EncodeCleanupStagingArea: %w", err) - } - mcmsTx, err := utils.GenerateMCMSTx(mcmsAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to generate MCMS operations for FeeQuoter Initialize: %w", err) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: []mcmstypes.Transaction{mcmsTx}, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/off_ramp.go b/deployment/ccip/changeset/aptos/operation/off_ramp.go deleted file mode 100644 index 32afdabe003..00000000000 --- a/deployment/ccip/changeset/aptos/operation/off_ramp.go +++ /dev/null @@ -1,131 +0,0 @@ -package operation - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - aptosutils "github.com/smartcontractkit/chainlink-aptos/relayer/utils" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" -) - -var OffRampOperations = []*operations.Operation[any, any, any]{ - UpdateOffRampSourcesOp.AsUntypedRelaxed(), - SetOcr3ConfigOp.AsUntypedRelaxed(), -} - -// UpdateOffRampSourcesInput contains configuration for updating OffRamp sources -type UpdateOffRampSourcesInput struct { - Updates map[uint64]v1_6.OffRampSourceUpdate -} - -// UpdateOffRampSourcesOp operation to update OffRamp source configurations -var UpdateOffRampSourcesOp = operations.NewOperation( - "update-offramp-sources-op", - Version1_0_0, - "Updates OffRamp source chain configurations", - updateOffRampSources, -) - -func updateOffRampSources(b operations.Bundle, deps dependency.AptosDeps, in UpdateOffRampSourcesInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - offRampBind := ccip_offramp.Bind(ccipAddress, deps.AptosChain.Client) - - // Transform the updates into the format expected by the Aptos contract - var sourceChainSelectors []uint64 - var sourceChainEnabled []bool - var sourceChainRMNVerificationDisabled []bool - var sourceChainOnRamp [][]byte - - for sourceChainSelector, update := range in.Updates { - sourceChainSelectors = append(sourceChainSelectors, sourceChainSelector) - sourceChainEnabled = append(sourceChainEnabled, update.IsEnabled) - sourceChainRMNVerificationDisabled = append(sourceChainRMNVerificationDisabled, update.IsRMNVerificationDisabled) - - onRampBytes, err := deps.CCIPOnChainState.GetOnRampAddressBytes(sourceChainSelector) - if err != nil { - return nil, fmt.Errorf("failed to get onRamp address for source chain %d: %w", sourceChainSelector, err) - } - sourceChainOnRamp = append(sourceChainOnRamp, onRampBytes) - } - - if len(sourceChainSelectors) == 0 { - b.Logger.Infow("No OffRamp source updates to apply") - return nil, nil - } - - // Encode the update operation - moduleInfo, function, _, args, err := offRampBind.Offramp().Encoder().ApplySourceChainConfigUpdates( - sourceChainSelectors, - sourceChainEnabled, - sourceChainRMNVerificationDisabled, - sourceChainOnRamp, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode ApplySourceChainConfigUpdates for OffRamp: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - txs = append(txs, tx) - - return txs, nil -} - -// SetOcr3ConfigInput contains configuration for setting the OCR3 config on the OffRamp -type SetOcr3ConfigInput struct { - OcrPluginType types.PluginType - OCRConfigArgs internal.MultiOCR3BaseOCRConfigArgsAptos -} - -// SetOcr3ConfigOp operation sets commit or exec OCR3 configuration for OffRamp -var SetOcr3ConfigOp = operations.NewOperation( - "set-ocr3-config-op", - Version1_0_0, - "Sets OCR3 configuration for OffRamp", - setOcr3Config, -) - -func setOcr3Config(b operations.Bundle, deps dependency.AptosDeps, in SetOcr3ConfigInput) (mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - offRampBind := ccip_offramp.Bind(ccipAddress, deps.AptosChain.Client) - - var transmitters []aptos.AccountAddress - for _, transmitter := range in.OCRConfigArgs.Transmitters { - address, err := aptosutils.PublicKeyBytesToAddress(transmitter) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to convert transmitter to address: %w", err) - } - transmitters = append(transmitters, address) - } - - moduleInfo, function, _, args, err := offRampBind.Offramp().Encoder().SetOcr3Config( - in.OCRConfigArgs.ConfigDigest[:], - uint8(in.OcrPluginType), - in.OCRConfigArgs.F, - in.OCRConfigArgs.IsSignatureVerificationEnabled, - in.OCRConfigArgs.Signers, - transmitters, - ) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode SetOcr3Config for commit: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to generate MCMS operations for OffRamp Initialize: %w", err) - } - - return tx, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/on_ramp.go b/deployment/ccip/changeset/aptos/operation/on_ramp.go deleted file mode 100644 index b365324e36a..00000000000 --- a/deployment/ccip/changeset/aptos/operation/on_ramp.go +++ /dev/null @@ -1,151 +0,0 @@ -package operation - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_onramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" -) - -var OnRampOperations = []*operations.Operation[any, any, any]{ - UpdateOnRampDestsOp.AsUntypedRelaxed(), - MigrateOnRampDestChainConfigsToV2Op.AsUntypedRelaxed(), -} - -// UpdateOnRampDestsInput contains configuration for updating OnRamp destinations -type UpdateOnRampDestsInput struct { - Updates map[uint64]v1_6.OnRampDestinationUpdate -} - -// UpdateOnRampDestsOp operation to update OnRamp destination configurations -var UpdateOnRampDestsOp = operations.NewOperation( - "update-onramp-dests-op", - Version1_0_0, - "Updates OnRamp destination chain configurations", - updateOnRampDests, -) - -func updateOnRampDests(b operations.Bundle, deps dependency.AptosDeps, in UpdateOnRampDestsInput) ([]mcmstypes.Transaction, error) { - var txs []mcmstypes.Transaction - - aptosState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - // Bind CCIP Package - ccipAddress := aptosState.CCIPAddress - onrampBind := ccip_onramp.Bind(ccipAddress, deps.AptosChain.Client) - - // Transform the updates into the format expected by the Aptos contract - var destChainSelectors []uint64 - var destChainRouters []aptos.AccountAddress - var destChainRouterStateAddresses []aptos.AccountAddress - var destChainAllowlistEnabled []bool - - // Get routers state addresses - var testRouterStateAddress aptos.AccountAddress - var routerStateAddress aptos.AccountAddress - if aptosState.TestRouterAddress != (aptos.AccountAddress{}) { - testRouter := ccip_router.Bind(aptosState.TestRouterAddress, deps.AptosChain.Client) - stateAddress, err := testRouter.Router().GetStateAddress(nil) - if err != nil { - return nil, fmt.Errorf("failed to get test router state address: %w", err) - } - testRouterStateAddress = stateAddress - } - // Router address is the router module address - router := ccip_router.Bind(ccipAddress, deps.AptosChain.Client) - // Router state address is the router state signer address - routerStateAddress, err := router.Router().GetStateAddress(nil) - if err != nil { - return nil, fmt.Errorf("failed to get router state address: %w", err) - } - - // Process each destination chain config update - for destChainSelector, update := range in.Updates { - // destChainRouters and destChainRouterStateAddresses - if !update.IsEnabled { - destChainRouters = append(destChainRouters, aptos.AccountAddress{}) - destChainRouterStateAddresses = append(destChainRouterStateAddresses, aptos.AccountAddress{}) - continue - } - - if update.TestRouter { - destChainRouters = append(destChainRouters, aptosState.TestRouterAddress) - destChainRouterStateAddresses = append(destChainRouterStateAddresses, testRouterStateAddress) - } else { - destChainRouters = append(destChainRouters, ccipAddress) - destChainRouterStateAddresses = append(destChainRouterStateAddresses, routerStateAddress) - } - // destChainSelectors - destChainSelectors = append(destChainSelectors, destChainSelector) - // destChainAllowlistEnabled - destChainAllowlistEnabled = append(destChainAllowlistEnabled, update.AllowListEnabled) - } - - if len(destChainSelectors) == 0 { - b.Logger.Infow("No OnRamp destination updates to apply") - return nil, nil - } - - // Encode the update operation - moduleInfo, function, _, args, err := onrampBind.Onramp().Encoder().ApplyDestChainConfigUpdatesV2( - destChainSelectors, - destChainRouters, - destChainRouterStateAddresses, - destChainAllowlistEnabled, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode ApplyDestChainConfigUpdates for OnRamp: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - txs = append(txs, tx) - - b.Logger.Infow("Adding OnRamp destination config update operation", - "chainCount", len(destChainSelectors)) - - return txs, nil -} - -type MigrateOnRampDestChainConfigsToV2Input struct { - DestChainSelectors []uint64 - RouterModuleAddresses []aptos.AccountAddress -} - -var MigrateOnRampDestChainConfigsToV2Op = operations.NewOperation( - "migrate-onramp-dest-chain-configs-to-v2-op", - Version1_0_0, - "Migrates OnRamp destination chain configs from V1 to V2", - migrateOnRampDestChainConfigsToV2, -) - -func migrateOnRampDestChainConfigsToV2(b operations.Bundle, deps dependency.AptosDeps, in MigrateOnRampDestChainConfigsToV2Input) ([]mcmstypes.Transaction, error) { - aptosState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - ccipAddress := aptosState.CCIPAddress - onrampBind := ccip_onramp.Bind(ccipAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := onrampBind.Onramp().Encoder().MigrateDestChainConfigsToV2( - in.DestChainSelectors, - in.RouterModuleAddresses, - ) - if err != nil { - return nil, fmt.Errorf("failed to encode MigrateDestChainConfigsToV2 for OnRamp: %w", err) - } - - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return nil, fmt.Errorf("failed to create transaction: %w", err) - } - - b.Logger.Infow("Adding OnRamp migrate dest chain configs to V2 operation", - "chainCount", len(in.DestChainSelectors)) - - return []mcmstypes.Transaction{tx}, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/registry.go b/deployment/ccip/changeset/aptos/operation/registry.go deleted file mode 100644 index 23964e1866e..00000000000 --- a/deployment/ccip/changeset/aptos/operation/registry.go +++ /dev/null @@ -1,33 +0,0 @@ -package operation - -import ( - cld_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" -) - -func GetAptosOperations() []*cld_ops.Operation[any, any, any] { - // Since go has no Union types we cannot typecheck the output of operations - // but only register operations returning: - // - mcmstypes.Transaction - // - []mcmstypes.Transaction - // - mcmstypes.Operation - // - []mcmstypes.Operation - // - mcmstypes.BatchOperation - // Otherwise dynamic sequence won't know how to handle the output - var operations []*cld_ops.Operation[any, any, any] - - operations = append(operations, CCIPOperations...) - operations = append(operations, FeeQuoterOperations...) - operations = append(operations, MCMSOperations...) - operations = append(operations, OffRampOperations...) - operations = append(operations, OnRampOperations...) - operations = append(operations, RouterOperations...) - operations = append(operations, TokenAdminRegistryOperations...) - operations = append(operations, TokenPoolOperations...) - operations = append(operations, TokenOperations...) - operations = append(operations, aptos.CurseMultipleOp.AsUntypedRelaxed()) - operations = append(operations, aptos.UncurseMultipleOp.AsUntypedRelaxed()) - operations = append(operations, aptos.InitializeAllowedCursersOp.AsUntypedRelaxed()) - - return operations -} diff --git a/deployment/ccip/changeset/aptos/operation/regulated_token.go b/deployment/ccip/changeset/aptos/operation/regulated_token.go deleted file mode 100644 index 1e0469f4250..00000000000 --- a/deployment/ccip/changeset/aptos/operation/regulated_token.go +++ /dev/null @@ -1,349 +0,0 @@ -package operation - -import ( - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token" - module_regulated_token "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token/regulated_token" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" -) - -// regulated_token cannot be deployed via MCMS: MCMS dispatches calls through -// dispatchable_fungible_asset (DFA), and regulated_token::initialize itself calls -// dispatchable_fungible_asset::register_dispatch_functions, which Aptos rejects as -// nested DFA dispatch (re-entrancy). Every operation in this file is therefore -// signed directly by the deployer and confirmed on chain — they do not produce -// MCMS transactions and must not be wrapped in an MCMS proposal. - -// DeployRegulatedTokenObjectOp publishes the regulated_token package to a new code object (one tx). -var DeployRegulatedTokenObjectOp = operations.NewOperation( - "deploy-regulated-token-object-op", - Version1_0_0, - "Deploy regulated_token package to a new object", - deployRegulatedTokenObject, -) - -func deployRegulatedTokenObject( - b operations.Bundle, - deps dependency.AptosDeps, - _ operations.EmptyInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - adminAddress := signer.AccountAddress() - - tokenAddress, tx, _, err := regulated_token.DeployToObject(signer, client, adminAddress) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("DeployToObject: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm DeployToObject: %w", err) - } - return tokenAddress, nil -} - -// DeployRegulatedTokenMCMSRegistrarInput is input for DeployRegulatedTokenMCMSRegistrarOp. -type DeployRegulatedTokenMCMSRegistrarInput struct { - TokenCodeObjectAddress aptos.AccountAddress - MCMSAddress aptos.AccountAddress - RegistrarPreregister bool -} - -// DeployRegulatedTokenMCMSRegistrarOp attaches the MCMS registrar to the token code object (one tx). -var DeployRegulatedTokenMCMSRegistrarOp = operations.NewOperation( - "deploy-regulated-token-mcms-registrar-op", - Version1_0_0, - "Deploy MCMS registrar on existing regulated token code object", - deployRegulatedTokenMCMSRegistrar, -) - -func deployRegulatedTokenMCMSRegistrar( - b operations.Bundle, - deps dependency.AptosDeps, - in DeployRegulatedTokenMCMSRegistrarInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - adminAddress := signer.AccountAddress() - - tx, _, err := regulated_token.DeployMCMSRegistrarToExistingObject( - signer, client, in.TokenCodeObjectAddress, adminAddress, in.MCMSAddress, in.RegistrarPreregister, - ) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("DeployMCMSRegistrarToExistingObject: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm DeployMCMSRegistrarToExistingObject: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// InitializeRegulatedTokenInput is input for InitializeRegulatedTokenOp. -type InitializeRegulatedTokenInput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenParams config.TokenParams -} - -// InitializeRegulatedTokenOp runs regulated_token::initialize (one tx). -var InitializeRegulatedTokenOp = operations.NewOperation( - "initialize-regulated-token-op", - Version1_0_0, - "Initialize regulated token metadata and hooks", - initializeRegulatedToken, -) - -func initializeRegulatedToken( - b operations.Bundle, - deps dependency.AptosDeps, - in InitializeRegulatedTokenInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - var maxSupply **big.Int - if in.TokenParams.MaxSupply != nil { - p := in.TokenParams.MaxSupply - maxSupply = &p - } - tx, err := token.RegulatedToken().Initialize( - opts, - maxSupply, - in.TokenParams.Name, - string(in.TokenParams.Symbol), - in.TokenParams.Decimals, - in.TokenParams.Icon, - in.TokenParams.Project, - ) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("initialize: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm initialize: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// GrantRegulatedTokenMinterRoleInput is input for GrantRegulatedTokenMinterRoleOp. -type GrantRegulatedTokenMinterRoleInput struct { - TokenCodeObjectAddress aptos.AccountAddress - Grantee aptos.AccountAddress -} - -// GrantRegulatedTokenMinterRoleOp grants MINTER_ROLE to one account (one tx). -var GrantRegulatedTokenMinterRoleOp = operations.NewOperation( - "grant-regulated-token-minter-role-op", - Version1_0_0, - "Grant regulated token minter role", - grantRegulatedTokenMinterRole, -) - -func grantRegulatedTokenMinterRole( - b operations.Bundle, - deps dependency.AptosDeps, - in GrantRegulatedTokenMinterRoleInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().GrantRole(opts, module_regulated_token.MINTER_ROLE, in.Grantee) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("GrantRole minter: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm GrantRole: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// RevokeRegulatedTokenMinterRoleInput is input for RevokeRegulatedTokenMinterRoleOp. -type RevokeRegulatedTokenMinterRoleInput struct { - TokenCodeObjectAddress aptos.AccountAddress - Account aptos.AccountAddress -} - -// RevokeRegulatedTokenMinterRoleOp revokes MINTER_ROLE from one account (one tx). -var RevokeRegulatedTokenMinterRoleOp = operations.NewOperation( - "revoke-regulated-token-minter-role-op", - Version1_0_0, - "Revoke regulated token minter role from an account", - revokeRegulatedTokenMinterRole, -) - -func revokeRegulatedTokenMinterRole( - b operations.Bundle, - deps dependency.AptosDeps, - in RevokeRegulatedTokenMinterRoleInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().RevokeRole(opts, module_regulated_token.MINTER_ROLE, in.Account) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("revoke role minter: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm revoke role: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// MintRegulatedTokenInput is input for MintRegulatedTokenOp. -type MintRegulatedTokenInput struct { - TokenCodeObjectAddress aptos.AccountAddress - To aptos.AccountAddress - Amount uint64 -} - -// MintRegulatedTokenOp mints to an address (one tx). -var MintRegulatedTokenOp = operations.NewOperation( - "mint-regulated-token-op", - Version1_0_0, - "Mint regulated token to an account", - mintRegulatedToken, -) - -func mintRegulatedToken( - b operations.Bundle, - deps dependency.AptosDeps, - in MintRegulatedTokenInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().Mint(opts, in.To, in.Amount) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("mint: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm mint: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// TransferRegulatedTokenOwnershipInput is input for TransferRegulatedTokenOwnershipOp. -type TransferRegulatedTokenOwnershipInput struct { - TokenCodeObjectAddress aptos.AccountAddress - To aptos.AccountAddress -} - -// TransferRegulatedTokenOwnershipOp starts ownership transfer to the given address (one tx). -var TransferRegulatedTokenOwnershipOp = operations.NewOperation( - "transfer-regulated-token-ownership-op", - Version1_0_0, - "Transfer regulated token ownership to the given address", - transferRegulatedTokenOwnership, -) - -func transferRegulatedTokenOwnership( - b operations.Bundle, - deps dependency.AptosDeps, - in TransferRegulatedTokenOwnershipInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().TransferOwnership(opts, in.To) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("TransferOwnership: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm TransferOwnership: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// ExecuteRegulatedTokenOwnershipTransferInput is input for ExecuteRegulatedTokenOwnershipTransferOp. -type ExecuteRegulatedTokenOwnershipTransferInput struct { - TokenCodeObjectAddress aptos.AccountAddress - To aptos.AccountAddress -} - -// ExecuteRegulatedTokenOwnershipTransferOp finalizes the 3-step ownable handoff by calling -// regulated_token::execute_ownership_transfer with the original deployer (one tx). It must -// be called after the new owner has accepted ownership. -var ExecuteRegulatedTokenOwnershipTransferOp = operations.NewOperation( - "execute-regulated-token-ownership-transfer-op", - Version1_0_0, - "Execute regulated token ownership transfer (finalize 3-step handoff)", - executeRegulatedTokenOwnershipTransfer, -) - -func executeRegulatedTokenOwnershipTransfer( - b operations.Bundle, - deps dependency.AptosDeps, - in ExecuteRegulatedTokenOwnershipTransferInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().ExecuteOwnershipTransfer(opts, in.To) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("execute ownership transfer: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm execute ownership transfer: %w", err) - } - return in.TokenCodeObjectAddress, nil -} - -// TransferRegulatedTokenAdminInput is input for TransferRegulatedTokenAdminOp. -type TransferRegulatedTokenAdminInput struct { - TokenCodeObjectAddress aptos.AccountAddress - NewAdmin aptos.AccountAddress -} - -// TransferRegulatedTokenAdminOp proposes admin role transfer to the given address (one tx). -var TransferRegulatedTokenAdminOp = operations.NewOperation( - "transfer-regulated-token-admin-op", - Version1_0_0, - "Transfer regulated token admin role to the given address", - transferRegulatedTokenAdmin, -) - -func transferRegulatedTokenAdmin( - b operations.Bundle, - deps dependency.AptosDeps, - in TransferRegulatedTokenAdminInput, -) (aptos.AccountAddress, error) { - _ = b - signer := deps.AptosChain.DeployerSigner - client := deps.AptosChain.Client - opts := &bind.TransactOpts{Signer: signer} - token := regulated_token.Bind(in.TokenCodeObjectAddress, client) - - tx, err := token.RegulatedToken().TransferAdmin(opts, in.NewAdmin) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("TransferAdmin: %w", err) - } - if err := deps.AptosChain.Confirm(tx.Hash); err != nil { - return aptos.AccountAddress{}, fmt.Errorf("confirm TransferAdmin: %w", err) - } - return in.TokenCodeObjectAddress, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/router.go b/deployment/ccip/changeset/aptos/operation/router.go deleted file mode 100644 index f79aaae71da..00000000000 --- a/deployment/ccip/changeset/aptos/operation/router.go +++ /dev/null @@ -1,56 +0,0 @@ -package operation - -import ( - "fmt" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - aptos_router "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router/router" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var RouterOperations = []*operations.Operation[any, any, any]{ - UpdateRouterOp.AsUntypedRelaxed(), -} - -// UpdateRouterDestInput contains configuration for updating FeeQuoter destination configs -type UpdateRouterDestInput struct { - Updates []aptos_router.OnRampSet -} - -// UpdateRouterOp... -var UpdateRouterOp = operations.NewOperation( - "update-router-op", - Version1_0_0, - "Updates Router destination chain configurations", - updateRouter, -) - -func updateRouter(b operations.Bundle, deps dependency.AptosDeps, in UpdateRouterDestInput) (mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - routerBind := ccip_router.Bind(ccipAddress, deps.AptosChain.Client) - - // Process each destination chain config update - var destChainSelectors []uint64 - var onRampVersions [][]byte - for _, update := range in.Updates { - destChainSelectors = append(destChainSelectors, update.DestChainSelector) - onRampVersions = append(onRampVersions, update.OnRampVersion) - } - moduleInfo, function, _, args, err := routerBind.Router().Encoder().SetOnRampVersions(destChainSelectors, onRampVersions) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode ApplyDestChainConfigUpdates for chains %d: %w", deps.AptosChain.Selector, err) - } - - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - b.Logger.Infow("Adding Router destination config update operation") - - return tx, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/token.go b/deployment/ccip/changeset/aptos/operation/token.go deleted file mode 100644 index 78a8d502912..00000000000 --- a/deployment/ccip/changeset/aptos/operation/token.go +++ /dev/null @@ -1,458 +0,0 @@ -package operation - -import ( - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/managed_token" - "github.com/smartcontractkit/chainlink-aptos/bindings/managed_token_faucet" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token" - "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -const managedTokenStateSeed = "managed_token::managed_token::token_state" - -// TokenOperations contains the token operations whose output is consumed by MCMS proposals. -var TokenOperations = []*operations.Operation[any, any, any]{ - DeployTokenMCMSRegistrarOp.AsUntypedRelaxed(), - InitializeTokenOp.AsUntypedRelaxed(), - MintTokensOp.AsUntypedRelaxed(), - ApplyAllowedMintersOp.AsUntypedRelaxed(), - ApplyAllowedBurnersOp.AsUntypedRelaxed(), - DeployTokenFaucetOp.AsUntypedRelaxed(), - GrantRoleOp.AsUntypedRelaxed(), - TransferTokenOwnershipOp.AsUntypedRelaxed(), - AcceptTokenOwnershipOp.AsUntypedRelaxed(), - ExecuteTokenOwnershipTransferOp.AsUntypedRelaxed(), - TransferTokenAdminOp.AsUntypedRelaxed(), - AcceptTokenAdminOp.AsUntypedRelaxed(), -} - -type DeployTokenInput struct { - Name string - Symbol string - MCMSAddress aptos.AccountAddress -} - -type DeployTokenOutput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenAddress aptos.AccountAddress - TokenOwnerAddress aptos.AccountAddress - MCMSOps []types.Operation -} - -// DeployTokenOp generates proposal to deploy a token -var DeployTokenOp = operations.NewOperation( - "deploy-token-op", - Version1_0_0, - "Deploy a managed token instance", - deployToken, -) - -func deployToken(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenInput) (DeployTokenOutput, error) { - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - - // Calculate token address - managedTokenSeed := fmt.Sprintf("%s::%s", in.Name, in.Symbol) // Use name and symbol as seed for uniqueness - managedTokenObjectAddress, err := mcmsContract.MCMSRegistry().GetNewCodeObjectAddress(nil, []byte(managedTokenSeed)) - if err != nil { - return DeployTokenOutput{}, fmt.Errorf("failed to GetNewCodeObjectAddress: %w", err) - } - managedTokenOwnerAddress, err := mcmsContract.MCMSRegistry().GetNewCodeObjectOwnerAddress(nil, []byte(managedTokenSeed)) - if err != nil { - return DeployTokenOutput{}, fmt.Errorf("failed to GetNewCodeObjectOwnerAddress: %w", err) - } - - // Calculate token Metadata Address - managedTokenStateAddress := managedTokenObjectAddress.NamedObjectAddress([]byte(managedTokenStateSeed)) - managedTokenMetadataAddress := managedTokenStateAddress.NamedObjectAddress([]byte(in.Symbol)) - - // Compile and create deploy operation for the token - managedTokenPayload, err := managed_token.Compile(managedTokenObjectAddress) - if err != nil { - return DeployTokenOutput{}, fmt.Errorf("failed to compile managed_token package: %w", err) - } - ops, err := utils.CreateChunksAndStage(managedTokenPayload, mcmsContract, deps.AptosChain.Selector, managedTokenSeed, nil) - if err != nil { - return DeployTokenOutput{}, fmt.Errorf("failed to create chunks for manage_token deployment: %w", err) - } - - return DeployTokenOutput{ - TokenCodeObjectAddress: managedTokenObjectAddress, - TokenAddress: managedTokenMetadataAddress, - TokenOwnerAddress: managedTokenOwnerAddress, - MCMSOps: ops, - }, nil -} - -type DeployTokenRegistrarInput struct { - TokenCodeObjectAddress aptos.AccountAddress - MCMSAddress aptos.AccountAddress -} - -// DeployTokenMCMSRegistrarOp generates proposal to deploy a MCMS registrar on a token package -var DeployTokenMCMSRegistrarOp = operations.NewOperation( - "deploy-token-mcms-registrar-op", - Version1_0_0, - "Deploy token MCMS registrar onto managed token code object", - deployTokenMCMSRegistrar, -) - -func deployTokenMCMSRegistrar(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenRegistrarInput) ([]types.Operation, error) { - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - - // Deploy MCMS Registrar - mcmsRegistrarPayload, err := managed_token.CompileMCMSRegistrar(in.TokenCodeObjectAddress, in.MCMSAddress, true) - if err != nil { - return nil, fmt.Errorf("failed to compile MCMS registrar: %w", err) - } - ops, err := utils.CreateChunksAndStage(mcmsRegistrarPayload, mcmsContract, deps.AptosChain.Selector, "", &in.TokenCodeObjectAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks for token pool: %w", err) - } - - return ops, nil -} - -type InitializeTokenInput struct { - TokenCodeObjectAddress aptos.AccountAddress - MaxSupply *big.Int - Name string - Symbol string - Decimals byte - Icon string - Project string -} - -// DeployTokenMCMSRegistrarOp generates proposal to deploy a MCMS registrar on a token package -var InitializeTokenOp = operations.NewOperation( - "initialize-token-op", - Version1_0_0, - "initialize token", - initializeToken, -) - -func initializeToken(b operations.Bundle, deps dependency.AptosDeps, in InitializeTokenInput) (types.Transaction, error) { - // Initialize managed token - var maxSupply **big.Int - if in.MaxSupply != nil { - maxSupply = &in.MaxSupply - } - boundManagedToken := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := boundManagedToken.ManagedToken().Encoder().Initialize( - maxSupply, - in.Name, - in.Symbol, - in.Decimals, - in.Icon, - in.Project, - ) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode initialize function: %w", err) - } - - // Create MCMS tx - tx, err := utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - return tx, nil -} - -type MintTokensInput struct { - TokenCodeObjectAddress aptos.AccountAddress - To aptos.AccountAddress - Amount uint64 -} - -var MintTokensOp = operations.NewOperation( - "mint-tokens-op", - Version1_0_0, - "Mints tokens to a target account", - mintTokens, -) - -func mintTokens(b operations.Bundle, deps dependency.AptosDeps, in MintTokensInput) (types.Transaction, error) { - boundManagedToken := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := boundManagedToken.ManagedToken().Encoder().Mint(in.To, in.Amount) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode mint function: %w", err) - } - - // Create MCMS tx - tx, err := utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - - return tx, nil -} - -type ApplyAllowedMintersInput struct { - // Must be of type managed_token - TokenCodeObjectAddress aptos.AccountAddress - MintersToAdd []aptos.AccountAddress - MintersToRemove []aptos.AccountAddress -} - -// GrantMinterPermissionsOp operation to grant minter permissions -var ApplyAllowedMintersOp = operations.NewOperation( - "apply-allowed-minters-op", - Version1_0_0, - "Applies the given minters remove/add to the managed token", - applyAllowedMinters, -) - -func applyAllowedMinters(b operations.Bundle, deps dependency.AptosDeps, in ApplyAllowedMintersInput) (types.Transaction, error) { - tokenContract := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := tokenContract.ManagedToken().Encoder().ApplyAllowedMinterUpdates(in.MintersToRemove, in.MintersToAdd) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode ApplyAllowedMinterUpdates: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type ApplyAllowedBurnersInput struct { - // Must be of type managed_token - TokenCodeObjectAddress aptos.AccountAddress - BurnersToAdd []aptos.AccountAddress - BurnersToRemove []aptos.AccountAddress -} - -// GrantBurnerPermissionsOp operation to grant burner permissions -var ApplyAllowedBurnersOp = operations.NewOperation( - "apply-allowed-burners-op", - Version1_0_0, - "Applies the given burners remove/add to the managed token", - applyAllowedBurners, -) - -func applyAllowedBurners(b operations.Bundle, deps dependency.AptosDeps, in ApplyAllowedBurnersInput) (types.Transaction, error) { - tokenContract := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := tokenContract.ManagedToken().Encoder().ApplyAllowedBurnerUpdates(in.BurnersToRemove, in.BurnersToAdd) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode ApplyAllowedBurnerUpdates: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type DeployTokenFaucetInput struct { - MCMSAddress aptos.AccountAddress - TokenCodeObjectAddress aptos.AccountAddress -} - -var DeployTokenFaucetOp = operations.NewOperation( - "deploy-token-faucet-op", - Version1_0_0, - "Deploy the faucet package onto a managed token code object", - deployTokenFaucet, -) - -func deployTokenFaucet(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenFaucetInput) ([]types.Operation, error) { - boundMcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - - managedTokenFaucetPayload, err := managed_token_faucet.Compile(in.TokenCodeObjectAddress) - if err != nil { - return nil, fmt.Errorf("failed to compile managed_token_faucet package: %w", err) - } - ops, err := utils.CreateChunksAndStage(managedTokenFaucetPayload, boundMcmsContract, deps.AptosChain.Selector, "", &in.TokenCodeObjectAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks for managed_token_faucet deployment: %w", err) - } - - return ops, nil -} - -type GrantRoleInput struct { - // Must be of type regulated_token - TokenCodeObjectAddress aptos.AccountAddress - RoleNumber uint8 - Account aptos.AccountAddress -} - -// For regulated tokens -var GrantRoleOp = operations.NewOperation( - "grant-role-op", - Version1_0_0, - "Grants the given role to the given account on the regulated token", - grantRole, -) - -func grantRole(b operations.Bundle, deps dependency.AptosDeps, in GrantRoleInput) (types.Transaction, error) { - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := tokenContract.RegulatedToken().Encoder().GrantRole(in.RoleNumber, in.Account) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode GrantRole: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type TransferTokenOwnershipInput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenType deployment.ContractType - To aptos.AccountAddress -} - -var TransferTokenOwnershipOp = operations.NewOperation( - "transfer-token-ownership-op", - Version1_0_0, - "Initiates the ownership transfer of a managed/regulated token to a given address", - transferTokenOwnership, -) - -func transferTokenOwnership(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenOwnershipInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenType { - case shared.AptosManagedTokenType: - tokenContract := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenContract.ManagedToken().Encoder().TransferOwnership(in.To) - case shared.AptosRegulatedTokenType: - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenContract.RegulatedToken().Encoder().TransferOwnership(in.To) - default: - return types.Transaction{}, fmt.Errorf("unsupported token type for TransferTokenOwnershipOp: %s", in.TokenType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode TransferOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type AcceptTokenOwnershipInput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenType deployment.ContractType -} - -var AcceptTokenOwnershipOp = operations.NewOperation( - "accept-token-ownership-op", - Version1_0_0, - "Accepts ownership of a managed/regulated token", - acceptTokenOwnership, -) - -func acceptTokenOwnership(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenOwnershipInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenType { - case shared.AptosManagedTokenType: - tokenContract := managed_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenContract.ManagedToken().Encoder().AcceptOwnership() - case shared.AptosRegulatedTokenType: - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenContract.RegulatedToken().Encoder().AcceptOwnership() - default: - return types.Transaction{}, fmt.Errorf("unsupported token type for AcceptTokenOwnershipOp: %s", in.TokenType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode AcceptOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type ExecuteTokenOwnershipTransferInput struct { - TokenCodeObjectAddress aptos.AccountAddress - To aptos.AccountAddress - TokenType deployment.ContractType -} - -var ExecuteTokenOwnershipTransferOp = operations.NewOperation( - "execute-token-ownership-transfer-op", - Version1_0_0, - "Executes the ownership transfer of a managed/regulated token, after ownership has been accepted by the receiver", - executeTokenOwnershipTransfer, -) - -func executeTokenOwnershipTransfer(b operations.Bundle, deps dependency.AptosDeps, in ExecuteTokenOwnershipTransferInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenType { - case shared.AptosManagedTokenType: - tokenContract := managed_token.Bind(in.TokenCodeObjectAddress, nil) - moduleInfo, function, _, args, err = tokenContract.ManagedToken().Encoder().ExecuteOwnershipTransfer(in.To) - case shared.AptosRegulatedTokenType: - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, nil) - moduleInfo, function, _, args, err = tokenContract.RegulatedToken().Encoder().ExecuteOwnershipTransfer(in.To) - default: - return types.Transaction{}, fmt.Errorf("unsupported token type for ExecuteTokenOwnershipTransferOp: %s", in.TokenType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode AcceptOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type TransferTokenAdminInput struct { - // Must be of type regulated_token - TokenCodeObjectAddress aptos.AccountAddress - NewAdmin aptos.AccountAddress -} - -var TransferTokenAdminOp = operations.NewOperation( - "transfer-token-admin-op", - Version1_0_0, - "Transfers the admin of a regulated token to a new account", - transferAdmin, -) - -func transferAdmin(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenAdminInput) (types.Transaction, error) { - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := tokenContract.RegulatedToken().Encoder().TransferAdmin(in.NewAdmin) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode TransferAdmin: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} - -type AcceptTokenAdminInput struct { - // Must be of type regulated_token - TokenCodeObjectAddress aptos.AccountAddress -} - -var AcceptTokenAdminOp = operations.NewOperation( - "accept-token-admin-op", - Version1_0_0, - "Accepts the admin role of a regulated token", - acceptTokenAdmin, -) - -func acceptTokenAdmin(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenAdminInput) (types.Transaction, error) { - tokenContract := regulated_token.Bind(in.TokenCodeObjectAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err := tokenContract.RegulatedToken().Encoder().AcceptAdmin() - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode AcceptAdmin: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenCodeObjectAddress, moduleInfo, function, args) -} diff --git a/deployment/ccip/changeset/aptos/operation/token_admin_registry.go b/deployment/ccip/changeset/aptos/operation/token_admin_registry.go deleted file mode 100644 index d120a44e4f8..00000000000 --- a/deployment/ccip/changeset/aptos/operation/token_admin_registry.go +++ /dev/null @@ -1,101 +0,0 @@ -package operation - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var TokenAdminRegistryOperations = []*operations.Operation[any, any, any]{ - ProposeAdministratorOp.AsUntypedRelaxed(), - AcceptAdminRoleOp.AsUntypedRelaxed(), - SetPoolOp.AsUntypedRelaxed(), -} - -type ProposeAdministratorInput struct { - TokenAddress aptos.AccountAddress - TokenAdministrator aptos.AccountAddress -} - -var ProposeAdministratorOp = operations.NewOperation( - "propose-administrator-op", - Version1_0_0, - "Proposes a new administrator for a given token", - proposeAdministrator, -) - -func proposeAdministrator(b operations.Bundle, deps dependency.AptosDeps, in ProposeAdministratorInput) (types.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := ccipBind.TokenAdminRegistry().Encoder().ProposeAdministrator(in.TokenAddress, in.TokenAdministrator) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode ProposeAdministrator: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - - return tx, nil -} - -var AcceptAdminRoleOp = operations.NewOperation( - "accept-admin-role-op", - Version1_0_0, - "Accepts a new administrator for a given token", - acceptAdminRole, -) - -func acceptAdminRole(b operations.Bundle, deps dependency.AptosDeps, tokenAddress aptos.AccountAddress) (types.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := ccipBind.TokenAdminRegistry().Encoder().AcceptAdminRole(tokenAddress) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode AcceptAdminRole: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - - return tx, nil -} - -type SetPoolInput struct { - TokenAddress aptos.AccountAddress - TokenPoolAddress aptos.AccountAddress -} - -var SetPoolOp = operations.NewOperation( - "set-pool-op", - Version1_0_0, - "Sets the pool for a given token", - setPool, -) - -func setPool(b operations.Bundle, deps dependency.AptosDeps, in SetPoolInput) (types.Transaction, error) { - // Bind CCIP Package - ccipAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress - ccipBind := ccip.Bind(ccipAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := ccipBind.TokenAdminRegistry().Encoder().SetPool(in.TokenAddress, in.TokenPoolAddress) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode SetPool: %w", err) - } - tx, err := utils.GenerateMCMSTx(ccipAddress, moduleInfo, function, args) - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to create transaction: %w", err) - } - - return tx, nil -} diff --git a/deployment/ccip/changeset/aptos/operation/token_pool.go b/deployment/ccip/changeset/aptos/operation/token_pool.go deleted file mode 100644 index e4b0c6b6824..00000000000 --- a/deployment/ccip/changeset/aptos/operation/token_pool.go +++ /dev/null @@ -1,498 +0,0 @@ -package operation - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/burn_mint_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/lock_release_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/managed_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/regulated_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/compile" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -var TokenPoolOperations = []*operations.Operation[any, any, any]{ - DeployTokenPoolModuleOp.AsUntypedRelaxed(), - ApplyChainUpdatesOp.AsUntypedRelaxed(), - SetChainRateLimiterConfigsOp.AsUntypedRelaxed(), - AddRemotePoolsOp.AsUntypedRelaxed(), - TransferTokenPoolOwnershipOp.AsUntypedRelaxed(), - AcceptTokenPoolOwnershipOp.AsUntypedRelaxed(), - ExecuteTokenPoolOwnershipTransferOp.AsUntypedRelaxed(), -} - -type DeployTokenPoolPackageOutput struct { - TokenPoolObjectAddress aptos.AccountAddress - MCMSOps []types.Operation -} - -// DeployTokenPoolPackageOp deploys token pool package to Token Object Address -var DeployTokenPoolPackageOp = operations.NewOperation( - "deploy-token-pool-package-op", - Version1_0_0, - "Deploy Aptos token pool package", - deployTokenPoolPackage, -) - -func deployTokenPoolPackage(b operations.Bundle, deps dependency.AptosDeps, poolSeed string) (DeployTokenPoolPackageOutput, error) { - aptosState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - mcmsContract := mcmsbind.Bind(aptosState.MCMSAddress, deps.AptosChain.Client) - - // Calculate pool address - tokenPoolObjectAddress, err := mcmsContract.MCMSRegistry().GetNewCodeObjectAddress(nil, []byte(poolSeed)) - if err != nil { - return DeployTokenPoolPackageOutput{}, fmt.Errorf("failed to GetNewCodeObjectAddress for pool seed %s: %w", poolSeed, err) - } - - payload, err := token_pool.Compile(tokenPoolObjectAddress, aptosState.CCIPAddress, aptosState.MCMSAddress) - if err != nil { - return DeployTokenPoolPackageOutput{}, fmt.Errorf("failed to compile token pool: %w", err) - } - ops, err := utils.CreateChunksAndStage(payload, mcmsContract, deps.AptosChain.Selector, poolSeed, nil) - if err != nil { - return DeployTokenPoolPackageOutput{}, fmt.Errorf("failed to create chunks for token pool: %w", err) - } - - return DeployTokenPoolPackageOutput{ - TokenPoolObjectAddress: tokenPoolObjectAddress, - MCMSOps: ops, - }, nil -} - -type DeployTokenPoolModuleInput struct { - PoolType cldf.ContractType - TokenCodeObjAddress aptos.AccountAddress - TokenAddress aptos.AccountAddress - TokenPoolObjAddress aptos.AccountAddress -} - -// DeployTokenPoolModuleOp deploys token pool module to Token Object Address -var DeployTokenPoolModuleOp = operations.NewOperation( - "deploy-token-pool-module-op", - Version1_0_0, - "Deploy Aptos token pool module", - deployTokenPoolModule, -) - -func deployTokenPoolModule(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenPoolModuleInput) ([]types.Operation, error) { - aptosState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - mcmsContract := mcmsbind.Bind(aptosState.MCMSAddress, deps.AptosChain.Client) - - var ops []types.Operation - - var ( - payload compile.CompiledPackage - err error - ) - switch in.PoolType { - case shared.AptosManagedTokenPoolType: - payload, err = managed_token_pool.Compile( - in.TokenPoolObjAddress, - aptosState.CCIPAddress, - aptosState.MCMSAddress, - in.TokenPoolObjAddress, - in.TokenCodeObjAddress, - true, - ) - case shared.BurnMintTokenPool: - payload, err = burn_mint_token_pool.Compile( - in.TokenPoolObjAddress, - aptosState.CCIPAddress, - aptosState.MCMSAddress, - in.TokenPoolObjAddress, - in.TokenAddress, - true, - ) - case shared.LockReleaseTokenPool: - payload, err = lock_release_token_pool.Compile( - in.TokenPoolObjAddress, - aptosState.CCIPAddress, - aptosState.MCMSAddress, - in.TokenPoolObjAddress, - in.TokenAddress, - true, - ) - case shared.AptosRegulatedTokenPoolType: - payload, err = regulated_token_pool.Compile( - in.TokenPoolObjAddress, - aptosState.CCIPAddress, - aptosState.MCMSAddress, - in.TokenPoolObjAddress, - in.TokenCodeObjAddress, - deps.AptosChain.DeployerSigner.AccountAddress(), // Unused parameter, since the admin is set on the token not the pool - true, - ) - default: - return nil, fmt.Errorf("unsupported token pool type for DeployTokenPoolModuleOp: %s", in.PoolType.String()) - } - if err != nil { - return nil, fmt.Errorf("failed to compile token pool: %w", err) - } - ops, err = utils.CreateChunksAndStage(payload, mcmsContract, deps.AptosChain.Selector, "", &in.TokenPoolObjAddress) - if err != nil { - return nil, fmt.Errorf("failed to create chunks for token pool: %w", err) - } - - return ops, nil -} - -type ApplyChainUpdatesInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType - RemoteChainSelectorsToRemove []uint64 - RemoteChainSelectorsToAdd []uint64 - RemotePoolAddresses [][][]byte - RemoteTokenAddresses [][]byte -} - -// ApplyChainUpdatesOp ... -var ApplyChainUpdatesOp = operations.NewOperation( - "apply-chain-updates-op", - Version1_0_0, - "Apply chain updates to an Aptos token pool", - applyChainUpdates, -) - -func applyChainUpdates(b operations.Bundle, deps dependency.AptosDeps, in ApplyChainUpdatesInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - poolBind := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.ManagedTokenPool().Encoder().ApplyChainUpdates( - in.RemoteChainSelectorsToRemove, - in.RemoteChainSelectorsToAdd, - in.RemotePoolAddresses, - in.RemoteTokenAddresses, - ) - case shared.AptosRegulatedTokenPoolType: - poolBind := regulated_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.RegulatedTokenPool().Encoder().ApplyChainUpdates( - in.RemoteChainSelectorsToRemove, - in.RemoteChainSelectorsToAdd, - in.RemotePoolAddresses, - in.RemoteTokenAddresses, - ) - case shared.BurnMintTokenPool: - poolBind := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.BurnMintTokenPool().Encoder().ApplyChainUpdates( - in.RemoteChainSelectorsToRemove, - in.RemoteChainSelectorsToAdd, - in.RemotePoolAddresses, - in.RemoteTokenAddresses, - ) - case shared.LockReleaseTokenPool: - poolBind := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.LockReleaseTokenPool().Encoder().ApplyChainUpdates( - in.RemoteChainSelectorsToRemove, - in.RemoteChainSelectorsToAdd, - in.RemotePoolAddresses, - in.RemoteTokenAddresses, - ) - default: - return types.Transaction{}, fmt.Errorf("unsupported token pool type for ApplyChainUpdatesOp: %v", in.TokenPoolType.String()) - } - - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode ApplyChainUpdates for chains: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) -} - -type SetChainRLConfigsInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType - RemoteChainSelectors []uint64 - OutboundIsEnableds []bool - OutboundCapacities []uint64 - OutboundRates []uint64 - InboundIsEnableds []bool - InboundCapacities []uint64 - InboundRates []uint64 -} - -var SetChainRateLimiterConfigsOp = operations.NewOperation( - "set-chain-rate-limiter-configs-op", - Version1_0_0, - "Set chain rate limiter configs for an Aptos token pool", - setChainRateLimiterConfigs, -) - -func setChainRateLimiterConfigs(b operations.Bundle, deps dependency.AptosDeps, in SetChainRLConfigsInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - poolBind := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.ManagedTokenPool().Encoder().SetChainRateLimiterConfigs( - in.RemoteChainSelectors, - in.OutboundIsEnableds, - in.OutboundCapacities, - in.OutboundRates, - in.InboundIsEnableds, - in.InboundCapacities, - in.InboundRates, - ) - case shared.AptosRegulatedTokenPoolType: - poolBind := regulated_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.RegulatedTokenPool().Encoder().SetChainRateLimiterConfigs( - in.RemoteChainSelectors, - in.OutboundIsEnableds, - in.OutboundCapacities, - in.OutboundRates, - in.InboundIsEnableds, - in.InboundCapacities, - in.InboundRates, - ) - case shared.BurnMintTokenPool: - poolBind := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.BurnMintTokenPool().Encoder().SetChainRateLimiterConfigs( - in.RemoteChainSelectors, - in.OutboundIsEnableds, - in.OutboundCapacities, - in.OutboundRates, - in.InboundIsEnableds, - in.InboundCapacities, - in.InboundRates, - ) - case shared.LockReleaseTokenPool: - poolBind := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = poolBind.LockReleaseTokenPool().Encoder().SetChainRateLimiterConfigs( - in.RemoteChainSelectors, - in.OutboundIsEnableds, - in.OutboundCapacities, - in.OutboundRates, - in.InboundIsEnableds, - in.InboundCapacities, - in.InboundRates, - ) - default: - return types.Transaction{}, fmt.Errorf("unsupported token pool type for SetChainRateLimiterConfigsOp: %v", in.TokenPoolType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode SetChainRateLimiterConfigs for chains: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) -} - -type AddRemotePoolsInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType - RemoteChainSelectors []uint64 - RemotePoolAddresses [][]byte -} - -var AddRemotePoolsOp = operations.NewOperation( - "add-remote-pools-op", - Version1_0_0, - "Adds new remote pools to an Aptos token pool", - addRemotePools, -) - -func addRemotePools(b operations.Bundle, deps dependency.AptosDeps, in AddRemotePoolsInput) ([]types.Transaction, error) { - txs := make([]types.Transaction, len(in.RemoteChainSelectors)) - - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - poolBind := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - for i, selector := range in.RemoteChainSelectors { - moduleInfo, function, _, args, err := poolBind.ManagedTokenPool().Encoder().AddRemotePool(selector, in.RemotePoolAddresses[i]) - if err != nil { - return nil, fmt.Errorf("failed to encode AddRemotePools for remote selector %d: %w", selector, err) - } - tx, err := utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) - if err != nil { - return nil, err - } - txs[i] = tx - } - case shared.AptosRegulatedTokenPoolType: - poolBind := regulated_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - for i, selector := range in.RemoteChainSelectors { - moduleInfo, function, _, args, err := poolBind.RegulatedTokenPool().Encoder().AddRemotePool(selector, in.RemotePoolAddresses[i]) - if err != nil { - return nil, fmt.Errorf("failed to encode AddRemotePools for remote selector %d: %w", selector, err) - } - tx, err := utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) - if err != nil { - return nil, err - } - txs[i] = tx - } - case shared.BurnFromMintTokenPool: - poolBind := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - for i, selector := range in.RemoteChainSelectors { - moduleInfo, function, _, args, err := poolBind.BurnMintTokenPool().Encoder().AddRemotePool(selector, in.RemotePoolAddresses[i]) - if err != nil { - return nil, fmt.Errorf("failed to encode AddRemotePools for remote selector %d: %w", selector, err) - } - tx, err := utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) - if err != nil { - return nil, err - } - txs[i] = tx - } - case shared.LockReleaseTokenPool: - poolBind := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - for i, selector := range in.RemoteChainSelectors { - moduleInfo, function, _, args, err := poolBind.LockReleaseTokenPool().Encoder().AddRemotePool(selector, in.RemotePoolAddresses[i]) - if err != nil { - return nil, fmt.Errorf("failed to encode AddRemotePools for remote selector %d: %w", selector, err) - } - tx, err := utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) - if err != nil { - return nil, err - } - txs[i] = tx - } - default: - return nil, fmt.Errorf("unsupported token pool type for AddRemotePoolsOp: %v", in.TokenPoolType.String()) - } - - return txs, nil -} - -// ######################## -// # Token Pool Ownership # -// ######################## - -type TransferTokenPoolOwnershipInput struct { - TokenPoolAddress aptos.AccountAddress - To aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -var TransferTokenPoolOwnershipOp = operations.NewOperation( - "transfer-token-pool-ownerhip-op", - Version1_0_0, - "Initiated the ownership transfer of a managed/BnM/LnR token pool to a given address", - transferTokenPoolOwnership, -) - -func transferTokenPoolOwnership(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenPoolOwnershipInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - tokenPoolContract := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.ManagedTokenPool().Encoder().TransferOwnership(in.To) - case shared.BurnMintTokenPool: - tokenPoolContract := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.BurnMintTokenPool().Encoder().TransferOwnership(in.To) - case shared.LockReleaseTokenPool: - tokenPoolContract := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.LockReleaseTokenPool().Encoder().TransferOwnership(in.To) - default: - return types.Transaction{}, fmt.Errorf("unsupported token pool type for TransferTokenPoolOwnershipOp: %s", in.TokenPoolType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode TransferOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) -} - -type AcceptTokenPoolOwnershipInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -var AcceptTokenPoolOwnershipOp = operations.NewOperation( - "accept-token-pool-ownership-op", - Version1_0_0, - "Accepts ownership of a managed/BnM/LnR token pool", - acceptTokenPoolOwnership, -) - -func acceptTokenPoolOwnership(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenPoolOwnershipInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - tokenPoolContract := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.ManagedTokenPool().Encoder().AcceptOwnership() - case shared.BurnMintTokenPool: - tokenPoolContract := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.BurnMintTokenPool().Encoder().AcceptOwnership() - case shared.LockReleaseTokenPool: - tokenPoolContract := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.LockReleaseTokenPool().Encoder().AcceptOwnership() - default: - return types.Transaction{}, fmt.Errorf("unsupported token pool type for AcceptTokenPoolOwnershipOp: %s", in.TokenPoolType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode AcceptOwnership: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) -} - -type ExecuteTokenPoolOwnershipTransferInput struct { - TokenPoolAddress aptos.AccountAddress - To aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -var ExecuteTokenPoolOwnershipTransferOp = operations.NewOperation( - "execute-token-pool-ownership-transfer-op", - Version1_0_0, - "Executes the ownership transfer of a managed/BnM/LnR token pool", - executeTokenPoolOwnershipTransfer, -) - -func executeTokenPoolOwnershipTransfer(b operations.Bundle, deps dependency.AptosDeps, in ExecuteTokenPoolOwnershipTransferInput) (types.Transaction, error) { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - tokenPoolContract := managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.ManagedTokenPool().Encoder().ExecuteOwnershipTransfer(in.To) - case shared.BurnMintTokenPool: - tokenPoolContract := burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.BurnMintTokenPool().Encoder().ExecuteOwnershipTransfer(in.To) - case shared.LockReleaseTokenPool: - tokenPoolContract := lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client) - moduleInfo, function, _, args, err = tokenPoolContract.LockReleaseTokenPool().Encoder().ExecuteOwnershipTransfer(in.To) - default: - return types.Transaction{}, fmt.Errorf("unsupported token pool type for ExecuteTokenPoolOwnershipTransferInput: %s", in.TokenPoolType.String()) - } - if err != nil { - return types.Transaction{}, fmt.Errorf("failed to encode ExecuteOwnershipTransfer: %w", err) - } - - return utils.GenerateMCMSTx(in.TokenPoolAddress, moduleInfo, function, args) -} diff --git a/deployment/ccip/changeset/aptos/operation/version.go b/deployment/ccip/changeset/aptos/operation/version.go deleted file mode 100644 index aa2f2248147..00000000000 --- a/deployment/ccip/changeset/aptos/operation/version.go +++ /dev/null @@ -1,6 +0,0 @@ -package operation - -import "github.com/Masterminds/semver/v3" - -// Holds versions for Aptos changeset/operations -var Version1_0_0 = semver.MustParse("1.0.0") diff --git a/deployment/ccip/changeset/aptos/sequence/deploy_ccip.go b/deployment/ccip/changeset/aptos/sequence/deploy_ccip.go deleted file mode 100644 index cf2f9fee867..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/deploy_ccip.go +++ /dev/null @@ -1,146 +0,0 @@ -package sequence - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -const aptosTokenAddress = "0xa" - -type DeployCCIPSeqInput struct { - MCMSAddress aptos.AccountAddress - CCIPConfig config.ChainContractParams - LinkTokenAddress aptos.AccountAddress -} - -type DeployCCIPSeqOutput struct { - CCIPAddress aptos.AccountAddress - MCMSOperations []mcmstypes.BatchOperation -} - -var DeployCCIPSequence = operations.NewSequence( - "deploy-aptos-ccip-sequence", - operation.Version1_0_0, - "Deploy Aptos CCIP contracts and initialize them", - deployCCIPSequence, -) - -func deployCCIPSequence(b operations.Bundle, deps dependency.AptosDeps, in DeployCCIPSeqInput) (DeployCCIPSeqOutput, error) { - var mcmsOperations []mcmstypes.BatchOperation - - // Cleanup MCMS staging area if not clear - cleanupReport, err := operations.ExecuteOperation(b, operation.CleanupStagingAreaOp, deps, in.MCMSAddress) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - if len(cleanupReport.Output.Transactions) > 0 { - mcmsOperations = append(mcmsOperations, cleanupReport.Output) - } - - // Generate batch operations to deploy CCIP package - deployCCIPInput := operation.DeployCCIPInput{ - MCMSAddress: in.MCMSAddress, - IsUpgrade: false, - } - deployCCIPReport, err := operations.ExecuteOperation(b, operation.DeployCCIPOp, deps, deployCCIPInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - ccipAddress := deployCCIPReport.Output.CCIPAddress - // For CCIP deployment the txs cannot be batched - it'd exceed Aptos API limits - // so they're converted to batch operations with single transactions in each batch - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployCCIPReport.Output.MCMSOperations)...) - - // Generate batch operations to deploy CCIP modules - deployModulesInput := operation.DeployModulesInput{ - MCMSAddress: in.MCMSAddress, - CCIPAddress: ccipAddress, - } - // OnRamp module - deployOnRampReport, err := operations.ExecuteOperation(b, operation.DeployOnRampOp, deps, deployModulesInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployOnRampReport.Output)...) - // OffRamp module - deployOffRampReport, err := operations.ExecuteOperation(b, operation.DeployOffRampOp, deps, deployModulesInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployOffRampReport.Output)...) - // Router module - deployRouterReport, err := operations.ExecuteOperation(b, operation.DeployRouterOp, deps, deployModulesInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployRouterReport.Output)...) - - var txs []mcmstypes.Transaction - // Generate txs to Initialize CCIP - initCCIPInput := operation.InitializeCCIPInput{ - MCMSAddress: in.MCMSAddress, - CCIPAddress: ccipAddress, - CCIPConfig: in.CCIPConfig, - LinkTokenAddress: in.LinkTokenAddress, - } - initCCIPReport, err := operations.ExecuteOperation(b, operation.InitializeCCIPOp, deps, initCCIPInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - txs = append(txs, initCCIPReport.Output...) - - // Apply Premium multiplier on fee tokens - multiplierConfig, err := getMultiplierConfig(in.CCIPConfig.FeeQuoterParams.PremiumMultiplierWeiPerEthByFeeToken, in.LinkTokenAddress) - if err != nil { - return DeployCCIPSeqOutput{}, fmt.Errorf("failed to get multiplier config: %w", err) - } - apmInput := operation.ApplyPremiumMultiplierInput{ - CCIPAddress: ccipAddress, - MultiplierBySourceToken: multiplierConfig, - } - applyPMultReport, err := operations.ExecuteOperation(b, operation.ApplyPremiumMultiplierOp, deps, apmInput) - if err != nil { - return DeployCCIPSeqOutput{}, err - } - txs = append(txs, applyPMultReport.Output...) - - // Generate batch operation - mcmsOperations = append(mcmsOperations, mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }) - - return DeployCCIPSeqOutput{ - CCIPAddress: ccipAddress, - MCMSOperations: mcmsOperations, - }, nil -} - -func getMultiplierConfig(multiplierBySymbol map[shared.TokenSymbol]uint64, linkTokenAddress aptos.AccountAddress) (map[string]uint64, error) { - multiplierByToken := make(map[string]uint64) - for symbol, multiplier := range multiplierBySymbol { - switch symbol { - case shared.APTSymbol: - address := aptos.AccountAddress{} - err := address.ParseStringRelaxed(aptosTokenAddress) - if err != nil { - return nil, fmt.Errorf("failed to parse Aptos token address %s: %w", aptosTokenAddress, err) - } - multiplierByToken[address.StringLong()] = multiplier - case shared.LinkSymbol: - multiplierByToken[linkTokenAddress.StringLong()] = multiplier - default: - return nil, fmt.Errorf("unsupported fee token symbol %s for Aptos CCIP", symbol) - } - } - return multiplierByToken, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/deploy_curse_mcms.go b/deployment/ccip/changeset/aptos/sequence/deploy_curse_mcms.go deleted file mode 100644 index 40a0fd7b467..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/deploy_curse_mcms.go +++ /dev/null @@ -1,116 +0,0 @@ -package sequence - -import ( - "github.com/aptos-labs/aptos-go-sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" -) - -// DeployCurseMCMSSeqInput holds the configuration for deploying CurseMCMS. -type DeployCurseMCMSSeqInput struct { - MCMSAddress aptos.AccountAddress - CCIPAddress aptos.AccountAddress - CurseMCMS cldfproposalutils.MCMSWithTimelockConfig -} - -// DeployCurseMCMSSeqOutput holds the deployed address and a CurseMCMS -// self-governance batch (AcceptOwnership + SetMinDelay) that must be submitted -// as a proposal targeting the CurseMCMS contract. -type DeployCurseMCMSSeqOutput struct { - CurseMCMSAddress aptos.AccountAddress - CurseMCMSOperation mcmstypes.BatchOperation -} - -var DeployCurseMCMSSequence = operations.NewSequence( - "deploy-aptos-curse-mcms-sequence", - operation.Version1_0_0, - "Deploy and configure Aptos CurseMCMS contract", - deployCurseMCMSSequence, -) - -func deployCurseMCMSSequence(b operations.Bundle, deps dependency.AptosDeps, in DeployCurseMCMSSeqInput) (DeployCurseMCMSSeqOutput, error) { - // Check if CurseMCMS is already deployed - onChainState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - if onChainState.CurseMCMSAddress != (aptos.AccountAddress{}) { - b.Logger.Infow("CurseMCMS already deployed", "addr", onChainState.CurseMCMSAddress.StringLong()) - return DeployCurseMCMSSeqOutput{}, nil - } - - // Deploy CurseMCMS - deployReport, err := operations.ExecuteOperation(b, operation.DeployCurseMCMSOp, deps, operation.DeployCurseMCMSInput{ - MCMSAddress: in.MCMSAddress, - CCIPAddress: in.CCIPAddress, - }) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - curseMCMSAddr := deployReport.Output - - // Configure CurseMCMS – bypasser - _, err = operations.ExecuteOperation(b, operation.ConfigureCurseMCMSOp, deps, operation.ConfigureCurseMCMSInput{ - CurseMCMSAddress: curseMCMSAddr, - MCMSConfigs: in.CurseMCMS.Bypasser, - MCMSRole: aptosmcms.TimelockRoleBypasser, - }) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - // Configure CurseMCMS – canceller - _, err = operations.ExecuteOperation(b, operation.ConfigureCurseMCMSOp, deps, operation.ConfigureCurseMCMSInput{ - CurseMCMSAddress: curseMCMSAddr, - MCMSConfigs: in.CurseMCMS.Canceller, - MCMSRole: aptosmcms.TimelockRoleCanceller, - }) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - // Configure CurseMCMS – proposer - _, err = operations.ExecuteOperation(b, operation.ConfigureCurseMCMSOp, deps, operation.ConfigureCurseMCMSInput{ - CurseMCMSAddress: curseMCMSAddr, - MCMSConfigs: in.CurseMCMS.Proposer, - MCMSRole: aptosmcms.TimelockRoleProposer, - }) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - // Transfer ownership to self (deployer-signed) - _, err = operations.ExecuteOperation(b, operation.TransferCurseMCMSOwnershipToSelfOp, deps, curseMCMSAddr) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - // Encode AcceptOwnership as a CurseMCMS proposal transaction - aoReport, err := operations.ExecuteOperation(b, operation.AcceptCurseMCMSOwnershipOp, deps, curseMCMSAddr) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - // Encode SetMinDelay as a CurseMCMS proposal transaction - mdReport, err := operations.ExecuteOperation(b, operation.SetCurseMCMSMinDelayOp, deps, operation.CurseMCMSMinDelayInput{ - CurseMCMSAddress: curseMCMSAddr, - TimelockMinDelay: (*in.CurseMCMS.TimelockMinDelay).Uint64(), - }) - if err != nil { - return DeployCurseMCMSSeqOutput{}, err - } - - curseMCMSOp := mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: []mcmstypes.Transaction{aoReport.Output, mdReport.Output}, - } - - return DeployCurseMCMSSeqOutput{ - CurseMCMSAddress: curseMCMSAddr, - CurseMCMSOperation: curseMCMSOp, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/deploy_mcms.go b/deployment/ccip/changeset/aptos/sequence/deploy_mcms.go deleted file mode 100644 index bdf7d092368..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/deploy_mcms.go +++ /dev/null @@ -1,97 +0,0 @@ -package sequence - -import ( - "github.com/aptos-labs/aptos-go-sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" -) - -// Deploy MCMS Sequence -type DeployMCMSSeqOutput struct { - MCMSAddress aptos.AccountAddress - MCMSOperation mcmstypes.BatchOperation -} - -var DeployMCMSSequence = operations.NewSequence( - "deploy-aptos-mcms-sequence", - operation.Version1_0_0, - "Deploy Aptos MCMS contract and configure it", - deployMCMSSequence, -) - -func deployMCMSSequence(b operations.Bundle, deps dependency.AptosDeps, configMCMS cldfproposalutils.MCMSWithTimelockConfig) (DeployMCMSSeqOutput, error) { - // Check if MCMS package is already deployed - onChainState := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector] - if onChainState.MCMSAddress != (aptos.AccountAddress{}) { - b.Logger.Infow("MCMS Package already deployed", "addr", onChainState.MCMSAddress.StringLong()) - return DeployMCMSSeqOutput{}, nil - } - // Deploy MCMS - deployMCMSReport, err := operations.ExecuteOperation(b, operation.DeployMCMSOp, deps, operations.EmptyInput{}) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - // Configure MCMS - configureMCMSBypassers := operation.ConfigureMCMSInput{ - MCMSAddress: deployMCMSReport.Output, - MCMSConfigs: configMCMS.Bypasser, - MCMSRole: aptosmcms.TimelockRoleBypasser, - } - _, err = operations.ExecuteOperation(b, operation.ConfigureMCMSOp, deps, configureMCMSBypassers) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - configureMCMSCancellers := operation.ConfigureMCMSInput{ - MCMSAddress: deployMCMSReport.Output, - MCMSConfigs: configMCMS.Canceller, - MCMSRole: aptosmcms.TimelockRoleCanceller, - } - _, err = operations.ExecuteOperation(b, operation.ConfigureMCMSOp, deps, configureMCMSCancellers) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - configureMCMSProposers := operation.ConfigureMCMSInput{ - MCMSAddress: deployMCMSReport.Output, - MCMSConfigs: configMCMS.Proposer, - MCMSRole: aptosmcms.TimelockRoleProposer, - } - _, err = operations.ExecuteOperation(b, operation.ConfigureMCMSOp, deps, configureMCMSProposers) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - // Transfer ownership to self - _, err = operations.ExecuteOperation(b, operation.TransferOwnershipToSelfOp, deps, deployMCMSReport.Output) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - // Accept ownership - aoReport, err := operations.ExecuteOperation(b, operation.AcceptOwnershipOp, deps, deployMCMSReport.Output) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - // Set MinDelay - timelockMinDelayInput := operation.TimelockMinDelayInput{ - MCMSAddress: deployMCMSReport.Output, - TimelockMinDelay: (*configMCMS.TimelockMinDelay).Uint64(), - } - mdReport, err := operations.ExecuteOperation(b, operation.SetMinDelayOP, deps, timelockMinDelayInput) - if err != nil { - return DeployMCMSSeqOutput{}, err - } - - // Generate MCMS Batch Operation - mcmsOps := mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: []mcmstypes.Transaction{aoReport.Output, mdReport.Output}, - } - - return DeployMCMSSeqOutput{ - MCMSAddress: deployMCMSReport.Output, - MCMSOperation: mcmsOps, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/dynamic.go b/deployment/ccip/changeset/aptos/sequence/dynamic.go deleted file mode 100644 index c5b83620a5d..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/dynamic.go +++ /dev/null @@ -1,64 +0,0 @@ -package sequence - -import ( - "fmt" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" -) - -type DynamicSeqInput struct { - Defs []operations.Definition - Inputs []any // Each element should be the corresponding input type for its operation - ChainSelector uint64 -} - -// DynamicSequence allows operations to be retrieved and executed at runtime -var DynamicSequence = operations.NewSequence( - "aptos-dynamic-sequence", - operation.Version1_0_0, - "Allows operations to be retrieved and executed at runtime", - dynamicSequence, -) - -func dynamicSequence(b operations.Bundle, deps dependency.AptosDeps, in DynamicSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, def := range in.Defs { - op, err := b.OperationRegistry.Retrieve(def) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to retrieve operation %s: %w", def.ID, err) - } - - res, err := operations.ExecuteOperation(b, op, any(deps), in.Inputs[i]) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute operation %s: %w", def.ID, err) - } - - // Handle different return types from operations - switch output := res.Output.(type) { - case mcmstypes.Transaction: - txs = append(txs, output) - case []mcmstypes.Transaction: - txs = append(txs, output...) - case mcmstypes.Operation: - txs = append(txs, output.Transaction) - case []mcmstypes.Operation: - for _, op := range output { - txs = append(txs, op.Transaction) - } - case mcmstypes.BatchOperation: - txs = append(txs, output.Transactions...) - default: - return mcmstypes.BatchOperation{}, fmt.Errorf("operation %s returned unexpected type %T", def.ID, res.Output) - } - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/migrate_onramp.go b/deployment/ccip/changeset/aptos/sequence/migrate_onramp.go deleted file mode 100644 index b7272ee5bec..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/migrate_onramp.go +++ /dev/null @@ -1,30 +0,0 @@ -package sequence - -import ( - "fmt" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" -) - -var MigrateOnRampDestChainConfigsToV2Sequence = operations.NewSequence( - "migrate-onramp-dest-chain-configs-to-v2-sequence", - operation.Version1_0_0, - "Migrates OnRamp destination chain configs from V1 to V2", - migrateOnRampDestChainConfigsToV2Sequence, -) - -func migrateOnRampDestChainConfigsToV2Sequence(b operations.Bundle, deps dependency.AptosDeps, in operation.MigrateOnRampDestChainConfigsToV2Input) (mcmstypes.BatchOperation, error) { - report, err := operations.ExecuteOperation(b, operation.MigrateOnRampDestChainConfigsToV2Op, deps, in) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to migrate OnRamp dest chain configs to V2: %w", err) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: report.Output, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/regulated_token.go b/deployment/ccip/changeset/aptos/sequence/regulated_token.go deleted file mode 100644 index b6623cb0b4a..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/regulated_token.go +++ /dev/null @@ -1,278 +0,0 @@ -package sequence - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -// DeployRegulatedTokenSeqInput is input for DeployRegulatedTokenSequence. -type DeployRegulatedTokenSeqInput struct { - MCMSAddress aptos.AccountAddress - TokenParams config.TokenParams - TokenMint *config.TokenMint - RegistrarPreregister bool -} - -// DeployRegulatedTokenSeqOutput contains token addresses and MCMS batch operations -// (accept_ownership + accept_admin) to be wrapped in a timelock proposal. -type DeployRegulatedTokenSeqOutput struct { - TokenCodeObjectAddress aptos.AccountAddress - TokenMetadataAddress aptos.AccountAddress - MCMSOperations []mcmstypes.BatchOperation -} - -var DeployRegulatedTokenSequence = operations.NewSequence( - "deploy-regulated-token-aptos-sequence", - operation.Version1_0_0, - "Deploy regulated token directly (regulated_token cannot be deployed via MCMS due to DFA re-entrancy) then build MCMS accept_ownership + accept_admin batch", - deployRegulatedTokenSequence, -) - -func deployRegulatedTokenSequence( - b operations.Bundle, - deps dependency.AptosDeps, - in DeployRegulatedTokenSeqInput, -) (DeployRegulatedTokenSeqOutput, error) { - objReport, err := operations.ExecuteOperation(b, operation.DeployRegulatedTokenObjectOp, deps, operations.EmptyInput{}) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("DeployRegulatedTokenObjectOp: %w", err) - } - codeObj := objReport.Output - - _, err = operations.ExecuteOperation(b, operation.DeployRegulatedTokenMCMSRegistrarOp, deps, operation.DeployRegulatedTokenMCMSRegistrarInput{ - TokenCodeObjectAddress: codeObj, - MCMSAddress: in.MCMSAddress, - RegistrarPreregister: in.RegistrarPreregister, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("DeployRegulatedTokenMCMSRegistrarOp: %w", err) - } - - _, err = operations.ExecuteOperation(b, operation.InitializeRegulatedTokenOp, deps, operation.InitializeRegulatedTokenInput{ - TokenCodeObjectAddress: codeObj, - TokenParams: in.TokenParams, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("InitializeRegulatedTokenOp: %w", err) - } - - // To be used for tests, staging and testnet - if in.TokenMint != nil { - deployerAddress := deps.AptosChain.DeployerSigner.AccountAddress() - _, err = operations.ExecuteOperation(b, operation.GrantRegulatedTokenMinterRoleOp, deps, operation.GrantRegulatedTokenMinterRoleInput{ - TokenCodeObjectAddress: codeObj, - Grantee: deployerAddress, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("GrantRegulatedTokenMinterRoleOp: %w", err) - } - _, err = operations.ExecuteOperation(b, operation.MintRegulatedTokenOp, deps, operation.MintRegulatedTokenInput{ - TokenCodeObjectAddress: codeObj, - To: in.TokenMint.To, - Amount: in.TokenMint.Amount, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("MintRegulatedTokenOp: %w", err) - } - // Revoke the deployer's MINTER_ROLE so it doesn't retain mint authority once admin - // is handed over to MCMS. Must happen while the deployer is still admin (i.e., before - // MCMS executes accept_admin from the proposal generated below). - _, err = operations.ExecuteOperation(b, operation.RevokeRegulatedTokenMinterRoleOp, deps, operation.RevokeRegulatedTokenMinterRoleInput{ - TokenCodeObjectAddress: codeObj, - Account: deployerAddress, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("RevokeRegulatedTokenMinterRoleOp: %w", err) - } - } - - mcmsContract := mcmsbind.Bind(in.MCMSAddress, deps.AptosChain.Client) - tokenOwnerAddress, err := mcmsContract.MCMSRegistry().GetPreexistingCodeObjectOwnerAddress(nil, codeObj) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("GetPreexistingCodeObjectOwnerAddress: %w", err) - } - _, err = operations.ExecuteOperation(b, operation.TransferRegulatedTokenOwnershipOp, deps, operation.TransferRegulatedTokenOwnershipInput{ - TokenCodeObjectAddress: codeObj, - To: tokenOwnerAddress, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("TransferRegulatedTokenOwnershipOp: %w", err) - } - - _, err = operations.ExecuteOperation(b, operation.TransferRegulatedTokenAdminOp, deps, operation.TransferRegulatedTokenAdminInput{ - TokenCodeObjectAddress: codeObj, - NewAdmin: tokenOwnerAddress, - }) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("TransferRegulatedTokenAdminOp: %w", err) - } - - token := regulated_token.Bind(codeObj, deps.AptosChain.Client) - tokenMetadata, err := token.RegulatedToken().TokenMetadata(nil) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("TokenMetadata: %w", err) - } - - acceptOwnershipReport, err := operations.ExecuteOperation( - b, - operation.AcceptTokenOwnershipOp, - deps, - operation.AcceptTokenOwnershipInput{ - TokenCodeObjectAddress: codeObj, - TokenType: shared.AptosRegulatedTokenType, - }, - ) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("AcceptTokenOwnershipOp: %w", err) - } - - acceptAdminReport, err := operations.ExecuteOperation( - b, - operation.AcceptTokenAdminOp, - deps, - operation.AcceptTokenAdminInput{ - TokenCodeObjectAddress: codeObj, - }, - ) - if err != nil { - return DeployRegulatedTokenSeqOutput{}, fmt.Errorf("AcceptTokenAdminOp: %w", err) - } - - mcmsOperations := []mcmstypes.BatchOperation{ - { - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: []mcmstypes.Transaction{acceptOwnershipReport.Output, acceptAdminReport.Output}, - }, - } - - return DeployRegulatedTokenSeqOutput{ - TokenCodeObjectAddress: codeObj, - TokenMetadataAddress: tokenMetadata, - MCMSOperations: mcmsOperations, - }, nil -} - -// FinalizeRegulatedTokenOwnershipSequence runs regulated_token::execute_ownership_transfer -// (EOA) to finalize the 3-step ownable handoff after MCMS has accepted ownership. The full -// validation (transfer is to MCMS, accepted, deployer is current owner) lives in -// VerifyFinalizeRegulatedTokenOwnership and must be invoked by the calling changeset's -// VerifyPreconditions; -var FinalizeRegulatedTokenOwnershipSequence = operations.NewSequence( - "finalize-regulated-token-ownership-sequence", - operation.Version1_0_0, - "Run regulated_token::execute_ownership_transfer (EOA) when a pending transfer exists", - finalizeRegulatedTokenOwnershipSequence, -) - -func finalizeRegulatedTokenOwnershipSequence( - b operations.Bundle, - deps dependency.AptosDeps, - tokenCodeObjectAddress aptos.AccountAddress, -) (aptos.AccountAddress, error) { - token := regulated_token.Bind(tokenCodeObjectAddress, deps.AptosChain.Client) - hasPending, err := token.RegulatedToken().HasPendingTransfer(nil) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("query has_pending_transfer: %w", err) - } - if !hasPending { - return aptos.AccountAddress{}, nil - } - pendingTo, err := token.RegulatedToken().PendingTransferTo(nil) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("query pending_transfer_to: %w", err) - } - if pendingTo == nil { - return aptos.AccountAddress{}, errors.New("pending_transfer_to is empty despite has_pending_transfer=true") - } - _, err = operations.ExecuteOperation( - b, - operation.ExecuteRegulatedTokenOwnershipTransferOp, - deps, - operation.ExecuteRegulatedTokenOwnershipTransferInput{ - TokenCodeObjectAddress: tokenCodeObjectAddress, - To: *pendingTo, - }, - ) - if err != nil { - return aptos.AccountAddress{}, fmt.Errorf("ExecuteRegulatedTokenOwnershipTransferOp: %w", err) - } - return *pendingTo, nil -} - -// VerifyFinalizeRegulatedTokenOwnership validates that the regulated token is in a state where -// the deployer EOA can run execute_ownership_transfer to finalize the 3-step handoff to MCMS. -func VerifyFinalizeRegulatedTokenOwnership( - deps dependency.AptosDeps, - tokenCodeObjectAddress aptos.AccountAddress, - mcmsAddress aptos.AccountAddress, -) error { - token := regulated_token.Bind(tokenCodeObjectAddress, deps.AptosChain.Client) - - hasPending, err := token.RegulatedToken().HasPendingTransfer(nil) - if err != nil { - return fmt.Errorf("query has_pending_transfer: %w", err) - } - if !hasPending { - return nil - } - - mcmsContract := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - expectedOwner, err := mcmsContract.MCMSRegistry().GetPreexistingCodeObjectOwnerAddress(nil, tokenCodeObjectAddress) - if err != nil { - return fmt.Errorf("get mcms preexisting code object owner: %w", err) - } - - pendingTo, err := token.RegulatedToken().PendingTransferTo(nil) - if err != nil { - return fmt.Errorf("query pending_transfer_to: %w", err) - } - if pendingTo == nil { - return errors.New("pending_transfer_to is empty despite has_pending_transfer=true") - } - if *pendingTo != expectedOwner { - return fmt.Errorf("pending_transfer_to %s does not match MCMS registry owner %s", pendingTo.StringLong(), expectedOwner.StringLong()) - } - - accepted, err := token.RegulatedToken().PendingTransferAccepted(nil) - if err != nil { - return fmt.Errorf("query pending_transfer_accepted: %w", err) - } - if accepted == nil || !*accepted { - return errors.New("pending transfer has not been accepted by MCMS") - } - - // The DeployRegulatedToken changeset emits accept_ownership and accept_admin in the same - // MCMS proposal, so once ownership is accepted we expect admin to be MCMS as well. The - // regulated pool deployment later emits an MCMS GrantRole for BRIDGE_MINTER_OR_BURNER_ROLE - // that requires MCMS to be admin at execution time; finalizing ownership here without that - // would produce a pool proposal that fails at execution. - currentAdmin, err := token.RegulatedToken().Admin(nil) - if err != nil { - return fmt.Errorf("query admin: %w", err) - } - if currentAdmin != expectedOwner { - return fmt.Errorf("admin %s has not been transferred to MCMS registry owner %s; accept_admin from the deploy proposal must execute before finalizing ownership", currentAdmin.StringLong(), expectedOwner.StringLong()) - } - - currentOwner, err := token.RegulatedToken().Owner(nil) - if err != nil { - return fmt.Errorf("query owner: %w", err) - } - deployerAddress := deps.AptosChain.DeployerSigner.AccountAddress() - if currentOwner != deployerAddress { - return fmt.Errorf("current owner %s is not the deployer EOA %s; only the original owner can execute the ownership transfer", currentOwner.StringLong(), deployerAddress.StringLong()) - } - - return nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/rmn_remote.go b/deployment/ccip/changeset/aptos/sequence/rmn_remote.go deleted file mode 100644 index 16458cd9a8d..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/rmn_remote.go +++ /dev/null @@ -1,91 +0,0 @@ -package sequence - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse" - "github.com/smartcontractkit/chainlink-ccip/deployment/utils/sequences" - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - aptosops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" -) - -type AptosCurseUncurseInput struct { - CCIPAddress aptos.AccountAddress - ChainSelector uint64 - Subjects []fastcurse.Subject -} - -var AptosCurseSequence = cldf_ops.NewSequence( - "aptos-curse-sequence", - operation.Version1_0_0, - "Curse sequence for Aptos", - func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in AptosCurseUncurseInput) (output sequences.OnChainOutput, err error) { - chain, ok := chains.AptosChains()[in.ChainSelector] - if !ok { - return sequences.OnChainOutput{}, fmt.Errorf("chain with selector %d not found in environment", in.ChainSelector) - } - subjectBytes := make([][]byte, len(in.Subjects)) - for i, subject := range in.Subjects { - subjectBytes[i] = subject[:] - } - curseInput := aptosops.CurseMultipleInput{ - CCIPAddress: in.CCIPAddress, - Subjects: subjectBytes, - } - deps := dependency.AptosDeps{ - AptosChain: chain, - } - report, err := cldf_ops.ExecuteOperation(b, aptosops.CurseMultipleOp, deps, curseInput) - if err != nil { - return sequences.OnChainOutput{}, fmt.Errorf("failed to execute curse operation on Aptos chain %d: %w", chain.Selector, err) - } - batchOperation := mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(chain.Selector), - Transactions: []mcmstypes.Transaction{report.Output}, - } - return sequences.OnChainOutput{ - BatchOps: []mcmstypes.BatchOperation{batchOperation}, - }, nil - }, -) - -var AptosUncurseSequence = cldf_ops.NewSequence( - "aptos-uncurse-sequence", - operation.Version1_0_0, - "Uncurse sequence for Aptos", - func(b cldf_ops.Bundle, chains cldf_chain.BlockChains, in AptosCurseUncurseInput) (output sequences.OnChainOutput, err error) { - chain, ok := chains.AptosChains()[in.ChainSelector] - if !ok { - return sequences.OnChainOutput{}, fmt.Errorf("chain with selector %d not found in environment", in.ChainSelector) - } - subjectBytes := make([][]byte, len(in.Subjects)) - for i, subject := range in.Subjects { - subjectBytes[i] = subject[:] - } - uncurseInput := aptosops.UncurseMultipleInput{ - CCIPAddress: in.CCIPAddress, - Subjects: subjectBytes, - } - deps := dependency.AptosDeps{ - AptosChain: chain, - } - report, err := cldf_ops.ExecuteOperation(b, aptosops.UncurseMultipleOp, deps, uncurseInput) - if err != nil { - return sequences.OnChainOutput{}, fmt.Errorf("failed to execute uncurse operation on Aptos chain %d: %w", chain.Selector, err) - } - batchOperation := mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(chain.Selector), - Transactions: []mcmstypes.Transaction{report.Output}, - } - return sequences.OnChainOutput{ - BatchOps: []mcmstypes.BatchOperation{batchOperation}, - }, nil - }, -) diff --git a/deployment/ccip/changeset/aptos/sequence/rmn_remote_test.go b/deployment/ccip/changeset/aptos/sequence/rmn_remote_test.go deleted file mode 100644 index 5069ad5f2e4..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/rmn_remote_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package sequence - -import ( - "context" - "testing" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/stretchr/testify/require" - - cldf_chain "github.com/smartcontractkit/chainlink-deployments-framework/chain" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink-deployments-framework/pkg/logger" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-ccip/deployment/fastcurse" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - aptosops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" -) - -func TestAptosCurseSequence_Success(t *testing.T) { - restore := overrideOps() - t.Cleanup(restore) - - ccipAddr := aptos.AccountAddress{} - chain := cldf_aptos.Chain{Selector: 101} - blockChains := cldf_chain.NewBlockChainsFromSlice([]cldf_chain.BlockChain{chain}) - - var subj fastcurse.Subject - copy(subj[:], []byte("hello")) - subjects := []fastcurse.Subject{subj} - - var gotDeps dependency.AptosDeps - var gotInput aptosops.CurseMultipleInput - stubTx := mcmstypes.Transaction{} - - aptosops.CurseMultipleOp = cldf_ops.NewOperation( - "stub-curse-op", - operation.Version1_0_0, - "stub", - func(_ cldf_ops.Bundle, deps dependency.AptosDeps, in aptosops.CurseMultipleInput) (mcmstypes.Transaction, error) { - gotDeps = deps - gotInput = in - return stubTx, nil - }, - ) - - bundle := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - - rep, err := cldf_ops.ExecuteSequence(bundle, AptosCurseSequence, blockChains, AptosCurseUncurseInput{ - CCIPAddress: ccipAddr, - ChainSelector: chain.Selector, - Subjects: subjects, - }) - require.NoError(t, err) - - require.Equal(t, chain, gotDeps.AptosChain) - require.Equal(t, ccipAddr, gotInput.CCIPAddress) - require.Len(t, gotInput.Subjects, 1) - require.Equal(t, subjects[0][:], gotInput.Subjects[0]) - - require.Len(t, rep.Output.BatchOps, 1) - require.Equal(t, mcmstypes.ChainSelector(chain.Selector), rep.Output.BatchOps[0].ChainSelector) - require.Equal(t, []mcmstypes.Transaction{stubTx}, rep.Output.BatchOps[0].Transactions) -} - -func TestAptosUncurseSequence_Success(t *testing.T) { - restore := overrideOps() - t.Cleanup(restore) - - ccipAddr := aptos.AccountAddress{} - chain := cldf_aptos.Chain{Selector: 202} - blockChains := cldf_chain.NewBlockChainsFromSlice([]cldf_chain.BlockChain{chain}) - - var subj fastcurse.Subject - copy(subj[:], []byte("world")) - subjects := []fastcurse.Subject{subj} - - var gotDeps dependency.AptosDeps - var gotInput aptosops.UncurseMultipleInput - stubTx := mcmstypes.Transaction{} - - aptosops.UncurseMultipleOp = cldf_ops.NewOperation( - "stub-uncurse-op", - operation.Version1_0_0, - "stub", - func(_ cldf_ops.Bundle, deps dependency.AptosDeps, in aptosops.UncurseMultipleInput) (mcmstypes.Transaction, error) { - gotDeps = deps - gotInput = in - return stubTx, nil - }, - ) - - bundle := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - - rep, err := cldf_ops.ExecuteSequence(bundle, AptosUncurseSequence, blockChains, AptosCurseUncurseInput{ - CCIPAddress: ccipAddr, - ChainSelector: chain.Selector, - Subjects: subjects, - }) - require.NoError(t, err) - - require.Equal(t, chain, gotDeps.AptosChain) - require.Equal(t, ccipAddr, gotInput.CCIPAddress) - require.Len(t, gotInput.Subjects, 1) - require.Equal(t, subjects[0][:], gotInput.Subjects[0]) - - require.Len(t, rep.Output.BatchOps, 1) - require.Equal(t, mcmstypes.ChainSelector(chain.Selector), rep.Output.BatchOps[0].ChainSelector) - require.Equal(t, []mcmstypes.Transaction{stubTx}, rep.Output.BatchOps[0].Transactions) -} - -func TestAptosCurseSequence_ChainNotFound(t *testing.T) { - restore := overrideOps() - t.Cleanup(restore) - - bundle := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - _, err := cldf_ops.ExecuteSequence(bundle, AptosCurseSequence, cldf_chain.NewBlockChainsFromSlice(nil), AptosCurseUncurseInput{ - ChainSelector: 999, - }) - require.Error(t, err) -} - -func TestAptosUncurseSequence_ChainNotFound(t *testing.T) { - restore := overrideOps() - t.Cleanup(restore) - - bundle := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - _, err := cldf_ops.ExecuteSequence(bundle, AptosUncurseSequence, cldf_chain.NewBlockChainsFromSlice(nil), AptosCurseUncurseInput{ - ChainSelector: 888, - }) - require.Error(t, err) -} - -func overrideOps() func() { - origCurse := aptosops.CurseMultipleOp - origUncurse := aptosops.UncurseMultipleOp - return func() { - aptosops.CurseMultipleOp = origCurse - aptosops.UncurseMultipleOp = origUncurse - } -} diff --git a/deployment/ccip/changeset/aptos/sequence/set_ocr3_offramp.go b/deployment/ccip/changeset/aptos/sequence/set_ocr3_offramp.go deleted file mode 100644 index 6d0b639be7a..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/set_ocr3_offramp.go +++ /dev/null @@ -1,104 +0,0 @@ -package sequence - -import ( - "fmt" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal" - "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/types" -) - -// Set OCR3 Offramp Sequence Input -type SetOCR3OfframpSeqInput struct { - HomeChainSelector uint64 - ChainSelector uint64 - ConfigType globals.ConfigType -} - -var SetOCR3OfframpSequence = operations.NewSequence( - "set-aptos-ocr3-offramp-sequence", - operation.Version1_0_0, - "Set OCR3 configuration for Aptos CCIP Offramp", - setOCR3OfframpSequence, -) - -func setOCR3OfframpSequence(b operations.Bundle, deps dependency.AptosDeps, in SetOCR3OfframpSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - donID, err := internal.DonIDForChain( - deps.CCIPOnChainState.Chains[in.HomeChainSelector].CapabilityRegistry, - deps.CCIPOnChainState.Chains[in.HomeChainSelector].CCIPHome, - in.ChainSelector, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to get DON ID: %w", err) - } - - // Default to active config if not set - if in.ConfigType == "" { - in.ConfigType = globals.ConfigTypeActive - } - - ocr3Args, err := internal.BuildSetOCR3ConfigArgsAptos( - donID, - deps.CCIPOnChainState.Chains[in.HomeChainSelector].CCIPHome, - in.ChainSelector, - in.ConfigType, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to build OCR3 config args: %w", err) - } - - var commitArgs *internal.MultiOCR3BaseOCRConfigArgsAptos - var execArgs *internal.MultiOCR3BaseOCRConfigArgsAptos - for _, ocr3Arg := range ocr3Args { - switch ocr3Arg.OcrPluginType { - case uint8(types.PluginTypeCCIPCommit): - commitArgs = &ocr3Arg - case uint8(types.PluginTypeCCIPExec): - execArgs = &ocr3Arg - default: - return mcmstypes.BatchOperation{}, fmt.Errorf("unknown plugin type %d", ocr3Arg.OcrPluginType) - } - } - - // Set commit OCR3 Config - commitReport, err := operations.ExecuteOperation( - b, - operation.SetOcr3ConfigOp, - deps, - operation.SetOcr3ConfigInput{ - OcrPluginType: types.PluginTypeCCIPCommit, - OCRConfigArgs: *commitArgs, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, err - } - txs = append(txs, commitReport.Output) - - // Set exec OCR3 Config - execReport, err := operations.ExecuteOperation( - b, - operation.SetOcr3ConfigOp, - deps, - operation.SetOcr3ConfigInput{ - OcrPluginType: types.PluginTypeCCIPExec, - OCRConfigArgs: *execArgs, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, err - } - txs = append(txs, execReport.Output) - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/token.go b/deployment/ccip/changeset/aptos/sequence/token.go deleted file mode 100644 index c9cf5bb6738..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/token.go +++ /dev/null @@ -1,359 +0,0 @@ -package sequence - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -type DeployTokenSeqInput struct { - MCMSAddress aptos.AccountAddress - TokenParams config.TokenParams - TokenMint *config.TokenMint -} - -type DeployTokenSeqOutput struct { - TokenAddress aptos.AccountAddress - TokenCodeObjAddress aptos.AccountAddress - TokenOwnerAddress aptos.AccountAddress - MCMSOperations []mcmstypes.BatchOperation -} - -var DeployAptosTokenSequence = operations.NewSequence( - "deploy-aptos-token", - operation.Version1_0_0, - "Deploys token and configures", - deployAptosTokenSequence, -) - -func deployAptosTokenSequence(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenSeqInput) (DeployTokenSeqOutput, error) { - var mcmsOperations []mcmstypes.BatchOperation - var txs []mcmstypes.Transaction - - // Cleanup staging area - cleanupReport, err := operations.ExecuteOperation(b, operation.CleanupStagingAreaOp, deps, in.MCMSAddress) - if err != nil { - return DeployTokenSeqOutput{}, err - } - if len(cleanupReport.Output.Transactions) > 0 { - mcmsOperations = append(mcmsOperations, cleanupReport.Output) - } - - // Deploy token - deployTInput := operation.DeployTokenInput{ - Name: in.TokenParams.Name, - Symbol: string(in.TokenParams.Symbol), - MCMSAddress: in.MCMSAddress, - } - deployTReport, err := operations.ExecuteOperation(b, operation.DeployTokenOp, deps, deployTInput) - if err != nil { - return DeployTokenSeqOutput{}, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployTReport.Output.MCMSOps)...) - - // Deploy token MCMS Registrar - deployTokenRegistrarIn := operation.DeployTokenRegistrarInput{ - TokenCodeObjectAddress: deployTReport.Output.TokenCodeObjectAddress, - MCMSAddress: in.MCMSAddress, - } - deployRegReport, err := operations.ExecuteOperation(b, operation.DeployTokenMCMSRegistrarOp, deps, deployTokenRegistrarIn) - if err != nil { - return DeployTokenSeqOutput{}, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployRegReport.Output)...) - - // Initialize token - initTokenInput := operation.InitializeTokenInput{ - TokenCodeObjectAddress: deployTReport.Output.TokenCodeObjectAddress, - MaxSupply: in.TokenParams.MaxSupply, - Name: in.TokenParams.Name, - Symbol: string(in.TokenParams.Symbol), - Decimals: in.TokenParams.Decimals, - Icon: in.TokenParams.Icon, - Project: in.TokenParams.Project, - } - initTokenReport, err := operations.ExecuteOperation(b, operation.InitializeTokenOp, deps, initTokenInput) - if err != nil { - return DeployTokenSeqOutput{}, err - } - txs = append(txs, initTokenReport.Output) - - // Mint test tokens - if in.TokenMint != nil { - mintTokenInput := operation.MintTokensInput{ - TokenCodeObjectAddress: deployTReport.Output.TokenCodeObjectAddress, - To: in.TokenMint.To, - Amount: in.TokenMint.Amount, - } - mintTokenReport, err := operations.ExecuteOperation(b, operation.MintTokensOp, deps, mintTokenInput) - if err != nil { - return DeployTokenSeqOutput{}, err - } - txs = append(txs, mintTokenReport.Output) - } - - mcmsOperations = append(mcmsOperations, mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }) - - return DeployTokenSeqOutput{ - TokenAddress: deployTReport.Output.TokenAddress, - TokenCodeObjAddress: deployTReport.Output.TokenCodeObjectAddress, - TokenOwnerAddress: deployTReport.Output.TokenOwnerAddress, - MCMSOperations: mcmsOperations, - }, nil -} - -type DeployTokenFaucetSeqInput struct { - MCMSAddress aptos.AccountAddress - TokenCodeObjAddress aptos.AccountAddress -} - -var DeployTokenFaucetSequence = operations.NewSequence( - "deploy-aptos-token-faucet", - operation.Version1_0_0, - "Deploys a token faucet onto an existing manage_token instance", - deployAptosTokenFaucetSequence, -) - -func deployAptosTokenFaucetSequence(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenFaucetSeqInput) ([]mcmstypes.BatchOperation, error) { - var mcmsOperations []mcmstypes.BatchOperation - - // Cleanup staging area - cleanupReport, err := operations.ExecuteOperation(b, operation.CleanupStagingAreaOp, deps, in.MCMSAddress) - if err != nil { - return nil, err - } - if len(cleanupReport.Output.Transactions) > 0 { - mcmsOperations = append(mcmsOperations, cleanupReport.Output) - } - - // Deploy token faucet module - deployTokenFaucetInput := operation.DeployTokenFaucetInput{ - MCMSAddress: in.MCMSAddress, - TokenCodeObjectAddress: in.TokenCodeObjAddress, - } - deployTokenFaucetReport, err := operations.ExecuteOperation(b, operation.DeployTokenFaucetOp, deps, deployTokenFaucetInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployTokenFaucetReport.Output)...) - - // Grant Mint rights to ManagedTokenFaucet signer - managedTokenFaucetStateAddress := in.TokenCodeObjAddress.NamedObjectAddress([]byte("ManagedTokenFaucet")) - applyMintersInput := operation.ApplyAllowedMintersInput{ - TokenCodeObjectAddress: in.TokenCodeObjAddress, - MintersToAdd: []aptos.AccountAddress{managedTokenFaucetStateAddress}, - } - applyAllowedMintersReport, err := operations.ExecuteOperation(b, operation.ApplyAllowedMintersOp, deps, applyMintersInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: []mcmstypes.Transaction{applyAllowedMintersReport.Output}, - }) - - return mcmsOperations, nil -} - -type TokenTransferInput struct { - TokenCodeObjAddress aptos.AccountAddress - TokenType deployment.ContractType - To aptos.AccountAddress -} - -type TransferTokenOwnershipsSeqInput struct { - Transfers []TokenTransferInput -} - -var TransferTokenOwnershipsSequence = operations.NewSequence( - "transfer-token-ownerships", - operation.Version1_0_0, - "Transfers the ownership of one or multiple managed/regulated token instances", - transferTokenOwnershipsSequence, -) - -func transferTokenOwnershipsSequence(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenOwnershipsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, transfer := range in.Transfers { - report, err := operations.ExecuteOperation( - b, - operation.TransferTokenOwnershipOp, - deps, - operation.TransferTokenOwnershipInput{ - TokenCodeObjectAddress: transfer.TokenCodeObjAddress, - TokenType: transfer.TokenType, - To: transfer.To, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d TransferTokenOwnershipOp of %v token %s: %w", i, transfer.TokenType.String(), transfer.TokenCodeObjAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type TokenAcceptInput struct { - TokenCodeObjAddress aptos.AccountAddress - TokenType deployment.ContractType -} - -type AcceptTokenOwnershipsSeqInput struct { - Accepts []TokenAcceptInput -} - -var AcceptTokenOwnershipsSequence = operations.NewSequence( - "accept-token-ownerships", - operation.Version1_0_0, - "Accepts the ownership of one or multiple managed/regulated token instances", - acceptTokenOwnershipsSequence, -) - -func acceptTokenOwnershipsSequence(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenOwnershipsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, accept := range in.Accepts { - report, err := operations.ExecuteOperation( - b, - operation.AcceptTokenOwnershipOp, - deps, - operation.AcceptTokenOwnershipInput{ - TokenCodeObjectAddress: accept.TokenCodeObjAddress, - TokenType: accept.TokenType, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d AcceptTokenOwnershipOp of %v token %s: %w", i, accept.TokenType.String(), accept.TokenCodeObjAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type ExecuteTokenOwnershipTransfersSeqInput struct { - Transfers []TokenTransferInput -} - -var ExecuteTokenOwnershipTransfersSequence = operations.NewSequence( - "execute-token-ownership-transfers", - operation.Version1_0_0, - "Executes the pending ownership transfer(s) of one or multiple managed/regulated token instances", - executeTokenOwnershipTransfersSequence, -) - -func executeTokenOwnershipTransfersSequence(b operations.Bundle, deps dependency.AptosDeps, in ExecuteTokenOwnershipTransfersSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, transfer := range in.Transfers { - report, err := operations.ExecuteOperation( - b, - operation.ExecuteTokenOwnershipTransferOp, - deps, - operation.ExecuteTokenOwnershipTransferInput{ - TokenCodeObjectAddress: transfer.TokenCodeObjAddress, - TokenType: transfer.TokenType, - To: transfer.To, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d ExecuteTokenOwnershipTransferOp of %v token %s: %w", i, transfer.TokenType.String(), transfer.TokenCodeObjAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type TransferTokenAdminsSeqInput struct { - Transfers []TokenTransferInput -} - -var TransferTokenAdminsSequence = operations.NewSequence( - "transfer-token-admins", - operation.Version1_0_0, - "Transfers the admin role of one or multiple regulated token instances", - transferTokenAdminsSequence, -) - -func transferTokenAdminsSequence(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenAdminsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, transfer := range in.Transfers { - report, err := operations.ExecuteOperation( - b, - operation.TransferTokenAdminOp, - deps, - operation.TransferTokenAdminInput{ - TokenCodeObjectAddress: transfer.TokenCodeObjAddress, - NewAdmin: transfer.To, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d TransferTokenAdminOp of token %s: %w", i, transfer.TokenCodeObjAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type AcceptTokenAdminsSeqInput struct { - Accepts []TokenAcceptInput -} - -var AcceptTokenAdminsSequence = operations.NewSequence( - "accept-token-admins", - operation.Version1_0_0, - "Accepts the admin role of one or multiple pending admin transfers on regulated token instances", - acceptTokenAdminsSequence, -) - -func acceptTokenAdminsSequence(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenAdminsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, accept := range in.Accepts { - report, err := operations.ExecuteOperation( - b, - operation.AcceptTokenAdminOp, - deps, - operation.AcceptTokenAdminInput{ - TokenCodeObjectAddress: accept.TokenCodeObjAddress, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d AcceptTokenAdminOp of token %s: %w", i, accept.TokenCodeObjAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/token_pool.go b/deployment/ccip/changeset/aptos/sequence/token_pool.go deleted file mode 100644 index f1a24261223..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/token_pool.go +++ /dev/null @@ -1,455 +0,0 @@ -package sequence - -import ( - "bytes" - "fmt" - "slices" - - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/burn_mint_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/lock_release_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/managed_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/regulated_token_pool" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - module_regulated_token "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token/regulated_token" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -// Deploy Token Pool sequence input -type DeployTokenPoolSeqInput struct { - TokenCodeObjAddress aptos.AccountAddress - TokenAddress aptos.AccountAddress - TokenOwnerAddress aptos.AccountAddress - PoolType cldf.ContractType - IsTokenOwnedByMCMS bool -} -type DeployTokenPoolSeqOutput struct { - TokenPoolAddress aptos.AccountAddress - MCMSOps []mcmstypes.BatchOperation -} - -// DeployAptosTokenPoolSequence deploys token pool to the same address as Token Object Address -var DeployAptosTokenPoolSequence = operations.NewSequence( - "deploy-aptos-token-pool", - operation.Version1_0_0, - "Deploys token and token pool and configures", - deployAptosTokenPoolSequence, -) - -func deployAptosTokenPoolSequence(b operations.Bundle, deps dependency.AptosDeps, in DeployTokenPoolSeqInput) (DeployTokenPoolSeqOutput, error) { - var mcmsOperations []mcmstypes.BatchOperation - var txs []mcmstypes.Transaction - mcmsAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].MCMSAddress - mcmsContract := mcmsbind.Bind(mcmsAddress, deps.AptosChain.Client) - - // 1 - Cleanup staging area - cleanupReport, err := operations.ExecuteOperation(b, operation.CleanupStagingAreaOp, deps, mcmsAddress) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute CleanupStagingAreaOp: %w", err) - } - if len(cleanupReport.Output.Transactions) > 0 { - mcmsOperations = append(mcmsOperations, cleanupReport.Output) - } - - // 2 - Deploy token pool package - // Get a deterministic seed using token address and pool type - tokenPoolSeed := fmt.Sprintf("%s::%s", in.TokenAddress.StringLong(), in.PoolType.String()) - deployTokenPoolPackageReport, err := operations.ExecuteOperation(b, operation.DeployTokenPoolPackageOp, deps, tokenPoolSeed) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute DeployTokenPoolPackageOp: %w", err) - } - tokenPoolObjectAddress := deployTokenPoolPackageReport.Output.TokenPoolObjectAddress - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployTokenPoolPackageReport.Output.MCMSOps)...) - - // 3 - Deploy token pool module - deployTokenPoolModuleInput := operation.DeployTokenPoolModuleInput{ - TokenAddress: in.TokenAddress, - TokenCodeObjAddress: in.TokenCodeObjAddress, - TokenPoolObjAddress: tokenPoolObjectAddress, - PoolType: in.PoolType, - } - deployTokenPoolModuleReport, err := operations.ExecuteOperation(b, operation.DeployTokenPoolModuleOp, deps, deployTokenPoolModuleInput) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute DeployTokenPoolModuleOp: %w", err) - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployTokenPoolModuleReport.Output)...) - - // 4 - ProposeAdministrator - // The initial administrator of the token pool will be set to the MCMS resource account owning CCIP - - // when calling admin function on the TAR, this signer will be used. - initialAdministrator, err := mcmsContract.MCMSRegistry().GetRegisteredOwnerAddress(nil, deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to get CCIP owner address to be set as an initial administrator: %w", err) - } - proposeAdministratorIn := operation.ProposeAdministratorInput{ - TokenAddress: in.TokenAddress, - TokenAdministrator: initialAdministrator, - } - paReport, err := operations.ExecuteOperation(b, operation.ProposeAdministratorOp, deps, proposeAdministratorIn) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute ProposeAdministratorOp: %w", err) - } - txs = append(txs, paReport.Output) - - // 5 - AcceptAdminRole - aaReport, err := operations.ExecuteOperation(b, operation.AcceptAdminRoleOp, deps, in.TokenAddress) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute AcceptAdminRoleOp: %w", err) - } - txs = append(txs, aaReport.Output) - - // 6 - SetPool - setPoolIn := operation.SetPoolInput{ - TokenAddress: in.TokenAddress, - TokenPoolAddress: tokenPoolObjectAddress, - } - spReport, err := operations.ExecuteOperation(b, operation.SetPoolOp, deps, setPoolIn) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute SetPoolOp: %w", err) - } - txs = append(txs, spReport.Output) - - // 7 - Grant BnM permission to the token pool - switch { - case in.PoolType == shared.AptosManagedTokenPoolType && in.IsTokenOwnedByMCMS: - tokenPoolStateAddress := tokenPoolObjectAddress.ResourceAccount([]byte("CcipManagedTokenPool")) - gmReport, err := operations.ExecuteOperation(b, operation.ApplyAllowedMintersOp, deps, operation.ApplyAllowedMintersInput{ - TokenCodeObjectAddress: in.TokenCodeObjAddress, - MintersToAdd: []aptos.AccountAddress{tokenPoolStateAddress}, - }) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute ApplyAllowedMintersOp: %w", err) - } - txs = append(txs, gmReport.Output) - - gbReport, err := operations.ExecuteOperation(b, operation.ApplyAllowedBurnersOp, deps, operation.ApplyAllowedBurnersInput{ - TokenCodeObjectAddress: in.TokenCodeObjAddress, - BurnersToAdd: []aptos.AccountAddress{tokenPoolStateAddress}, - }) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute ApplyAllowedBurnersOp: %w", err) - } - txs = append(txs, gbReport.Output) - case in.PoolType == shared.AptosRegulatedTokenPoolType && in.IsTokenOwnedByMCMS: - tokenPoolStateAddress := tokenPoolObjectAddress.ResourceAccount([]byte("CcipRegulatedTokenPool")) - gmReport, err := operations.ExecuteOperation(b, operation.GrantRoleOp, deps, operation.GrantRoleInput{ - TokenCodeObjectAddress: in.TokenCodeObjAddress, - RoleNumber: module_regulated_token.BRIDGE_MINTER_OR_BURNER_ROLE, - Account: tokenPoolStateAddress, - }) - if err != nil { - return DeployTokenPoolSeqOutput{}, fmt.Errorf("failed to execute GrantRoleOp: %w", err) - } - txs = append(txs, gmReport.Output) - } - - mcmsOperations = append(mcmsOperations, mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }) - - return DeployTokenPoolSeqOutput{ - TokenPoolAddress: tokenPoolObjectAddress, - MCMSOps: mcmsOperations, - }, nil -} - -// Connect Token Pool sequence input -type ConnectTokenPoolSeqInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType - RemotePools map[uint64]RemotePool - RemotePoolsToRemove []uint64 // To re-set a pool also add its address on the removing list - TokenAddress aptos.AccountAddress - TokenTransferFeeByRemoteChainConfig map[uint64]fee_quoter.TokenTransferFeeConfig -} - -type RemotePool struct { - RemotePoolAddress []byte - RemoteTokenAddress []byte - config.RateLimiterConfig -} - -var ConnectTokenPoolSequence = operations.NewSequence( - "connect-aptos-evm-token-pools", - operation.Version1_0_0, - "Connects EVM<>Aptos lanes token pools", - connectTokenPoolSequence, -) - -func connectTokenPoolSequence(b operations.Bundle, deps dependency.AptosDeps, in ConnectTokenPoolSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - // Chain updates - applyChainUpdatesInput := operation.ApplyChainUpdatesInput{ - TokenPoolAddress: in.TokenPoolAddress, - TokenPoolType: in.TokenPoolType, - RemoteChainSelectorsToRemove: in.RemotePoolsToRemove, - RemoteChainSelectorsToAdd: nil, - RemotePoolAddresses: nil, - RemoteTokenAddresses: nil, - } - - // Remote Pool Adds - addRemotePoolsInput := operation.AddRemotePoolsInput{ - TokenPoolAddress: in.TokenPoolAddress, - TokenPoolType: in.TokenPoolType, - RemoteChainSelectors: nil, - RemotePoolAddresses: nil, - } - - // Update rate limits - setChainRLConfigsInput := operation.SetChainRLConfigsInput{ - TokenPoolAddress: in.TokenPoolAddress, - TokenPoolType: in.TokenPoolType, - RemoteChainSelectors: nil, - OutboundIsEnableds: nil, - OutboundCapacities: nil, - OutboundRates: nil, - InboundIsEnableds: nil, - InboundCapacities: nil, - InboundRates: nil, - } - - var ( - supportedChains []uint64 - err error - ) - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - supportedChains, err = managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).ManagedTokenPool().GetSupportedChains(nil) - case shared.AptosRegulatedTokenPoolType: - supportedChains, err = regulated_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).RegulatedTokenPool().GetSupportedChains(nil) - case shared.BurnFromMintTokenPool: - supportedChains, err = burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).BurnMintTokenPool().GetSupportedChains(nil) - case shared.LockReleaseTokenPool: - supportedChains, err = lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).LockReleaseTokenPool().GetSupportedChains(nil) - } - if err != nil { - b.Logger.Debugf("failed to get supported chains from token pool (%s) %s, likely because it isn't deployed yet: %v", in.TokenPoolType.String(), in.TokenPoolAddress.StringLong(), err) - } - for remoteSel, remotePool := range in.RemotePools { - // Always apply rate limits - setChainRLConfigsInput.RemoteChainSelectors = append(setChainRLConfigsInput.RemoteChainSelectors, remoteSel) - setChainRLConfigsInput.OutboundIsEnableds = append(setChainRLConfigsInput.OutboundIsEnableds, remotePool.OutboundIsEnabled) - setChainRLConfigsInput.OutboundCapacities = append(setChainRLConfigsInput.OutboundCapacities, remotePool.OutboundCapacity) - setChainRLConfigsInput.OutboundRates = append(setChainRLConfigsInput.OutboundRates, remotePool.OutboundRate) - setChainRLConfigsInput.InboundIsEnableds = append(setChainRLConfigsInput.InboundIsEnableds, remotePool.InboundIsEnabled) - setChainRLConfigsInput.InboundCapacities = append(setChainRLConfigsInput.InboundCapacities, remotePool.InboundCapacity) - setChainRLConfigsInput.InboundRates = append(setChainRLConfigsInput.InboundRates, remotePool.InboundRate) - - isSupportedChain := slices.Contains(supportedChains, remoteSel) - if !isSupportedChain { - // Only add the remote chain if it isn't supported yet - applyChainUpdatesInput.RemoteChainSelectorsToAdd = append(applyChainUpdatesInput.RemoteChainSelectorsToAdd, remoteSel) - applyChainUpdatesInput.RemotePoolAddresses = append(applyChainUpdatesInput.RemotePoolAddresses, [][]byte{remotePool.RemotePoolAddress}) - applyChainUpdatesInput.RemoteTokenAddresses = append(applyChainUpdatesInput.RemoteTokenAddresses, remotePool.RemoteTokenAddress) - } else { - // If the chain is supported, check if there's an updated remote pool that hasn't been configured yet - var configuredRemotePools [][]byte - switch in.TokenPoolType { - case shared.AptosManagedTokenPoolType: - configuredRemotePools, err = managed_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).ManagedTokenPool().GetRemotePools(nil, remoteSel) - case shared.AptosRegulatedTokenPoolType: - configuredRemotePools, err = regulated_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).RegulatedTokenPool().GetRemotePools(nil, remoteSel) - case shared.BurnFromMintTokenPool: - configuredRemotePools, err = burn_mint_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).BurnMintTokenPool().GetRemotePools(nil, remoteSel) - case shared.LockReleaseTokenPool: - configuredRemotePools, err = lock_release_token_pool.Bind(in.TokenPoolAddress, deps.AptosChain.Client).LockReleaseTokenPool().GetRemotePools(nil, remoteSel) - } - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to get remote pools from token pool (%s) %s for selector %d: %w", in.TokenPoolType.String(), in.TokenPoolAddress.StringLong(), remoteSel, err) - } - isRemotePoolSupported := false - for _, configuredRemotePool := range configuredRemotePools { - if bytes.Equal(configuredRemotePool, remotePool.RemotePoolAddress) { - isRemotePoolSupported = true - break - } - } - if !isRemotePoolSupported { - addRemotePoolsInput.RemoteChainSelectors = append(addRemotePoolsInput.RemoteChainSelectors, remoteSel) - addRemotePoolsInput.RemotePoolAddresses = append(addRemotePoolsInput.RemotePoolAddresses, remotePool.RemotePoolAddress) - } - } - } - - // Apply chain updates if there are any - if (len(applyChainUpdatesInput.RemoteChainSelectorsToAdd) + len(applyChainUpdatesInput.RemoteChainSelectorsToRemove)) > 0 { - applyChainUpdatesReport, err := operations.ExecuteOperation(b, operation.ApplyChainUpdatesOp, deps, applyChainUpdatesInput) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute ApplyChainUpdatesOp: %w", err) - } - txs = append(txs, applyChainUpdatesReport.Output) - } - - // Add remote pools if there are any to apply - if len(addRemotePoolsInput.RemoteChainSelectors) > 0 { - addRemotePoolsReport, err := operations.ExecuteOperation(b, operation.AddRemotePoolsOp, deps, addRemotePoolsInput) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute AddRemotePoolsOp: %w", err) - } - txs = append(txs, addRemotePoolsReport.Output...) - } - - // Set chain rate limiter configs - if len(setChainRLConfigsInput.RemoteChainSelectors) > 0 { - setChainRateLimiterReport, err := operations.ExecuteOperation(b, operation.SetChainRateLimiterConfigsOp, deps, setChainRLConfigsInput) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute SetChainRateLimiterConfigsOp: %w", err) - } - txs = append(txs, setChainRateLimiterReport.Output) - } - - // Apply token transfer fee configuration updates - for destSelector, feeConfig := range in.TokenTransferFeeByRemoteChainConfig { - applyTokenTransferFeeCfgInput := operation.ApplyTokenTransferFeeCfgInput{ - DestChainSelector: destSelector, - ConfigsByToken: map[string]fee_quoter.TokenTransferFeeConfig{in.TokenAddress.StringLong(): feeConfig}, - } - applyTokenTransferFeeCfgReport, err := operations.ExecuteOperation(b, operation.ApplyTokenTransferFeeCfgOp, deps, applyTokenTransferFeeCfgInput) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute ApplyTokenTransferFeeCfgOp: %w", err) - } - txs = append(txs, applyTokenTransferFeeCfgReport.Output...) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -// ######################## -// # Token Pool Ownership # -// ######################## - -type TokenPoolTransferInput struct { - TokenPoolAddress aptos.AccountAddress - To aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -type TransferTokenPoolOwnershipsSeqInput struct { - Transfers []TokenPoolTransferInput -} - -var TransferTokenPoolOwnershipsSequence = operations.NewSequence( - "transfer-token-pool-ownerships", - operation.Version1_0_0, - "Initiates the ownership transfer of one or multiple managed/BnM/LnR token pool instances to a new owner", - transferTokenPoolOwnershipSequence, -) - -func transferTokenPoolOwnershipSequence(b operations.Bundle, deps dependency.AptosDeps, in TransferTokenPoolOwnershipsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, transfer := range in.Transfers { - report, err := operations.ExecuteOperation( - b, - operation.TransferTokenPoolOwnershipOp, - deps, - operation.TransferTokenPoolOwnershipInput{ - TokenPoolAddress: transfer.TokenPoolAddress, - To: transfer.To, - TokenPoolType: transfer.TokenPoolType, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d TransferTokenPoolOwnershipOp of token pool %s: %w", i, transfer.TokenPoolAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type TokenPoolAcceptInput struct { - TokenPoolAddress aptos.AccountAddress - TokenPoolType cldf.ContractType -} - -type AcceptTokenPoolOwnershipsSeqInput struct { - Accepts []TokenPoolAcceptInput -} - -var AcceptTokenPoolOwnershipsSequence = operations.NewSequence( - "accept-token-pool-ownerships", - operation.Version1_0_0, - "Accept ownership of one or multiple managed/BnM/LnR token pool instances", - acceptTokenPoolOwnershipsSequence, -) - -func acceptTokenPoolOwnershipsSequence(b operations.Bundle, deps dependency.AptosDeps, in AcceptTokenPoolOwnershipsSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, accept := range in.Accepts { - report, err := operations.ExecuteOperation( - b, - operation.AcceptTokenPoolOwnershipOp, - deps, - operation.AcceptTokenPoolOwnershipInput{ - TokenPoolAddress: accept.TokenPoolAddress, - TokenPoolType: accept.TokenPoolType, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d AcceptTokenPoolOwnershipOp of token pool %s: %w", i, accept.TokenPoolAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} - -type ExecuteTokenPoolOwnershipTransfersSeqInput struct { - Transfers []TokenPoolTransferInput -} - -var ExecuteTokenPoolOwnershipTransfersSequence = operations.NewSequence( - "execute-token-pool-ownership-transfers", - operation.Version1_0_0, - "Executed the ownership transfer of one or multiple managed/BnM/LnR token pool instances", - executeTokenPoolOwnershipTransfersSequence, -) - -func executeTokenPoolOwnershipTransfersSequence(b operations.Bundle, deps dependency.AptosDeps, in ExecuteTokenPoolOwnershipTransfersSeqInput) (mcmstypes.BatchOperation, error) { - var txs []mcmstypes.Transaction - - for i, transfer := range in.Transfers { - report, err := operations.ExecuteOperation( - b, - operation.ExecuteTokenPoolOwnershipTransferOp, - deps, - operation.ExecuteTokenPoolOwnershipTransferInput{ - TokenPoolAddress: transfer.TokenPoolAddress, - To: transfer.To, - TokenPoolType: transfer.TokenPoolType, - }, - ) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to execute %d ExecuteTokenPoolOwnershipTransferOp of token pool %s: %w", i, transfer.TokenPoolAddress.StringLong(), err) - } - txs = append(txs, report.Output) - } - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: txs, - }, nil -} diff --git a/deployment/ccip/changeset/aptos/sequence/update_lane.go b/deployment/ccip/changeset/aptos/sequence/update_lane.go deleted file mode 100644 index f45bf4b8ac6..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/update_lane.go +++ /dev/null @@ -1,195 +0,0 @@ -package sequence - -import ( - "fmt" - "math/big" - - "github.com/aptos-labs/aptos-go-sdk" - chainsel "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" - - aptos_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - aptos_router "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router/router" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" -) - -var defaultOnRampVersion = []byte{1, 6, 0} - -type UpdateAptosLanesSeqInput struct { - UpdateFeeQuoterDestsConfig operation.UpdateFeeQuoterDestsInput - UpdateFeeQuoterPricesConfig operation.UpdateFeeQuoterPricesInput - UpdateOnRampDestsConfig operation.UpdateOnRampDestsInput - UpdateOffRampSourcesConfig operation.UpdateOffRampSourcesInput - UpdateRouterDestConfig operation.UpdateRouterDestInput -} - -// UpdateAptosLanesSequence orchestrates operations to update Aptos lanes -var UpdateAptosLanesSequence = operations.NewSequence( - "update-aptos-lanes-sequence", - operation.Version1_0_0, - "Update Aptos CCIP lanes to enable or disable connections", - updateAptosLanesSequence, -) - -func updateAptosLanesSequence(b operations.Bundle, deps dependency.AptosDeps, in UpdateAptosLanesSeqInput) (mcmstypes.BatchOperation, error) { - var mcmsTxs []mcmstypes.Transaction - - // 1. Update FeeQuoters with destination configs - b.Logger.Info("Updating destination configs on FeeQuoters") - feeQuoterDestReport, err := operations.ExecuteOperation(b, operation.UpdateFeeQuoterDestsOp, deps, in.UpdateFeeQuoterDestsConfig) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to update FeeQuoter destinations: %w", err) - } - mcmsTxs = append(mcmsTxs, feeQuoterDestReport.Output...) - - // 2. Configure destinations on OnRamps - b.Logger.Info("Updating destination configs on OnRamps") - onRampReport, err := operations.ExecuteOperation(b, operation.UpdateOnRampDestsOp, deps, in.UpdateOnRampDestsConfig) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to update OnRamp destinations: %w", err) - } - mcmsTxs = append(mcmsTxs, onRampReport.Output...) - - // 3. Configure sources on OffRamps - b.Logger.Info("Updating source configs on OffRamps") - offRampReport, err := operations.ExecuteOperation(b, operation.UpdateOffRampSourcesOp, deps, in.UpdateOffRampSourcesConfig) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to update OffRamp sources: %w", err) - } - mcmsTxs = append(mcmsTxs, offRampReport.Output...) - - // 4. Adds CCIP owner to OffRamp allow list - b.Logger.Info("Adding CCIP owner to OffRamp allow list") - allowedOfframpReport, err := operations.ExecuteOperation(b, operation.ApplyAllowedOfframpUpdatesOp, deps, operations.EmptyInput{}) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to apply allowed OffRamp updates: %w", err) - } - mcmsTxs = append(mcmsTxs, allowedOfframpReport.Output) - - // 5. Update FeeQuoters with gas prices - b.Logger.Info("Updating gas prices on FeeQuoters") - feeQuoterPricesReport, err := operations.ExecuteOperation(b, operation.UpdateFeeQuoterPricesOp, deps, in.UpdateFeeQuoterPricesConfig) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to update FeeQuoter prices: %w", err) - } - mcmsTxs = append(mcmsTxs, feeQuoterPricesReport.Output...) - - // 6. Update Router with destination OnRamp versions - b.Logger.Info("Updating Router") - routerReport, err := operations.ExecuteOperation(b, operation.UpdateRouterOp, deps, in.UpdateRouterDestConfig) - if err != nil { - return mcmstypes.BatchOperation{}, fmt.Errorf("failed to update Router: %w", err) - } - mcmsTxs = append(mcmsTxs, routerReport.Output) - - return mcmstypes.BatchOperation{ - ChainSelector: mcmstypes.ChainSelector(deps.AptosChain.Selector), - Transactions: mcmsTxs, - }, nil -} - -// ToAptosUpdateLanesConfig converts UpdateAptosLanesConfig into Aptos specific update inputs -func ToAptosUpdateLanesConfig(aptosChains map[uint64]aptosstate.CCIPChainState, cfg config.UpdateAptosLanesConfig) map[uint64]UpdateAptosLanesSeqInput { - updateInputsByAptosChain := make(map[uint64]UpdateAptosLanesSeqInput) - - // Group the operations by Aptos chain - for _, lane := range cfg.Lanes { - // Process lanes with Aptos as the source chain - if lane.Source.GetChainFamily() == chainsel.FamilyAptos { - source := lane.Source.(config.AptosChainDefinition) - if _, exists := updateInputsByAptosChain[source.Selector]; !exists { - updateInputsByAptosChain[source.Selector] = UpdateAptosLanesSeqInput{} - } - mcmsAddress := aptosChains[source.Selector].MCMSAddress - setAptosSourceUpdates(lane, updateInputsByAptosChain, cfg.TestRouter, mcmsAddress) - } - - // Process lanes with Aptos as the destination chain - if lane.Dest.GetChainFamily() == chainsel.FamilyAptos { - dest := lane.Dest.(config.AptosChainDefinition) - if _, exists := updateInputsByAptosChain[dest.Selector]; !exists { - updateInputsByAptosChain[dest.Selector] = UpdateAptosLanesSeqInput{} - } - mcmsAddress := aptosChains[dest.Selector].MCMSAddress - setAptosDestinationUpdates(lane, updateInputsByAptosChain, cfg.TestRouter, mcmsAddress) - } - } - - return updateInputsByAptosChain -} - -func setAptosSourceUpdates(lane config.LaneConfig, updateInputsByAptosChain map[uint64]UpdateAptosLanesSeqInput, isTestRouter bool, mcmsAddress aptos.AccountAddress) { - source := lane.Source.(config.AptosChainDefinition) - dest := lane.Dest.(config.EVMChainDefinition) - isEnabled := !lane.IsDisabled - - // Setting the destination on the on ramp - input := updateInputsByAptosChain[source.Selector] - if input.UpdateOnRampDestsConfig.Updates == nil { - input.UpdateOnRampDestsConfig.Updates = make(map[uint64]v1_6.OnRampDestinationUpdate) - } - input.UpdateOnRampDestsConfig.Updates[dest.Selector] = v1_6.OnRampDestinationUpdate{ - IsEnabled: isEnabled, - TestRouter: isTestRouter, - AllowListEnabled: dest.AllowListEnabled, - } - - // Setting gas prices updates - if input.UpdateFeeQuoterPricesConfig.GasPrices == nil { - input.UpdateFeeQuoterPricesConfig.GasPrices = make(map[uint64]*big.Int) - } - input.UpdateFeeQuoterPricesConfig.GasPrices[dest.Selector] = dest.GasPrice - - // Setting token prices updates - if input.UpdateFeeQuoterPricesConfig.TokenPrices == nil { - input.UpdateFeeQuoterPricesConfig.TokenPrices = make(map[string]*big.Int) - } - for tokenAddr, price := range source.TokenPrices { - input.UpdateFeeQuoterPricesConfig.TokenPrices[tokenAddr.StringLong()] = price - } - - // Setting the fee quoter destination on the source chain - if input.UpdateFeeQuoterDestsConfig.Updates == nil { - input.UpdateFeeQuoterDestsConfig.Updates = make(map[uint64]aptos_fee_quoter.DestChainConfig) - } - input.UpdateFeeQuoterDestsConfig.Updates[dest.Selector] = dest.GetConvertedAptosFeeQuoterConfig() - - // Setting Router OnRamp version updates - if input.UpdateRouterDestConfig.Updates == nil { - input.UpdateRouterDestConfig.Updates = []aptos_router.OnRampSet{} - } - onRampVersion := dest.OnRampVersion - if onRampVersion == nil { - onRampVersion = defaultOnRampVersion - } - input.UpdateRouterDestConfig.Updates = append(input.UpdateRouterDestConfig.Updates, aptos_router.OnRampSet{ - DestChainSelector: dest.Selector, - OnRampVersion: onRampVersion, - }) - - updateInputsByAptosChain[source.Selector] = input -} - -func setAptosDestinationUpdates(lane config.LaneConfig, updateInputsByAptosChain map[uint64]UpdateAptosLanesSeqInput, isTestRouter bool, mcmsAddress aptos.AccountAddress) { - source := lane.Source.(config.EVMChainDefinition) - dest := lane.Dest.(config.AptosChainDefinition) - isEnabled := !lane.IsDisabled - - // Setting off ramp updates - input := updateInputsByAptosChain[dest.Selector] - if input.UpdateOffRampSourcesConfig.Updates == nil { - input.UpdateOffRampSourcesConfig.Updates = make(map[uint64]v1_6.OffRampSourceUpdate) - } - input.UpdateOffRampSourcesConfig.Updates[source.Selector] = v1_6.OffRampSourceUpdate{ - IsEnabled: isEnabled, - TestRouter: isTestRouter, - IsRMNVerificationDisabled: source.RMNVerificationDisabled, - } - - updateInputsByAptosChain[dest.Selector] = input -} diff --git a/deployment/ccip/changeset/aptos/sequence/upgrade_ccip.go b/deployment/ccip/changeset/aptos/sequence/upgrade_ccip.go deleted file mode 100644 index 2e118440cc4..00000000000 --- a/deployment/ccip/changeset/aptos/sequence/upgrade_ccip.go +++ /dev/null @@ -1,74 +0,0 @@ -package sequence - -import ( - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/operation" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -var UpgradeCCIPSequence = operations.NewSequence( - "upgrade-aptos-ccip-sequence", - operation.Version1_0_0, - "Upgrade Aptos CCIP contracts", - upgradeCCIPSequence, -) - -func upgradeCCIPSequence(b operations.Bundle, deps dependency.AptosDeps, in config.UpgradeAptosChainConfig) ([]mcmstypes.BatchOperation, error) { - var mcmsOperations []mcmstypes.BatchOperation - mcmsAddress := deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].MCMSAddress - // Cleanup staging area - cleanupReport, err := operations.ExecuteOperation(b, operation.CleanupStagingAreaOp, deps, mcmsAddress) - if err != nil { - return nil, err - } - if len(cleanupReport.Output.Transactions) > 0 { - mcmsOperations = append(mcmsOperations, cleanupReport.Output) - } - - if in.UpgradeCCIP { - deployCCIPInput := operation.DeployCCIPInput{ - MCMSAddress: mcmsAddress, - IsUpgrade: in.UpgradeCCIP, - } - deployCCIPReport, err := operations.ExecuteOperation(b, operation.DeployCCIPOp, deps, deployCCIPInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployCCIPReport.Output.MCMSOperations)...) - } - - deployModulesInput := operation.DeployModulesInput{ - MCMSAddress: mcmsAddress, - CCIPAddress: deps.CCIPOnChainState.AptosChains[deps.AptosChain.Selector].CCIPAddress, - } - - if in.UpgradeOnRamp { - deployOnRampReport, err := operations.ExecuteOperation(b, operation.DeployOnRampOp, deps, deployModulesInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployOnRampReport.Output)...) - } - - if in.UpgradeOffRamp { - deployOffRampReport, err := operations.ExecuteOperation(b, operation.DeployOffRampOp, deps, deployModulesInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployOffRampReport.Output)...) - } - - if in.UpgradeRouter { - deployRouterReport, err := operations.ExecuteOperation(b, operation.DeployRouterOp, deps, deployModulesInput) - if err != nil { - return nil, err - } - mcmsOperations = append(mcmsOperations, utils.ToBatchOperations(deployRouterReport.Output)...) - } - - return mcmsOperations, nil -} diff --git a/deployment/ccip/changeset/aptos/test_helpers.go b/deployment/ccip/changeset/aptos/test_helpers.go deleted file mode 100644 index f9580442e2f..00000000000 --- a/deployment/ccip/changeset/aptos/test_helpers.go +++ /dev/null @@ -1,85 +0,0 @@ -package aptos - -import ( - "math/big" - "testing" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - cldftesthelpers "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils/testhelpers" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" -) - -const ( - mockMCMSAddress = "0x3f20aa841a0eb5c038775bdb868924770df1ce377cc0013b3ba4ac9fd69a4f90" - mockAddress = "0x13a9f1a109368730f2e355d831ba8fbf5942fb82321863d55de54cb4ebe5d18f" - - sepChainSelector = 11155111 - sepMockOnRampAddress = "0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59" -) - -func getTestAddressBook(t *testing.T, addrByChain map[uint64]map[string]cldf.TypeAndVersion) cldf.AddressBook { - ab := cldf.NewMemoryAddressBook() - for chain, addrTypeAndVersion := range addrByChain { - for addr, typeAndVersion := range addrTypeAndVersion { - err := ab.Save(chain, addr, typeAndVersion) - require.NoError(t, err) - } - } - return ab -} - -func MustParseAddress(t *testing.T, addr string) aptos.AccountAddress { - t.Helper() - var address aptos.AccountAddress - err := address.ParseStringRelaxed(addr) - assert.NoError(t, err) - return address -} - -func GetMockChainContractParams(t *testing.T, chainSelector uint64) config.ChainContractParams { - mockParsedAddress := MustParseAddress(t, mockAddress) - mockParsedLinkAddress := MustParseAddress(t, shared.AptosAPTAddress) - - return config.ChainContractParams{ - FeeQuoterParams: config.FeeQuoterParams{ - MaxFeeJuelsPerMsg: big.NewInt(1000000), - TokenPriceStalenessThreshold: 1000000, - FeeTokens: []aptos.AccountAddress{mockParsedLinkAddress}, - // Using default EVM values for PremiumMultiplierWeiPerEthByFeeToken - PremiumMultiplierWeiPerEthByFeeToken: map[shared.TokenSymbol]uint64{ - shared.APTSymbol: 1_000_000_000_000_000_000, - shared.LinkSymbol: 900_000_000_000_000_000, - }, - }, - OffRampParams: config.OffRampParams{ - ChainSelector: chainSelector, - PermissionlessExecutionThreshold: uint32(60 * 60 * 8), - IsRMNVerificationDisabled: []bool{false}, - SourceChainSelectors: []uint64{sepChainSelector}, - SourceChainIsEnabled: []bool{true}, - SourceChainsOnRamp: [][]byte{common.HexToAddress(sepMockOnRampAddress).Bytes()}, - }, - OnRampParams: config.OnRampParams{ - ChainSelector: chainSelector, - AllowlistAdmin: mockParsedAddress, - FeeAggregator: mockParsedAddress, - }, - } -} - -func getMockMCMSConfig(t *testing.T) cldfproposalutils.MCMSWithTimelockConfig { - return cldfproposalutils.MCMSWithTimelockConfig{ - Canceller: cldftesthelpers.SingleGroupMCMS(t), - Proposer: cldftesthelpers.SingleGroupMCMS(t), - Bypasser: cldftesthelpers.SingleGroupMCMS(t), - TimelockMinDelay: big.NewInt(1), - } -} diff --git a/deployment/ccip/changeset/aptos/utils/mcms.go b/deployment/ccip/changeset/aptos/utils/mcms.go deleted file mode 100644 index d76b756717b..00000000000 --- a/deployment/ccip/changeset/aptos/utils/mcms.go +++ /dev/null @@ -1,224 +0,0 @@ -package utils - -import ( - "encoding/json" - "errors" - "fmt" - "strings" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/smartcontractkit/mcms" - mcmssdk "github.com/smartcontractkit/mcms/sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" - - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/compile" - mcmsbind "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" -) - -const MCMSProposalVersion = "v1" - -func GenerateProposal( - env cldf.Environment, - mcmsAddress aptos.AccountAddress, - chainSel uint64, - operations []mcmstypes.BatchOperation, - description string, - mcmsCfg cldfproposalutils.TimelockConfig, -) (*mcms.TimelockProposal, error) { - // Get role from action - role, err := cldfproposalutils.GetAptosRoleFromAction(mcmsCfg.MCMSAction) - if err != nil { - return nil, fmt.Errorf("failed to get role from action: %w", err) - } - inspector := aptosmcms.NewInspector(env.BlockChains.AptosChains()[chainSel].Client, role) - - return proposeutils.BuildProposalFromBatchesV2( - env, - map[uint64]string{chainSel: mcmsAddress.StringLong()}, - map[uint64]string{chainSel: mcmsAddress.StringLong()}, - map[uint64]mcmssdk.Inspector{chainSel: inspector}, - operations, - description, - mcmsCfg, - ) -} - -// GenerateCurseMCMSProposal creates a TimelockProposal targeting the CurseMCMS -// contract. It uses NewInspectorWithMCMSType(MCMSTypeCurse) so the inspector -// reads config from the "curse_mcms" module instead of "mcms". It also sets -// MCMSType=MCMSTypeCurse in the chain metadata so downstream tools -// (mcms-tools set-signers, executor, etc.) use the correct binding. -func GenerateCurseMCMSProposal( - env cldf.Environment, - curseMCMSAddress aptos.AccountAddress, - chainSel uint64, - operations []mcmstypes.BatchOperation, - description string, - mcmsCfg cldfproposalutils.TimelockConfig, -) (*mcms.TimelockProposal, error) { - role, err := cldfproposalutils.GetAptosRoleFromAction(mcmsCfg.MCMSAction) - if err != nil { - return nil, fmt.Errorf("failed to get role from action: %w", err) - } - inspector := aptosmcms.NewInspectorWithMCMSType(env.BlockChains.AptosChains()[chainSel].Client, role, aptosmcms.MCMSTypeCurse) - - proposal, err := proposeutils.BuildProposalFromBatchesV2( - env, - map[uint64]string{chainSel: curseMCMSAddress.StringLong()}, - map[uint64]string{chainSel: curseMCMSAddress.StringLong()}, - map[uint64]mcmssdk.Inspector{chainSel: inspector}, - operations, - description, - mcmsCfg, - ) - if err != nil { - return nil, err - } - - if err := markChainMetadataAsCurseMCMS(proposal, mcmstypes.ChainSelector(chainSel)); err != nil { - return nil, fmt.Errorf("failed to set MCMSType in chain metadata: %w", err) - } - - return proposal, nil -} - -// markChainMetadataAsCurseMCMS sets MCMSType=MCMSTypeCurse in the Aptos -// AdditionalFieldsMetadata for the given chain selector. -func markChainMetadataAsCurseMCMS(proposal *mcms.TimelockProposal, cs mcmstypes.ChainSelector) error { - meta, ok := proposal.ChainMetadata[cs] - if !ok { - return fmt.Errorf("chain selector %d not found in proposal chain metadata", cs) - } - var afm aptosmcms.AdditionalFieldsMetadata - if len(meta.AdditionalFields) > 0 { - if err := json.Unmarshal(meta.AdditionalFields, &afm); err != nil { - return fmt.Errorf("unmarshal additional fields metadata: %w", err) - } - } - afm.MCMSType = aptosmcms.MCMSTypeCurse - b, err := json.Marshal(afm) - if err != nil { - return fmt.Errorf("marshal additional fields metadata: %w", err) - } - meta.AdditionalFields = b - proposal.ChainMetadata[cs] = meta - return nil -} - -// ToBatchOperations converts Operations into BatchOperations with a single transaction each -func ToBatchOperations(ops []mcmstypes.Operation) []mcmstypes.BatchOperation { - var batchOps []mcmstypes.BatchOperation - for _, op := range ops { - batchOps = append(batchOps, mcmstypes.BatchOperation{ - ChainSelector: op.ChainSelector, - Transactions: []mcmstypes.Transaction{op.Transaction}, - }) - } - return batchOps -} - -// IsMCMSStagingAreaClean checks if the MCMS staging area is clean -func IsMCMSStagingAreaClean(client aptos.AptosRpcClient, aptosMCMSObjAddr aptos.AccountAddress) (bool, error) { - resources, err := client.AccountResources(aptosMCMSObjAddr) - if err != nil { - return false, err - } - for _, resource := range resources { - if strings.Contains(resource.Type, "StagingArea") { - return false, nil - } - } - return true, nil -} - -// CreateChunksAndStage creates chunks from the compiled packages and build MCMS operations to stages them within the MCMS contract -func CreateChunksAndStage( - payload compile.CompiledPackage, - mcmsContract mcmsbind.MCMS, - chainSel uint64, - seed string, - codeObjectAddress *aptos.AccountAddress, -) ([]mcmstypes.Operation, error) { - mcmsAddress := mcmsContract.Address() - // Validate seed XOR codeObjectAddress, one and only one must be provided - if (seed != "") == (codeObjectAddress != nil) { - return nil, errors.New("either provide seed to publishToObject or objectAddress to upgradeObjectCode") - } - - var operations []mcmstypes.Operation - - // Create chunks - chunks, err := bind.CreateChunks(payload, bind.ChunkSizeInBytes) - if err != nil { - return operations, fmt.Errorf("failed to create chunks: %w", err) - } - - // Stage chunks with mcms_deployer module and execute with the last one - for i, chunk := range chunks { - var ( - moduleInfo bind.ModuleInformation - function string - args [][]byte - err error - ) - - // First chunks get staged, the last one gets published or upgraded - switch { - case i != len(chunks)-1: - moduleInfo, function, _, args, err = mcmsContract.MCMSDeployer().Encoder().StageCodeChunk( - chunk.Metadata, - chunk.CodeIndices, - chunk.Chunks, - ) - case seed != "": - moduleInfo, function, _, args, err = mcmsContract.MCMSDeployer().Encoder().StageCodeChunkAndPublishToObject( - chunk.Metadata, - chunk.CodeIndices, - chunk.Chunks, - []byte(seed), - ) - default: - moduleInfo, function, _, args, err = mcmsContract.MCMSDeployer().Encoder().StageCodeChunkAndUpgradeObjectCode( - chunk.Metadata, - chunk.CodeIndices, - chunk.Chunks, - *codeObjectAddress, - ) - } - if err != nil { - return operations, fmt.Errorf("failed to encode chunk %d: %w", i, err) - } - - tx, err := GenerateMCMSTx(mcmsAddress, moduleInfo, function, args) - if err != nil { - return operations, fmt.Errorf("failed to create transaction: %w", err) - } - - operations = append(operations, mcmstypes.Operation{ - ChainSelector: mcmstypes.ChainSelector(chainSel), - Transaction: tx, - }) - } - - return operations, nil -} - -// GenerateMCMSTx is a helper function that generates a MCMS txs for the given parameters -func GenerateMCMSTx(toAddress aptos.AccountAddress, moduleInfo bind.ModuleInformation, function string, args [][]byte) (mcmstypes.Transaction, error) { - return aptosmcms.NewTransaction( - moduleInfo.PackageName, - moduleInfo.ModuleName, - function, - toAddress, - aptosmcms.ArgsToData(args), - "", - nil, - ) -} diff --git a/deployment/ccip/changeset/aptos/utils/modules.go b/deployment/ccip/changeset/aptos/utils/modules.go deleted file mode 100644 index e3aec930ebd..00000000000 --- a/deployment/ccip/changeset/aptos/utils/modules.go +++ /dev/null @@ -1,14 +0,0 @@ -package utils - -import "github.com/aptos-labs/aptos-go-sdk" - -func IsModuleDeployed(client aptos.AptosRpcClient, address aptos.AccountAddress, moduleName string) (bool, error) { - module, err := client.AccountModule(address, moduleName) - if err != nil { - return false, err - } - if module == nil { - return false, nil - } - return true, nil -} diff --git a/deployment/ccip/changeset/testhelpers/helpers.go b/deployment/ccip/changeset/testhelpers/helpers.go index ab9e8e7ddb6..d85dafb4d91 100644 --- a/deployment/ccip/changeset/testhelpers/helpers.go +++ b/deployment/ccip/changeset/testhelpers/helpers.go @@ -3,7 +3,9 @@ package testhelpers import ( "context" "fmt" + "math" "math/big" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -11,6 +13,15 @@ import ( "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/multicall3" ) +// mcmsValidUntil converts t to a ValidUntil uint32 unix timestamp. +func mcmsValidUntil(t time.Time) (uint32, error) { + ts := t.Unix() + if ts < 0 || ts > math.MaxUint32 { + return 0, fmt.Errorf("unix timestamp %d out of range for uint32", ts) + } + return uint32(ts), nil +} + // CCIPSendCalldata packs the calldata for the Router's ccipSend method. // This is expected to be used in Multicall scenarios (i.e multiple ccipSend calls // in a single transaction). diff --git a/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go b/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go index 784c46ea87b..dcda0e47e09 100644 --- a/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go +++ b/deployment/ccip/changeset/testhelpers/test_adapter_aptos.go @@ -17,10 +17,10 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3" + aptosstate "github.com/smartcontractkit/chainlink-aptos/deployment/state" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" cldf "github.com/smartcontractkit/chainlink-deployments-framework/chain" "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" ) @@ -35,7 +35,7 @@ func NewAptosAdapter(chain cldf.BlockChain, env deployment.Environment) Adapter if !ok { panic(fmt.Sprintf("invalid chain type: %T", chain)) } - state, err := aptosstate.LoadOnchainStateAptos(env) + state, err := aptosstate.LoadOnchainState(env) if err != nil { panic(fmt.Sprintf("failed to load onchain state: %T", err)) } diff --git a/deployment/ccip/changeset/testhelpers/test_environment.go b/deployment/ccip/changeset/testhelpers/test_environment.go index 87e5a1e10c3..192def9932b 100644 --- a/deployment/ccip/changeset/testhelpers/test_environment.go +++ b/deployment/ccip/changeset/testhelpers/test_environment.go @@ -47,8 +47,13 @@ import ( sui_cs "github.com/smartcontractkit/chainlink-sui/deployment/changesets" + evmdeploy "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/deploy" + deployops "github.com/smartcontractkit/chainlink-ccip/deployment/deploy" + cciputils "github.com/smartcontractkit/chainlink-ccip/deployment/utils" + cs_ccip "github.com/smartcontractkit/chainlink-ccip/deployment/utils/changesets" + ccipmcms "github.com/smartcontractkit/chainlink-ccip/deployment/utils/mcms" + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" sui_cs_core "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/sui" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" ccipops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/evm/v1_6" @@ -770,6 +775,9 @@ func NewEnvironment(t *testing.T, tEnv TestEnvironment) DeployedEnv { tEnv.StartNodes(t, crConfig) dEnv = tEnv.DeployedEnvironment() dEnv.Env.ExistingAddresses = ab + ds, err := shared.PopulateDataStore(ab) + require.NoError(t, err) + dEnv.Env.DataStore = ds.Seal() return dEnv } @@ -1396,20 +1404,24 @@ func AddCCIPContractsToEnvironment(t *testing.T, allChains []uint64, tEnv TestEn CCIPHomeConfigType: globals.ConfigTypeActive, }, )) - apps = append(apps, commonchangeset.Configure( - // Enable the OCR config on the remote chains. - aptoscs.SetOCR3Offramp{}, - v1_6.SetOCR3OffRampConfig{ - HomeChainSel: e.HomeChainSel, - RemoteChainSels: aptosChains, - CCIPHomeConfigType: globals.ConfigTypeActive, - MCMS: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, + if len(aptosChains) > 0 { + validUntil, err := mcmsValidUntil(time.Now().Add(24 * time.Hour)) + require.NoError(t, err) + apps = append(apps, commonchangeset.Configure( + // Enable the OCR config on the remote chains. + evmdeploy.SetOCR3Config(deployops.GetRegistry(), cs_ccip.GetRegistry()), + deployops.SetOCR3ConfigArgs{ + HomeChainSel: e.HomeChainSel, + RemoteChainSels: aptosChains, + ConfigType: cciputils.ConfigTypeActive, + MCMS: ccipmcms.Input{ + ValidUntil: validUntil, + TimelockDelay: mcmstypes.NewDuration(time.Second), + TimelockAction: mcmstypes.TimelockActionSchedule, + }, }, - }, - )) + )) + } if tEnv.TestConfigs().CCIPSolanaContractVersion == ccipChangeSetSolanaV0_1_1.SolanaContractV0_1_1 { apps = append(apps, commonchangeset.Configure( // Enable the OCR config on the remote chains. diff --git a/deployment/ccip/changeset/testhelpers/test_helpers_aptos.go b/deployment/ccip/changeset/testhelpers/test_helpers_aptos.go index cdc0f265fac..bf5f1d81d99 100644 --- a/deployment/ccip/changeset/testhelpers/test_helpers_aptos.go +++ b/deployment/ccip/changeset/testhelpers/test_helpers_aptos.go @@ -39,17 +39,25 @@ import ( cldftesthelpers "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils/testhelpers" "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/burn_mint_erc677" + aptoscs "github.com/smartcontractkit/chainlink-aptos/deployment/ccip" + "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/config" + shared "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/shared" + aptosstate "github.com/smartcontractkit/chainlink-aptos/deployment/state" + aptostypes "github.com/smartcontractkit/chainlink-aptos/deployment/types" + "github.com/smartcontractkit/chainlink/deployment" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" ccipclient "github.com/smartcontractkit/chainlink/deployment/ccip/shared/client" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset" ) +func mustParseAptosAddress(t *testing.T, addr string) aptos.AccountAddress { + var address aptos.AccountAddress + require.NoError(t, address.ParseStringRelaxed(addr)) + return address +} + func DeployChainContractsToAptosCS(t *testing.T, e DeployedEnv, chainSelector uint64) commoncs.ConfiguredChangeSet { ccipConfig := config.DeployAptosChainConfig{ ContractParamsPerChain: map[uint64]config.ChainContractParams{ @@ -57,7 +65,7 @@ func DeployChainContractsToAptosCS(t *testing.T, e DeployedEnv, chainSelector ui FeeQuoterParams: config.FeeQuoterParams{ MaxFeeJuelsPerMsg: new(big.Int).Mul(big.NewInt(100_000_000), big.NewInt(1e18)), // 100M LINK @ 18 decimals TokenPriceStalenessThreshold: 24 * 60 * 60, - FeeTokens: []aptos.AccountAddress{aptoscs.MustParseAddress(t, shared.AptosAPTAddress)}, // LINK token will be deployed and added here automatically + FeeTokens: []aptos.AccountAddress{mustParseAptosAddress(t, shared.AptosAPTAddress)}, // LINK token will be deployed and added here automatically PremiumMultiplierWeiPerEthByFeeToken: map[shared.TokenSymbol]uint64{ shared.APTSymbol: 11e17, shared.LinkSymbol: 9e18, @@ -78,7 +86,7 @@ func DeployChainContractsToAptosCS(t *testing.T, e DeployedEnv, chainSelector ui }, }, }, - MCMSDeployConfigPerChain: map[uint64]cldfproposalutils.MCMSWithTimelockConfig{ + MCMSDeployConfigPerChain: map[uint64]aptostypes.MCMSWithTimelockConfigV2{ chainSelector: { Canceller: cldftesthelpers.SingleGroupMCMS(t), Proposer: cldftesthelpers.SingleGroupMCMS(t), @@ -480,7 +488,7 @@ func DeployRegulatedTransferableTokenAptos( // DeployAptosCCIPReceiver deploys the ccip_dummy_receiver package to all Aptos chains, saving the resulting address in the address book for future use func DeployAptosCCIPReceiver(t *testing.T, e cldf.Environment) { - state, err := aptosstate.LoadOnchainStateAptos(e) + state, err := aptosstate.LoadOnchainState(e) require.NoError(t, err) for selector, onchainState := range state { // ccip_dummy_receiver includes ptt_dummy_receiver, which requires resource-account deployment. diff --git a/deployment/ccip/changeset/testhelpers/test_helpers_aptos_lanes.go b/deployment/ccip/changeset/testhelpers/test_helpers_aptos_lanes.go new file mode 100644 index 00000000000..57ee9b8c95f --- /dev/null +++ b/deployment/ccip/changeset/testhelpers/test_helpers_aptos_lanes.go @@ -0,0 +1,293 @@ +package testhelpers + +import ( + "encoding/binary" + "fmt" + "math/big" + "testing" + "time" + + "github.com/Masterminds/semver/v3" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + chainsel "github.com/smartcontractkit/chain-selectors" + mcmstypes "github.com/smartcontractkit/mcms/types" + "github.com/stretchr/testify/require" + + _ "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/adapters" // register Aptos deploy/lane/curse/mcms adapters + _ "github.com/smartcontractkit/chainlink-ccip/chains/evm/deployment/v1_6_0/sequences" // register EVM deploy/lane adapters + "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_3/fee_quoter" + "github.com/smartcontractkit/chainlink-ccip/deployment/lanes" + cs_ccip "github.com/smartcontractkit/chainlink-ccip/deployment/utils/changesets" + ccipmcms "github.com/smartcontractkit/chainlink-ccip/deployment/utils/mcms" + cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" + + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" + "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" + commoncs "github.com/smartcontractkit/chainlink/deployment/common/changeset" +) + +// addAptosMixedLane wires an Aptos↔peer lane via ConnectChains, then reconciles any +// EVM router mapping the mixed-family adapters may have skipped. +func addAptosMixedLane( + t *testing.T, + e *DeployedEnv, + state stateview.CCIPOnChainState, + from, to uint64, + fromFamily, toFamily string, + isTestRouter bool, + gasPrices map[uint64]*big.Int, + tokenPrices map[string]*big.Int, + fqCfg fee_quoter.FeeQuoterDestChainConfig, +) error { + changesets := addLaneAptosChangesets(t, from, to, isTestRouter, gasPrices, tokenPrices, fqCfg) + var err error + e.Env, _, err = commoncs.ApplyChangesets(t, e.Env, changesets) + if err != nil { + return err + } + return ensureEVMRouterLaneConfig(t, e, state, from, to, fromFamily, toFamily, isTestRouter) +} + +// addLaneAptosChangesets connects an Aptos chain with its (EVM or Aptos) peer via the +// generic lanes.ConnectChains changeset, which configures both legs of the lane using the +// adapters registered by the chainlink-aptos and chainlink-ccip EVM adapter packages. +// Gas prices are keyed by chain selector (a missing entry falls back to the adapter default). +// Token prices are attached to the source chain definition; the Aptos source leg uses them +// when seeding FeeQuoter prices. +func addLaneAptosChangesets( + t *testing.T, + srcChainSelector, destChainSelector uint64, + isTestRouter bool, + gasPrices map[uint64]*big.Int, + tokenPrices map[string]*big.Int, + fqCfg fee_quoter.FeeQuoterDestChainConfig, +) []commoncs.ConfiguredChangeSet { + srcFamily, err := chainsel.GetSelectorFamily(srcChainSelector) + require.NoError(t, err) + destFamily, err := chainsel.GetSelectorFamily(destChainSelector) + require.NoError(t, err) + + if srcFamily != chainsel.FamilyAptos && destFamily != chainsel.FamilyAptos { + t.Fatalf("At least one of the provided source/destination chains has to be Aptos. srcFamily: %v destFamily: %v", srcFamily, destFamily) + } + + destFQOverride := feeQuoterDestChainConfigOverride(fqCfg) + + makeDefinition := func(selector uint64) lanes.ChainDefinition { + definition := lanes.ChainDefinition{ + Selector: selector, + GasPrice: gasPrices[selector], + RMNVerificationEnabled: false, + AllowListEnabled: false, + } + if selector == srcChainSelector { + definition.TokenPrices = tokenPrices + } + if selector == destChainSelector { + definition.FeeQuoterDestChainConfigOverrides = &destFQOverride + } + return definition + } + + validUntil, err := mcmsValidUntil(time.Now().Add(24 * time.Hour)) + require.NoError(t, err) + + return []commoncs.ConfiguredChangeSet{ + commoncs.Configure( + lanes.ConnectChains(lanes.GetLaneAdapterRegistry(), cs_ccip.GetRegistry()), + lanes.ConnectChainsConfig{ + MCMS: ccipmcms.Input{ + ValidUntil: validUntil, + TimelockDelay: mcmstypes.NewDuration(time.Second), + TimelockAction: mcmstypes.TimelockActionSchedule, + }, + Lanes: []lanes.LaneConfig{ + { + Version: semver.MustParse("1.6.0"), + ChainA: makeDefinition(srcChainSelector), + ChainB: makeDefinition(destChainSelector), + TestRouter: isTestRouter, + }, + }, + }, + ), + } +} + +func feeQuoterDestChainConfigOverride(cfg fee_quoter.FeeQuoterDestChainConfig) lanes.FeeQuoterDestChainConfigOverride { + lanesCfg := evmBindingFQToLanesFQ(cfg) + return func(dst *lanes.FeeQuoterDestChainConfig) { + *dst = lanesCfg + } +} + +func evmBindingFQToLanesFQ(cfg fee_quoter.FeeQuoterDestChainConfig) lanes.FeeQuoterDestChainConfig { + return lanes.FeeQuoterDestChainConfig{ + OverrideExistingConfig: true, + IsEnabled: cfg.IsEnabled, + MaxDataBytes: cfg.MaxDataBytes, + MaxPerMsgGasLimit: cfg.MaxPerMsgGasLimit, + DestGasOverhead: cfg.DestGasOverhead, + DestGasPerPayloadByteBase: cfg.DestGasPerPayloadByteBase, + ChainFamilySelector: binary.BigEndian.Uint32(cfg.ChainFamilySelector[:]), + DefaultTokenFeeUSDCents: cfg.DefaultTokenFeeUSDCents, + DefaultTokenDestGasOverhead: cfg.DefaultTokenDestGasOverhead, + DefaultTxGasLimit: cfg.DefaultTxGasLimit, + // #nosec G115 - test FeeQuoter configs use small network-fee values (e.g. 10 cents). + NetworkFeeUSDCents: uint16(cfg.NetworkFeeUSDCents), + V1Params: &lanes.FeeQuoterV1Params{ + MaxNumberOfTokensPerMsg: cfg.MaxNumberOfTokensPerMsg, + DestGasPerPayloadByteHigh: cfg.DestGasPerPayloadByteHigh, + DestGasPerPayloadByteThreshold: cfg.DestGasPerPayloadByteThreshold, + DestDataAvailabilityOverheadGas: cfg.DestDataAvailabilityOverheadGas, + DestGasPerDataAvailabilityByte: cfg.DestGasPerDataAvailabilityByte, + DestDataAvailabilityMultiplierBps: cfg.DestDataAvailabilityMultiplierBps, + EnforceOutOfOrder: cfg.EnforceOutOfOrder, + GasMultiplierWeiPerEth: cfg.GasMultiplierWeiPerEth, + GasPriceStalenessThreshold: cfg.GasPriceStalenessThreshold, + }, + } +} + +// ensureEVMRouterLaneConfig verifies EVM router on-ramp/off-ramp mappings for mixed +// Aptos lanes. ConnectChains should configure these via adapters; this is a narrow +// fallback that applies router-only changesets when the on-chain mapping is missing. +func ensureEVMRouterLaneConfig( + t *testing.T, + e *DeployedEnv, + state stateview.CCIPOnChainState, + from, to uint64, + fromFamily, toFamily string, + isTestRouter bool, +) error { + if fromFamily == chainsel.FamilyEVM && toFamily == chainsel.FamilyAptos { + return ensureEVMLaneLeg( + t, e, + func() (bool, error) { return evmSourceRouterWired(e, state, from, to, isTestRouter) }, + func() []commoncs.ConfiguredChangeSet { return addEVMSourceRouterRampChangesets(from, to, isTestRouter) }, + fmt.Sprintf("EVM source router on chain %d missing on-ramp for destination %d", from, to), + ) + } + + if fromFamily == chainsel.FamilyAptos && toFamily == chainsel.FamilyEVM { + return ensureEVMLaneLeg( + t, e, + func() (bool, error) { return evmDestRouterWired(e, state, to, from, isTestRouter) }, + func() []commoncs.ConfiguredChangeSet { return addEVMDestRouterRampChangesets(to, from, isTestRouter) }, + fmt.Sprintf("EVM destination router on chain %d missing off-ramp for source %d", to, from), + ) + } + + return nil +} + +func ensureEVMLaneLeg( + t *testing.T, + e *DeployedEnv, + isWired func() (bool, error), + apply func() []commoncs.ConfiguredChangeSet, + verifyErrMsg string, +) error { + wired, err := isWired() + if err != nil { + return err + } + if wired { + return nil + } + + changesets := apply() + if len(changesets) > 0 { + e.Env, _, err = commoncs.ApplyChangesets(t, e.Env, changesets) + if err != nil { + return err + } + } + + wired, err = isWired() + if err != nil { + return err + } + if !wired { + return fmt.Errorf("%s", verifyErrMsg) + } + return nil +} + +func evmSourceRouterWired(e *DeployedEnv, state stateview.CCIPOnChainState, evmSource, remoteDest uint64, isTestRouter bool) (bool, error) { + chainState := state.MustGetEVMChainState(evmSource) + routerContract := chainState.Router + if isTestRouter { + routerContract = chainState.TestRouter + } + if routerContract == nil { + return false, fmt.Errorf("router not found for EVM source chain %d", evmSource) + } + if chainState.OnRamp == nil { + return false, fmt.Errorf("on-ramp not found for EVM source chain %d", evmSource) + } + + onRamp, err := routerContract.GetOnRamp(&bind.CallOpts{Context: e.Env.GetContext()}, remoteDest) + if err != nil { + return false, fmt.Errorf("get on-ramp for EVM source chain %d and destination %d: %w", evmSource, remoteDest, err) + } + + return onRamp == chainState.OnRamp.Address(), nil +} + +func evmDestRouterWired(e *DeployedEnv, state stateview.CCIPOnChainState, evmDest, remoteSource uint64, isTestRouter bool) (bool, error) { + chainState := state.MustGetEVMChainState(evmDest) + routerContract := chainState.Router + if isTestRouter { + routerContract = chainState.TestRouter + } + if routerContract == nil { + return false, fmt.Errorf("router not found for EVM destination chain %d", evmDest) + } + if chainState.OffRamp == nil { + return false, fmt.Errorf("off-ramp not found for EVM destination chain %d", evmDest) + } + + isOffRamp, err := routerContract.IsOffRamp(&bind.CallOpts{Context: e.Env.GetContext()}, remoteSource, chainState.OffRamp.Address()) + if err != nil { + return false, fmt.Errorf("check off-ramp for EVM destination chain %d and source %d: %w", evmDest, remoteSource, err) + } + + return isOffRamp, nil +} + +func addEVMSourceRouterRampChangesets(from, to uint64, isTestRouter bool) []commoncs.ConfiguredChangeSet { + return []commoncs.ConfiguredChangeSet{ + commoncs.Configure( + cldf.CreateLegacyChangeSet(v1_6.UpdateRouterRampsChangeset), + v1_6.UpdateRouterRampsConfig{ + TestRouter: isTestRouter, + UpdatesByChain: map[uint64]v1_6.RouterUpdates{ + from: { + OnRampUpdates: map[uint64]bool{ + to: true, + }, + }, + }, + }, + ), + } +} + +func addEVMDestRouterRampChangesets(to, from uint64, isTestRouter bool) []commoncs.ConfiguredChangeSet { + return []commoncs.ConfiguredChangeSet{ + commoncs.Configure( + cldf.CreateLegacyChangeSet(v1_6.UpdateRouterRampsChangeset), + v1_6.UpdateRouterRampsConfig{ + TestRouter: isTestRouter, + UpdatesByChain: map[uint64]v1_6.RouterUpdates{ + to: { + OffRampUpdates: map[uint64]bool{ + from: true, + }, + }, + }, + }, + ), + } +} diff --git a/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go b/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go index ea977206777..e554594f3ff 100644 --- a/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go +++ b/deployment/ccip/changeset/testhelpers/test_helpers_solana_v0_1_0.go @@ -24,7 +24,6 @@ import ( "github.com/gagliardetto/solana-go/programs/token" "github.com/gagliardetto/solana-go/rpc" chainsel "github.com/smartcontractkit/chain-selectors" - mcmstypes "github.com/smartcontractkit/mcms/types" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" @@ -36,7 +35,6 @@ import ( cldlegacysolmcms "github.com/smartcontractkit/cld-changesets/legacy/pkg/family/solana" pdasol "github.com/smartcontractkit/cld-changesets/pkg/family/solana" - aptos_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" "github.com/smartcontractkit/chainlink-aptos/bindings/helpers" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_5_1/burn_mint_token_pool" @@ -76,8 +74,6 @@ import ( "github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/initial/mock_v3_aggregator_contract" "github.com/smartcontractkit/chainlink/deployment" - aptoscs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" ccipChangeSetSolanaV0_1_0 "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana_v0_1_0" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6" "github.com/smartcontractkit/chainlink/deployment/ccip/internal/bigint" @@ -950,6 +946,10 @@ func AddLane( require.NoError(t, err) changesets := []commoncs.ConfiguredChangeSet{} + if fromFamily == chainsel.FamilyAptos || toFamily == chainsel.FamilyAptos { + return addAptosMixedLane(t, e, state, from, to, fromFamily, toFamily, isTestRouter, gasPrices, tokenPrices, fqCfg) + } + switch fromFamily { case chainsel.FamilyEVM: evmTokenPrices := make(map[common.Address]*big.Int, len(tokenPrices)) @@ -959,12 +959,6 @@ func AddLane( changesets = append(changesets, AddEVMSrcChangesets(from, to, isTestRouter, gasPrices, evmTokenPrices, fqCfg)...) case chainsel.FamilySolana: changesets = append(changesets, AddLaneSolanaChangesetsV0_1_0(e, from, to, toFamily)...) - case chainsel.FamilyAptos: - aptosTokenPrices := make(map[aptos.AccountAddress]*big.Int, len(tokenPrices)) - for address, price := range tokenPrices { - aptosTokenPrices[aptoscs.MustParseAddress(t, address)] = price - } - changesets = append(changesets, AddLaneAptosChangesets(t, from, to, gasPrices, aptosTokenPrices)...) } switch toFamily { @@ -972,14 +966,13 @@ func AddLane( changesets = append(changesets, AddEVMDestChangesets(e, to, from, isTestRouter)...) case chainsel.FamilySolana: changesets = append(changesets, AddLaneSolanaChangesetsV0_1_0(e, to, from, fromFamily)...) - case chainsel.FamilyAptos: - changesets = append(changesets, AddLaneAptosChangesets(t, from, to, gasPrices, nil)...) } e.Env, _, err = commoncs.ApplyChangesets(t, e.Env, changesets) if err != nil { return err } + return nil } @@ -1048,29 +1041,22 @@ func AddLaneSolanaChangesetsV0_1_0(e *DeployedEnv, solChainSelector, remoteChain return solanaChangesets } -func AddEVMSrcChangesets(from, to uint64, isTestRouter bool, gasprice map[uint64]*big.Int, tokenPrices map[common.Address]*big.Int, fqCfg fee_quoter.FeeQuoterDestChainConfig) []commoncs.ConfiguredChangeSet { - evmSrcChangesets := []commoncs.ConfiguredChangeSet{ - commoncs.Configure( - cldf.CreateLegacyChangeSet(v1_6.UpdateOnRampsDestsChangeset), - v1_6.UpdateOnRampDestsConfig{ - UpdatesByChain: map[uint64]map[uint64]v1_6.OnRampDestinationUpdate{ - from: { - to: { - IsEnabled: true, - TestRouter: isTestRouter, - AllowListEnabled: false, - }, - }, - }, - }, - ), +func addEVMFeeQuoterDestAndPricesChangesets( + from, to uint64, + gasPrices map[uint64]*big.Int, + tokenPrices map[common.Address]*big.Int, + fqCfg fee_quoter.FeeQuoterDestChainConfig, + mcms *cldfproposalutils.TimelockConfig, +) []commoncs.ConfiguredChangeSet { + return []commoncs.ConfiguredChangeSet{ commoncs.Configure( cldf.CreateLegacyChangeSet(v1_6.UpdateFeeQuoterPricesChangeset), v1_6.UpdateFeeQuoterPricesConfig{ + MCMS: mcms, PricesByChain: map[uint64]v1_6.FeeQuoterPriceUpdatePerSource{ from: { TokenPrices: tokenPrices, - GasPrices: gasprice, + GasPrices: gasPrices, }, }, }, @@ -1078,6 +1064,7 @@ func AddEVMSrcChangesets(from, to uint64, isTestRouter bool, gasprice map[uint64 commoncs.Configure( cldf.CreateLegacyChangeSet(v1_6.UpdateFeeQuoterDestsChangeset), v1_6.UpdateFeeQuoterDestsConfig{ + MCMS: mcms, UpdatesByChain: map[uint64]map[uint64]fee_quoter.FeeQuoterDestChainConfig{ from: { to: fqCfg, @@ -1085,6 +1072,28 @@ func AddEVMSrcChangesets(from, to uint64, isTestRouter bool, gasprice map[uint64 }, }, ), + } +} + +func AddEVMSrcChangesets(from, to uint64, isTestRouter bool, gasprice map[uint64]*big.Int, tokenPrices map[common.Address]*big.Int, fqCfg fee_quoter.FeeQuoterDestChainConfig) []commoncs.ConfiguredChangeSet { + evmSrcChangesets := []commoncs.ConfiguredChangeSet{ + commoncs.Configure( + cldf.CreateLegacyChangeSet(v1_6.UpdateOnRampsDestsChangeset), + v1_6.UpdateOnRampDestsConfig{ + UpdatesByChain: map[uint64]map[uint64]v1_6.OnRampDestinationUpdate{ + from: { + to: { + IsEnabled: true, + TestRouter: isTestRouter, + AllowListEnabled: false, + }, + }, + }, + }, + ), + } + evmSrcChangesets = append(evmSrcChangesets, addEVMFeeQuoterDestAndPricesChangesets(from, to, gasprice, tokenPrices, fqCfg, nil)...) + evmSrcChangesets = append(evmSrcChangesets, commoncs.Configure( cldf.CreateLegacyChangeSet(v1_6.UpdateRouterRampsChangeset), v1_6.UpdateRouterRampsConfig{ @@ -1099,7 +1108,7 @@ func AddEVMSrcChangesets(from, to uint64, isTestRouter bool, gasprice map[uint64 }, }, ), - } + ) return evmSrcChangesets } @@ -1159,131 +1168,6 @@ func AddSuiDestChangeset(e *DeployedEnv, to, from uint64, isTestRouter bool) []c return suiDstChangesets } -func AddLaneAptosChangesets(t *testing.T, srcChainSelector, destChainSelector uint64, gasPrices map[uint64]*big.Int, tokenPrices map[aptos.AccountAddress]*big.Int) []commoncs.ConfiguredChangeSet { - srcFamily, err := chainsel.GetSelectorFamily(srcChainSelector) - require.NoError(t, err) - destFamily, err := chainsel.GetSelectorFamily(destChainSelector) - require.NoError(t, err) - - if srcFamily != chainsel.FamilyAptos && - destFamily != chainsel.FamilyAptos { - t.Fatalf("At least one of the provided source/destination chains has to be Aptos. srcFamily: %v destFamily: %v", srcFamily, destFamily) - } - - var src, dest config.ChainDefinition - - switch srcFamily { - case chainsel.FamilyEVM: - src = config.EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - }, - Selector: srcChainSelector, - }, - } - case chainsel.FamilyAptos: - src = config.AptosChainDefinition{ - TokenPrices: tokenPrices, - ConnectionConfig: v1_6.ConnectionConfig{ - RMNVerificationDisabled: true, - }, - Selector: srcChainSelector, - AddTokenTransferFeeConfigs: nil, - RemoveTokenTransferFeeConfigs: nil, - } - default: - t.Fatalf("Unsupported source chain family: %v", srcFamily) - } - - switch destFamily { - case chainsel.FamilyEVM: - dest = config.EVMChainDefinition{ - ChainDefinition: v1_6.ChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - AllowListEnabled: false, - }, - Selector: destChainSelector, - GasPrice: gasPrices[destChainSelector], - FeeQuoterDestChainConfig: fee_quoter.FeeQuoterDestChainConfig{ - IsEnabled: true, - MaxNumberOfTokensPerMsg: 10, - MaxDataBytes: 30_000, - MaxPerMsgGasLimit: 3_000_000, - DestGasOverhead: ccipevm.DestGasOverhead, - DestGasPerPayloadByteBase: ccipevm.CalldataGasPerByteBase, - DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, - DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, - DestDataAvailabilityOverheadGas: 100, - DestGasPerDataAvailabilityByte: 16, - DestDataAvailabilityMultiplierBps: 1, - ChainFamilySelector: [4]byte{0x28, 0x12, 0xd5, 0x2c}, - EnforceOutOfOrder: false, - DefaultTokenFeeUSDCents: 25, - DefaultTokenDestGasOverhead: 90_000, - DefaultTxGasLimit: 200_000, - GasMultiplierWeiPerEth: 11e8, // TODO what's the scale here ? - GasPriceStalenessThreshold: 0, - NetworkFeeUSDCents: 10, - }, - }, - OnRampVersion: []byte{1, 6, 0}, - } - case chainsel.FamilyAptos: - dest = config.AptosChainDefinition{ - ConnectionConfig: v1_6.ConnectionConfig{ - AllowListEnabled: false, - }, - Selector: destChainSelector, - GasPrice: gasPrices[destChainSelector], - FeeQuoterDestChainConfig: aptos_fee_quoter.DestChainConfig{ - IsEnabled: true, - MaxNumberOfTokensPerMsg: 10, - MaxDataBytes: 30_000, - MaxPerMsgGasLimit: 3_000_000, - DestGasOverhead: ccipevm.DestGasOverhead, - DestGasPerPayloadByteBase: ccipevm.CalldataGasPerByteBase, - DestGasPerPayloadByteHigh: ccipevm.CalldataGasPerByteHigh, - DestGasPerPayloadByteThreshold: ccipevm.CalldataGasPerByteThreshold, - DestDataAvailabilityOverheadGas: 100, - DestGasPerDataAvailabilityByte: 16, - DestDataAvailabilityMultiplierBps: 1, - ChainFamilySelector: []byte{0xac, 0x77, 0xff, 0xec}, - EnforceOutOfOrder: true, - DefaultTokenFeeUsdCents: 25, - DefaultTokenDestGasOverhead: 90_000, - DefaultTxGasLimit: 200_000, - GasMultiplierWeiPerEth: 11e17, - GasPriceStalenessThreshold: 0, - NetworkFeeUsdCents: 10, - }, - } - default: - t.Fatalf("Unsupported dstination chain family: %v", srcFamily) - } - - return []commoncs.ConfiguredChangeSet{ - commoncs.Configure( - aptoscs.AddAptosLanes{}, - config.UpdateAptosLanesConfig{ - AptosMCMSConfig: &cldfproposalutils.TimelockConfig{ - MinDelay: time.Second, - MCMSAction: mcmstypes.TimelockActionSchedule, - OverrideRoot: false, - }, - Lanes: []config.LaneConfig{ - { - Source: src, - Dest: dest, - IsDisabled: false, - }, - }, - TestRouter: false, - }, - ), - } -} - // RemoveLane removes a lane between the source and destination chains in the deployed environment. func RemoveLane(t *testing.T, e *DeployedEnv, src, dest uint64, isTestRouter bool) { var err error @@ -1943,7 +1827,7 @@ func Transfer( case chainsel.FamilyAptos: feeTokenAddr := aptos.AccountAddress{} if len(feeToken) > 0 { - feeTokenAddr = aptoscs.MustParseAddress(t, feeToken) + feeTokenAddr = mustParseAptosAddress(t, feeToken) } msg = AptosSendRequest{ Data: data, diff --git a/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go b/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go index 7804d5c2e0d..cfa7b5be477 100644 --- a/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go +++ b/deployment/ccip/changeset/v1_5_1/cs_configure_token_pools.go @@ -29,7 +29,7 @@ import ( mcmschangesets "github.com/smartcontractkit/cld-changesets/legacy/mcms/changesets" proposeutils "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" + aptosstate "github.com/smartcontractkit/chainlink-aptos/deployment/state" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/evm" solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" diff --git a/deployment/ccip/changeset/v1_6/cs_home_chain.go b/deployment/ccip/changeset/v1_6/cs_home_chain.go index dd25602ad96..187b6bdfaa6 100644 --- a/deployment/ccip/changeset/v1_6/cs_home_chain.go +++ b/deployment/ccip/changeset/v1_6/cs_home_chain.go @@ -28,6 +28,7 @@ import ( "github.com/smartcontractkit/cld-changesets/legacy/mcms/proposeutils" cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm" + "github.com/smartcontractkit/chainlink-deployments-framework/datastore" cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" @@ -72,12 +73,12 @@ func DeployHomeChainChangeset(env cldf.Environment, cfg DeployHomeChainConfig) ( } ab := cldf.NewMemoryAddressBook() // Note we also deploy the cap reg. - _, err = deployHomeChain(env.Logger, env, ab, env.BlockChains.EVMChains()[cfg.HomeChainSel], cfg.RMNStaticConfig, cfg.RMNDynamicConfig, cfg.NodeOperators, cfg.NodeP2PIDsPerNodeOpAdmin) + _, err = deployHomeChain(env.Logger, env, ab, env.ExistingAddresses, env.BlockChains.EVMChains()[cfg.HomeChainSel], cfg.RMNStaticConfig, cfg.RMNDynamicConfig, cfg.NodeOperators, cfg.NodeP2PIDsPerNodeOpAdmin) if err != nil { env.Logger.Errorw("Failed to deploy cap reg", "err", err, "addresses", env.ExistingAddresses) - ds, err2 := shared.PopulateDataStore(ab) + ds, err2 := populateHomeChainDataStore(env.ExistingAddresses, ab) if err2 != nil { - err2 = fmt.Errorf("failed to populate in-memory DataStore: %w", err) + err2 = fmt.Errorf("failed to populate in-memory DataStore: %w", err2) } return cldf.ChangesetOutput{ @@ -86,9 +87,9 @@ func DeployHomeChainChangeset(env cldf.Environment, cfg DeployHomeChainConfig) ( }, errors.Join(err, err2) } - ds, err := shared.PopulateDataStore(ab) + ds, err := populateHomeChainDataStore(env.ExistingAddresses, ab) if err != nil { - return cldf.ChangesetOutput{}, fmt.Errorf("failed to populate in-memory DataStore: %w", err) + return cldf.ChangesetOutput{}, err } return cldf.ChangesetOutput{ @@ -97,6 +98,44 @@ func DeployHomeChainChangeset(env cldf.Environment, cfg DeployHomeChainConfig) ( }, nil } +func populateHomeChainDataStore(existingAddresses cldf.AddressBook, ab cldf.AddressBook) (*datastore.MemoryDataStore, error) { + dsAb := cldf.NewMemoryAddressBook() + if existingAddresses != nil { + if err := dsAb.Merge(existingAddresses); err != nil { + return nil, fmt.Errorf("merge existing addresses for DataStore: %w", err) + } + } + if err := dsAb.Merge(ab); err != nil { + return nil, fmt.Errorf("merge new addresses for DataStore: %w", err) + } + ds, err := shared.PopulateDataStore(dsAb) + if err != nil { + return nil, fmt.Errorf("failed to populate in-memory DataStore: %w", err) + } + return ds, nil +} + +func saveExistingContractIfNeeded( + ab cldf.AddressBook, + existingAddresses cldf.AddressBook, + chainSelector uint64, + address common.Address, + tv cldf.TypeAndVersion, +) error { + if existingAddresses != nil { + addrs, err := existingAddresses.AddressesForChain(chainSelector) + if err == nil { + if _, exists := addrs[address.Hex()]; exists { + return nil + } + } + } + if err := ab.Save(chainSelector, address.Hex(), tv); err != nil { + return fmt.Errorf("save existing %s to address book: %w", tv.Type, err) + } + return nil +} + type DeployHomeChainConfig struct { HomeChainSel uint64 RMNStaticConfig rmn_home.RMNHomeStaticConfig @@ -139,6 +178,7 @@ func deployCapReg( lggr logger.Logger, state stateview.CCIPOnChainState, ab cldf.AddressBook, + existingAddresses cldf.AddressBook, chain cldf_evm.Chain, ) (*cldf.ContractDeploy[*capabilities_registry.CapabilitiesRegistry], error) { homeChainState, exists := state.Chains[chain.Selector] @@ -146,8 +186,12 @@ func deployCapReg( cr := homeChainState.CapabilityRegistry if cr != nil { lggr.Infow("Found CapabilitiesRegistry in chain state", "address", cr.Address().String()) + tv := cldf.NewTypeAndVersion(shared.CapabilitiesRegistry, deployment.Version1_0_0) + if err := saveExistingContractIfNeeded(ab, existingAddresses, chain.Selector, cr.Address(), tv); err != nil { + return nil, err + } return &cldf.ContractDeploy[*capabilities_registry.CapabilitiesRegistry]{ - Address: cr.Address(), Contract: cr, Tv: cldf.NewTypeAndVersion(shared.CapabilitiesRegistry, deployment.Version1_0_0), + Address: cr.Address(), Contract: cr, Tv: tv, }, nil } } @@ -180,6 +224,7 @@ func deployHomeChain( lggr logger.Logger, e cldf.Environment, ab cldf.AddressBook, + existingAddresses cldf.AddressBook, chain cldf_evm.Chain, rmnHomeStatic rmn_home.RMNHomeStaticConfig, rmnHomeDynamic rmn_home.RMNHomeDynamicConfig, @@ -192,7 +237,7 @@ func deployHomeChain( return nil, fmt.Errorf("failed to load onchain state: %w", err) } // Deploy CapabilitiesRegistry, CCIPHome, RMNHome - capReg, err := deployCapReg(lggr, state, ab, chain) + capReg, err := deployCapReg(lggr, state, ab, existingAddresses, chain) if err != nil { return nil, err } @@ -204,8 +249,13 @@ func deployHomeChain( } var ccipHomeAddr common.Address if state.Chains[chain.Selector].CCIPHome != nil { - lggr.Infow("CCIPHome already deployed", "addr", state.Chains[chain.Selector].CCIPHome.Address().String()) - ccipHomeAddr = state.Chains[chain.Selector].CCIPHome.Address() + ccipHome := state.Chains[chain.Selector].CCIPHome + lggr.Infow("CCIPHome already deployed", "addr", ccipHome.Address().String()) + tv := cldf.NewTypeAndVersion(shared.CCIPHome, deployment.Version1_6_0) + if err := saveExistingContractIfNeeded(ab, existingAddresses, chain.Selector, ccipHome.Address(), tv); err != nil { + return nil, err + } + ccipHomeAddr = ccipHome.Address() } else { ccipHome, err := cldf.DeployContract( lggr, chain, ab, @@ -230,8 +280,12 @@ func deployHomeChain( ccipHomeAddr = ccipHome.Address } rmnHome := state.Chains[chain.Selector].RMNHome - if state.Chains[chain.Selector].RMNHome != nil { - lggr.Infow("RMNHome already deployed", "addr", state.Chains[chain.Selector].RMNHome.Address().String()) + if rmnHome != nil { + lggr.Infow("RMNHome already deployed", "addr", rmnHome.Address().String()) + tv := cldf.NewTypeAndVersion(shared.RMNHome, deployment.Version1_6_0) + if err := saveExistingContractIfNeeded(ab, existingAddresses, chain.Selector, rmnHome.Address(), tv); err != nil { + return nil, err + } } else { rmnHomeContract, err := cldf.DeployContract( lggr, chain, ab, diff --git a/deployment/ccip/changeset/v1_6/cs_rmn_curse_uncurse.go b/deployment/ccip/changeset/v1_6/cs_rmn_curse_uncurse.go index 532e633e71f..15cea82e376 100644 --- a/deployment/ccip/changeset/v1_6/cs_rmn_curse_uncurse.go +++ b/deployment/ccip/changeset/v1_6/cs_rmn_curse_uncurse.go @@ -30,14 +30,15 @@ import ( cldfproposalutils "github.com/smartcontractkit/chainlink-deployments-framework/engine/cld/mcms/proposalutils" "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - aptosUtils "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" + "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/dependency" + aptos_ops "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/operation/rmn" + aptosUtils "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/utils" + aptosstateview "github.com/smartcontractkit/chainlink-aptos/deployment/state" + "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" - aptos_ops "github.com/smartcontractkit/chainlink/deployment/ccip/operation/aptos" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/deployergroup" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosstateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/evm" solanastateview "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" ) diff --git a/deployment/ccip/operation/aptos/rmn.go b/deployment/ccip/operation/aptos/rmn.go deleted file mode 100644 index 5e76e9494ac..00000000000 --- a/deployment/ccip/operation/aptos/rmn.go +++ /dev/null @@ -1,131 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/Masterminds/semver/v3" - "github.com/aptos-labs/aptos-go-sdk" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/utils" -) - -// allow test seams -var ( - ccipBindFn = ccip.Bind - generateMCMSTxFn = utils.GenerateMCMSTx -) - -// CurseMultipleInput is the input for cursing multiple subjects -type CurseMultipleInput struct { - CCIPAddress aptos.AccountAddress - Subjects [][]byte -} - -// OP: CurseMultipleOp generates MCMS transaction to curse multiple subjects -var CurseMultipleOp = operations.NewOperation( - "curse-multiple-op", - semver.MustParse("1.0.0"), - "Generates MCMS transaction to curse multiple subjects on RMN Remote", - curseMultiple, -) - -func curseMultiple(b operations.Bundle, deps dependency.AptosDeps, in CurseMultipleInput) (mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := in.CCIPAddress - ccipBind := ccipBindFn(ccipAddress, deps.AptosChain.Client) - - // Encode curse multiple operation - moduleInfo, function, _, args, err := ccipBind.RMNRemote().Encoder().CurseMultiple(in.Subjects) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode CurseMultiple: %w", err) - } - - // Generate MCMS transaction - tx, err := generateMCMSTxFn(ccipAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to generate MCMS transaction: %w", err) - } - - return tx, nil -} - -// UncurseMultipleInput is the input for uncursing multiple subjects -type UncurseMultipleInput struct { - CCIPAddress aptos.AccountAddress - Subjects [][]byte -} - -// OP: UncurseMultipleOp generates MCMS transaction to uncurse multiple subjects -var UncurseMultipleOp = operations.NewOperation( - "uncurse-multiple-op", - semver.MustParse("1.0.0"), - "Generates MCMS transaction to uncurse multiple subjects on RMN Remote", - uncurseMultiple, -) - -func uncurseMultiple(b operations.Bundle, deps dependency.AptosDeps, in UncurseMultipleInput) (mcmstypes.Transaction, error) { - // Bind CCIP Package - ccipAddress := in.CCIPAddress - ccipBind := ccipBindFn(ccipAddress, deps.AptosChain.Client) - - // Encode uncurse multiple operation - moduleInfo, function, _, args, err := ccipBind.RMNRemote().Encoder().UncurseMultiple(in.Subjects) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode UncurseMultiple: %w", err) - } - - // Generate MCMS transaction - tx, err := generateMCMSTxFn(ccipAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to generate MCMS transaction: %w", err) - } - - return tx, nil -} - -// InitializeAllowedCursersInput is the input for initializing allowed cursers on RMN Remote -type InitializeAllowedCursersInput struct { - CCIPAddress aptos.AccountAddress - CurseMCMSAddress aptos.AccountAddress -} - -// OP: InitializeAllowedCursersOp generates MCMS transaction to register CurseMCMS as an allowed curser on RMN Remote -var InitializeAllowedCursersOp = operations.NewOperation( - "initialize-allowed-cursers-op", - semver.MustParse("1.0.0"), - "Generates MCMS transaction to register CurseMCMS as an allowed curser on RMN Remote", - initializeAllowedCursers, -) - -func initializeAllowedCursers(b operations.Bundle, deps dependency.AptosDeps, in InitializeAllowedCursersInput) (mcmstypes.Transaction, error) { - ccipBind := ccipBindFn(in.CCIPAddress, deps.AptosChain.Client) - - moduleInfo, function, _, args, err := ccipBind.RMNRemote().Encoder().InitializeAllowedCursersV2( - []aptos.AccountAddress{in.CurseMCMSAddress}, - ) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to encode InitializeAllowedCursersV2: %w", err) - } - - tx, err := generateMCMSTxFn(in.CCIPAddress, moduleInfo, function, args) - if err != nil { - return mcmstypes.Transaction{}, fmt.Errorf("failed to generate MCMS transaction: %w", err) - } - return tx, nil -} - -// IsSubjectCursed checks whether the given subject (or a global curse) exists on the RMN Remote. -func IsSubjectCursed(deps dependency.AptosDeps, ccipAddress aptos.AccountAddress, subject []byte) (bool, error) { - ccipBind := ccipBindFn(ccipAddress, deps.AptosChain.Client) - callOpts := &bind.CallOpts{} - cursed, err := ccipBind.RMNRemote().IsCursed(callOpts, subject) - if err != nil { - return false, fmt.Errorf("failed to check if subject is cursed: %w", err) - } - return cursed, nil -} diff --git a/deployment/ccip/operation/aptos/rmn_test.go b/deployment/ccip/operation/aptos/rmn_test.go deleted file mode 100644 index 51b74574c27..00000000000 --- a/deployment/ccip/operation/aptos/rmn_test.go +++ /dev/null @@ -1,296 +0,0 @@ -package aptos - -import ( - "context" - "math/big" - "testing" - - "github.com/aptos-labs/aptos-go-sdk" - "github.com/aptos-labs/aptos-go-sdk/api" - "github.com/stretchr/testify/require" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - module_auth "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/auth" - module_fee_quoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" - module_nonce_manager "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/nonce_manager" - module_receiver_registry "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/receiver_registry" - module_rmn_remote "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/rmn_remote" - module_token_admin_registry "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/token_admin_registry" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - cldf_ops "github.com/smartcontractkit/chainlink-deployments-framework/operations" - "github.com/smartcontractkit/chainlink-deployments-framework/pkg/logger" - - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/dependency" -) - -func TestCurseMultipleOp(t *testing.T) { - restore := overrideSeams() - t.Cleanup(restore) - - ccipAddr := aptos.AccountAddress{} - subjects := [][]byte{{1, 2, 3}} - deps := dependency.AptosDeps{AptosChain: cldf_aptos.Chain{Selector: 99}} - - rmn := newStubRMNRemote() - stub := &stubCCIP{addr: ccipAddr, rmn: rmn} - ccipBindFn = func(addr aptos.AccountAddress, _ aptos.AptosRpcClient) ccip.CCIP { - require.Equal(t, ccipAddr, addr) - return stub - } - - wantTx := mcmstypes.Transaction{} - generateMCMSTxFn = func(to aptos.AccountAddress, mi bind.ModuleInformation, fn string, args [][]byte) (mcmstypes.Transaction, error) { - require.Equal(t, ccipAddr, to) - require.Equal(t, "rmn_remote", mi.ModuleName) - require.Equal(t, "curse_multiple", fn) - require.Equal(t, subjects, args) - return wantTx, nil - } - - b := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - - report, err := cldf_ops.ExecuteOperation(b, CurseMultipleOp, deps, CurseMultipleInput{ - CCIPAddress: ccipAddr, - Subjects: subjects, - }) - require.NoError(t, err) - require.Equal(t, wantTx, report.Output) - require.Equal(t, subjects, rmn.enc.lastSubjects) -} - -func TestUncurseMultipleOp(t *testing.T) { - restore := overrideSeams() - t.Cleanup(restore) - - ccipAddr := aptos.AccountAddress{} - subjects := [][]byte{{9, 8}} - deps := dependency.AptosDeps{AptosChain: cldf_aptos.Chain{Selector: 42}} - - rmn := newStubRMNRemote() - stub := &stubCCIP{addr: ccipAddr, rmn: rmn} - ccipBindFn = func(addr aptos.AccountAddress, _ aptos.AptosRpcClient) ccip.CCIP { - require.Equal(t, ccipAddr, addr) - return stub - } - - wantTx := mcmstypes.Transaction{} - generateMCMSTxFn = func(to aptos.AccountAddress, mi bind.ModuleInformation, fn string, args [][]byte) (mcmstypes.Transaction, error) { - require.Equal(t, ccipAddr, to) - require.Equal(t, "rmn_remote", mi.ModuleName) - require.Equal(t, "uncurse_multiple", fn) - require.Equal(t, subjects, args) - return wantTx, nil - } - - b := cldf_ops.NewBundle(context.Background, logger.Nop(), cldf_ops.NewMemoryReporter()) - - report, err := cldf_ops.ExecuteOperation(b, UncurseMultipleOp, deps, UncurseMultipleInput{ - CCIPAddress: ccipAddr, - Subjects: subjects, - }) - require.NoError(t, err) - require.Equal(t, wantTx, report.Output) - require.Equal(t, subjects, rmn.enc.lastSubjects) -} - -func TestIsSubjectCursed(t *testing.T) { - restore := overrideSeams() - t.Cleanup(restore) - - ccipAddr := aptos.AccountAddress{} - deps := dependency.AptosDeps{AptosChain: cldf_aptos.Chain{Selector: 7}} - wantSubject := []byte{5, 5, 5} - - rmn := newStubRMNRemote() - rmn.cursed = true - stub := &stubCCIP{addr: ccipAddr, rmn: rmn} - ccipBindFn = func(addr aptos.AccountAddress, _ aptos.AptosRpcClient) ccip.CCIP { - require.Equal(t, ccipAddr, addr) - return stub - } - - isCursed, err := IsSubjectCursed(deps, ccipAddr, wantSubject) - require.NoError(t, err) - require.True(t, isCursed) - require.Equal(t, wantSubject, rmn.lastSubject) -} - -// --- test seams and stubs --- - -func overrideSeams() func() { - origBind := ccipBindFn - origGen := generateMCMSTxFn - return func() { - ccipBindFn = origBind - generateMCMSTxFn = origGen - } -} - -type stubCCIP struct { - addr aptos.AccountAddress - rmn *stubRMNRemote -} - -func (s *stubCCIP) Address() aptos.AccountAddress { return s.addr } -func (s *stubCCIP) Auth() module_auth.AuthInterface { return nil } -func (s *stubCCIP) FeeQuoter() module_fee_quoter.FeeQuoterInterface { - return nil -} -func (s *stubCCIP) NonceManager() module_nonce_manager.NonceManagerInterface { return nil } -func (s *stubCCIP) ReceiverRegistry() module_receiver_registry.ReceiverRegistryInterface { - return nil -} -func (s *stubCCIP) TokenAdminRegistry() module_token_admin_registry.TokenAdminRegistryInterface { - return nil -} -func (s *stubCCIP) RMNRemote() module_rmn_remote.RMNRemoteInterface { return s.rmn } - -type stubRMNRemote struct { - enc *stubEncoder - cursed bool - lastSubject []byte -} - -func newStubRMNRemote() *stubRMNRemote { - return &stubRMNRemote{enc: &stubEncoder{}} -} - -func (s *stubRMNRemote) Encoder() module_rmn_remote.RMNRemoteEncoder { return s.enc } -func (s *stubRMNRemote) IsCursed(_ *bind.CallOpts, subject []byte) (bool, error) { - s.lastSubject = subject - return s.cursed, nil -} - -// Unused interface methods – keep minimal stubs to satisfy compiler. -func (s *stubRMNRemote) TypeAndVersion(*bind.CallOpts) (string, error) { return "", nil } -func (s *stubRMNRemote) Verify(*bind.CallOpts, aptos.AccountAddress, []uint64, [][]byte, []uint64, []uint64, [][]byte, [][]byte) (bool, error) { - return false, nil -} -func (s *stubRMNRemote) GetArm(*bind.CallOpts) (aptos.AccountAddress, error) { - return aptos.AccountAddress{}, nil -} -func (s *stubRMNRemote) GetVersionedConfig(*bind.CallOpts) (uint32, module_rmn_remote.Config, error) { - return 0, module_rmn_remote.Config{}, nil -} -func (s *stubRMNRemote) GetLocalChainSelector(*bind.CallOpts) (uint64, error) { return 0, nil } -func (s *stubRMNRemote) GetReportDigestHeader(*bind.CallOpts) ([]byte, error) { return nil, nil } -func (s *stubRMNRemote) GetCursedSubjects(*bind.CallOpts) ([][]byte, error) { return nil, nil } -func (s *stubRMNRemote) IsCursedGlobal(*bind.CallOpts) (bool, error) { return false, nil } -func (s *stubRMNRemote) IsCursedU128(*bind.CallOpts, *big.Int) (bool, error) { return false, nil } -func (s *stubRMNRemote) IsAllowedCurser(*bind.CallOpts, aptos.AccountAddress) (bool, error) { - return false, nil -} -func (s *stubRMNRemote) GetAllowedCursers(*bind.CallOpts) ([]aptos.AccountAddress, error) { - return nil, nil -} -func (s *stubRMNRemote) Initialize(*bind.TransactOpts, uint64) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) SetConfig(*bind.TransactOpts, []byte, [][]byte, []uint64, uint64) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) Curse(*bind.TransactOpts, []byte) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) CurseMultiple(*bind.TransactOpts, [][]byte) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) Uncurse(*bind.TransactOpts, []byte) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) InitializeAllowedCursersV2(*bind.TransactOpts, []aptos.AccountAddress) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) AddAllowedCursers(*bind.TransactOpts, []aptos.AccountAddress) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) RemoveAllowedCursers(*bind.TransactOpts, []aptos.AccountAddress) (*api.PendingTransaction, error) { - return nil, nil -} -func (s *stubRMNRemote) UncurseMultiple(*bind.TransactOpts, [][]byte) (*api.PendingTransaction, error) { - return nil, nil -} - -// encoder methods -type stubEncoder struct { - lastSubjects [][]byte -} - -func (s *stubEncoder) CurseMultiple(subjects [][]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - s.lastSubjects = subjects - return bind.ModuleInformation{ModuleName: "rmn_remote"}, "curse_multiple", nil, subjects, nil -} - -func (s *stubEncoder) UncurseMultiple(subjects [][]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - s.lastSubjects = subjects - return bind.ModuleInformation{ModuleName: "rmn_remote"}, "uncurse_multiple", nil, subjects, nil -} -func (s *stubEncoder) TypeAndVersion() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) Verify(aptos.AccountAddress, []uint64, [][]byte, []uint64, []uint64, [][]byte, [][]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetArm() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetVersionedConfig() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetLocalChainSelector() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetReportDigestHeader() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetCursedSubjects() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) IsCursedGlobal() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) IsCursed([]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) IsCursedU128(*big.Int) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) Initialize(uint64) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) SetConfig([]byte, [][]byte, []uint64, uint64) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) Curse([]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) Uncurse([]byte) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) IsAllowedCurser(aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) GetAllowedCursers() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) InitializeAllowedCursersV2([]aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) AddAllowedCursers([]aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) RemoveAllowedCursers([]aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) AssertOwnerOrAllowedCurser(aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) MCMSEntrypoint(aptos.AccountAddress) (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} -func (s *stubEncoder) RegisterMCMSEntrypoint() (bind.ModuleInformation, string, []aptos.TypeTag, [][]byte, error) { - return bind.ModuleInformation{}, "", nil, nil, nil -} diff --git a/deployment/ccip/shared/stateview/aptos/state.go b/deployment/ccip/shared/stateview/aptos/state.go deleted file mode 100644 index b188422ab51..00000000000 --- a/deployment/ccip/shared/stateview/aptos/state.go +++ /dev/null @@ -1,392 +0,0 @@ -package aptos - -import ( - "errors" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - "golang.org/x/sync/errgroup" - - module_offramp "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp/offramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/regulated_token_pool" - aptosHelpers "github.com/smartcontractkit/chainlink-aptos/bindings/helpers" - "github.com/smartcontractkit/chainlink-aptos/bindings/managed_token" - "github.com/smartcontractkit/chainlink-aptos/bindings/regulated_token" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/internal/maputils" - "github.com/smartcontractkit/chainlink/deployment/ccip/view" - aptosview "github.com/smartcontractkit/chainlink/deployment/ccip/view/aptos" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/burn_mint_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/lock_release_token_pool" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/managed_token_pool" - "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - "github.com/smartcontractkit/chainlink/deployment/common/types" -) - -type CCIPChainState struct { - MCMSAddress aptos.AccountAddress - CurseMCMSAddress aptos.AccountAddress - CCIPAddress aptos.AccountAddress - - LinkTokenAddress aptos.AccountAddress - ManagedTokens map[shared.TokenSymbol]aptos.AccountAddress - - AptosManagedTokenPools map[aptos.AccountAddress]aptos.AccountAddress // TokenAddress -> TokenPoolAddress - RegulatedTokenPools map[aptos.AccountAddress]aptos.AccountAddress // TokenAddress -> TokenPoolAddress - BurnMintTokenPools map[aptos.AccountAddress]aptos.AccountAddress // TokenAddress -> TokenPoolAddress - LockReleaseTokenPools map[aptos.AccountAddress]aptos.AccountAddress // TokenAddress -> TokenPoolAddress - - // Test contracts - TestRouterAddress aptos.AccountAddress - ReceiverAddress aptos.AccountAddress -} - -// LoadOnchainStateAptos loads chain state for Aptos chains from env -func LoadOnchainStateAptos(env cldf.Environment) (map[uint64]CCIPChainState, error) { - aptosChains := make(map[uint64]CCIPChainState) - for chainSelector := range env.BlockChains.AptosChains() { - addresses, err := env.ExistingAddresses.AddressesForChain(chainSelector) - if err != nil { - // Chain not found in address book, initialize empty - if !errors.Is(err, cldf.ErrChainNotFound) { - return aptosChains, err - } - addresses = make(map[string]cldf.TypeAndVersion) - } - chainState, err := loadAptosChainStateFromAddresses(addresses, env.BlockChains.AptosChains()[chainSelector].Client) - if err != nil { - return aptosChains, err - } - aptosChains[chainSelector] = chainState - } - return aptosChains, nil -} - -func loadAptosChainStateFromAddresses(addresses map[string]cldf.TypeAndVersion, client aptos.AptosRpcClient) (CCIPChainState, error) { - chainState := CCIPChainState{ - ManagedTokens: make(map[shared.TokenSymbol]aptos.AccountAddress), - AptosManagedTokenPools: make(map[aptos.AccountAddress]aptos.AccountAddress), - RegulatedTokenPools: make(map[aptos.AccountAddress]aptos.AccountAddress), - BurnMintTokenPools: make(map[aptos.AccountAddress]aptos.AccountAddress), - LockReleaseTokenPools: make(map[aptos.AccountAddress]aptos.AccountAddress), - } - - for addrStr, typeAndVersion := range addresses { - // Parse address - address := &aptos.AccountAddress{} - err := address.ParseStringRelaxed(addrStr) - if err != nil { - return chainState, fmt.Errorf("failed to parse address %s for %s: %w", addrStr, typeAndVersion.Type, err) - } - // Set address based on type - switch typeAndVersion.Type { - case shared.AptosMCMSType: - chainState.MCMSAddress = *address - case shared.AptosCurseMCMSType: - chainState.CurseMCMSAddress = *address - case shared.AptosCCIPType: - chainState.CCIPAddress = *address - case types.LinkToken: - chainState.LinkTokenAddress = *address - case shared.AptosReceiverType: - chainState.ReceiverAddress = *address - case shared.AptosManagedTokenType: - noLabel := typeAndVersion.Labels.IsEmpty() - symbol := shared.TokenSymbol("") - if noLabel { - token := managed_token.Bind(*address, client) - metadataAddress, err := token.ManagedToken().TokenMetadata(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get FA Metadata for ManagedToken %s: %w", addrStr, err) - } - metadata, err := aptosHelpers.GetFungibleAssetMetadata(client, metadataAddress) - if err != nil { - return chainState, fmt.Errorf("failed to get Fungible Asset Metadata for Managed Token %s: %w", addrStr, err) - } - symbol = shared.TokenSymbol(metadata.Symbol) - } else { - symbol = shared.TokenSymbol(typeAndVersion.Labels.List()[0]) - } - chainState.ManagedTokens[symbol] = *address - case shared.AptosRegulatedTokenType: - noLabel := typeAndVersion.Labels.IsEmpty() - symbol := shared.TokenSymbol("") - if noLabel { - token := regulated_token.Bind(*address, client) - metadataAddress, err := token.RegulatedToken().TokenMetadata(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get FA Metadata for RegulatedToken %s: %w", addrStr, err) - } - metadata, err := aptosHelpers.GetFungibleAssetMetadata(client, metadataAddress) - if err != nil { - return chainState, fmt.Errorf("failed to get Fungible Asset Metadata for RegulatedToken %s: %w", addrStr, err) - } - symbol = shared.TokenSymbol(metadata.Symbol) - } else { - symbol = shared.TokenSymbol(typeAndVersion.Labels.List()[0]) - } - chainState.ManagedTokens[symbol] = *address - case shared.AptosManagedTokenPoolType: - noLabel := typeAndVersion.Labels.IsEmpty() - token := aptos.AccountAddress{} - if noLabel { - pool := managed_token_pool.Bind(*address, client) - t, err := pool.ManagedTokenPool().GetToken(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get token for ManagedTokenPool %s: %w", addrStr, err) - } - token = t - } else { - labels := typeAndVersion.Labels.List() - tokenStr := labels[0] - err := token.ParseStringRelaxed(tokenStr) - if err != nil { - return chainState, fmt.Errorf("failed to parse token address %s for ManagedTokenPool %s: %w", tokenStr, addrStr, err) - } - } - chainState.AptosManagedTokenPools[token] = *address - case shared.AptosRegulatedTokenPoolType: - noLabel := typeAndVersion.Labels.IsEmpty() - token := aptos.AccountAddress{} - if noLabel { - pool := regulated_token_pool.Bind(*address, client) - t, err := pool.RegulatedTokenPool().GetToken(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get token for RegulatedTokenPool: %s: %w", addrStr, err) - } - token = t - } else { - labels := typeAndVersion.Labels.List() - tokenStr := labels[0] - err := token.ParseStringRelaxed(tokenStr) - if err != nil { - return chainState, fmt.Errorf("failed to parse token address %s for RegulatedTokenPool %s: %w", tokenStr, addrStr, err) - } - } - chainState.RegulatedTokenPools[token] = *address - case shared.BurnMintTokenPool: - noLabel := typeAndVersion.Labels.IsEmpty() - token := aptos.AccountAddress{} - if noLabel { - pool := burn_mint_token_pool.Bind(*address, client) - t, err := pool.BurnMintTokenPool().GetToken(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get token for BurnMintTokenPool %s: %w", addrStr, err) - } - token = t - } else { - labels := typeAndVersion.Labels.List() - tokenStr := labels[0] - err := token.ParseStringRelaxed(tokenStr) - if err != nil { - return chainState, fmt.Errorf("failed to parse token address %s for BurnMintTokenPool %s: %w", tokenStr, addrStr, err) - } - } - chainState.BurnMintTokenPools[token] = *address - case shared.LockReleaseTokenPool: - noLabel := typeAndVersion.Labels.IsEmpty() - token := aptos.AccountAddress{} - if noLabel { - pool := lock_release_token_pool.Bind(*address, client) - t, err := pool.LockReleaseTokenPool().GetToken(nil) - if err != nil { - return chainState, fmt.Errorf("failed to get token for LockReleaseTokenPool %s: %w", addrStr, err) - } - token = t - } else { - labels := typeAndVersion.Labels.List() - tokenStr := labels[0] - err := token.ParseStringRelaxed(tokenStr) - if err != nil { - return chainState, fmt.Errorf("failed to parse token address %s for LockReleaseTokenPool %s: %w", tokenStr, addrStr, err) - } - } - chainState.LockReleaseTokenPools[token] = *address - } - } - return chainState, nil -} - -func GetOfframpDynamicConfig(c cldf_aptos.Chain, ccipAddress aptos.AccountAddress) (module_offramp.DynamicConfig, error) { - offrampBind := ccip_offramp.Bind(ccipAddress, c.Client) - return offrampBind.Offramp().GetDynamicConfig(&bind.CallOpts{}) -} - -func FindAptosAddress(tv cldf.TypeAndVersion, addresses map[string]cldf.TypeAndVersion) aptos.AccountAddress { - for address, tandv := range addresses { - if tv.Equal(tandv) { - addr := aptos.AccountAddress{} - _ = addr.ParseStringRelaxed(address) - return addr - } - } - return aptos.AccountAddress{} -} - -func (s CCIPChainState) GenerateView(e *cldf.Environment, selector uint64, chainName string) (view.AptosChainView, error) { - lggr := e.Logger - chain := e.BlockChains.AptosChains()[selector] - chainView := view.NewAptosChainView() - errGroup := errgroup.Group{} - lggr.Infow("generating Aptos chain view", - "chain", chain.Name, - "selector", selector) - - // Tokens - errGroup.Go(func() error { - for symbol, address := range s.ManagedTokens { - tokenView, err := aptosview.GenerateTokenView(chain, address) - if err != nil { - return fmt.Errorf("failed to generate token view for managed token (%s) %s: %w", symbol, address.StringLong(), err) - } - chainView.UpdateMu.Lock() - if symbol == shared.LinkSymbol { - chainView.LinkToken = tokenView - } else { - chainView.Tokens[symbol.String()] = tokenView - } - chainView.UpdateMu.Unlock() - lggr.Infow("generated token view", "tokenAddress", address.StringLong(), "symbol", symbol, "chain", chainName) - } - return nil - }) - - // MCMS - errGroup.Go(func() error { - mcmsView, err := aptosview.GenerateMCMSWithTimelockView(chain, s.MCMSAddress) - if err != nil { - return fmt.Errorf("failed to generate MCMS with timelock view for MCMS with timelock %s: %w", s.MCMSAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.MCMSWithTimelock = mcmsView - chainView.UpdateMu.Unlock() - lggr.Infow("generated MCMS with timelock view", "MCMSAddress", s.MCMSAddress.StringLong(), "chain", chainName) - return nil - }) - - // CCIP - errGroup.Go(func() error { - ccipView, err := aptosview.GenerateCCIPView(chain, s.CCIPAddress, s.CCIPAddress) - if err != nil { - return fmt.Errorf("failed to generate CCIP view for CCIP contract %s: %w", s.CCIPAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.CCIP = ccipView - chainView.UpdateMu.Unlock() - lggr.Infow("generated CCIP view", "CCIPAddress", s.CCIPAddress.StringLong(), "chain", chainName) - return nil - }) - - errGroup.Go(func() error { - routerView, err := aptosview.GenerateRouterView(chain, s.CCIPAddress, []aptos.AccountAddress{s.CCIPAddress}, false) - if err != nil { - return fmt.Errorf("failed to generate router view for router %s: %w", s.CCIPAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.Router[s.CCIPAddress.StringLong()] = routerView - chainView.UpdateMu.Unlock() - lggr.Infow("generated router view", "routerAddress", s.CCIPAddress.StringLong(), "chain", chainName) - return nil - }) - - errGroup.Go(func() error { - onRampView, err := aptosview.GenerateOnRampView(chain, s.CCIPAddress, s.CCIPAddress, s.CCIPAddress) - if err != nil { - return fmt.Errorf("failed to generate OnRamp view for OnRamp contract %s: %w", s.CCIPAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.OnRamp[s.CCIPAddress.StringLong()] = onRampView - chainView.UpdateMu.Unlock() - lggr.Infow("generated onRamp view", "onRampAddress", s.CCIPAddress.StringLong(), "chain", chainName) - return nil - }) - - errGroup.Go(func() error { - offRampView, err := aptosview.GenerateOffRampView(chain, s.CCIPAddress, s.CCIPAddress) - if err != nil { - return fmt.Errorf("failed to generate OffRamp view for OffRamp contract %s: %w", s.CCIPAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.OffRamp[s.CCIPAddress.StringLong()] = offRampView - chainView.UpdateMu.Unlock() - lggr.Infow("gneerated offRamp view", "offRampAddress", s.CCIPAddress.StringLong(), "chain", chainName) - return nil - }) - - // Token pools - errGroup.Go(func() error { - for tokenAddress, tokenPoolAddress := range s.AptosManagedTokenPools { - faMetadata, err := aptosHelpers.GetFungibleAssetMetadata(chain.Client, tokenAddress) - if err != nil { - return fmt.Errorf("failed to get fungible asset metadata for token %s: %w", tokenAddress, err) - } - contract := managed_token_pool.Bind(tokenPoolAddress, chain.Client) - tokenPoolView, err := aptosview.GenerateTokenPoolView(chain, tokenPoolAddress, contract.ManagedTokenPool()) - if err != nil { - return fmt.Errorf("failed to generate token pool view for ManagedTokenPool %s: %w", tokenPoolAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.TokenPools = maputils.AddValueToNestedMap(chainView.TokenPools, faMetadata.Symbol, tokenPoolAddress.StringLong(), tokenPoolView) - chainView.UpdateMu.Unlock() - } - return nil - }) - errGroup.Go(func() error { - for tokenAddress, tokenPoolAddress := range s.RegulatedTokenPools { - faMetadata, err := aptosHelpers.GetFungibleAssetMetadata(chain.Client, tokenAddress) - if err != nil { - return fmt.Errorf("failed to get fungible asset metadata for token %s: %w", tokenAddress, err) - } - contract := regulated_token_pool.Bind(tokenPoolAddress, chain.Client) - tokenPoolView, err := aptosview.GenerateTokenPoolView(chain, tokenPoolAddress, contract.RegulatedTokenPool()) - if err != nil { - return fmt.Errorf("failed to generate token pool view for RegulatedTokenPool %s: %w", tokenPoolAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.TokenPools = maputils.AddValueToNestedMap(chainView.TokenPools, faMetadata.Symbol, tokenPoolAddress.StringLong(), tokenPoolView) - chainView.UpdateMu.Unlock() - } - return nil - }) - errGroup.Go(func() error { - for tokenAddress, tokenPoolAddress := range s.BurnMintTokenPools { - faMetadata, err := aptosHelpers.GetFungibleAssetMetadata(chain.Client, tokenAddress) - if err != nil { - return fmt.Errorf("failed to get fungible asset metadata for token %s: %w", tokenAddress, err) - } - contract := burn_mint_token_pool.Bind(tokenPoolAddress, chain.Client) - tokenPoolView, err := aptosview.GenerateTokenPoolView(chain, tokenPoolAddress, contract.BurnMintTokenPool()) - if err != nil { - return fmt.Errorf("failed to generate token pool view for BurnMintTokenPool %s: %w", tokenPoolAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.TokenPools = maputils.AddValueToNestedMap(chainView.TokenPools, faMetadata.Symbol, tokenPoolAddress.StringLong(), tokenPoolView) - chainView.UpdateMu.Unlock() - } - return nil - }) - errGroup.Go(func() error { - for tokenAddress, tokenPoolAddress := range s.LockReleaseTokenPools { - faMetadata, err := aptosHelpers.GetFungibleAssetMetadata(chain.Client, tokenAddress) - if err != nil { - return fmt.Errorf("failed to get fungible asset metadata for token %s: %w", tokenAddress, err) - } - contract := lock_release_token_pool.Bind(tokenPoolAddress, chain.Client) - tokenPoolView, err := aptosview.GenerateTokenPoolView(chain, tokenPoolAddress, contract.LockReleaseTokenPool()) - if err != nil { - return fmt.Errorf("failed to generate token pool view for LockReleaseTokenPool %s: %w", tokenPoolAddress.StringLong(), err) - } - chainView.UpdateMu.Lock() - chainView.TokenPools = maputils.AddValueToNestedMap(chainView.TokenPools, faMetadata.Symbol, tokenPoolAddress.StringLong(), tokenPoolView) - chainView.UpdateMu.Unlock() - } - return nil - }) - - return chainView, errGroup.Wait() -} diff --git a/deployment/ccip/shared/stateview/state.go b/deployment/ccip/shared/stateview/state.go index 1795c017ed6..16a85c70e2f 100644 --- a/deployment/ccip/shared/stateview/state.go +++ b/deployment/ccip/shared/stateview/state.go @@ -43,9 +43,10 @@ import ( suistate "github.com/smartcontractkit/chainlink-sui/deployment" tonstate "github.com/smartcontractkit/chainlink-ton/deployment/state" + aptosstate "github.com/smartcontractkit/chainlink-aptos/deployment/state" + "github.com/smartcontractkit/chainlink/deployment/ccip/internal/maputils" ccipshared "github.com/smartcontractkit/chainlink/deployment/ccip/shared" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/evm" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" @@ -1042,7 +1043,7 @@ func LoadOnchainState(e cldf.Environment, opts ...LoadOption) (CCIPOnChainState, if err != nil { return CCIPOnChainState{}, err } - aptosChains, err := aptosstate.LoadOnchainStateAptos(e) + aptosChains, err := aptosstate.LoadOnchainState(e) if err != nil { return CCIPOnChainState{}, err } diff --git a/deployment/ccip/view/aptos/ccip.go b/deployment/ccip/view/aptos/ccip.go deleted file mode 100644 index f892e99d416..00000000000 --- a/deployment/ccip/view/aptos/ccip.go +++ /dev/null @@ -1,254 +0,0 @@ -package aptos - -import ( - "encoding/hex" - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - chainselectors "github.com/smartcontractkit/chain-selectors" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/globals" -) - -type CCIPView struct { - ContractMetaData - - FeeQuoter FeeQuoterView `json:"feeQuoter"` - RMNRemote RMNRemoteView `json:"rmnRemote"` - TokenAdminRegistry TokenAdminRegistryView `json:"tokenAdminRegistry"` - NonceManager NonceManagerView `json:"nonceManager"` - ReceiverRegistry ReceiverRegistryView `json:"receiverRegistry"` -} - -type FeeQuoterView struct { - ContractMetaData - - FeeTokens []string `json:"feeTokens"` - StaticConfig FeeQuoterStaticConfig `json:"staticConfig"` - DestinationChainConfigs map[uint64]FeeQuoterDestChainConfig `json:"destinationChainConfigs"` -} - -type FeeQuoterStaticConfig struct { - MaxFeeJuelsPerMsg string `json:"maxFeeJuelsPerMsg"` - LinkToken string `json:"linkToken"` - TokenPriceStalenessThreshold uint64 `json:"tokenPriceStalenessThreshold"` -} - -type FeeQuoterDestChainConfig struct { - IsEnabled bool `json:"isEnabled"` - MaxNumberOfTokensPerMsg uint16 `json:"maxNumberOfTokensPerMsg"` - MaxDataBytes uint32 `json:"maxDataBytes"` - MaxPerMsgGasLimit uint32 `json:"maxPerMsgGasLimit"` - DestGasOverhead uint32 `json:"destGasOverhead"` - DestGasPerPayloadByteBase uint8 `json:"destGasPerPayloadByteBase"` - DestGasPerPayloadByteHigh uint8 `json:"destGasPerPayloadByteHigh"` - DestGasPerPayloadByteThreshold uint16 `json:"destGasPerPayloadByteThreshold"` - DestDataAvailabilityOverheadGas uint32 `json:"destDataAvailabilityOverheadGas"` - DestGasPerDataAvailabilityByte uint16 `json:"destGasPerDataAvailabilityByte"` - DestDataAvailabilityMultiplierBps uint16 `json:"destDataAvailabilityMultiplierBps"` - ChainFamilySelector string `json:"chainFamilySelector"` - EnforceOutOfOrder bool `json:"enforceOutOfOrder"` - DefaultTokenFeeUsdCents uint16 `json:"defaultTokenFeeUsdCents"` - DefaultTokenDestGasOverhead uint32 `json:"defaultTokenDestGasOverhead"` - DefaultTxGasLimit uint32 `json:"defaultTxGasLimit"` - GasMultiplierWeiPerEth uint64 `json:"gasMultiplierWeiPerEth"` - GasPriceStalenessThreshold uint32 `json:"gasPriceStalenessThreshold"` - NetworkFeeUsdCents uint32 `json:"networkFeeUsdCents"` -} - -type RMNRemoteView struct { - ContractMetaData - IsCursed bool `json:"isCursed"` - Config RMNRemoteVersionedConfig `json:"config"` - CursedSubjectEntries []RMNRemoteCurseEntry `json:"cursedSubjectEntries"` -} - -type RMNRemoteVersionedConfig struct { - Version uint32 `json:"version"` - Signers []RMNRemoteSigner `json:"signers"` - Fsign uint64 `json:"fSign"` -} - -type RMNRemoteSigner struct { - OnchainPublicKey string `json:"onchain_public_key"` // Follow EVM snake_case - NodeIndex uint64 `json:"node_index"` -} - -type RMNRemoteCurseEntry struct { - Subject string `json:"subject"` - Selector uint64 `json:"selector"` -} - -type TokenAdminRegistryView struct { - ContractMetaData -} - -type NonceManagerView struct { - ContractMetaData -} - -type ReceiverRegistryView struct { - ContractMetaData -} - -func GenerateCCIPView(chain cldf_aptos.Chain, ccipAddress aptos.AccountAddress, routerAddress aptos.AccountAddress) (CCIPView, error) { - boundCCIP := ccip.Bind(ccipAddress, chain.Client) - boundRouter := ccip_router.Bind(ccipAddress, chain.Client) - - ccipOwner, err := boundCCIP.Auth().Owner(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get owner of CCIP %s: %w", ccipAddress.StringLong(), err) - } - - // Router - destChainSelectors, err := boundRouter.Router().GetDestChains(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get destChains of router %s: %w", routerAddress.StringLong(), err) - } - - // FeeQuoter - feeQuoterTypeAndVersion, err := boundCCIP.FeeQuoter().TypeAndVersion(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get typeAndVersion of feeQuoter %s: %w", ccipAddress.StringLong(), err) - } - feeQuoterStaticConfig, err := boundCCIP.FeeQuoter().GetStaticConfig(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get staticConfig of feeQuoter %s: %w", ccipAddress.StringLong(), err) - } - feeQuoterFeeTkns, err := boundCCIP.FeeQuoter().GetFeeTokens(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get feeTokens of feeQuoter %s: %w", ccipAddress.StringLong(), err) - } - feeQuoterFeeTokens := make([]string, len(feeQuoterFeeTkns)) - for i, feeToken := range feeQuoterFeeTkns { - feeQuoterFeeTokens[i] = feeToken.StringLong() - } - destinationChainConfigs := make(map[uint64]FeeQuoterDestChainConfig, len(destChainSelectors)) - for _, selector := range destChainSelectors { - destChainConfig, err := boundCCIP.FeeQuoter().GetDestChainConfig(nil, selector) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get destChainConfig for chain %d of feeQuoter %s: %w", selector, ccipAddress.StringLong(), err) - } - destinationChainConfigs[selector] = FeeQuoterDestChainConfig{ - IsEnabled: destChainConfig.IsEnabled, - MaxNumberOfTokensPerMsg: destChainConfig.MaxNumberOfTokensPerMsg, - MaxDataBytes: destChainConfig.MaxDataBytes, - MaxPerMsgGasLimit: destChainConfig.MaxPerMsgGasLimit, - DestGasOverhead: destChainConfig.DestGasOverhead, - DestGasPerPayloadByteBase: destChainConfig.DestGasPerPayloadByteBase, - DestGasPerPayloadByteHigh: destChainConfig.DestGasPerPayloadByteHigh, - DestGasPerPayloadByteThreshold: destChainConfig.DestGasPerPayloadByteThreshold, - DestDataAvailabilityOverheadGas: destChainConfig.DestDataAvailabilityOverheadGas, - DestGasPerDataAvailabilityByte: destChainConfig.DestGasPerDataAvailabilityByte, - DestDataAvailabilityMultiplierBps: destChainConfig.DestDataAvailabilityMultiplierBps, - ChainFamilySelector: hex.EncodeToString(destChainConfig.ChainFamilySelector), - EnforceOutOfOrder: destChainConfig.EnforceOutOfOrder, - DefaultTokenFeeUsdCents: destChainConfig.DefaultTokenFeeUsdCents, - DefaultTokenDestGasOverhead: destChainConfig.DefaultTokenDestGasOverhead, - DefaultTxGasLimit: destChainConfig.DefaultTxGasLimit, - GasMultiplierWeiPerEth: destChainConfig.GasMultiplierWeiPerEth, - GasPriceStalenessThreshold: destChainConfig.GasPriceStalenessThreshold, - NetworkFeeUsdCents: destChainConfig.NetworkFeeUsdCents, - } - } - - // RMNRemote - rmnRemoteTypeAndVersion, err := boundCCIP.RMNRemote().TypeAndVersion(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get typeAndVersion of RMNRemote %s: %w", ccipAddress.StringLong(), err) - } - cursedSubjects, err := boundCCIP.RMNRemote().GetCursedSubjects(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get cursedSubjects of RMNRemote %s: %w", ccipAddress.StringLong(), err) - } - cursedSubjectEntries := make([]RMNRemoteCurseEntry, len(cursedSubjects)) - for i, subject := range cursedSubjects { - cursedSubjectEntries[i] = RMNRemoteCurseEntry{ - Subject: hex.EncodeToString(subject), - Selector: globals.FamilyAwareSubjectToSelector(globals.Subject(subject), chainselectors.FamilyAptos), - } - } - version, rmnRemoteConfig, err := boundCCIP.RMNRemote().GetVersionedConfig(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get versionedConfig of RMNRemote %s: %w", ccipAddress.StringLong(), err) - } - rmnRemoteVersionedConfig := RMNRemoteVersionedConfig{ - Version: version, - Signers: make([]RMNRemoteSigner, len(rmnRemoteConfig.Signers)), - Fsign: rmnRemoteConfig.FSign, - } - for i, signer := range rmnRemoteConfig.Signers { - rmnRemoteVersionedConfig.Signers[i] = RMNRemoteSigner{ - OnchainPublicKey: string(signer.OnchainPublicKey), - NodeIndex: signer.NodeIndex, - } - } - - // Token Admin Registry - tokenAdminRegistryTypeAndVersion, err := boundCCIP.TokenAdminRegistry().TypeAndVersion(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get typeAndVersion of TokenAdminRegistry %s: %w", ccipAddress.StringLong(), err) - } - - // Nonce Manager - nonceManagerTypeAndVersion, err := boundCCIP.NonceManager().TypeAndVersion(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get typeAndVersion of NonceManager %s: %w", ccipAddress.StringLong(), err) - } - - // Receiver Registry - receiverRegistryTypeAndVersion, err := boundCCIP.ReceiverRegistry().TypeAndVersion(nil) - if err != nil { - return CCIPView{}, fmt.Errorf("failed to get typeAndVersion of ReceiverRegistry %s: %w", ccipAddress.StringLong(), err) - } - - return CCIPView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - Owner: ccipOwner.StringLong(), - }, - FeeQuoter: FeeQuoterView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - TypeAndVersion: feeQuoterTypeAndVersion, - }, - FeeTokens: feeQuoterFeeTokens, - StaticConfig: FeeQuoterStaticConfig{ - MaxFeeJuelsPerMsg: feeQuoterStaticConfig.MaxFeeJuelsPerMsg.String(), - LinkToken: feeQuoterStaticConfig.LinkToken.StringLong(), - TokenPriceStalenessThreshold: feeQuoterStaticConfig.TokenPriceStalenessThreshold, - }, - DestinationChainConfigs: destinationChainConfigs, - }, - RMNRemote: RMNRemoteView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - TypeAndVersion: rmnRemoteTypeAndVersion, - }, - IsCursed: len(cursedSubjectEntries) != 0, - Config: rmnRemoteVersionedConfig, - CursedSubjectEntries: cursedSubjectEntries, - }, - TokenAdminRegistry: TokenAdminRegistryView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - TypeAndVersion: tokenAdminRegistryTypeAndVersion, - }, - }, - NonceManager: NonceManagerView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - TypeAndVersion: nonceManagerTypeAndVersion, - }, - }, - ReceiverRegistry: ReceiverRegistryView{ - ContractMetaData: ContractMetaData{ - Address: ccipAddress.StringLong(), - TypeAndVersion: receiverRegistryTypeAndVersion, - }, - }, - }, nil -} diff --git a/deployment/ccip/view/aptos/contract_metadata.go b/deployment/ccip/view/aptos/contract_metadata.go deleted file mode 100644 index 39f9f7a3dc4..00000000000 --- a/deployment/ccip/view/aptos/contract_metadata.go +++ /dev/null @@ -1,7 +0,0 @@ -package aptos - -type ContractMetaData struct { - Address string `json:"address,omitempty"` - Owner string `json:"owner,omitempty"` - TypeAndVersion string `json:"typeAndVersion,omitempty"` -} diff --git a/deployment/ccip/view/aptos/mcms.go b/deployment/ccip/view/aptos/mcms.go deleted file mode 100644 index 7453515c2f0..00000000000 --- a/deployment/ccip/view/aptos/mcms.go +++ /dev/null @@ -1,95 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - aptosmcms "github.com/smartcontractkit/mcms/sdk/aptos" - mcmstypes "github.com/smartcontractkit/mcms/types" - - "github.com/smartcontractkit/chainlink-aptos/bindings/mcms" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" -) - -type MCMSWithTimelockView struct { - ContractMetaData - - Bypasser mcmstypes.Config - Proposer mcmstypes.Config - Canceller mcmstypes.Config - - TimelockMinDelay uint64 - TimelockBlockedFunctions []TimelockBlockedFunction -} - -type TimelockBlockedFunction struct { - Target string - ModuleName string - FunctionName string -} - -func GenerateMCMSWithTimelockView(chain cldf_aptos.Chain, mcmsAddress aptos.AccountAddress) (MCMSWithTimelockView, error) { - boundMCMS := mcms.Bind(mcmsAddress, chain.Client) - - mcmsOwner, err := boundMCMS.MCMSAccount().Owner(nil) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to retrieve owner of MCMS: %w", err) - } - - // Query configs - configTransformer := aptosmcms.NewConfigTransformer() - bypasserCfg, err := boundMCMS.MCMS().GetConfig(nil, aptosmcms.TimelockRoleBypasser.Byte()) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to query bypasser config: %w", err) - } - bypasserConfig, err := configTransformer.ToConfig(bypasserCfg) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to convert aptos bypasser config: %w", err) - } - proposerCfg, err := boundMCMS.MCMS().GetConfig(nil, aptosmcms.TimelockRoleProposer.Byte()) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to query proposer config: %w", err) - } - proposerConfig, err := configTransformer.ToConfig(proposerCfg) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to convert aptos proposer config: %w", err) - } - cancellerCfg, err := boundMCMS.MCMS().GetConfig(nil, aptosmcms.TimelockRoleCanceller.Byte()) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to query canceler config: %w", err) - } - cancellerConfig, err := configTransformer.ToConfig(cancellerCfg) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to convert aptos canceller config: %w", err) - } - - // Timelock - timelockMinDelay, err := boundMCMS.MCMS().TimelockMinDelay(nil) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to query timelock min delay: %w", err) - } - blockedFunctions, err := boundMCMS.MCMS().TimelockGetBlockedFunctions(nil) - if err != nil { - return MCMSWithTimelockView{}, fmt.Errorf("failed to query timelock blocked functions: %w", err) - } - TimelockBlockedFunctions := make([]TimelockBlockedFunction, len(blockedFunctions)) - for i, function := range blockedFunctions { - TimelockBlockedFunctions[i] = TimelockBlockedFunction{ - Target: function.Target.StringLong(), - ModuleName: function.ModuleName, - FunctionName: function.FunctionName, - } - } - - return MCMSWithTimelockView{ - ContractMetaData: ContractMetaData{ - Address: mcmsAddress.StringLong(), - Owner: mcmsOwner.StringLong(), - }, - Bypasser: *bypasserConfig, - Proposer: *proposerConfig, - Canceller: *cancellerConfig, - - TimelockMinDelay: timelockMinDelay, - }, nil -} diff --git a/deployment/ccip/view/aptos/offramp.go b/deployment/ccip/view/aptos/offramp.go deleted file mode 100644 index b193e0dc5fc..00000000000 --- a/deployment/ccip/view/aptos/offramp.go +++ /dev/null @@ -1,100 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/view/shared" -) - -type OffRampView struct { - ContractMetaData - - StaticConfig OffRampStaticConfig `json:"staticConfig"` - DynamicConfig OffRampDynamicConfig `json:"dynamicConfig"` - SourceChainConfigs map[uint64]OffRampSourceChainConfig `json:"sourceChainConfigs"` -} - -type OffRampStaticConfig struct { - ChainSelector uint64 - RMNRemote string - TokenAdminRegistry string - NonceManager string -} - -type OffRampDynamicConfig struct { - FeeQuoter string - PermissionlessExecutionThresholdSeconds uint32 -} - -type OffRampSourceChainConfig struct { - Router string - IsEnabled bool - IsRMNVerificationDisabled bool - OnRamp string -} - -func GenerateOffRampView(chain cldf_aptos.Chain, offRampAddress aptos.AccountAddress, routerAddress aptos.AccountAddress) (OffRampView, error) { - boundOffRamp := ccip_offramp.Bind(offRampAddress, chain.Client) - boundRouter := ccip_router.Bind(routerAddress, chain.Client) - - typeAndVersion, err := boundOffRamp.Offramp().TypeAndVersion(nil) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get typeAndVersion of offramp %s: %w", offRampAddress.StringLong(), err) - } - owner, err := boundOffRamp.Offramp().Owner(nil) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get owner of offRamp %s: %w", offRampAddress.StringLong(), err) - } - - destChainSelectors, err := boundRouter.Router().GetDestChains(nil) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get destChainSelectors of router %s: %w", routerAddress.StringLong(), err) - } - - staticConfig, err := boundOffRamp.Offramp().GetStaticConfig(nil) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get staticConfig of offramp %s: %w", offRampAddress.StringLong(), err) - } - dynamicConfig, err := boundOffRamp.Offramp().GetDynamicConfig(nil) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get dynamicConfig of offramp %s: %w", offRampAddress.StringLong(), err) - } - - sourceChainConfigs := make(map[uint64]OffRampSourceChainConfig, len(destChainSelectors)) - for _, destChainSelector := range destChainSelectors { - sourceChainConfig, err := boundOffRamp.Offramp().GetSourceChainConfig(nil, destChainSelector) - if err != nil { - return OffRampView{}, fmt.Errorf("failed to get sourceChainConfig for chain %d of offRamp %s: %w", destChainSelector, offRampAddress.StringLong(), err) - } - sourceChainConfigs[destChainSelector] = OffRampSourceChainConfig{ - Router: sourceChainConfig.Router.StringLong(), - IsEnabled: sourceChainConfig.IsEnabled, - IsRMNVerificationDisabled: sourceChainConfig.IsRMNVerificationDisabled, - OnRamp: shared.GetAddressFromBytes(destChainSelector, sourceChainConfig.OnRamp), - } - } - - return OffRampView{ - ContractMetaData: ContractMetaData{ - Address: offRampAddress.StringLong(), - Owner: owner.StringLong(), - TypeAndVersion: typeAndVersion, - }, - StaticConfig: OffRampStaticConfig{ - ChainSelector: staticConfig.ChainSelector, - RMNRemote: staticConfig.RMNRemote.StringLong(), - TokenAdminRegistry: staticConfig.TokenAdminRegistry.StringLong(), - NonceManager: staticConfig.NonceManager.StringLong(), - }, - DynamicConfig: OffRampDynamicConfig{ - FeeQuoter: dynamicConfig.FeeQuoter.StringLong(), - PermissionlessExecutionThresholdSeconds: dynamicConfig.PermissionlessExecutionThresholdSeconds, - }, - SourceChainConfigs: sourceChainConfigs, - }, nil -} diff --git a/deployment/ccip/view/aptos/onramp.go b/deployment/ccip/view/aptos/onramp.go deleted file mode 100644 index a24f0c45430..00000000000 --- a/deployment/ccip/view/aptos/onramp.go +++ /dev/null @@ -1,144 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_onramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" -) - -type OnRampView struct { - ContractMetaData - - StaticConfig OnRampStaticConfig `json:"staticConfig"` - DynamicConfig OnRampDynamicConfig `json:"dynamicConfig"` - SourceTokenToPool map[string]string `json:"sourceTokenToPool"` - DestChainSpecificData map[uint64]DestChainSpecificData `json:"destChainSpecificData"` -} - -type OnRampStaticConfig struct { - ChainSelector uint64 -} - -type OnRampDynamicConfig struct { - FeeAggregator string - AllowlistAdmin string -} - -type DestChainSpecificData struct { - AllowedSendersList []string `json:"allowedSendersList"` - DestChainConfig OnRampDestChainConfig `json:"destChainConfig"` -} - -type OnRampDestChainConfig struct { - AllowlistEnabled bool - Router string - RouterStateAddress string -} - -func GenerateOnRampView( - chain cldf_aptos.Chain, - onRampAddress aptos.AccountAddress, - routerAddress aptos.AccountAddress, - ccipAddress aptos.AccountAddress, -) (OnRampView, error) { - boundOnRamp := ccip_onramp.Bind(onRampAddress, chain.Client) - boundRouter := ccip_router.Bind(routerAddress, chain.Client) - boundCCIP := ccip.Bind(ccipAddress, chain.Client) - - typeAndVersion, err := boundOnRamp.Onramp().TypeAndVersion(nil) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get typeAndVersion of onRamp %s: %w", onRampAddress.StringLong(), err) - } - destinationChainSelectors, err := boundRouter.Router().GetDestChains(nil) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get destChainSelectors of router %s: %w", routerAddress.StringLong(), err) - } - - owner, err := boundOnRamp.Onramp().Owner(nil) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get owner of onramp %s: %w", onRampAddress.StringLong(), err) - } - staticConfig, err := boundOnRamp.Onramp().GetStaticConfig(nil) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get staticConfig of onRamp %s: %w", onRampAddress.StringLong(), err) - } - dynamicConfig, err := boundOnRamp.Onramp().GetDynamicConfig(nil) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get dynamicConfig of onRamp %s: %w", onRampAddress.StringLong(), err) - } - - nodeInfo, err := chain.Client.Info() - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get node info from Aptos client: %w", err) - } - ledgerVersion := nodeInfo.LedgerVersion() - callOpts := &bind.CallOpts{ - LedgerVersion: &ledgerVersion, - } - var ( - sourceTokens []aptos.AccountAddress - nextKey aptos.AccountAddress - next = true - sourceTokensToPool = make(map[string]string) - ) - for next { - sourceTokens, nextKey, next, err = boundCCIP.TokenAdminRegistry().GetAllConfiguredTokens(callOpts, nextKey, 100) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get allConfiguredTokens of tokenAdminRegistry %s: %w", ccipAddress.StringLong(), err) - } - pools, err := boundCCIP.TokenAdminRegistry().GetPools(callOpts, sourceTokens) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get pools of tokenAdminRegistry %s: %w", ccipAddress.StringLong(), err) - } - for i, pool := range pools { - sourceTokensToPool[sourceTokens[i].StringLong()] = pool.StringLong() - } - } - - destChainSpecificData := make(map[uint64]DestChainSpecificData, len(destinationChainSelectors)) - for _, selector := range destinationChainSelectors { - _, allowlistEnabled, routerAddr, routerStateAddr, err := boundOnRamp.Onramp().GetDestChainConfigV2(nil, selector) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get destChainConfig for selector %d of onRamp %s: %w", selector, onRampAddress.StringLong(), err) - } - _, allowedSenders, err := boundOnRamp.Onramp().GetAllowedSendersList(nil, selector) - if err != nil { - return OnRampView{}, fmt.Errorf("failed to get allowedSendersList for selector %d of onRamp %s: %w", selector, onRampAddress.StringLong(), err) - } - allowedSenderStrings := make([]string, len(allowedSenders)) - for i, allowedSender := range allowedSenders { - allowedSenderStrings[i] = allowedSender.StringLong() - } - destChainSpecificData[selector] = DestChainSpecificData{ - AllowedSendersList: allowedSenderStrings, - DestChainConfig: OnRampDestChainConfig{ - AllowlistEnabled: allowlistEnabled, - Router: routerAddr.StringLong(), - RouterStateAddress: routerStateAddr.StringLong(), - }, - } - } - - return OnRampView{ - ContractMetaData: ContractMetaData{ - Address: onRampAddress.StringLong(), - Owner: owner.StringLong(), - TypeAndVersion: typeAndVersion, - }, - StaticConfig: OnRampStaticConfig{ - ChainSelector: staticConfig.ChainSelector, - }, - DynamicConfig: OnRampDynamicConfig{ - FeeAggregator: dynamicConfig.FeeAggregator.StringLong(), - AllowlistAdmin: dynamicConfig.AllowlistAdmin.StringLong(), - }, - SourceTokenToPool: sourceTokensToPool, - DestChainSpecificData: destChainSpecificData, - }, nil -} diff --git a/deployment/ccip/view/aptos/router.go b/deployment/ccip/view/aptos/router.go deleted file mode 100644 index 4a0b337c802..00000000000 --- a/deployment/ccip/view/aptos/router.go +++ /dev/null @@ -1,79 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_offramp" - "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_router" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" -) - -type RouterView struct { - ContractMetaData - - IsTestRouter bool `json:"isTestRouter"` - OnRamps map[uint64]string `json:"onRamps"` // Map of DestinationChainSelector to OnRampAddress - OffRamps map[uint64]string `json:"offRamps"` // Map of DestinationChainSelector to OffRampAddress -} - -func GenerateRouterView(chain cldf_aptos.Chain, routerAddress aptos.AccountAddress, offRampAddresses []aptos.AccountAddress, isTestRouter bool) (RouterView, error) { - boundRouter := ccip_router.Bind(routerAddress, chain.Client) - - typeAndVersion, err := boundRouter.Router().TypeAndVersion(nil) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get typeAndVersion of router %s: %w", routerAddress.StringLong(), err) - } - owner, err := boundRouter.Router().Owner(nil) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get owner of router %s: %w", routerAddress.StringLong(), err) - } - - // OnRamps - destinationChainSelectors, err := boundRouter.Router().GetDestChains(nil) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get destChainSelectors of router %s: %w", routerAddress.StringLong(), err) - } - onrampVersions, err := boundRouter.Router().GetOnRampVersions(nil, destinationChainSelectors) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get onRamp versions of router %s: %w", routerAddress.StringLong(), err) - } - onRamps := make(map[uint64]string, len(onrampVersions)) - for i, destChainSelector := range destinationChainSelectors { - onRampAddress, err := boundRouter.Router().GetOnRampForVersion(nil, onrampVersions[i]) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get onRamp for version %d of router %s: %w", onrampVersions[i], routerAddress.StringLong(), err) - } - onRamps[destChainSelector] = onRampAddress.StringLong() - } - - // OffRamps - // Since on Aptos, we're not tracking the offramps in the router, we're instead iterating over all known offramps - // and for each are checking if it has a source chain config set for the current router. - offRamps := make(map[uint64]string) - for _, offRampAddress := range offRampAddresses { - boundOffRamp := ccip_offramp.Bind(offRampAddress, chain.Client) - sourceChainSelectors, sourceChainConfigs, err := boundOffRamp.Offramp().GetAllSourceChainConfigs(nil) - if err != nil { - return RouterView{}, fmt.Errorf("failed to get sourceChainConfigs of offRamp %s: %w", offRampAddress.StringLong(), err) - } - for i, sourceChainConfig := range sourceChainConfigs { - if sourceChainConfig.Router == routerAddress { - sourceChainSelector := sourceChainSelectors[i] - offRamps[sourceChainSelector] = offRampAddress.StringLong() - } - } - } - - return RouterView{ - ContractMetaData: ContractMetaData{ - Address: routerAddress.StringLong(), - Owner: owner.StringLong(), - TypeAndVersion: typeAndVersion, - }, - IsTestRouter: isTestRouter, - OnRamps: onRamps, - OffRamps: offRamps, - }, nil -} diff --git a/deployment/ccip/view/aptos/token.go b/deployment/ccip/view/aptos/token.go deleted file mode 100644 index 9f8cfa1c5a6..00000000000 --- a/deployment/ccip/view/aptos/token.go +++ /dev/null @@ -1,73 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/helpers" - "github.com/smartcontractkit/chainlink-aptos/bindings/managed_token" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" -) - -type TokenView struct { - ContractMetaData - - Name string `json:"name"` - Symbol string `json:"symbol"` - Decimals uint8 `json:"decimals"` - IconURI string `json:"iconURI,omitempty"` - ProjectURI string `json:"projectURI,omitempty"` - - Burners []aptos.AccountAddress `json:"burners"` - Minters []aptos.AccountAddress `json:"minters"` - ManagedTokenObjectAddress string `json:"managedTokenObjectAddress,omitempty"` -} - -// GenerateTokenView generates a token view for a given managed token. -// The provided address must be a `managed_token` deployment. -func GenerateTokenView(chain cldf_aptos.Chain, managedTokenObjectAddress aptos.AccountAddress) (TokenView, error) { - objectOwner, err := helpers.GetObjectOwner(chain.Client, managedTokenObjectAddress) - if err != nil { - return TokenView{}, err - } - - boundToken := managed_token.Bind(managedTokenObjectAddress, chain.Client) - typeAndVersion, err := boundToken.ManagedToken().TypeAndVersion(nil) - if err != nil { - return TokenView{}, fmt.Errorf("failed to get typeAndVersion of managedToken %s: %w", managedTokenObjectAddress.StringLong(), err) - } - faMetadataAddress, err := boundToken.ManagedToken().TokenMetadata(nil) - if err != nil { - return TokenView{}, fmt.Errorf("failed to get tokenMetadata of managedToken %s: %w", managedTokenObjectAddress.StringLong(), err) - } - metadata, err := helpers.GetFungibleAssetMetadata(chain.Client, faMetadataAddress) - if err != nil { - return TokenView{}, fmt.Errorf("failed to get fungible asset metadata of fungibleAsset %s: %w", faMetadataAddress.StringLong(), err) - } - - burners, err := boundToken.ManagedToken().GetAllowedBurners(nil) - if err != nil { - return TokenView{}, fmt.Errorf("failed to get burners of managedToken %s: %w", managedTokenObjectAddress.StringLong(), err) - } - minters, err := boundToken.ManagedToken().GetAllowedMinters(nil) - if err != nil { - return TokenView{}, fmt.Errorf("failed to get minters of managedToken %s: %w", managedTokenObjectAddress.StringLong(), err) - } - - return TokenView{ - ContractMetaData: ContractMetaData{ - Address: faMetadataAddress.StringLong(), - Owner: objectOwner.StringLong(), - TypeAndVersion: typeAndVersion, - }, - Name: metadata.Name, - Symbol: metadata.Symbol, - Decimals: metadata.Decimals, - IconURI: metadata.IconURI, - ProjectURI: metadata.ProjectURI, - Burners: burners, - Minters: minters, - ManagedTokenObjectAddress: managedTokenObjectAddress.StringLong(), - }, nil -} diff --git a/deployment/ccip/view/aptos/token_pool.go b/deployment/ccip/view/aptos/token_pool.go deleted file mode 100644 index 7b7268505a7..00000000000 --- a/deployment/ccip/view/aptos/token_pool.go +++ /dev/null @@ -1,127 +0,0 @@ -package aptos - -import ( - "fmt" - - "github.com/aptos-labs/aptos-go-sdk" - - "github.com/smartcontractkit/chainlink-aptos/bindings/bind" - module_rate_limiter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_token_pools/token_pool/rate_limiter" - cldf_aptos "github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos" - "github.com/smartcontractkit/chainlink/deployment/ccip/view/shared" -) - -type TokenPoolView struct { - ContractMetaData - - Token string `json:"token"` - RemoteChainConfigs map[uint64]RemoteChainConfig `json:"remoteChainConfigs"` - AllowList []string `json:"allowList"` - AllowListEnabled bool `json:"allowListEnabled"` -} - -type RemoteChainConfig struct { - RemoteTokenAddress string - RemotePoolAddresses []string - InboundRateLimiterConfig RateLimiterConfig - OutboundRateLimiterConfig RateLimiterConfig -} - -type RateLimiterConfig struct { - IsEnabled bool - Capacity uint64 - Rate uint64 -} - -type PoolInterface interface { - Owner(opts *bind.CallOpts) (aptos.AccountAddress, error) - TypeAndVersion(opts *bind.CallOpts) (string, error) - GetToken(opts *bind.CallOpts) (aptos.AccountAddress, error) - GetAllowlistEnabled(opts *bind.CallOpts) (bool, error) - GetAllowlist(opts *bind.CallOpts) ([]aptos.AccountAddress, error) - GetSupportedChains(opts *bind.CallOpts) ([]uint64, error) - GetRemotePools(opts *bind.CallOpts, remoteChainSelector uint64) ([][]byte, error) - GetRemoteToken(opts *bind.CallOpts, remoteChainSelector uint64) ([]byte, error) - GetCurrentInboundRateLimiterState(opts *bind.CallOpts, remoteChainSelector uint64) (module_rate_limiter.TokenBucket, error) - GetCurrentOutboundRateLimiterState(opts *bind.CallOpts, remoteChainSelector uint64) (module_rate_limiter.TokenBucket, error) -} - -func GenerateTokenPoolView(chain cldf_aptos.Chain, address aptos.AccountAddress, boundTokenPoolModule PoolInterface) (TokenPoolView, error) { - owner, err := boundTokenPoolModule.Owner(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get owner of token pool %s: %w", address.StringLong(), err) - } - typeAndVersion, err := boundTokenPoolModule.TypeAndVersion(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get typeAndVersion of token pool %s: %w", address.StringLong(), err) - } - token, err := boundTokenPoolModule.GetToken(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get token of token pool %s: %w", address.StringLong(), err) - } - allowlistEnabled, err := boundTokenPoolModule.GetAllowlistEnabled(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get allowlist of token pool %s: %w", address.StringLong(), err) - } - allowlist, err := boundTokenPoolModule.GetAllowlist(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get allowlist of token pool %s: %w", address.StringLong(), err) - } - allowListStrings := make([]string, len(allowlist)) - for i, address := range allowlist { - allowListStrings[i] = address.StringLong() - } - remoteChains, err := boundTokenPoolModule.GetSupportedChains(nil) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get supportedChains of token pool %s: %w", address.StringLong(), err) - } - remoteChainConfigs := make(map[uint64]RemoteChainConfig, len(remoteChains)) - for _, selector := range remoteChains { - remotePools, err := boundTokenPoolModule.GetRemotePools(nil, selector) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get remotePools of token pool %s for chain %d: %w", address.StringLong(), selector, err) - } - remotePoolStrings := make([]string, len(remotePools)) - for i, remotePool := range remotePools { - remotePoolStrings[i] = shared.GetAddressFromBytes(selector, remotePool) - } - remoteToken, err := boundTokenPoolModule.GetRemoteToken(nil, selector) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get remoteToken of token pool %s for chain %d: %w", address.StringLong(), selector, err) - } - inboundState, err := boundTokenPoolModule.GetCurrentInboundRateLimiterState(nil, selector) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get inboundRateLimiterState of token pool %s for chain %d: %w", address.StringLong(), selector, err) - } - outboundState, err := boundTokenPoolModule.GetCurrentOutboundRateLimiterState(nil, selector) - if err != nil { - return TokenPoolView{}, fmt.Errorf("failed to get outboundRateLimiterState of token pool %s for chain %d: %w", address.StringLong(), selector, err) - } - remoteChainConfigs[selector] = RemoteChainConfig{ - RemoteTokenAddress: shared.GetAddressFromBytes(selector, remoteToken), - RemotePoolAddresses: remotePoolStrings, - InboundRateLimiterConfig: RateLimiterConfig{ - IsEnabled: inboundState.IsEnabled, - Capacity: inboundState.Capacity, - Rate: inboundState.Rate, - }, - OutboundRateLimiterConfig: RateLimiterConfig{ - IsEnabled: outboundState.IsEnabled, - Capacity: outboundState.Capacity, - Rate: outboundState.Rate, - }, - } - } - - return TokenPoolView{ - ContractMetaData: ContractMetaData{ - Address: address.StringLong(), - Owner: owner.StringLong(), - TypeAndVersion: typeAndVersion, - }, - Token: token.StringLong(), - RemoteChainConfigs: remoteChainConfigs, - AllowList: allowListStrings, - AllowListEnabled: allowlistEnabled, - }, nil -} diff --git a/deployment/ccip/view/view.go b/deployment/ccip/view/view.go index 8a1b14a2270..18fb217b094 100644 --- a/deployment/ccip/view/view.go +++ b/deployment/ccip/view/view.go @@ -7,8 +7,9 @@ import ( suistate "github.com/smartcontractkit/chainlink-sui/deployment" tonstate "github.com/smartcontractkit/chainlink-ton/deployment/state" + aptosview "github.com/smartcontractkit/chainlink-aptos/deployment/view" + "github.com/smartcontractkit/chainlink/deployment/ccip/internal/maputils" - "github.com/smartcontractkit/chainlink/deployment/ccip/view/aptos" "github.com/smartcontractkit/chainlink/deployment/ccip/view/shared" "github.com/smartcontractkit/chainlink/deployment/ccip/view/solana" "github.com/smartcontractkit/chainlink/deployment/ccip/view/v1_0" @@ -129,40 +130,9 @@ func (v *ChainView) UpdateRegistryModuleView(registryModuleAddress string, regis v.RegistryModules[registryModuleAddress] = registryModuleView } -type AptosChainView struct { - ChainSelector uint64 `json:"chainSelector,omitempty"` - ChainID string `json:"chainID,omitempty"` - - MCMSWithTimelock aptos.MCMSWithTimelockView `json:"mcmsWithTimelock"` - - LinkToken aptos.TokenView `json:"linkToken"` - Tokens map[string]aptos.TokenView `json:"tokens,omitempty"` - - CCIP aptos.CCIPView `json:"ccip"` - Router map[string]aptos.RouterView `json:"router,omitempty"` - OnRamp map[string]aptos.OnRampView `json:"onRamp,omitempty"` - OffRamp map[string]aptos.OffRampView `json:"offRamp,omitempty"` +type AptosChainView = aptosview.AptosChainView - TokenPools map[string]map[string]aptos.TokenPoolView `json:"poolByTokens,omitempty"` // TokenSymbol => TokenPool Address => PoolView - - UpdateMu *sync.Mutex `json:"-"` -} - -func NewAptosChainView() AptosChainView { - return AptosChainView{ - ChainSelector: 0, - ChainID: "", - MCMSWithTimelock: aptos.MCMSWithTimelockView{}, - LinkToken: aptos.TokenView{}, - Tokens: make(map[string]aptos.TokenView), - CCIP: aptos.CCIPView{}, - Router: make(map[string]aptos.RouterView), - OnRamp: make(map[string]aptos.OnRampView), - OffRamp: make(map[string]aptos.OffRampView), - TokenPools: make(map[string]map[string]aptos.TokenPoolView), - UpdateMu: &sync.Mutex{}, - } -} +var NewAptosChainView = aptosview.NewAptosChainView type CCIPView struct { Chains map[string]ChainView `json:"chains,omitempty"` diff --git a/deployment/environment/crib/lane_config.go b/deployment/environment/crib/lane_config.go index d3daeba5bb3..a27c4ce06f1 100644 --- a/deployment/environment/crib/lane_config.go +++ b/deployment/environment/crib/lane_config.go @@ -17,6 +17,7 @@ import ( "github.com/smartcontractkit/chainlink-aptos/bindings/ccip_onramp" + aptosState "github.com/smartcontractkit/chainlink-aptos/deployment/state" solRouter "github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/v0_1_1/ccip_router" solCommonUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/common" ccipSolState "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state" @@ -25,7 +26,6 @@ import ( cldf_solana "github.com/smartcontractkit/chainlink-deployments-framework/chain/solana" cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosState "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/evm" solState "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/solana" ) diff --git a/deployment/go.mod b/deployment/go.mod index 77286d5ddba..0941b285db7 100644 --- a/deployment/go.mod +++ b/deployment/go.mod @@ -40,7 +40,8 @@ require ( github.com/smartcontractkit/ccip-contract-examples/chains/evm v0.0.0-20260129135848-c86808ba5cb9 github.com/smartcontractkit/ccip-owner-contracts v0.1.0 github.com/smartcontractkit/chain-selectors v1.0.104 - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 + github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260415165642-49f23e4d76cc @@ -77,11 +78,11 @@ require ( github.com/xssnick/tonutils-go v1.14.1 github.com/zksync-sdk/zksync2-go v1.1.1-0.20250620124214-2c742ee399c6 go.uber.org/zap v1.28.0 - golang.org/x/crypto v0.52.0 + golang.org/x/crypto v0.53.0 golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a golang.org/x/mod v0.36.0 golang.org/x/oauth2 v0.36.0 - golang.org/x/sync v0.20.0 + golang.org/x/sync v0.21.0 google.golang.org/grpc v1.81.1 google.golang.org/protobuf v1.36.11 gopkg.in/guregu/null.v4 v4.0.0 @@ -146,7 +147,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.104.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beevik/ntp v1.5.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect @@ -423,7 +424,7 @@ require ( github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 // indirect github.com/sirupsen/logrus v1.9.4 // indirect github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260706093831-dad26b360094 // indirect github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260626151909-052e55e62e62 // indirect github.com/smartcontractkit/chainlink-feeds v0.1.2-0.20250227211209-7cd000095135 // indirect @@ -449,7 +450,7 @@ require ( github.com/smartcontractkit/chainlink-testing-framework/parrot v0.6.2 // indirect github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.5 // indirect github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20260408092456-3c6369888d4a // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20241009055228-33d0c0bf38de // indirect github.com/smartcontractkit/tdh2/go/tdh2 v0.0.0-20251120172354-e8ec0386b06c // indirect @@ -526,9 +527,9 @@ require ( go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect golang.org/x/arch v0.22.0 // indirect golang.org/x/net v0.55.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/term v0.43.0 // indirect - golang.org/x/text v0.37.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/term v0.44.0 // indirect + golang.org/x/text v0.38.0 // indirect golang.org/x/time v0.15.0 // indirect golang.org/x/tools v0.45.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect diff --git a/deployment/go.sum b/deployment/go.sum index aaa375dedf4..8540a46c8fe 100644 --- a/deployment/go.sum +++ b/deployment/go.sum @@ -209,8 +209,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.104.0 h1:651Sh6J2FtatfnVzlOQ3/Ye1WWPAseZ6E/tSQxEKdSI= github.com/aws/jsii-runtime-go v1.104.0/go.mod h1:7ZmQXxV0AAhhvv/GaHX4n6zbgA1tSRVdnQYAJbIhXHk= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= @@ -1363,12 +1363,14 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 h1:bFgzlJz8H+y0TLyV0Z+ix2WqcvKRMhcS0SmMc9BRZ4g= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754/go.mod h1:FBy6zgPkTw4oScyLnU5DeG61dBZzIHrwJfbuYDrH2+k= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1475,8 +1477,8 @@ github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57 github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57cf3c/go.mod h1:gL4GT6WUvna7MYGJXAqOq65xpQpG9bnQcdAfqCbKgH4= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g= @@ -1812,8 +1814,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= -golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= -golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1945,8 +1947,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2037,8 +2039,8 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2052,8 +2054,8 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= -golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2069,8 +2071,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/go.md b/go.md index 64dfe0418fe..107d1e3b5c0 100644 --- a/go.md +++ b/go.md @@ -314,6 +314,8 @@ flowchart LR click chain-selectors href "https://github.com/smartcontractkit/chain-selectors" chainlink-aptos --> chainlink-framework/metrics click chainlink-aptos href "https://github.com/smartcontractkit/chainlink-aptos" + chainlink-aptos/deployment + click chainlink-aptos/deployment href "https://github.com/smartcontractkit/chainlink-aptos" chainlink-automation --> chainlink-common click chainlink-automation href "https://github.com/smartcontractkit/chainlink-automation" chainlink-canton --> chainlink-ccv/build/devenv @@ -492,6 +494,7 @@ flowchart LR chainlink/core/scripts/cre/environment/examples/workflows/proof-of-reserve/cron-based --> cre-sdk-go/capabilities/scheduler/cron click chainlink/core/scripts/cre/environment/examples/workflows/proof-of-reserve/cron-based href "https://github.com/smartcontractkit/chainlink" chainlink/deployment --> ccip-contract-examples/chains/evm + chainlink/deployment --> chainlink-aptos/deployment chainlink/deployment --> chainlink-ccip/deployment chainlink/deployment --> chainlink-solana/contracts chainlink/deployment --> chainlink-sui/deployment @@ -675,6 +678,12 @@ flowchart LR end click chainlink-repo href "https://github.com/smartcontractkit/chainlink" + subgraph chainlink-aptos-repo[chainlink-aptos] + chainlink-aptos + chainlink-aptos/deployment + end + click chainlink-aptos-repo href "https://github.com/smartcontractkit/chainlink-aptos" + subgraph chainlink-ccip-repo[chainlink-ccip] chainlink-ccip chainlink-ccip/chains/evm @@ -794,5 +803,5 @@ flowchart LR click testrig-repo href "https://github.com/smartcontractkit/testrig" classDef outline stroke-dasharray:6,fill:none; - class chainlink-repo,chainlink-ccip-repo,chainlink-ccv-repo,chainlink-common-repo,chainlink-evm-repo,chainlink-framework-repo,chainlink-protos-repo,chainlink-solana-repo,chainlink-sui-repo,chainlink-testing-framework-repo,chainlink-ton-repo,cre-sdk-go-repo,tdh2-repo,testrig-repo outline + class chainlink-repo,chainlink-aptos-repo,chainlink-ccip-repo,chainlink-ccv-repo,chainlink-common-repo,chainlink-evm-repo,chainlink-framework-repo,chainlink-protos-repo,chainlink-solana-repo,chainlink-sui-repo,chainlink-testing-framework-repo,chainlink-ton-repo,cre-sdk-go-repo,tdh2-repo,testrig-repo outline ``` diff --git a/go.mod b/go.mod index 3014ddb9f4d..04bd09e83f8 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,7 @@ require ( github.com/shirou/gopsutil/v3 v3.24.3 github.com/shopspring/decimal v1.4.0 github.com/smartcontractkit/chain-selectors v1.0.104 - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-automation v0.8.1 github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd diff --git a/go.sum b/go.sum index bfab02b97a6..02d8278dfcd 100644 --- a/go.sum +++ b/go.sum @@ -1148,8 +1148,8 @@ github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 76a9572a0aa..3c13ccab125 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -28,7 +28,7 @@ require ( github.com/rs/zerolog v1.35.1 github.com/segmentio/ksuid v1.0.4 github.com/smartcontractkit/chain-selectors v1.0.104 - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260506144252-c100eabfda74 @@ -54,8 +54,8 @@ require ( github.com/testcontainers/testcontainers-go v0.42.0 go.uber.org/zap v1.28.0 golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a - golang.org/x/sync v0.20.0 - golang.org/x/text v0.37.0 + golang.org/x/sync v0.21.0 + golang.org/x/text v0.38.0 google.golang.org/grpc v1.81.1 gopkg.in/guregu/null.v4 v4.0.0 ) @@ -116,7 +116,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.104.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beevik/ntp v1.5.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect @@ -398,8 +398,9 @@ require ( github.com/slack-go/slack v0.23.1 // indirect github.com/smartcontractkit/ccip-contract-examples/chains/evm v0.0.0-20260129135848-c86808ba5cb9 // indirect github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect + github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20260618155522-3600f66e26cd // indirect github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260706093831-dad26b360094 // indirect github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260626151909-052e55e62e62 // indirect @@ -433,7 +434,7 @@ require ( github.com/smartcontractkit/chainlink-ton/deployment v0.0.0-20260601214705-1ab0adfd785f // indirect github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20260408092456-3c6369888d4a // indirect github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect github.com/smartcontractkit/smdkg v0.0.0-20251029093710-c38905e58aeb // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20241009055228-33d0c0bf38de // indirect @@ -512,12 +513,12 @@ require ( go.yaml.in/yaml/v3 v3.0.4 // indirect go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect golang.org/x/arch v0.22.0 // indirect - golang.org/x/crypto v0.52.0 // indirect + golang.org/x/crypto v0.53.0 // indirect golang.org/x/mod v0.36.0 // indirect golang.org/x/net v0.55.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/term v0.43.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/term v0.44.0 // indirect golang.org/x/time v0.15.0 // indirect golang.org/x/tools v0.45.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index c31786746d0..b05f6ba2afd 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -201,8 +201,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.104.0 h1:651Sh6J2FtatfnVzlOQ3/Ye1WWPAseZ6E/tSQxEKdSI= github.com/aws/jsii-runtime-go v1.104.0/go.mod h1:7ZmQXxV0AAhhvv/GaHX4n6zbgA1tSRVdnQYAJbIhXHk= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= @@ -1350,12 +1350,14 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 h1:bFgzlJz8H+y0TLyV0Z+ix2WqcvKRMhcS0SmMc9BRZ4g= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754/go.mod h1:FBy6zgPkTw4oScyLnU5DeG61dBZzIHrwJfbuYDrH2+k= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1460,8 +1462,8 @@ github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57 github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57cf3c/go.mod h1:gL4GT6WUvna7MYGJXAqOq65xpQpG9bnQcdAfqCbKgH4= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g= @@ -1792,8 +1794,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= -golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= -golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1925,8 +1927,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2017,8 +2019,8 @@ golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2032,8 +2034,8 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= -golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2049,8 +2051,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/integration-tests/load/go.mod b/integration-tests/load/go.mod index c9a99dbcf5c..6f96f83b13c 100644 --- a/integration-tests/load/go.mod +++ b/integration-tests/load/go.mod @@ -19,7 +19,7 @@ require ( github.com/gagliardetto/solana-go v1.13.0 github.com/rs/zerolog v1.35.1 github.com/smartcontractkit/chain-selectors v1.0.104 - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260506144252-c100eabfda74 @@ -36,7 +36,7 @@ require ( github.com/smartcontractkit/chainlink/v2 v2.29.0 github.com/stretchr/testify v1.11.1 go.uber.org/atomic v1.11.0 - golang.org/x/sync v0.20.0 + golang.org/x/sync v0.21.0 ) require ( @@ -106,7 +106,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.104.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/basgys/goxml2json v1.1.1-0.20231018121955-e66ee54ceaad // indirect github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect @@ -477,8 +477,9 @@ require ( github.com/slack-go/slack v0.23.1 // indirect github.com/smartcontractkit/ccip-contract-examples/chains/evm v0.0.0-20260129135848-c86808ba5cb9 // indirect github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect + github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 // indirect github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect github.com/smartcontractkit/chainlink-ccip/deployment v0.0.0-20260618155522-3600f66e26cd // indirect github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260706093831-dad26b360094 // indirect github.com/smartcontractkit/chainlink-common/keystore v1.2.0 // indirect @@ -520,7 +521,7 @@ require ( github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20260408092456-3c6369888d4a // indirect github.com/smartcontractkit/cld-changesets v0.5.0 // indirect github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c // indirect github.com/smartcontractkit/mcms v0.48.0 // indirect @@ -627,14 +628,14 @@ require ( go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect golang.org/x/arch v0.22.0 // indirect - golang.org/x/crypto v0.52.0 // indirect + golang.org/x/crypto v0.53.0 // indirect golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a // indirect golang.org/x/mod v0.36.0 // indirect golang.org/x/net v0.55.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/term v0.43.0 // indirect - golang.org/x/text v0.37.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/term v0.44.0 // indirect + golang.org/x/text v0.38.0 // indirect golang.org/x/time v0.15.0 // indirect golang.org/x/tools v0.45.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect diff --git a/integration-tests/load/go.sum b/integration-tests/load/go.sum index ea64ea73bf2..10e2892edcc 100644 --- a/integration-tests/load/go.sum +++ b/integration-tests/load/go.sum @@ -246,8 +246,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.104.0 h1:651Sh6J2FtatfnVzlOQ3/Ye1WWPAseZ6E/tSQxEKdSI= github.com/aws/jsii-runtime-go v1.104.0/go.mod h1:7ZmQXxV0AAhhvv/GaHX4n6zbgA1tSRVdnQYAJbIhXHk= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= @@ -1612,12 +1612,14 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754 h1:bFgzlJz8H+y0TLyV0Z+ix2WqcvKRMhcS0SmMc9BRZ4g= +github.com/smartcontractkit/chainlink-aptos/deployment v0.0.0-20260706100550-d43558069754/go.mod h1:FBy6zgPkTw4oScyLnU5DeG61dBZzIHrwJfbuYDrH2+k= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1728,8 +1730,8 @@ github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57 github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57cf3c/go.mod h1:gL4GT6WUvna7MYGJXAqOq65xpQpG9bnQcdAfqCbKgH4= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g= @@ -2146,8 +2148,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988= -golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2295,8 +2297,8 @@ golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2393,8 +2395,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -2414,8 +2416,8 @@ golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= -golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4= -golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2435,8 +2437,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go b/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go index e35901584c2..9f3fa697e7c 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_messaging_test.go @@ -54,7 +54,7 @@ func Test_CCIP_Messaging_EVM2Aptos(t *testing.T) { lggr.Debug("Source chain (EVM): ", sourceChain, "Dest chain (Aptos): ", destChain) - testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, sourceChain, destChain, false) + require.NoError(t, testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, sourceChain, destChain, false)) var ( nonce uint64 @@ -416,7 +416,7 @@ func Test_CCIP_Messaging_Aptos2EVM(t *testing.T) { lggr.Debug("Source chain (Aptos): ", sourceChain, "Dest chain (EVM): ", destChain) - testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, sourceChain, destChain, false) + require.NoError(t, testhelpers.AddLaneWithDefaultPricesAndFeeQuoterConfig(t, &e, state, sourceChain, destChain, false)) aptosCallOpts := &aptos_call_opts.CallOpts{} diff --git a/integration-tests/smoke/ccip/ccip_aptos_msghasher_test.go b/integration-tests/smoke/ccip/ccip_aptos_msghasher_test.go index 0d9aa135bb4..61afab57719 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_msghasher_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_msghasher_test.go @@ -21,10 +21,10 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipaptos" "github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/ccipevm" + aptosstate "github.com/smartcontractkit/chainlink-aptos/deployment/state" "github.com/smartcontractkit/chainlink-evm/pkg/utils" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview" - aptosstate "github.com/smartcontractkit/chainlink/deployment/ccip/shared/stateview/aptos" testsetups "github.com/smartcontractkit/chainlink/integration-tests/testsetups/ccip" "github.com/aptos-labs/aptos-go-sdk" diff --git a/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go index 2b297565cbe..a63540d7383 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_regulated_token_transfer_test.go @@ -11,9 +11,9 @@ import ( aptos_call_opts "github.com/smartcontractkit/chainlink-aptos/bindings/bind" aptos_feequoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" + "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/config" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router" "github.com/smartcontractkit/chainlink-deployments-framework/chain" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" ccipclient "github.com/smartcontractkit/chainlink/deployment/ccip/shared/client" diff --git a/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go b/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go index 04f884264c8..66c660b7383 100644 --- a/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go +++ b/integration-tests/smoke/ccip/ccip_aptos_token_transfer_test.go @@ -13,9 +13,9 @@ import ( aptos_call_opts "github.com/smartcontractkit/chainlink-aptos/bindings/bind" aptos_feequoter "github.com/smartcontractkit/chainlink-aptos/bindings/ccip/fee_quoter" + "github.com/smartcontractkit/chainlink-aptos/deployment/ccip/config" "github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_2_0/router" "github.com/smartcontractkit/chainlink-deployments-framework/chain" - "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/aptos/config" "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers" "github.com/smartcontractkit/chainlink/deployment/ccip/shared" ccipclient "github.com/smartcontractkit/chainlink/deployment/ccip/shared/client" diff --git a/plugins/plugins.public.yaml b/plugins/plugins.public.yaml index 957cbe64d2f..ddec05f079a 100644 --- a/plugins/plugins.public.yaml +++ b/plugins/plugins.public.yaml @@ -10,7 +10,7 @@ defaults: plugins: aptos: - moduleURI: "github.com/smartcontractkit/chainlink-aptos" - gitRef: "v0.0.0-20260609211101-71d38bd6a0a9" + gitRef: "v0.0.0-20260706100550-d43558069754" installPath: "./cmd/chainlink-aptos" sui: diff --git a/system-tests/lib/go.mod b/system-tests/lib/go.mod index e1e8dfb3fd2..d68530c4e00 100644 --- a/system-tests/lib/go.mod +++ b/system-tests/lib/go.mod @@ -35,7 +35,7 @@ require ( github.com/scylladb/go-reflectx v1.0.1 github.com/sethvargo/go-retry v0.3.0 github.com/smartcontractkit/chain-selectors v1.0.104 - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260415165642-49f23e4d76cc github.com/smartcontractkit/chainlink-common v0.11.2-0.20260701091216-9264d4444ce0 github.com/smartcontractkit/chainlink-common/keystore v1.2.0 @@ -74,8 +74,8 @@ require ( github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect github.com/quic-go/qpack v0.6.0 // indirect github.com/quic-go/quic-go v0.59.1 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect ) @@ -133,7 +133,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.112.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beevik/ntp v1.5.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect diff --git a/system-tests/lib/go.sum b/system-tests/lib/go.sum index 430939337f4..cf48dc25dec 100644 --- a/system-tests/lib/go.sum +++ b/system-tests/lib/go.sum @@ -213,8 +213,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.112.0 h1:7jusWZUgSTuSPLa2ZRv+siGuyoFSzFNk/TaHqlcFe6Y= github.com/aws/jsii-runtime-go v1.112.0/go.mod h1:jiAbLN2Hz+7At3C59LsQyv8gK3HvfNYF2YFPkWLHll8= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= @@ -1529,12 +1529,12 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1639,8 +1639,8 @@ github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57 github.com/smartcontractkit/cre-sdk-go v1.9.0-capdev.1.0.20260625132924-dcceeb57cf3c/go.mod h1:gL4GT6WUvna7MYGJXAqOq65xpQpG9bnQcdAfqCbKgH4= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g= diff --git a/system-tests/tests/go.mod b/system-tests/tests/go.mod index f576eb686de..8e581bbf87e 100644 --- a/system-tests/tests/go.mod +++ b/system-tests/tests/go.mod @@ -152,7 +152,7 @@ require ( github.com/shopspring/decimal v1.4.0 // indirect github.com/sigstore/sigstore v1.10.4 // indirect github.com/sigstore/sigstore-go v1.1.4 // indirect - github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 // indirect + github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 // indirect github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd // indirect github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260511195239-0f6e1b177fc7 // indirect github.com/smartcontractkit/chainlink-ccv v0.0.2-0.20260706093831-dad26b360094 // indirect @@ -168,7 +168,7 @@ require ( github.com/smartcontractkit/chainlink-protos/node-platform v0.0.0-20260512230622-65f10f4cd305 // indirect github.com/smartcontractkit/chainlink-solana/contracts v0.0.0-20260513123719-d347eaf314e1 // indirect github.com/smartcontractkit/chainlink-testing-framework/lib v1.54.9 // indirect - github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba // indirect + github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 // indirect github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c // indirect github.com/smartcontractkit/tdh2/go/ocr2/decryptionplugin v0.0.0-20241009055228-33d0c0bf38de // indirect github.com/stellar/go-stellar-sdk v0.5.0 // indirect @@ -235,7 +235,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect github.com/aws/constructs-go/constructs/v10 v10.4.2 // indirect github.com/aws/jsii-runtime-go v1.112.0 // indirect - github.com/aws/smithy-go v1.27.1 // indirect + github.com/aws/smithy-go v1.27.2 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -525,7 +525,7 @@ require ( github.com/sirupsen/logrus v1.9.4 // indirect github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect - github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 + github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 github.com/smartcontractkit/chainlink-automation v0.8.1 // indirect github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee // indirect github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.11-0.20260626151909-052e55e62e62 diff --git a/system-tests/tests/go.sum b/system-tests/tests/go.sum index f177e4c8e41..daaf03be26a 100644 --- a/system-tests/tests/go.sum +++ b/system-tests/tests/go.sum @@ -215,8 +215,8 @@ github.com/aws/constructs-go/constructs/v10 v10.4.2 h1:+hDLTsFGLJmKIn0Dg20vWpKBr github.com/aws/constructs-go/constructs/v10 v10.4.2/go.mod h1:cXsNCKDV+9eR9zYYfwy6QuE4uPFp6jsq6TtH1MwBx9w= github.com/aws/jsii-runtime-go v1.112.0 h1:7jusWZUgSTuSPLa2ZRv+siGuyoFSzFNk/TaHqlcFe6Y= github.com/aws/jsii-runtime-go v1.112.0/go.mod h1:jiAbLN2Hz+7At3C59LsQyv8gK3HvfNYF2YFPkWLHll8= -github.com/aws/smithy-go v1.27.1 h1:4T340VFndXtADGF52gYa1POyL7s9E4Z1OeZ1hCscIw8= -github.com/aws/smithy-go v1.27.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= +github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk= +github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= @@ -1543,12 +1543,12 @@ github.com/smartcontractkit/ccip-owner-contracts v0.1.0 h1:GiBDtlx7539o7AKlDV+9L github.com/smartcontractkit/ccip-owner-contracts v0.1.0/go.mod h1:NnT6w4Kj42OFFXhSx99LvJZWPpMjmo4+CpDEWfw61xY= github.com/smartcontractkit/chain-selectors v1.0.104 h1:/n9pPGM5W/+r1eHoWZv4VwX9LNS1af4+ICyhM8zKRNM= github.com/smartcontractkit/chain-selectors v1.0.104/go.mod h1:qy7whtgG5g+7z0jt0nRyii9bLND9m15NZTzuQPkMZ5w= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9 h1:O5t0naKzEHQs7PtK1iMWqPbTqVleBPJwUjGEwVj7BVU= -github.com/smartcontractkit/chainlink-aptos v0.0.0-20260609211101-71d38bd6a0a9/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754 h1:ZMLJrtr74dBVg8j7SKFBL+sKOqioq3FcH9hLilegg+A= +github.com/smartcontractkit/chainlink-aptos v0.0.0-20260706100550-d43558069754/go.mod h1:QzCiWXguySSjbcZfHclM2DS3rGTKAHZLNJOVreJY93o= github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU= github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320 h1:ix4tCtSTB7S2XGll+uqnhrqAQ+2iW/Zk/vnPjBMYRB0= -github.com/smartcontractkit/chainlink-canton v0.0.0-20260609155219-dcbe77d4a320/go.mod h1:WKmNUX4oy8IvB66ukudrE99uaXjlZ7WghCDwHOTyB1c= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58 h1:QT9lFZBf3bFsp7oJWLTQuUXW4FU5QXyJx2a2qZ40G6Q= +github.com/smartcontractkit/chainlink-canton v0.0.0-20260615233851-4e78e7c23a58/go.mod h1:hDT64O8SNupR2xM10u/t+a9LpArKbecgU8jiY2It6QU= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee h1:YAE9gMuCsjp3toJXBQge7pvSZhsFCv9GakTEjjoiE50= github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee/go.mod h1:2xVZJ3o9udYFeJhwyHXAMlNhptJ99uoiGjzfOicYNX8= github.com/smartcontractkit/chainlink-ccip/chains/evm v0.0.0-20260618155522-3600f66e26cd h1:2xcFpdxKxQ0Ss54L6TepjgAHOihASG1Oe30UGX5WKW8= @@ -1657,8 +1657,8 @@ github.com/smartcontractkit/cre-sdk-go v1.12.1-0.20260617153047-4f3b50819080 h1: github.com/smartcontractkit/cre-sdk-go v1.12.1-0.20260617153047-4f3b50819080/go.mod h1:8SdXmiZoi+8tTlW8JtjuyvxnoNaFreWaNk3rWqj4aLg= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad h1:lgHxTHuzJIF3Vj6LSMOnjhqKgRqYW+0MV2SExtCYL1Q= github.com/smartcontractkit/freeport v0.1.3-0.20250828155247-add56fa28aad/go.mod h1:T4zH9R8R8lVWKfU7tUvYz2o2jMv1OpGCdpY2j2QZXzU= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba h1:peYJwUWOv54aigdk1VFzkmXdZmZK4xixfxv0Af1l6/I= -github.com/smartcontractkit/go-daml v0.0.0-20260604143752-c6f6567940ba/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774 h1:EN2PhfCPJrLa6rVWkuv+MfsHk0cd4c8iL8cjEi4pmls= +github.com/smartcontractkit/go-daml v0.0.0-20260615231356-88c6ee9b5774/go.mod h1:SqWfl3Bp9NleC9jhzFUaOGzOZeKfldpY4QOW6A6NSNM= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20260508200755-99940c85383c h1:meDKygNIR0tdT3Xmxe9NwyuiaCCDL0a9COqZ+4cL89g=