Skip to content

Commit

Permalink
Revert "reorder fields in MerkleRoot struct" (#1417)
Browse files Browse the repository at this point in the history
## Motivation
Avoid forcing breaking changes on RMN nodes

## Solution
This reverts commit da570c5.
  • Loading branch information
RyanRHall authored Sep 9, 2024
1 parent 53a8491 commit 8e883b0
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 72 deletions.
52 changes: 26 additions & 26 deletions contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ MultiOCR3Base_transmit:test_UnauthorizedSigner_Revert() (gas: 61131)
MultiOCR3Base_transmit:test_UnconfiguredPlugin_Revert() (gas: 39888)
MultiOCR3Base_transmit:test_ZeroSignatures_Revert() (gas: 32971)
MultiOnRampTokenPoolReentrancy:test_OnRampTokenPoolReentrancy_Success() (gas: 411753)
MultiRampsE2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1527968)
MultiRampsE2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1528026)
NonceManager_NonceIncrementation:test_getIncrementedOutboundNonce_Success() (gas: 37916)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Skip() (gas: 23709)
NonceManager_NonceIncrementation:test_incrementInboundNonce_Success() (gas: 38799)
Expand Down Expand Up @@ -608,7 +608,7 @@ OCR2Base_transmit:test_Transmit2SignersSuccess_gas() (gas: 51689)
OCR2Base_transmit:test_UnAuthorizedTransmitter_Revert() (gas: 23499)
OCR2Base_transmit:test_UnauthorizedSigner_Revert() (gas: 39695)
OCR2Base_transmit:test_WrongNumberOfSignatures_Revert() (gas: 20572)
OffRamp_afterOC3ConfigSet:test_afterOCR3ConfigSet_SignatureVerificationDisabled_Revert() (gas: 5850100)
OffRamp_afterOC3ConfigSet:test_afterOCR3ConfigSet_SignatureVerificationDisabled_Revert() (gas: 5849491)
OffRamp_applySourceChainConfigUpdates:test_AddMultipleChains_Success() (gas: 468052)
OffRamp_applySourceChainConfigUpdates:test_AddNewChain_Success() (gas: 99216)
OffRamp_applySourceChainConfigUpdates:test_ApplyZeroUpdates_Success() (gas: 12392)
Expand All @@ -626,26 +626,26 @@ OffRamp_batchExecute:test_SingleReport_Success() (gas: 155963)
OffRamp_batchExecute:test_Unhealthy_Success() (gas: 573311)
OffRamp_batchExecute:test_ZeroReports_Revert() (gas: 10440)
OffRamp_ccipReceive:test_Reverts() (gas: 15705)
OffRamp_commit:test_FailedRMNVerification_Reverts() (gas: 64343)
OffRamp_commit:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 67494)
OffRamp_commit:test_InvalidInterval_Revert() (gas: 59807)
OffRamp_commit:test_InvalidRootRevert() (gas: 58865)
OffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6454926)
OffRamp_commit:test_NoConfig_Revert() (gas: 6038739)
OffRamp_commit:test_OnlyGasPriceUpdates_Success() (gas: 113421)
OffRamp_commit:test_OnlyPriceUpdateStaleReport_Revert() (gas: 121444)
OffRamp_commit:test_OnlyTokenPriceUpdates_Success() (gas: 113442)
OffRamp_commit:test_PriceSequenceNumberCleared_Success() (gas: 355496)
OffRamp_commit:test_ReportAndPriceUpdate_Success() (gas: 166631)
OffRamp_commit:test_ReportOnlyRootSuccess_gas() (gas: 141711)
OffRamp_commit:test_RootAlreadyCommitted_Revert() (gas: 142664)
OffRamp_commit:test_SourceChainNotEnabled_Revert() (gas: 59129)
OffRamp_commit:test_StaleReportWithRoot_Success() (gas: 239467)
OffRamp_commit:test_UnauthorizedTransmitter_Revert() (gas: 122361)
OffRamp_commit:test_Unhealthy_Revert() (gas: 57858)
OffRamp_commit:test_ValidPriceUpdateThenStaleReportWithRoot_Success() (gas: 211983)
OffRamp_commit:test_ZeroEpochAndRound_Revert() (gas: 51264)
OffRamp_constructor:test_Constructor_Success() (gas: 6039389)
OffRamp_commit:test_FailedRMNVerification_Reverts() (gas: 64462)
OffRamp_commit:test_InvalidIntervalMinLargerThanMax_Revert() (gas: 67674)
OffRamp_commit:test_InvalidInterval_Revert() (gas: 59928)
OffRamp_commit:test_InvalidRootRevert() (gas: 58963)
OffRamp_commit:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6454659)
OffRamp_commit:test_NoConfig_Revert() (gas: 6038472)
OffRamp_commit:test_OnlyGasPriceUpdates_Success() (gas: 113541)
OffRamp_commit:test_OnlyPriceUpdateStaleReport_Revert() (gas: 121576)
OffRamp_commit:test_OnlyTokenPriceUpdates_Success() (gas: 113562)
OffRamp_commit:test_PriceSequenceNumberCleared_Success() (gas: 355724)
OffRamp_commit:test_ReportAndPriceUpdate_Success() (gas: 166923)
OffRamp_commit:test_ReportOnlyRootSuccess_gas() (gas: 141978)
OffRamp_commit:test_RootAlreadyCommitted_Revert() (gas: 142982)
OffRamp_commit:test_SourceChainNotEnabled_Revert() (gas: 59250)
OffRamp_commit:test_StaleReportWithRoot_Success() (gas: 240109)
OffRamp_commit:test_UnauthorizedTransmitter_Revert() (gas: 122475)
OffRamp_commit:test_Unhealthy_Revert() (gas: 57991)
OffRamp_commit:test_ValidPriceUpdateThenStaleReportWithRoot_Success() (gas: 212415)
OffRamp_commit:test_ZeroEpochAndRound_Revert() (gas: 51324)
OffRamp_constructor:test_Constructor_Success() (gas: 6038780)
OffRamp_constructor:test_SourceChainSelector_Revert() (gas: 136917)
OffRamp_constructor:test_ZeroChainSelector_Revert() (gas: 103646)
OffRamp_constructor:test_ZeroNonceManager_Revert() (gas: 101523)
Expand All @@ -656,12 +656,12 @@ OffRamp_execute:test_IncorrectArrayType_Revert() (gas: 17281)
OffRamp_execute:test_LargeBatch_Success() (gas: 3378308)
OffRamp_execute:test_MultipleReportsWithPartialValidationFailures_Success() (gas: 372457)
OffRamp_execute:test_MultipleReports_Success() (gas: 298416)
OffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6861731)
OffRamp_execute:test_NoConfig_Revert() (gas: 6086529)
OffRamp_execute:test_NoConfigWithOtherConfigPresent_Revert() (gas: 6861122)
OffRamp_execute:test_NoConfig_Revert() (gas: 6085920)
OffRamp_execute:test_NonArray_Revert() (gas: 27721)
OffRamp_execute:test_SingleReport_Success() (gas: 175215)
OffRamp_execute:test_UnauthorizedTransmitter_Revert() (gas: 147455)
OffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6864474)
OffRamp_execute:test_WrongConfigWithSigners_Revert() (gas: 6863865)
OffRamp_execute:test_ZeroReports_Revert() (gas: 17162)
OffRamp_executeSingleMessage:test_MessageSender_Revert() (gas: 18212)
OffRamp_executeSingleMessage:test_NonContractWithTokens_Success() (gas: 249178)
Expand All @@ -678,7 +678,7 @@ OffRamp_executeSingleReport:test_EmptyReport_Revert() (gas: 21860)
OffRamp_executeSingleReport:test_InvalidSourcePoolAddress_Success() (gas: 502029)
OffRamp_executeSingleReport:test_ManualExecutionNotYetEnabled_Revert() (gas: 47635)
OffRamp_executeSingleReport:test_MismatchingDestChainSelector_Revert() (gas: 33895)
OffRamp_executeSingleReport:test_MismatchingOnRampRoot_Revert() (gas: 155036)
OffRamp_executeSingleReport:test_MismatchingOnRampRoot_Revert() (gas: 155054)
OffRamp_executeSingleReport:test_NonExistingSourceChain_Revert() (gas: 28472)
OffRamp_executeSingleReport:test_ReceiverError_Success() (gas: 187688)
OffRamp_executeSingleReport:test_RetryFailedMessageWithoutManualExecution_Revert() (gas: 198173)
Expand Down
8 changes: 5 additions & 3 deletions contracts/src/v0.8/ccip/libraries/Internal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,13 @@ library Internal {

/// @dev Struct to hold a merkle root and an interval for a source chain so that an array of these can be passed in the CommitReport.
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
/// @dev ineffiecient struct packing intentionally chosen to maintain order of specificity. Not a storage struct so impact is minimal.
// solhint-disable-next-line gas-struct-packing
struct MerkleRoot {
uint64 sourceChainSelector; // ──╮ Remote source chain selector that the Merkle Root is scoped to
uint64 minSeqNr; // | Minimum sequence number, inclusive
uint64 sourceChainSelector; // Remote source chain selector that the Merkle Root is scoped to
bytes onRampAddress; // Generic onramp address, to support arbitrary sources; for EVM, use abi.encode
uint64 minSeqNr; // ─────────────╮ Minimum sequence number, inclusive
uint64 maxSeqNr; // ─────────────╯ Maximum sequence number, inclusive
bytes32 merkleRoot; // Merkle root covering the interval & source chain messages
bytes onRampAddress; // Generic onramp address, to support arbitrary sources; for EVM, use abi.encode
}
}
8 changes: 4 additions & 4 deletions contracts/src/v0.8/ccip/test/e2e/MultiRampsEnd2End.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ contract MultiRampsE2E is OnRampSetup, OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](2);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR,
onRampAddress: abi.encode(address(s_onRamp)),
minSeqNr: messages1[0].header.sequenceNumber,
maxSeqNr: messages1[1].header.sequenceNumber,
merkleRoot: merkleRoots[0],
onRampAddress: abi.encode(address(s_onRamp))
merkleRoot: merkleRoots[0]
});
roots[1] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR + 1,
onRampAddress: abi.encode(address(s_onRamp)),
minSeqNr: messages2[0].header.sequenceNumber,
maxSeqNr: messages2[0].header.sequenceNumber,
merkleRoot: merkleRoots[1],
onRampAddress: abi.encode(address(s_onRamp))
merkleRoot: merkleRoots[1]
});

