From 86a9363f6b84d7650c2d924eee556f09d18c0ef2 Mon Sep 17 00:00:00 2001 From: Oliver Townsend <133903322+ogtownsend@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:18:01 -0700 Subject: [PATCH] CCIP 3388 - add commit store and RMN proxy state generation (#14551) * CCIP 3388 - add commit store and RMN proxy state generation * update ARM to RMN --- integration-tests/deployment/ccip/deploy.go | 1 + integration-tests/deployment/ccip/state.go | 29 ++++++- .../deployment/ccip/view/chain.go | 37 ++++++--- .../ccip/view/v1_0/rmn_proxy_contract.go | 33 ++++++++ .../deployment/ccip/view/v1_5/commit_store.go | 81 +++++++++++++++++++ 5 files changed, 167 insertions(+), 14 deletions(-) create mode 100644 integration-tests/deployment/ccip/view/v1_0/rmn_proxy_contract.go create mode 100644 integration-tests/deployment/ccip/view/v1_5/commit_store.go diff --git a/integration-tests/deployment/ccip/deploy.go b/integration-tests/deployment/ccip/deploy.go index 15a897e5729..0f42bd235b9 100644 --- a/integration-tests/deployment/ccip/deploy.go +++ b/integration-tests/deployment/ccip/deploy.go @@ -41,6 +41,7 @@ var ( ARMProxy deployment.ContractType = "ARMProxy" WETH9 deployment.ContractType = "WETH9" Router deployment.ContractType = "Router" + CommitStore deployment.ContractType = "CommitStore" TokenAdminRegistry deployment.ContractType = "TokenAdminRegistry" NonceManager deployment.ContractType = "NonceManager" FeeQuoter deployment.ContractType = "FeeQuoter" diff --git a/integration-tests/deployment/ccip/state.go b/integration-tests/deployment/ccip/state.go index c09dc17eef5..6b894d93b0e 100644 --- a/integration-tests/deployment/ccip/state.go +++ b/integration-tests/deployment/ccip/state.go @@ -9,6 +9,8 @@ import ( chainsel "github.com/smartcontractkit/chain-selectors" "github.com/smartcontractkit/chainlink/integration-tests/deployment" + "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_0" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store" "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view" "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_2" @@ -40,10 +42,11 @@ type CCIPChainState struct { OnRamp *onramp.OnRamp OffRamp *offramp.OffRamp FeeQuoter *fee_quoter.FeeQuoter - ArmProxy *rmn_proxy_contract.RMNProxyContract + RMNProxy *rmn_proxy_contract.RMNProxyContract NonceManager *nonce_manager.NonceManager TokenAdminRegistry *token_admin_registry.TokenAdminRegistry Router *router.Router + CommitStore *commit_store.CommitStore Weth9 *weth9.WETH9 RMNRemote *rmn_remote.RMNRemote // TODO: May need to support older link too @@ -128,6 +131,22 @@ func (c CCIPChainState) GenerateView() (view.ChainView, error) { } chainView.OffRamp[c.OffRamp.Address().Hex()] = offRampView } + + if c.CommitStore != nil { + commitStoreView, err := v1_5.GenerateCommitStoreView(c.CommitStore) + if err != nil { + return chainView, err + } + chainView.CommitStore[c.CommitStore.Address().Hex()] = commitStoreView + } + + if c.RMNProxy != nil { + rmnProxyView, err := v1_0.GenerateRMNProxyView(c.RMNProxy) + if err != nil { + return chainView, err + } + chainView.RMNProxy[c.RMNProxy.Address().Hex()] = rmnProxyView + } return chainView, nil } @@ -238,7 +257,7 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type if err != nil { return state, err } - state.ArmProxy = armProxy + state.RMNProxy = armProxy case deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev).String(): rmnRemote, err := rmn_remote.NewRMNRemote(common.HexToAddress(address), chain.Client) if err != nil { @@ -257,6 +276,12 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type return state, err } state.NonceManager = nm + case deployment.NewTypeAndVersion(CommitStore, deployment.Version1_5_0).String(): + cs, err := commit_store.NewCommitStore(common.HexToAddress(address), chain.Client) + if err != nil { + return state, err + } + state.CommitStore = cs case deployment.NewTypeAndVersion(TokenAdminRegistry, deployment.Version1_5_0).String(): tm, err := token_admin_registry.NewTokenAdminRegistry(common.HexToAddress(address), chain.Client) if err != nil { diff --git a/integration-tests/deployment/ccip/view/chain.go b/integration-tests/deployment/ccip/view/chain.go index 8dbd6cabbba..06f0059e67b 100644 --- a/integration-tests/deployment/ccip/view/chain.go +++ b/integration-tests/deployment/ccip/view/chain.go @@ -1,29 +1,42 @@ package view import ( + "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_0" "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_2" "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_5" "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_6" ) type ChainView struct { + // v1.0 + RMNProxy map[string]v1_0.RMNProxyView `json:"rmnProxy,omitempty"` + // v1.2 + Router map[string]v1_2.RouterView `json:"router,omitempty"` + // v1.5 TokenAdminRegistry map[string]v1_5.TokenAdminRegistryView `json:"tokenAdminRegistry,omitempty"` - FeeQuoter map[string]v1_6.FeeQuoterView `json:"feeQuoter,omitempty"` - NonceManager map[string]v1_6.NonceManagerView `json:"nonceManager,omitempty"` - Router map[string]v1_2.RouterView `json:"router,omitempty"` - RMN map[string]v1_6.RMNRemoteView `json:"rmn,omitempty"` - OnRamp map[string]v1_6.OnRampView `json:"onRamp,omitempty"` - OffRamp map[string]v1_6.OffRampView `json:"offRamp,omitempty"` + CommitStore map[string]v1_5.CommitStoreView `json:"commitStore,omitempty"` + // v1.6 + FeeQuoter map[string]v1_6.FeeQuoterView `json:"feeQuoter,omitempty"` + NonceManager map[string]v1_6.NonceManagerView `json:"nonceManager,omitempty"` + RMN map[string]v1_6.RMNRemoteView `json:"rmn,omitempty"` + OnRamp map[string]v1_6.OnRampView `json:"onRamp,omitempty"` + OffRamp map[string]v1_6.OffRampView `json:"offRamp,omitempty"` } func NewChain() ChainView { return ChainView{ + // v1.0 + RMNProxy: make(map[string]v1_0.RMNProxyView), + // v1.2 + Router: make(map[string]v1_2.RouterView), + // v1.5 TokenAdminRegistry: make(map[string]v1_5.TokenAdminRegistryView), - NonceManager: make(map[string]v1_6.NonceManagerView), - Router: make(map[string]v1_2.RouterView), - RMN: make(map[string]v1_6.RMNRemoteView), - OnRamp: make(map[string]v1_6.OnRampView), - OffRamp: make(map[string]v1_6.OffRampView), - FeeQuoter: make(map[string]v1_6.FeeQuoterView), + CommitStore: make(map[string]v1_5.CommitStoreView), + // v1.6 + FeeQuoter: make(map[string]v1_6.FeeQuoterView), + NonceManager: make(map[string]v1_6.NonceManagerView), + RMN: make(map[string]v1_6.RMNRemoteView), + OnRamp: make(map[string]v1_6.OnRampView), + OffRamp: make(map[string]v1_6.OffRampView), } } diff --git a/integration-tests/deployment/ccip/view/v1_0/rmn_proxy_contract.go b/integration-tests/deployment/ccip/view/v1_0/rmn_proxy_contract.go new file mode 100644 index 00000000000..bac32bf0f26 --- /dev/null +++ b/integration-tests/deployment/ccip/view/v1_0/rmn_proxy_contract.go @@ -0,0 +1,33 @@ +package v1_0 + +import ( + "fmt" + + "github.com/ethereum/go-ethereum/common" + + "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/types" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_proxy_contract" +) + +type RMNProxyView struct { + types.ContractMetaData + RMN common.Address `json:"rmn"` +} + +func GenerateRMNProxyView(r *rmn_proxy_contract.RMNProxyContract) (RMNProxyView, error) { + if r == nil { + return RMNProxyView{}, fmt.Errorf("cannot generate view for nil RMNProxy") + } + meta, err := types.NewContractMetaData(r, r.Address()) + if err != nil { + return RMNProxyView{}, fmt.Errorf("failed to generate contract metadata for RMNProxy: %w", err) + } + rmn, err := r.GetARM(nil) + if err != nil { + return RMNProxyView{}, fmt.Errorf("failed to get ARM: %w", err) + } + return RMNProxyView{ + ContractMetaData: meta, + RMN: rmn, + }, nil +} diff --git a/integration-tests/deployment/ccip/view/v1_5/commit_store.go b/integration-tests/deployment/ccip/view/v1_5/commit_store.go new file mode 100644 index 00000000000..0aa483e1678 --- /dev/null +++ b/integration-tests/deployment/ccip/view/v1_5/commit_store.go @@ -0,0 +1,81 @@ +package v1_5 + +import ( + "fmt" + + "github.com/ethereum/go-ethereum/common" + + "github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/types" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store" +) + +type CommitStoreView struct { + types.ContractMetaData + DynamicConfig commit_store.CommitStoreDynamicConfig `json:"dynamicConfig"` + ExpectedNextSequenceNumber uint64 `json:"expectedNextSequenceNumber"` + LatestPriceEpochAndRound uint64 `json:"latestPriceEpochAndRound"` + StaticConfig commit_store.CommitStoreStaticConfig `json:"staticConfig"` + Transmitters []common.Address `json:"transmitters"` + IsUnpausedAndNotCursed bool `json:"isUnpausedAndNotCursed"` + LatestConfigDetails commit_store.LatestConfigDetails `json:"latestConfigDetails"` + LatestConfigDigestAndEpoch commit_store.LatestConfigDigestAndEpoch `json:"latestConfigDigestAndEpoch"` + Paused bool `json:"paused"` +} + +func GenerateCommitStoreView(c *commit_store.CommitStore) (CommitStoreView, error) { + if c == nil { + return CommitStoreView{}, fmt.Errorf("cannot generate view for nil CommitStore") + } + meta, err := types.NewContractMetaData(c, c.Address()) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to generate contract metadata for CommitStore: %w", err) + } + dynamicConfig, err := c.GetDynamicConfig(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get dynamic config: %w", err) + } + expectedNextSequenceNumber, err := c.GetExpectedNextSequenceNumber(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get expected next sequence number: %w", err) + } + latestPriceEpochAndRound, err := c.GetLatestPriceEpochAndRound(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get latest price epoch and round: %w", err) + } + staticConfig, err := c.GetStaticConfig(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get static config: %w", err) + } + transmitters, err := c.GetTransmitters(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get transmitters: %w", err) + } + isUnpausedAndNotCursed, err := c.IsUnpausedAndNotCursed(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get is unpaused and not cursed: %w", err) + } + latestConfigDetails, err := c.LatestConfigDetails(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get latest config details: %w", err) + } + latestConfigDigestAndEpoch, err := c.LatestConfigDigestAndEpoch(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get latest config digest and epoch: %w", err) + } + paused, err := c.Paused(nil) + if err != nil { + return CommitStoreView{}, fmt.Errorf("failed to get paused: %w", err) + } + return CommitStoreView{ + ContractMetaData: meta, + DynamicConfig: dynamicConfig, + ExpectedNextSequenceNumber: expectedNextSequenceNumber, + LatestPriceEpochAndRound: latestPriceEpochAndRound, + StaticConfig: staticConfig, + Transmitters: transmitters, + IsUnpausedAndNotCursed: isUnpausedAndNotCursed, + LatestConfigDetails: latestConfigDetails, + LatestConfigDigestAndEpoch: latestConfigDigestAndEpoch, + Paused: paused, + }, nil +}