-
Notifications
You must be signed in to change notification settings - Fork 56
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
Make onRamp mutable in OffRamp #1422
Changes from 10 commits
b6d52f9
2a6fb27
72b52e8
4456bc5
bc82b76
5fde62e
9977ca4
da09dc4
e2bcb9c
1324349
b461638
e1c2bfd
77db35e
cfbf85c
54afc4f
97cdccb
2b52acd
52d36b1
48868c7
1f19f84
2abe966
85ee9c7
f4dcd49
8495bb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,8 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |
error InvalidMessageDestChainSelector(uint64 messageDestChainSelector); | ||
error SourceChainSelectorMismatch(uint64 reportSourceChainSelector, uint64 messageSourceChainSelector); | ||
error SignatureVerificationDisabled(); | ||
error InvalidOnRamp(bytes reportOnRamp, bytes configOnRamp); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: naming - should we name this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think here the most likely scenario is that the wrong onRamp would be the configured one, not the one from the commit report. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main confusion with the current naming is that this is easily confused with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to |
||
error InvalidOnRampUpdate(); | ||
|
||
/// @dev Atlas depends on this event, if changing, please notify Atlas. | ||
event StaticConfigSet(StaticConfig staticConfig); | ||
|
@@ -132,6 +134,8 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |
|
||
// STATIC CONFIG | ||
string public constant override typeAndVersion = "OffRamp 1.6.0-dev"; | ||
/// @dev Hash of encoded address(0) used for empty address checks | ||
bytes32 internal constant EMPTY_ENCODED_ADDRESS_HASH = keccak256(abi.encode(address(0))); | ||
/// @dev ChainSelector of this chain | ||
uint64 internal immutable i_chainSelector; | ||
/// @dev The RMN verification contract | ||
|
@@ -617,6 +621,11 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |
} | ||
|
||
SourceChainConfig storage sourceChainConfig = _getEnabledSourceChainConfig(sourceChainSelector); | ||
bytes memory onRamp = sourceChainConfig.onRamp; | ||
|
||
if (keccak256(root.onRampAddress) != keccak256(onRamp)) { | ||
revert InvalidOnRamp(root.onRampAddress, onRamp); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: reading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, updated. |
||
|
||
if (sourceChainConfig.minSeqNr != root.minSeqNr || root.minSeqNr > root.maxSeqNr) { | ||
revert InvalidInterval(root.sourceChainSelector, root.minSeqNr, root.maxSeqNr); | ||
|
@@ -738,24 +747,29 @@ contract OffRamp is ITypeAndVersion, MultiOCR3Base { | |
} | ||
|
||
SourceChainConfig storage currentConfig = s_sourceChainConfigs[sourceChainSelector]; | ||
bytes memory currentOnRamp = currentConfig.onRamp; | ||
bytes memory newOnRamp = sourceConfigUpdate.onRamp; | ||
|
||
// OnRamp can never be zero - if it is, then the source chain has been added for the first time | ||
if (currentOnRamp.length == 0) { | ||
if (newOnRamp.length == 0) { | ||
revert ZeroAddressNotAllowed(); | ||
} | ||
|
||
currentConfig.onRamp = newOnRamp; | ||
if (currentConfig.onRamp.length == 0) { | ||
currentConfig.minSeqNr = 1; | ||
emit SourceChainSelectorAdded(sourceChainSelector); | ||
} else if (keccak256(currentOnRamp) != keccak256(newOnRamp)) { | ||
revert InvalidStaticConfig(sourceChainSelector); | ||
elatoskinas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// OnRamp can never be zero - if it is, then the source chain has been added for the first time | ||
if (newOnRamp.length == 0 || keccak256(newOnRamp) == EMPTY_ENCODED_ADDRESS_HASH) { | ||
revert ZeroAddressNotAllowed(); | ||
} | ||
|
||
// OnRamp updates should only happens due to a misconfiguration | ||
// If an OnRamp is misconfigured not reports should have been committed and no messages should have been executed | ||
// This is enforced byt the onRamp address check in the commit function | ||
if (currentConfig.minSeqNr != 1) { | ||
elatoskinas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
revert InvalidOnRampUpdate(); | ||
elatoskinas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
currentConfig.onRamp = newOnRamp; | ||
currentConfig.isEnabled = sourceConfigUpdate.isEnabled; | ||
currentConfig.router = sourceConfigUpdate.router; | ||
|
||
emit SourceChainConfigSet(sourceChainSelector, currentConfig); | ||
} | ||
} | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