OffRamp.CommitReport memory report =
Expand Down
40 changes: 20 additions & 20 deletions contracts/src/v0.8/ccip/test/offRamp/OffRamp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,10 @@ contract OffRamp_executeSingleReport is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: 2,
merkleRoot: merkleRoot,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: merkleRoot
});

return OffRamp.CommitReport({
Expand Down Expand Up @@ -3138,10 +3138,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: max1,
merkleRoot: root,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: root
});

OffRamp.CommitReport memory commitReport =
Expand All @@ -3167,10 +3167,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: maxSeq,
merkleRoot: "stale report 1",
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: "stale report 1"
});
OffRamp.CommitReport memory commitReport =
OffRamp.CommitReport({priceUpdates: _getEmptyPriceUpdates(), merkleRoots: roots, rmnSignatures: s_rmnSignatures});
Expand Down Expand Up @@ -3318,10 +3318,10 @@ contract OffRamp_commit is OffRampSetup {
roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: maxSeq,
merkleRoot: "stale report",
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: "stale report"
});
commitReport.priceUpdates = _getSingleTokenPriceUpdateStruct(s_sourceFeeToken, tokenPrice2);
commitReport.merkleRoots = roots;
Expand Down Expand Up @@ -3424,10 +3424,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: 4,
merkleRoot: bytes32(0),
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: bytes32(0)
});
OffRamp.CommitReport memory commitReport =
OffRamp.CommitReport({priceUpdates: _getEmptyPriceUpdates(), merkleRoots: roots, rmnSignatures: s_rmnSignatures});
Expand All @@ -3440,10 +3440,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 2,
maxSeqNr: 2,
merkleRoot: bytes32(0),
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: bytes32(0)
});
OffRamp.CommitReport memory commitReport =
OffRamp.CommitReport({priceUpdates: _getEmptyPriceUpdates(), merkleRoots: roots, rmnSignatures: s_rmnSignatures});
Expand All @@ -3461,10 +3461,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: 0,
merkleRoot: bytes32(0),
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: bytes32(0)
});
OffRamp.CommitReport memory commitReport =
OffRamp.CommitReport({priceUpdates: _getEmptyPriceUpdates(), merkleRoots: roots, rmnSignatures: s_rmnSignatures});
Expand Down Expand Up @@ -3509,10 +3509,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: 0,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: 2,
merkleRoot: "Only a single root",
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: "Only a single root"
});

OffRamp.CommitReport memory commitReport =
Expand All @@ -3526,10 +3526,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: 2,
merkleRoot: "Only a single root",
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: "Only a single root"
});
OffRamp.CommitReport memory commitReport =
OffRamp.CommitReport({priceUpdates: _getEmptyPriceUpdates(), merkleRoots: roots, rmnSignatures: s_rmnSignatures});
Expand All @@ -3548,10 +3548,10 @@ contract OffRamp_commit is OffRampSetup {
Internal.MerkleRoot[] memory roots = new Internal.MerkleRoot[](1);
roots[0] = Internal.MerkleRoot({
sourceChainSelector: SOURCE_CHAIN_SELECTOR_1,
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1),
minSeqNr: 1,
maxSeqNr: s_maxInterval,
merkleRoot: "test #2",
onRampAddress: abi.encode(ON_RAMP_ADDRESS_1)
merkleRoot: "test #2"
});

return OffRamp.CommitReport({
Expand Down
Loading

0 comments on commit 8e883b0

Please sign in to comment.