From 48a464fc0b8840ef81903bff73b07543c62249d8 Mon Sep 17 00:00:00 2001 From: "Abdelrahman Soliman (Boda)" <2677789+asoliman92@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:48:34 +0200 Subject: [PATCH] Fix RMN contracts breaking changes [CCIP-4590] (#379) * RMNHome f to fObserve * RMNRemote f to fSign * change function name for RMNHome * change function name for RMNRemote --------- Co-authored-by: dimitris --- commit/factory_test.go | 4 ++-- commit/merkleroot/observation_test.go | 2 +- commit/merkleroot/rmn/controller.go | 6 ++--- commit/merkleroot/rmn/controller_test.go | 16 +++++++------- commit/merkleroot/rmn/types/config.go | 4 ++-- commit/merkleroot/rmn/types/config_test.go | 8 +++---- commit/merkleroot/validate_observation.go | 2 +- .../merkleroot/validate_observation_test.go | 16 +++++++------- commit/report.go | 2 +- commit/report_test.go | 2 +- internal/libs/testhelpers/common.go | 2 +- internal/reader/rmn_remote.go | 4 ++-- mocks/internal_/reader/rmn_remote.go | 22 +++++++++---------- mocks/pkg/reader/rmn_home.go | 22 +++++++++---------- pkg/reader/ccip.go | 2 +- pkg/reader/rmn_home.go | 10 ++++----- pkg/reader/rmn_home_test.go | 20 ++++++++--------- 17 files changed, 72 insertions(+), 72 deletions(-) diff --git a/commit/factory_test.go b/commit/factory_test.go index da105a12c..2bebcfeb4 100644 --- a/commit/factory_test.go +++ b/commit/factory_test.go @@ -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{}, }, @@ -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{}, }, diff --git a/commit/merkleroot/observation_test.go b/commit/merkleroot/observation_test.go index 56bfbcc29..5544abd96 100644 --- a/commit/merkleroot/observation_test.go +++ b/commit/merkleroot/observation_test.go @@ -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) diff --git a/commit/merkleroot/rmn/controller.go b/commit/merkleroot/rmn/controller.go index 61d0f5b90..047710252 100644 --- a/commit/merkleroot/rmn/controller.go +++ b/commit/merkleroot/rmn/controller.go @@ -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) } @@ -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) } @@ -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, diff --git a/commit/merkleroot/rmn/controller_test.go b/commit/merkleroot/rmn/controller_test.go index e1f3a25f9..b865ddc7b 100644 --- a/commit/merkleroot/rmn/controller_test.go +++ b/commit/merkleroot/rmn/controller_test.go @@ -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}, @@ -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) @@ -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( @@ -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, ) @@ -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]) @@ -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() { @@ -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) }() @@ -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)) }) } diff --git a/commit/merkleroot/rmn/types/config.go b/commit/merkleroot/rmn/types/config.go index de27b889a..f5b4ce8bb 100644 --- a/commit/merkleroot/rmn/types/config.go +++ b/commit/merkleroot/rmn/types/config.go @@ -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") } @@ -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{}) } diff --git a/commit/merkleroot/rmn/types/config_test.go b/commit/merkleroot/rmn/types/config_test.go index ab793ccfd..81270ba16 100644 --- a/commit/merkleroot/rmn/types/config_test.go +++ b/commit/merkleroot/rmn/types/config_test.go @@ -43,7 +43,7 @@ func TestRMNRemoteConfig_IsEmpty(t *testing.T) { { name: "Config with only F", config: RemoteConfig{ - F: 1, + FSign: 1, }, expected: false, }, @@ -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}, }, @@ -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}, }, @@ -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}, }, diff --git a/commit/merkleroot/validate_observation.go b/commit/merkleroot/validate_observation.go index 40ffaf221..043b63415 100644 --- a/commit/merkleroot/validate_observation.go +++ b/commit/merkleroot/validate_observation.go @@ -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") } diff --git a/commit/merkleroot/validate_observation_test.go b/commit/merkleroot/validate_observation_test.go index e3213f07c..df5ba36e2 100644 --- a/commit/merkleroot/validate_observation_test.go +++ b/commit/merkleroot/validate_observation_test.go @@ -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}, }, @@ -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}, }, @@ -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}, }, @@ -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}, }, @@ -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}, }, @@ -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{}, }, @@ -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}, }, @@ -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}, }, diff --git a/commit/report.go b/commit/report.go index c6e0885ea..e38b28360 100644 --- a/commit/report.go +++ b/commit/report.go @@ -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() { diff --git a/commit/report_test.go b/commit/report_test.go index 32c90f66c..7b739b5f9 100644 --- a/commit/report_test.go +++ b/commit/report_test.go @@ -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{ diff --git a/internal/libs/testhelpers/common.go b/internal/libs/testhelpers/common.go index f261cc734..1282e8331 100644 --- a/internal/libs/testhelpers/common.go +++ b/internal/libs/testhelpers/common.go @@ -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(), } diff --git a/internal/reader/rmn_remote.go b/internal/reader/rmn_remote.go index c146930c0..78bd20d4a 100644 --- a/internal/reader/rmn_remote.go +++ b/internal/reader/rmn_remote.go @@ -7,7 +7,7 @@ import ( ) type RMNRemote interface { - GetF() uint64 + GetFSign() uint64 GetSignersInfo() []rmntypes.RemoteSignerInfo GetRmnReportVersion() string GetRmnRemoteContractAddress() string @@ -24,7 +24,7 @@ func NewRMNRemotePoller() RMNRemote { } } -func (r *RmnRemotePoller) GetF() uint64 { +func (r *RmnRemotePoller) GetFSign() uint64 { panic("implement me") } diff --git a/mocks/internal_/reader/rmn_remote.go b/mocks/internal_/reader/rmn_remote.go index 9337567fb..7399f4248 100644 --- a/mocks/internal_/reader/rmn_remote.go +++ b/mocks/internal_/reader/rmn_remote.go @@ -22,12 +22,12 @@ func (_m *MockRMNRemote) EXPECT() *MockRMNRemote_Expecter { return &MockRMNRemote_Expecter{mock: &_m.Mock} } -// GetF provides a mock function with given fields: -func (_m *MockRMNRemote) GetF() uint64 { +// GetFSign provides a mock function with given fields: +func (_m *MockRMNRemote) GetFSign() uint64 { ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetF") + panic("no return value specified for GetFSign") } var r0 uint64 @@ -40,29 +40,29 @@ func (_m *MockRMNRemote) GetF() uint64 { return r0 } -// MockRMNRemote_GetF_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetF' -type MockRMNRemote_GetF_Call struct { +// MockRMNRemote_GetFSign_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFSign' +type MockRMNRemote_GetFSign_Call struct { *mock.Call } -// GetF is a helper method to define mock.On call -func (_e *MockRMNRemote_Expecter) GetF() *MockRMNRemote_GetF_Call { - return &MockRMNRemote_GetF_Call{Call: _e.mock.On("GetF")} +// GetFSign is a helper method to define mock.On call +func (_e *MockRMNRemote_Expecter) GetFSign() *MockRMNRemote_GetFSign_Call { + return &MockRMNRemote_GetFSign_Call{Call: _e.mock.On("GetFSign")} } -func (_c *MockRMNRemote_GetF_Call) Run(run func()) *MockRMNRemote_GetF_Call { +func (_c *MockRMNRemote_GetFSign_Call) Run(run func()) *MockRMNRemote_GetFSign_Call { _c.Call.Run(func(args mock.Arguments) { run() }) return _c } -func (_c *MockRMNRemote_GetF_Call) Return(_a0 uint64) *MockRMNRemote_GetF_Call { +func (_c *MockRMNRemote_GetFSign_Call) Return(_a0 uint64) *MockRMNRemote_GetFSign_Call { _c.Call.Return(_a0) return _c } -func (_c *MockRMNRemote_GetF_Call) RunAndReturn(run func() uint64) *MockRMNRemote_GetF_Call { +func (_c *MockRMNRemote_GetFSign_Call) RunAndReturn(run func() uint64) *MockRMNRemote_GetFSign_Call { _c.Call.Return(run) return _c } diff --git a/mocks/pkg/reader/rmn_home.go b/mocks/pkg/reader/rmn_home.go index 825cad5cf..1f4d8084b 100644 --- a/mocks/pkg/reader/rmn_home.go +++ b/mocks/pkg/reader/rmn_home.go @@ -129,12 +129,12 @@ func (_c *MockRMNHome_GetAllConfigDigests_Call) RunAndReturn(run func() (ccipocr return _c } -// GetF provides a mock function with given fields: configDigest -func (_m *MockRMNHome) GetF(configDigest ccipocr3.Bytes32) (map[ccipocr3.ChainSelector]int, error) { +// GetFObserve provides a mock function with given fields: configDigest +func (_m *MockRMNHome) GetFObserve(configDigest ccipocr3.Bytes32) (map[ccipocr3.ChainSelector]int, error) { ret := _m.Called(configDigest) if len(ret) == 0 { - panic("no return value specified for GetF") + panic("no return value specified for GetFObserve") } var r0 map[ccipocr3.ChainSelector]int @@ -159,30 +159,30 @@ func (_m *MockRMNHome) GetF(configDigest ccipocr3.Bytes32) (map[ccipocr3.ChainSe return r0, r1 } -// MockRMNHome_GetF_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetF' -type MockRMNHome_GetF_Call struct { +// MockRMNHome_GetFObserve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFObserve' +type MockRMNHome_GetFObserve_Call struct { *mock.Call } -// GetF is a helper method to define mock.On call +// GetFObserve is a helper method to define mock.On call // - configDigest ccipocr3.Bytes32 -func (_e *MockRMNHome_Expecter) GetF(configDigest interface{}) *MockRMNHome_GetF_Call { - return &MockRMNHome_GetF_Call{Call: _e.mock.On("GetF", configDigest)} +func (_e *MockRMNHome_Expecter) GetFObserve(configDigest interface{}) *MockRMNHome_GetFObserve_Call { + return &MockRMNHome_GetFObserve_Call{Call: _e.mock.On("GetFObserve", configDigest)} } -func (_c *MockRMNHome_GetF_Call) Run(run func(configDigest ccipocr3.Bytes32)) *MockRMNHome_GetF_Call { +func (_c *MockRMNHome_GetFObserve_Call) Run(run func(configDigest ccipocr3.Bytes32)) *MockRMNHome_GetFObserve_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(ccipocr3.Bytes32)) }) return _c } -func (_c *MockRMNHome_GetF_Call) Return(_a0 map[ccipocr3.ChainSelector]int, _a1 error) *MockRMNHome_GetF_Call { +func (_c *MockRMNHome_GetFObserve_Call) Return(_a0 map[ccipocr3.ChainSelector]int, _a1 error) *MockRMNHome_GetFObserve_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockRMNHome_GetF_Call) RunAndReturn(run func(ccipocr3.Bytes32) (map[ccipocr3.ChainSelector]int, error)) *MockRMNHome_GetF_Call { +func (_c *MockRMNHome_GetFObserve_Call) RunAndReturn(run func(ccipocr3.Bytes32) (map[ccipocr3.ChainSelector]int, error)) *MockRMNHome_GetFObserve_Call { _c.Call.Return(run) return _c } diff --git a/pkg/reader/ccip.go b/pkg/reader/ccip.go index e1a9fb2e8..b0993a989 100644 --- a/pkg/reader/ccip.go +++ b/pkg/reader/ccip.go @@ -698,7 +698,7 @@ func (r *ccipChainReader) GetRMNRemoteConfig( ContractAddress: rmnRemoteAddress, ConfigDigest: cciptypes.Bytes32(vc.Config.RMNHomeContractConfigDigest), Signers: signers, - F: vc.Config.F, + FSign: vc.Config.F, ConfigVersion: vc.Version, RmnReportVersion: header.DigestHeader, }, nil diff --git a/pkg/reader/rmn_home.go b/pkg/reader/rmn_home.go index 6fc52e249..aa325c730 100644 --- a/pkg/reader/rmn_home.go +++ b/pkg/reader/rmn_home.go @@ -38,9 +38,9 @@ type RMNHome interface { GetRMNNodesInfo(configDigest cciptypes.Bytes32) ([]rmntypes.HomeNodeInfo, error) // IsRMNHomeConfigDigestSet checks if the configDigest is set in the RMNHome contract IsRMNHomeConfigDigestSet(configDigest cciptypes.Bytes32) bool - // GetF gets the F value for each source chain in the given configDigest. + // GetFObserve gets the F value for each source chain in the given configDigest. // Maximum number of faulty observers; F+1 observers required to agree on an observation for a source chain. - GetF(configDigest cciptypes.Bytes32) (map[cciptypes.ChainSelector]int, error) + GetFObserve(configDigest cciptypes.Bytes32) (map[cciptypes.ChainSelector]int, error) // GetOffChainConfig gets the offchain config for the given configDigest GetOffChainConfig(configDigest cciptypes.Bytes32) (cciptypes.Bytes, error) // GetAllConfigDigests gets the active and candidate RMNHomeConfigs @@ -195,7 +195,7 @@ func (r *rmnHomePoller) IsRMNHomeConfigDigestSet(configDigest cciptypes.Bytes32) return ok } -func (r *rmnHomePoller) GetF(configDigest cciptypes.Bytes32) (map[cciptypes.ChainSelector]int, error) { +func (r *rmnHomePoller) GetFObserve(configDigest cciptypes.Bytes32) (map[cciptypes.ChainSelector]int, error) { r.mutex.RLock() defer r.mutex.RUnlock() _, ok := r.rmnHomeState.rmnHomeConfig[configDigest] @@ -304,7 +304,7 @@ func convertOnChainConfigToRMNHomeChainConfig( homeFMap := make(map[cciptypes.ChainSelector]int) for _, chain := range versionedConfig.DynamicConfig.SourceChains { - homeFMap[chain.ChainSelector] = int(chain.F) + homeFMap[chain.ChainSelector] = int(chain.FObserve) for j := 0; j < len(nodes); j++ { isObserver, err := IsNodeObserver(chain, j, len(nodes)) if err != nil { @@ -388,7 +388,7 @@ type Node struct { // SourceChain mirrors RMNHome.sol's SourceChain struct type SourceChain struct { ChainSelector cciptypes.ChainSelector `json:"chainSelector"` - F uint64 `json:"f"` // previously: MinObservers + FObserve uint64 `json:"fObserve"` // previously: MinObservers / F ObserverNodesBitmap *big.Int `json:"observerNodesBitmap"` } diff --git a/pkg/reader/rmn_home_test.go b/pkg/reader/rmn_home_test.go index cb3a32753..17b72e37b 100644 --- a/pkg/reader/rmn_home_test.go +++ b/pkg/reader/rmn_home_test.go @@ -250,7 +250,7 @@ func Test_RMNHomePollingWorking(t *testing.T) { require.NotEmpty(t, offchainConfig) } - minObsMap, err := configPoller.GetF(config.ConfigDigest) + minObsMap, err := configPoller.GetFObserve(config.ConfigDigest) if isEmpty { require.Error(t, err) require.Empty(t, minObsMap) @@ -323,7 +323,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Node is observer", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(7), // 111 in binary }, nodeIndex: 1, @@ -335,7 +335,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Node is not observer", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(5), // 101 in binary }, nodeIndex: 1, @@ -347,7 +347,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Node index out of range (high)", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(7), // 111 in binary }, nodeIndex: 3, @@ -359,7 +359,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Negative node index", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(7), // 111 in binary }, nodeIndex: -1, @@ -371,7 +371,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Invalid bitmap (out of bounds)", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(8), // 1000 in binary }, nodeIndex: 0, @@ -383,7 +383,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Zero total nodes", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(1), }, nodeIndex: 0, @@ -395,7 +395,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Total nodes exceeds 256", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 3, + FObserve: 3, ObserverNodesBitmap: big.NewInt(1), }, nodeIndex: 0, @@ -407,7 +407,7 @@ func TestIsNodeObserver(t *testing.T) { name: "Last valid node is observer", sourceChain: SourceChain{ ChainSelector: cciptypes.ChainSelector(1), - F: 1, + FObserve: 1, ObserverNodesBitmap: new(big.Int).SetBit(big.NewInt(0), 255, 1), // Only the 256th bit is set }, nodeIndex: 255, @@ -447,7 +447,7 @@ func createTestRMNHomeConfigs( SourceChains: []SourceChain{ { ChainSelector: cciptypes.ChainSelector(id), - F: uint64(id), + FObserve: uint64(id), ObserverNodesBitmap: big.NewInt(int64(id)), }, },