Skip to content

Commit

Permalink
allow address 0
Browse files Browse the repository at this point in the history
  • Loading branch information
RensR committed Nov 26, 2024
1 parent ac73acd commit c8a9af3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ RMNRemote_curse:test_curse_AlreadyCursed_duplicateSubject_reverts() (gas: 154501
RMNRemote_curse:test_curse_calledByNonOwner_reverts() (gas: 18734)
RMNRemote_curse:test_curse_success() (gas: 149475)
RMNRemote_global_and_legacy_curses:test_global_and_legacy_curses_success() (gas: 133441)
RMNRemote_isBlessed:test_isBlessed() (gas: 17502)
RMNRemote_isBlessed:test_isBlessed() (gas: 17588)
RMNRemote_setConfig:test_setConfig_ZeroValueNotAllowed_revert() (gas: 37971)
RMNRemote_setConfig:test_setConfig_addSigner_removeSigner_success() (gas: 993448)
RMNRemote_setConfig:test_setConfig_duplicateOnChainPublicKey_reverts() (gas: 323540)
Expand Down
6 changes: 5 additions & 1 deletion contracts/src/v0.8/ccip/rmn/RMNRemote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
error ThresholdNotMet();
error UnexpectedSigner();
error ZeroValueNotAllowed();
error IsBlessedNotAvailable();

event ConfigSet(uint32 indexed version, Config config);
event Cursed(bytes16[] subjects);
Expand Down Expand Up @@ -89,7 +90,6 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
if (localChainSelector == 0) revert ZeroValueNotAllowed();
i_localChainSelector = localChainSelector;

if (address(legacyRMN) == address(0)) revert ZeroValueNotAllowed();
i_legacyRMN = legacyRMN;
}

Expand Down Expand Up @@ -284,6 +284,10 @@ contract RMNRemote is Ownable2StepMsgSender, ITypeAndVersion, IRMNRemote, IRMN {
function isBlessed(
TaggedRoot calldata taggedRoot
) external view returns (bool) {
if (i_legacyRMN == IRMN(address(0))) {
revert IsBlessedNotAvailable();
}

return i_legacyRMN.isBlessed(taggedRoot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@ contract RMNRemote_constructor is RMNRemoteSetup {
function test_constructor() public view {
assertEq(s_rmnRemote.getLocalChainSelector(), 1);
}

function test_constructor_RevertWhen_ZeroValueNotAllowed() public {
vm.expectRevert(RMNRemote.ZeroValueNotAllowed.selector);
new RMNRemote(0, s_legacyRMN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ contract RMNRemote_isBlessed is RMNRemoteSetup {

assertFalse(s_rmnRemote.isBlessed(taggedRoot));
}

function test_isBlessed_RevertWhen_IsBlessedNotAvailable() public {
IRMN.TaggedRoot memory taggedRoot = IRMN.TaggedRoot({root: keccak256("root"), commitStore: makeAddr("commitStore")});

s_rmnRemote = new RMNRemote(100, IRMN(address(0)));

vm.expectRevert(RMNRemote.IsBlessedNotAvailable.selector);
s_rmnRemote.isBlessed(taggedRoot);
}
}
4 changes: 2 additions & 2 deletions core/gethwrappers/ccip/generated/rmn_remote/rmn_remote.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ registry_module_owner_custom: ../../../contracts/solc/v0.8.24/RegistryModuleOwne
report_codec: ../../../contracts/solc/v0.8.24/ReportCodec/ReportCodec.abi ../../../contracts/solc/v0.8.24/ReportCodec/ReportCodec.bin 6c943b39f003aa67c3cefa19a8ff99e846236a058e1ceae77569c3a065ffd5c7
rmn_home: ../../../contracts/solc/v0.8.24/RMNHome/RMNHome.abi ../../../contracts/solc/v0.8.24/RMNHome/RMNHome.bin 84ca84b3d0c00949905a3d10a91255f877cf32b2a0d7f7f7ce3121ced34a8cb7
rmn_proxy_contract: ../../../contracts/solc/v0.8.24/ARMProxy/ARMProxy.abi ../../../contracts/solc/v0.8.24/ARMProxy/ARMProxy.bin b048d8e752e3c41113ebb305c1efa06737ad36b4907b93e627fb0a3113023454
rmn_remote: ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.abi ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.bin 17c47ebb5f750f2b8e6c6ce7dc3e1bede7e7ebe7d663097e3db738ad72c9d290
rmn_remote: ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.abi ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.bin 941118dfdc6bb042c339cfe8d8e0c7a0b486afb731a785d58a64994e7a13c459
router: ../../../contracts/solc/v0.8.24/Router/Router.abi ../../../contracts/solc/v0.8.24/Router/Router.bin 2e4f0a7826c8abb49d882bb49fc5ff20a186dbd3137624b9097ffed903ae4888
token_admin_registry: ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.abi ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.bin 397bc7be08c2848c0f4715f90b16206d6367f78ffb7cd48e2b1dfc0ccc5aea26
token_pool: ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.abi ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.bin e2d55e56f5401e8cb52fbf4c7dbc477548b5ca2f1d6a28561ebd523f42113c55
Expand Down
5 changes: 4 additions & 1 deletion deployment/ccip/changeset/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"golang.org/x/sync/errgroup"

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

"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/internal"

"github.com/smartcontractkit/chainlink/deployment"
Expand Down Expand Up @@ -589,6 +590,8 @@ func deployChainContracts(
chain.DeployerKey,
chain.Client,
chain.Selector,
// Indicates no legacy RMN contract
common.HexToAddress("0x0"),
)
return deployment.ContractDeploy[*rmn_remote.RMNRemote]{
rmnRemoteAddr, rmnRemote, tx, deployment.NewTypeAndVersion(RMNRemote, deployment.Version1_6_0_dev), err2,
Expand Down

0 comments on commit c8a9af3

Please sign in to comment.