Skip to content

Commit

Permalink
rmn details
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Sep 10, 2024
1 parent 5a8812c commit 85e01a8
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 6 deletions.
36 changes: 36 additions & 0 deletions integration-tests/deployment/ccip/contractwrappers/rmn1_6/rmn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package rmn1_6

import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"

"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/rmn_remote"
)

type RMN struct {
*rmn_remote.RMNRemote
}

func (rmn *RMN) GetVersionedConfig(opts *bind.CallOpts) (view.RMNRemoteVersionedConfig, error) {
config, err := rmn.RMNRemote.GetVersionedConfig(opts)
if err != nil {
return view.RMNRemoteVersionedConfig{}, err
}
var signers []view.RMNRemoteSigner
for _, signer := range config.Config.Signers {
signers = append(signers, view.RMNRemoteSigner{
OnchainPublicKey: signer.OnchainPublicKey.Hex(),
NodeIndex: signer.NodeIndex,
})
}
return view.RMNRemoteVersionedConfig{
Version: config.Version,
MinSigners: config.Config.MinSigners,
Signers: signers,
}, nil

}

func New(rmn *rmn_remote.RMNRemote) *RMN {
return &RMN{rmn}
}
13 changes: 11 additions & 2 deletions integration-tests/deployment/ccip/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
owner_wrappers "github.com/smartcontractkit/ccip-owner-contracts/gethwrappers"

"github.com/smartcontractkit/chainlink/integration-tests/deployment"
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/contractwrappers/rmn1_6"
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/contractwrappers/router1_2"
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view"

Expand Down Expand Up @@ -37,7 +38,7 @@ type CCIPChainState struct {
TokenAdminRegistry *token_admin_registry.TokenAdminRegistry
Router *router1_2.Router
Weth9 *weth9.WETH9
RMNRemote *rmn_remote.RMNRemote
RMNRemote *rmn1_6.RMN
// TODO: May need to support older link too
LinkToken *burn_mint_erc677.BurnMintERC677
// Note we only expect one of these (on the home chain)
Expand Down Expand Up @@ -103,6 +104,14 @@ func (s CCIPOnChainState) Snapshot(chains []uint64) (view.CCIPSnapShot, error) {
}
c.NonceManager[nm.Address().Hex()] = nmSnapshot
}
rmn := s.Chains[chainSelector].RMNRemote
if rmn != nil {
rmnSnapshot, err := view.RMNSnapshot(rmn)
if err != nil {
return snapshot, err
}
c.RMN[rmn.Address().Hex()] = rmnSnapshot
}
snapshot.Chains[chainName] = c
}
return snapshot, nil
Expand Down Expand Up @@ -174,7 +183,7 @@ func LoadChainState(chain deployment.Chain, addresses map[string]deployment.Type
if err != nil {
return state, err
}
state.RMNRemote = rmnRemote
state.RMNRemote = rmn1_6.New(rmnRemote)
case deployment.NewTypeAndVersion(WETH9, deployment.Version1_0_0).String():
weth9, err := weth9.NewWETH9(common.HexToAddress(address), chain.Client)
if err != nil {
Expand Down
8 changes: 6 additions & 2 deletions integration-tests/deployment/ccip/view/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ type Chain struct {
TokenAdminRegistry map[string]TokenAdminRegistry `json:"tokenAdminRegistry"`
NonceManager map[string]NonceManager `json:"nonceManager"`
Router map[string]Router `json:"router"`
RMN map[string]RMN `json:"rmn"`
}

func NewChain() Chain {
return Chain{
TokenAdminRegistry: make(map[string]TokenAdminRegistry),
NonceManager: make(map[string]NonceManager),
DestinationChainSelectors: make([]uint64, 0),
TokenAdminRegistry: make(map[string]TokenAdminRegistry),
NonceManager: make(map[string]NonceManager),
Router: make(map[string]Router),
RMN: make(map[string]RMN),
}
}
52 changes: 52 additions & 0 deletions integration-tests/deployment/ccip/view/rmn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package view

import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
)

type RMN struct {
Contract
IsCursed bool `json:"isCursed"`
Config RMNRemoteVersionedConfig `json:"config"`
}

type RMNRemoteVersionedConfig struct {
Version uint32 `json:"version"`
Signers []RMNRemoteSigner `json:"signers"`
MinSigners uint64 `json:"minSigners"`
}

type RMNRemoteSigner struct {
OnchainPublicKey string `json:"onchain_public_key"`
NodeIndex uint64 `json:"node_index"`
}

func RMNSnapshot(rmnReader RMNReader) (RMN, error) {
tv, err := rmnReader.TypeAndVersion(nil)
if err != nil {
return RMN{}, err
}
config, err := rmnReader.GetVersionedConfig(nil)
if err != nil {
return RMN{}, err
}
isCursed, err := rmnReader.IsCursed0(nil)
if err != nil {
return RMN{}, err
}
return RMN{
Contract: Contract{
Address: rmnReader.Address().Hex(),
TypeAndVersion: tv,
},
IsCursed: isCursed,
Config: config,
}, nil
}

type RMNReader interface {
ContractState
GetVersionedConfig(opts *bind.CallOpts) (RMNRemoteVersionedConfig, error)
IsCursed(opts *bind.CallOpts, subject [16]byte) (bool, error)
IsCursed0(opts *bind.CallOpts) (bool, error)
}
4 changes: 2 additions & 2 deletions integration-tests/deployment/ccip/view/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func RouterSnapshot(r RouterReader) (Router, error) {
}

type RouterOffRamp struct {
SourceChainSelector uint64
OffRamp string
SourceChainSelector uint64 `json:"source_chain_selector"`
OffRamp string `json:"off_ramp"`
}

type RouterReader interface {
Expand Down

0 comments on commit 85e01a8

Please sign in to comment.