Skip to content

Commit

Permalink
Fix RMN contracts breaking changes [CCIP-4590] (#379)
Browse files Browse the repository at this point in the history
* RMNHome f to fObserve

* RMNRemote f to fSign

* change function name for RMNHome

* change function name for RMNRemote

---------

Co-authored-by: dimitris <[email protected]>
  • Loading branch information
asoliman92 and dimkouv authored Jan 7, 2025
1 parent a741be8 commit 48a464f
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions commit/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Test_maxObservationLength(t *testing.T) {
ContractAddress: make([]byte, 20),
ConfigDigest: [32]byte{},
Signers: make([]rmntypes.RemoteSignerInfo, estimatedMaxRmnNodesCount),
F: math.MaxUint64,
FSign: math.MaxUint64,
ConfigVersion: math.MaxUint32,
RmnReportVersion: [32]byte{},
},
Expand Down Expand Up @@ -175,7 +175,7 @@ func Test_maxOutcomeLength(t *testing.T) {
ContractAddress: make([]byte, 20),
ConfigDigest: [32]byte{},
Signers: make([]rmntypes.RemoteSignerInfo, estimatedMaxRmnNodesCount),
F: math.MaxUint64,
FSign: math.MaxUint64,
ConfigVersion: math.MaxUint32,
RmnReportVersion: [32]byte{},
},
Expand Down
2 changes: 1 addition & 1 deletion commit/merkleroot/observation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ func Test_shouldSkipRMNVerification(t *testing.T) {

prevOutcome := Outcome{}
if !tc.rmnRemoteConfigEmpty {
prevOutcome.RMNRemoteCfg = rmntypes.RemoteConfig{F: 1}
prevOutcome.RMNRemoteCfg = rmntypes.RemoteConfig{FSign: 1}
}

shouldSkip, err := shouldSkipRMNVerification(tc.nextProcessorState, q, prevOutcome)
Expand Down
6 changes: 3 additions & 3 deletions commit/merkleroot/rmn/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (c *controller) ComputeReportSignatures(
return nil, fmt.Errorf("process update requests: %w", err)
}

homeFMap, err := c.rmnHomeReader.GetF(rmnRemoteCfg.ConfigDigest)
homeFMap, err := c.rmnHomeReader.GetFObserve(rmnRemoteCfg.ConfigDigest)
if err != nil {
return nil, fmt.Errorf("get home F: %w", err)
}
Expand Down Expand Up @@ -625,7 +625,7 @@ func (c *controller) getRmnReportSignatures(
// At this point it is also possible that the signed observations contain
// different roots for the same source chain and interval.

homeChainF, err := c.rmnHomeReader.GetF(rmnRemoteCfg.ConfigDigest)
homeChainF, err := c.rmnHomeReader.GetFObserve(rmnRemoteCfg.ConfigDigest)
if err != nil {
return nil, fmt.Errorf("get home reader F: %w", err)
}
Expand Down Expand Up @@ -685,7 +685,7 @@ func (c *controller) getRmnReportSignatures(
},
AttributedSignedObservations: transformAndSortObservations(rmnSignedObservations),
}
remoteF := int(rmnRemoteCfg.F)
remoteF := int(rmnRemoteCfg.FSign)
signers := rmnRemoteCfg.Signers
requestIDs, signersRequested, err := c.sendReportSignatureRequest(
reportSigReq,
Expand Down
16 changes: 8 additions & 8 deletions commit/merkleroot/rmn/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
rmnRemoteCfg := rmntypes.RemoteConfig{
ContractAddress: []byte{1, 2, 3},
ConfigDigest: cciptypes.Bytes32{0x1, 0x2, 0x3},
F: 2,
FSign: 2,
Signers: []rmntypes.RemoteSignerInfo{
{
OnchainPublicKey: []byte{1, 2, 3},
Expand Down Expand Up @@ -493,7 +493,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
t.Run("empty lane update request", func(t *testing.T) {
ts := newTestSetup(t)

ts.rmnHomeMock.On("GetF", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
ts.rmnHomeMock.On("GetFObserve", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
map[cciptypes.ChainSelector]int{chainS1: 2, chainS2: 2}, nil)

ts.rmnHomeMock.On("GetRMNNodesInfo", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(ts.rmnNodes, nil)
Expand All @@ -511,7 +511,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
ts := newTestSetup(t)

ts.rmnHomeMock.On("GetRMNNodesInfo", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(ts.rmnNodes, nil)
ts.rmnHomeMock.On("GetF", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
ts.rmnHomeMock.On("GetFObserve", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
map[cciptypes.ChainSelector]int{chainS1: 2, chainS2: 2, chainD1: 2}, nil)
go func() {
requestIDs, requestedChains := ts.waitForObservationRequestsToBeSent(
Expand All @@ -522,7 +522,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {

requestIDs = ts.waitForReportSignatureRequestsToBeSent(
t, ts.peerClient,
int(ts.remoteRMNCfg.F)+1,
int(ts.remoteRMNCfg.FSign)+1,
ts.homeF,
)

Expand All @@ -537,7 +537,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
)
assert.NoError(t, err)
assert.Len(t, sigs.LaneUpdates, len(ts.updateRequests))
assert.Len(t, sigs.Signatures, int(ts.remoteRMNCfg.F+1))
assert.Len(t, sigs.Signatures, int(ts.remoteRMNCfg.FSign+1))
// Make sure signature are in ascending signer address order
for i := 1; i < len(sigs.Signatures); i++ {
assert.True(t, sigs.Signatures[i].R[0] > sigs.Signatures[i-1].R[0])
Expand All @@ -552,7 +552,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
ts.rmnController.reportsInitialRequestTimerDuration = time.Nanosecond

ts.rmnHomeMock.On("GetRMNNodesInfo", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(ts.rmnNodes, nil)
ts.rmnHomeMock.On("GetF", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
ts.rmnHomeMock.On("GetFObserve", cciptypes.Bytes32{0x1, 0x2, 0x3}).Return(
map[cciptypes.ChainSelector]int{chainS1: 2, chainS2: 2}, nil)

go func() {
Expand All @@ -578,7 +578,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
t.Logf("requestIDs: %v", requestIDs)

// requests should be sent to more than F+1 nodes, since we hit the timer timeout
assert.Greater(t, len(requestIDs), int(ts.remoteRMNCfg.F)+1)
assert.Greater(t, len(requestIDs), int(ts.remoteRMNCfg.FSign)+1)

ts.nodesRespondToTheSignatureRequests(ts.peerClient, requestIDs)
}()
Expand All @@ -591,7 +591,7 @@ func TestClient_ComputeReportSignatures(t *testing.T) {
)
assert.NoError(t, err)
assert.Len(t, sigs.LaneUpdates, len(ts.updateRequests))
assert.Len(t, sigs.Signatures, int(ts.remoteRMNCfg.F+1))
assert.Len(t, sigs.Signatures, int(ts.remoteRMNCfg.FSign+1))
})
}

Expand Down
4 changes: 2 additions & 2 deletions commit/merkleroot/rmn/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type RemoteConfig struct {
ConfigDigest cciptypes.Bytes32 `json:"configDigest"`
Signers []RemoteSignerInfo `json:"signers"`
// F defines the max number of faulty RMN nodes; F+1 signers are required to verify a report.
F uint64 `json:"f"` // previously: MinSigners
FSign uint64 `json:"fSign"` // previously: MinSigners
ConfigVersion uint32 `json:"configVersion"`
RmnReportVersion cciptypes.Bytes32 `json:"rmnReportVersion"` // e.g., keccak256("RMN_V1_6_ANY2EVM_REPORT")
}
Expand All @@ -44,7 +44,7 @@ func (r RemoteConfig) IsEmpty() bool {
return len(r.ContractAddress) == 0 &&
r.ConfigDigest == (cciptypes.Bytes32{}) &&
len(r.Signers) == 0 &&
r.F == 0 &&
r.FSign == 0 &&
r.ConfigVersion == 0 &&
r.RmnReportVersion == (cciptypes.Bytes32{})
}
Expand Down
8 changes: 4 additions & 4 deletions commit/merkleroot/rmn/types/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestRMNRemoteConfig_IsEmpty(t *testing.T) {
{
name: "Config with only F",
config: RemoteConfig{
F: 1,
FSign: 1,
},
expected: false,
},
Expand All @@ -67,7 +67,7 @@ func TestRMNRemoteConfig_IsEmpty(t *testing.T) {
ContractAddress: cciptypes.UnknownAddress{1, 2, 3},
ConfigDigest: cciptypes.Bytes32{1},
Signers: []RemoteSignerInfo{{}, {}},
F: 2,
FSign: 2,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{1},
},
Expand All @@ -79,7 +79,7 @@ func TestRMNRemoteConfig_IsEmpty(t *testing.T) {
ContractAddress: nil,
ConfigDigest: cciptypes.Bytes32{1},
Signers: []RemoteSignerInfo{{}, {}},
F: 2,
FSign: 2,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{1},
},
Expand All @@ -91,7 +91,7 @@ func TestRMNRemoteConfig_IsEmpty(t *testing.T) {
ContractAddress: cciptypes.UnknownAddress{},
ConfigDigest: cciptypes.Bytes32{1},
Signers: []RemoteSignerInfo{{}, {}},
F: 2,
FSign: 2,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{1},
},
Expand Down
2 changes: 1 addition & 1 deletion commit/merkleroot/validate_observation.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func validateRMNRemoteConfig(
return fmt.Errorf("empty RmnReportVersion")
}

if uint64(len(rmnRemoteConfig.Signers)) < rmnRemoteConfig.F+1 {
if uint64(len(rmnRemoteConfig.Signers)) < rmnRemoteConfig.FSign+1 {
return fmt.Errorf("not enough signers to cover F+1 threshold")
}

Expand Down
16 changes: 8 additions & 8 deletions commit/merkleroot/validate_observation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -215,7 +215,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -233,7 +233,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -251,7 +251,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -267,7 +267,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
Signers: []types.RemoteSignerInfo{
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1}, // <----
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -285,7 +285,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{},
},
Expand All @@ -303,7 +303,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 1}, // <---------
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand All @@ -321,7 +321,7 @@ func Test_validateRMNRemoteConfig(t *testing.T) {
{OnchainPublicKey: []byte{0, 0, 2}, NodeIndex: 1},
{OnchainPublicKey: []byte{0, 0, 3}, NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: 1,
RmnReportVersion: cciptypes.Bytes32{0, 0, 0, 1},
},
Expand Down
2 changes: 1 addition & 1 deletion commit/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (p *Plugin) Reports(
}

if outcome.MerkleRootOutcome.OutcomeType == merkleroot.ReportGenerated {
repInfo = ReportInfo{RemoteF: outcome.MerkleRootOutcome.RMNRemoteCfg.F}
repInfo = ReportInfo{RemoteF: outcome.MerkleRootOutcome.RMNRemoteCfg.FSign}
}

if rep.IsEmpty() {
Expand Down
2 changes: 1 addition & 1 deletion commit/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestPluginReports(t *testing.T) {
MerkleRoot: ccipocr3.Bytes32{1, 2, 3, 4, 5, 6},
},
},
RMNRemoteCfg: rmntypes.RemoteConfig{F: 123},
RMNRemoteCfg: rmntypes.RemoteConfig{FSign: 123},
},
TokenPriceOutcome: tokenprice.Outcome{
TokenPrices: []ccipocr3.TokenPrice{
Expand Down
2 changes: 1 addition & 1 deletion internal/libs/testhelpers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func CreateRMNRemoteCfg() rmntypes.RemoteConfig {
{OnchainPublicKey: append(rand.RandomBytes(20), byte(1)), NodeIndex: 1},
{OnchainPublicKey: append(rand.RandomBytes(20), byte(2)), NodeIndex: 2},
},
F: 1,
FSign: 1,
ConfigVersion: rand.RandomUint32(),
RmnReportVersion: rand.RandomReportVersion(),
}
Expand Down
4 changes: 2 additions & 2 deletions internal/reader/rmn_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type RMNRemote interface {
GetF() uint64
GetFSign() uint64
GetSignersInfo() []rmntypes.RemoteSignerInfo
GetRmnReportVersion() string
GetRmnRemoteContractAddress() string
Expand All @@ -24,7 +24,7 @@ func NewRMNRemotePoller() RMNRemote {
}
}

func (r *RmnRemotePoller) GetF() uint64 {
func (r *RmnRemotePoller) GetFSign() uint64 {
panic("implement me")
}

Expand Down
22 changes: 11 additions & 11 deletions mocks/internal_/reader/rmn_remote.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 48a464f

Please sign in to comment.