Skip to content

Commit

Permalink
Merge d99e573 into fcefd62
Browse files Browse the repository at this point in the history
  • Loading branch information
jhweintraub authored Jan 8, 2025
2 parents fcefd62 + d99e573 commit 48b46e9
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-lizards-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Changed RMNRemote and RMNHome parameter f to fObserve and fSign #updated
5 changes: 5 additions & 0 deletions contracts/.changeset/stale-dots-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

replace f with fObserve in RMNHome and RMNRemote and update all tests CCIP-4058
4 changes: 2 additions & 2 deletions contracts/src/v0.8/ccip/rmn/RMNHome.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract RMNHome is Ownable2StepMsgSender, ITypeAndVersion {

struct SourceChain {
uint64 chainSelector; // ─╮ The Source chain selector.
uint64 f; // ─────────────╯ Maximum number of faulty observers; f+1 observers required to agree on an observation for this source chain.
uint64 fObserve; // ─────────────╯ Maximum number of faulty observers; f+1 observers required to agree on an observation for this source chain.
uint256 observerNodesBitmap; // ObserverNodesBitmap & (1<<i) == (1<<i) iff StaticConfig.nodes[i] is an observer for this source chain.
}

Expand Down Expand Up @@ -387,7 +387,7 @@ contract RMNHome is Ownable2StepMsgSender, ITypeAndVersion {
}

// min observers are tenable.
if (observersCount < 2 * currentSourceChain.f + 1) {
if (observersCount < 2 * currentSourceChain.fObserve + 1) {
revert NotEnoughObservers();
}
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/v0.8/ccip/rmn/RMNRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
struct Config {
bytes32 rmnHomeContractConfigDigest; // Digest of the RMNHome contract config.
Signer[] signers; // List of signers.
uint64 f; // Max number of faulty RMN nodes; f+1 signers are required to verify a report, must configure 2f+1 signers in total.
uint64 fSign; // Max number of faulty RMN nodes; f+1 signers are required to verify a report, must configure 2f+1 signers in total.
}

/// @dev part of the payload that RMN nodes sign: keccak256(abi.encode(RMN_V1_6_ANY2EVM_REPORT, report)).
Expand Down Expand Up @@ -101,7 +101,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
if (s_configCount == 0) {
revert ConfigNotSet();
}
if (signatures.length < s_config.f + 1) revert ThresholdNotMet();
if (signatures.length < s_config.fSign + 1) revert ThresholdNotMet();

bytes32 digest = keccak256(
abi.encode(
Expand Down Expand Up @@ -150,7 +150,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
}

// min signers requirement is tenable.
if (newConfig.signers.length < 2 * newConfig.f + 1) {
if (newConfig.signers.length < 2 * newConfig.fSign + 1) {
revert NotEnoughSigners();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract RMNHome_revokeCandidate is RMNHomeTestSetup {
bytes32 digest = s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, ZERO_DIGEST);
s_rmnHome.promoteCandidateAndRevokeActive(digest, ZERO_DIGEST);

config.dynamicConfig.sourceChains[1].f--;
config.dynamicConfig.sourceChains[1].fObserve--;
s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, ZERO_DIGEST);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract RMNHome_setCandidate is RMNHomeTestSetup {
for (uint256 i = 0; i < storedDynamicConfig.sourceChains.length; i++) {
RMNHome.SourceChain memory storedSourceChain = storedDynamicConfig.sourceChains[i];
assertEq(storedSourceChain.chainSelector, versionedConfig.dynamicConfig.sourceChains[i].chainSelector);
assertEq(storedSourceChain.f, versionedConfig.dynamicConfig.sourceChains[i].f);
assertEq(storedSourceChain.fObserve, versionedConfig.dynamicConfig.sourceChains[i].fObserve);
assertEq(storedSourceChain.observerNodesBitmap, versionedConfig.dynamicConfig.sourceChains[i].observerNodesBitmap);
}
assertEq(storedDynamicConfig.offchainConfig, versionedConfig.dynamicConfig.offchainConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract RMNHome_setDynamicConfig is RMNHomeTestSetup {
(bytes32 priorActiveDigest,) = s_rmnHome.getConfigDigests();

Config memory config = _getBaseConfig();
config.dynamicConfig.sourceChains[1].f--;
config.dynamicConfig.sourceChains[1].fObserve--;

(, bytes32 candidateConfigDigest) = s_rmnHome.getConfigDigests();

Expand All @@ -27,7 +27,9 @@ contract RMNHome_setDynamicConfig is RMNHomeTestSetup {

(RMNHome.VersionedConfig memory storedVersionedConfig, bool ok) = s_rmnHome.getConfig(candidateConfigDigest);
assertTrue(ok);
assertEq(storedVersionedConfig.dynamicConfig.sourceChains[0].f, config.dynamicConfig.sourceChains[0].f);
assertEq(
storedVersionedConfig.dynamicConfig.sourceChains[0].fObserve, config.dynamicConfig.sourceChains[0].fObserve
);

// Asser the digests don't change when updating the dynamic config
(bytes32 activeDigest, bytes32 candidateDigest) = s_rmnHome.getConfigDigests();
Expand All @@ -38,7 +40,7 @@ contract RMNHome_setDynamicConfig is RMNHomeTestSetup {
// Asserts the validation function is being called
function test_RevertWhen_setDynamicConfig_MinObserversTooHigh() public {
Config memory config = _getBaseConfig();
config.dynamicConfig.sourceChains[0].f++;
config.dynamicConfig.sourceChains[0].fObserve++;

vm.expectRevert(abi.encodeWithSelector(RMNHome.DigestNotFound.selector, ZERO_DIGEST));
s_rmnHome.setDynamicConfig(config.dynamicConfig, ZERO_DIGEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract RMNHome_validateStaticAndDynamicConfig is RMNHomeTestSetup {

function test_RevertWhen_validateStaticAndDynamicConfig_NotEnoughObservers() public {
Config memory config = _getBaseConfig();
config.dynamicConfig.sourceChains[0].f++;
config.dynamicConfig.sourceChains[0].fObserve++;

vm.expectRevert(RMNHome.NotEnoughObservers.selector);
s_rmnHome.setCandidate(config.staticConfig, config.dynamicConfig, ZERO_DIGEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ contract RMNHomeTestSetup is Test {

RMNHome.SourceChain[] memory sourceChains = new RMNHome.SourceChain[](2);
// Observer 0 for source chain 9000
sourceChains[0] = RMNHome.SourceChain({chainSelector: 9000, f: 1, observerNodesBitmap: 1 << 0 | 1 << 1 | 1 << 2});
sourceChains[0] =
RMNHome.SourceChain({chainSelector: 9000, fObserve: 1, observerNodesBitmap: 1 << 0 | 1 << 1 | 1 << 2});
// Observers 0, 1 and 2 for source chain 9001
sourceChains[1] = RMNHome.SourceChain({chainSelector: 9001, f: 1, observerNodesBitmap: 1 << 0 | 1 << 1 | 1 << 2});
sourceChains[1] =
RMNHome.SourceChain({chainSelector: 9001, fObserve: 1, observerNodesBitmap: 1 << 0 | 1 << 1 | 1 << 2});

return Config({
staticConfig: RMNHome.StaticConfig({nodes: nodes, offchainConfig: abi.encode("static_config")}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {RMNRemoteSetup} from "./RMNRemoteSetup.t.sol";
contract RMNRemote_setConfig is RMNRemoteSetup {
function test_RevertWhen_setConfig_ZeroValueNotAllowed() public {
RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: bytes32(0), signers: s_signers, f: 1});
RMNRemote.Config({rmnHomeContractConfigDigest: bytes32(0), signers: s_signers, fSign: 1});

vm.expectRevert(RMNRemote.ZeroValueNotAllowed.selector);

Expand All @@ -18,7 +18,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
uint32 currentConfigVersion = 0;
uint256 numSigners = s_signers.length;
RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 1});
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 1});

vm.expectEmit();
emit RMNRemote.ConfigSet(++currentConfigVersion, config);
Expand All @@ -28,7 +28,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
// add a signer
address newSigner = makeAddr("new signer");
s_signers.push(RMNRemote.Signer({onchainPublicKey: newSigner, nodeIndex: uint64(numSigners)}));
config = RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 1});
config = RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 1});

vm.expectEmit();
emit RMNRemote.ConfigSet(++currentConfigVersion, config);
Expand All @@ -44,7 +44,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
// remove two signers
s_signers.pop();
s_signers.pop();
config = RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 1});
config = RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 1});

vm.expectEmit();
emit RMNRemote.ConfigSet(++currentConfigVersion, config);
Expand All @@ -59,7 +59,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
function test_RevertWhen_setConfig_invalidSignerOrder() public {
s_signers.push(RMNRemote.Signer({onchainPublicKey: address(4), nodeIndex: 0}));
RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 1});
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 1});

vm.expectRevert(RMNRemote.InvalidSignerOrder.selector);
s_rmnRemote.setConfig(config);
Expand All @@ -69,7 +69,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
RMNRemote.Config memory config = RMNRemote.Config({
rmnHomeContractConfigDigest: _randomBytes32(),
signers: s_signers,
f: uint64(s_signers.length / 2) // at least 2f+1 is required
fSign: uint64(s_signers.length / 2) // at least 2f+1 is required
});

vm.expectRevert(RMNRemote.NotEnoughSigners.selector);
Expand All @@ -79,7 +79,7 @@ contract RMNRemote_setConfig is RMNRemoteSetup {
function test_RevertWhen_setConfig_duplicateOnChainPublicKey() public {
s_signers.push(RMNRemote.Signer({onchainPublicKey: s_signerWallets[0].addr, nodeIndex: uint64(s_signers.length)}));
RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 1});
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 1});

vm.expectRevert(RMNRemote.DuplicateOnchainPublicKey.selector);
s_rmnRemote.setConfig(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract RMNRemote_verify_withConfigSet is RMNRemoteSetup {
super.setUp();

RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 3});
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 3});
s_rmnRemote.setConfig(config);
_generatePayloadAndSigs(2, 4);
}
Expand Down Expand Up @@ -55,7 +55,7 @@ contract RMNRemote_verify_withConfigSet is RMNRemoteSetup {

function test_verify_RevertWhen_ThresholdNotMet() public {
RMNRemote.Config memory config =
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, f: 2}); // 3 = f+1 sigs required
RMNRemote.Config({rmnHomeContractConfigDigest: _randomBytes32(), signers: s_signers, fSign: 2}); // 3 = f+1 sigs required
s_rmnRemote.setConfig(config);

