Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMN home and remote readers #137

Merged
merged 11 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ packages:
github.com/smartcontractkit/chainlink-ccip/internal/reader:
interfaces:
HomeChain:
RMNHome:
RMNRemote:
CCIP:
PriceReader:
github.com/smartcontractkit/chainlink-ccip/internal/reader/contractreader:
Expand Down
46 changes: 46 additions & 0 deletions commit/merkleroot/rmn/types/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package types

import (
"crypto/ed25519"

mapset "github.com/deckarep/golang-set/v2"

ragep2ptypes "github.com/smartcontractkit/libocr/ragep2p/types"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
)

type NodeID uint32
0xnogo marked this conversation as resolved.
Show resolved Hide resolved

// RMNHomeConfig contains the configuration fetched from the RMNHome contract.
type RMNHomeConfig struct {
Nodes []RMNHomeNodeInfo
SourceChainMinObservers map[cciptypes.ChainSelector]uint64
ConfigDigest cciptypes.Bytes32
OffchainConfig cciptypes.Bytes // The raw offchain config
}

// RMNHomeNodeInfo contains information about a node from the RMNHome contract.
type RMNHomeNodeInfo struct {
ID NodeID // ID is the index of this node in the RMN config
PeerID ragep2ptypes.PeerID // The peer ID of the node
SupportedSourceChains mapset.Set[cciptypes.ChainSelector] // Set of supported source chains by the node
OffchainPublicKey *ed25519.PublicKey // The public key is used to verify observations
}

// RMNRemoteConfig contains the configuration fetched from the RMNRemote contract.
type RMNRemoteConfig struct {
ContractAddress cciptypes.Bytes
ConfigDigest cciptypes.Bytes32
Signers []RMNRemoteSignerInfo
MinSigners uint64
0xnogo marked this conversation as resolved.
Show resolved Hide resolved
ConfigVersion uint32
RmnReportVersion string // e.g., "RMN_V1_6_ANY2EVM_REPORT"
}

// RMNRemoteSignerInfo contains information about a signer from the RMNRemote contract.
type RMNRemoteSignerInfo struct {
OnchainPublicKey cciptypes.Bytes // The signer's onchain address, used to verify report signature
NodeIndex uint64 // The index of the node in the RMN config
SignObservationPrefix string // The prefix of the observation to sign
}
29 changes: 7 additions & 22 deletions internal/reader/home_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/libocr/commontypes"
libocrtypes "github.com/smartcontractkit/libocr/ragep2p/types"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand All @@ -23,15 +22,10 @@ import (
)

var (
chainA = cciptypes.ChainSelector(1)
chainB = cciptypes.ChainSelector(2)
chainC = cciptypes.ChainSelector(3)
oracleAId = commontypes.OracleID(1)
p2pOracleAId = libocrtypes.PeerID{byte(oracleAId)}
oracleBId = commontypes.OracleID(2)
p2pOracleBId = libocrtypes.PeerID{byte(oracleBId)}
oracleCId = commontypes.OracleID(3)
p2pOracleCId = libocrtypes.PeerID{byte(oracleCId)}
ccipConfigBoundContract = types.BoundContract{
Address: "0xCCIPConfigFakeAddress",
Name: consts.ContractNameCCIPConfig,
}
)

func TestHomeChainConfigPoller_HealthReport(t *testing.T) {
Expand All @@ -52,10 +46,7 @@ func TestHomeChainConfigPoller_HealthReport(t *testing.T) {
homeChainReader,
logger.Test(t),
tickTime,
types.BoundContract{
Address: "0xCCIPConfigFakeAddress",
Name: consts.ContractNameCCIPConfig,
},
ccipConfigBoundContract,
)
require.NoError(t, configPoller.Start(context.Background()))
// Initially it's healthy
Expand Down Expand Up @@ -151,10 +142,7 @@ func Test_PollingWorking(t *testing.T) {
homeChainReader,
logger.Test(t),
tickTime,
types.BoundContract{
Address: "0xCCIPConfigFakeAddress",
Name: consts.ContractNameCCIPConfig,
},
ccipConfigBoundContract,
)

require.NoError(t, configPoller.Start(context.Background()))
Expand Down Expand Up @@ -209,10 +197,7 @@ func Test_HomeChainPoller_GetOCRConfig(t *testing.T) {
homeChainReader,
logger.Test(t),
10*time.Millisecond,
types.BoundContract{
Address: "0xCCIPConfigFakeAddress",
Name: consts.ContractNameCCIPConfig,
},
ccipConfigBoundContract,
)

configs, err := configPoller.GetOCRConfigs(context.Background(), donID, pluginType)
Expand Down
Loading
Loading