Skip to content

Commit

Permalink
CCIP 3388 - add commit store and RMN proxy state generation (#14551)
Browse files Browse the repository at this point in the history
* CCIP 3388 - add commit store and RMN proxy state generation

* update ARM to RMN
  • Loading branch information
ogtownsend authored Sep 27, 2024
1 parent 0e35bc7 commit 86a9363
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 14 deletions.
1 change: 1 addition & 0 deletions integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 27 additions & 2 deletions integration-tests/deployment/ccip/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
37 changes: 25 additions & 12 deletions integration-tests/deployment/ccip/view/chain.go
Original file line number Diff line number Diff line change
@@ -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),
}
}
33 changes: 33 additions & 0 deletions integration-tests/deployment/ccip/view/v1_0/rmn_proxy_contract.go
Original file line number Diff line number Diff line change
@@ -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
}
81 changes: 81 additions & 0 deletions integration-tests/deployment/ccip/view/v1_5/commit_store.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 86a9363

Please sign in to comment.