_generatePayloadAndSigs(2, 2); // 2 sigs generated, but 3 required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func GenerateRMNHomeConfigs(
SourceChains: []rmn_home.RMNHomeSourceChain{
{
ChainSelector: chainSelector,
F: f,
FObserve: f,
ObserverNodesBitmap: observerBitmap,
},
},
Expand Down
2 changes: 1 addition & 1 deletion core/gethwrappers/ccip/generated/rmn_home/rmn_home.go

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

2 changes: 1 addition & 1 deletion core/gethwrappers/ccip/generated/rmn_remote/rmn_remote.go

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

2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_deploy_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func deployChainContracts(
Signers: []rmn_remote.RMNRemoteSigner{
{NodeIndex: 0, OnchainPublicKey: common.Address{1}},
},
F: 0, // TODO: update when we have signers
FSign: 0, // TODO: update when we have signers
})
if _, err := deployment.ConfirmIfNoError(chain, tx, err); err != nil {
e.Logger.Errorw("Failed to confirm RMNRemote config", "chain", chain.String(), "err", err)
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/cs_update_rmn_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func NewSetRMNRemoteConfigChangeset(e deployment.Environment, config SetRMNRemot
newConfig := rmn_remote.RMNRemoteConfig{
RmnHomeContractConfigDigest: activeConfig,
Signers: remoteConfig.Signers,
F: remoteConfig.F,
FSign: remoteConfig.F,
}

if reflect.DeepEqual(currentVersionConfig.Config, newConfig) {
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/view/v1_6/rmnhome.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type RMNHomeDynamicConfig struct {

type RMNHomeSourceChain struct {
ChainSelector uint64 `json:"selector"`
F uint64 `json:"f"`
FObserve uint64 `json:"fObserve"`
ObserverNodesBitmap *big.Int `json:"observerNodesBitmap"`
}

Expand Down Expand Up @@ -146,7 +146,7 @@ func mapSourceChains(chains []rmn_home.RMNHomeSourceChain) []RMNHomeSourceChain
for i, chain := range chains {
result[i] = RMNHomeSourceChain{
ChainSelector: chain.ChainSelector,
F: chain.F,
FObserve: chain.FObserve,
ObserverNodesBitmap: chain.ObserverNodesBitmap,
}
}
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/view/v1_6/rmnremote.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type RMNRemoteView struct {
type RMNRemoteVersionedConfig struct {
Version uint32 `json:"version"`
Signers []RMNRemoteSigner `json:"signers"`
F uint64 `json:"f"`
Fsign uint64 `json:"fSign"`
}

type RMNRemoteSigner struct {
Expand All @@ -34,7 +34,7 @@ func GenerateRMNRemoteView(rmnReader *rmn_remote.RMNRemote) (RMNRemoteView, erro
rmnConfig := RMNRemoteVersionedConfig{
Version: config.Version,
Signers: make([]RMNRemoteSigner, 0, len(config.Config.Signers)),
F: config.Config.F,
Fsign: config.Config.FSign,
}
for _, signer := range config.Config.Signers {
rmnConfig.Signers = append(rmnConfig.Signers, RMNRemoteSigner{
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/ccip/ccip_rmn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (tc *rmnTestCase) populateFields(t *testing.T, envWithRMN changeset.Deploye
// configure remote chain details on the home contract
tc.pf.rmnHomeSourceChains = append(tc.pf.rmnHomeSourceChains, rmn_home.RMNHomeSourceChain{
ChainSelector: tc.pf.chainSelectors[remoteChainIdx],
F: uint64(remoteF),
FObserve: uint64(remoteF),
ObserverNodesBitmap: createObserverNodesBitmap(tc.pf.chainSelectors[remoteChainIdx], tc.rmnNodes, tc.pf.chainSelectors),
})
}
Expand Down

0 comments on commit 48b46e9

Please sign in to comment.