Skip to content

Commit

Permalink
CCIP-3785 fix data availability bytes length calc (#14798)
Browse files Browse the repository at this point in the history
* comment fix

* fix comments and bytes length calc

* fixing bytes calculation for MESSAGE_FIXED_BYTES

* fixing bytes calculation for MESSAGE_FIXED_BYTES

* fix comments

* CCIP-3785 changeset

* CCIP-3785 comment correction

* merge fix

* changeset for core
  • Loading branch information
0xsuryansh authored Oct 17, 2024
1 parent 693d4bc commit 26e22eb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-pianos-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal Update gethwrapper for FeeQuoter, Internal.sol comment and byte calc update
8 changes: 8 additions & 0 deletions contracts/.changeset/chatty-keys-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@chainlink/contracts': patch
---

#internal fixing comments and data availability bytes length calculation


PR issue : CCIP-3785
2 changes: 1 addition & 1 deletion contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ CCIPHome_setCandidate:test_setCandidate_ConfigDigestMismatch_reverts() (gas: 138
CCIPHome_setCandidate:test_setCandidate_success() (gas: 1357884)
DefensiveExampleTest:test_HappyPath_Success() (gas: 200048)
DefensiveExampleTest:test_Recovery() (gas: 424306)
E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1518567)
E2E:test_E2E_3MessagesMMultiOffRampSuccess_gas() (gas: 1518589)
EtherSenderReceiverTest_ccipReceive:test_ccipReceive_fallbackToWethTransfer() (gas: 96909)
EtherSenderReceiverTest_ccipReceive:test_ccipReceive_happyPath() (gas: 49796)
EtherSenderReceiverTest_ccipReceive:test_ccipReceive_wrongToken() (gas: 17435)
Expand Down
23 changes: 14 additions & 9 deletions contracts/src/v0.8/ccip/libraries/Internal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,26 @@ library Internal {
uint256 proofFlagBits;
}

/// @dev Any2EVMRampMessage struct has 10 fields, including 3 variable unnested arrays (data, receiver and tokenAmounts).
/// @dev Any2EVMRampMessage struct has 10 fields, including 3 variable unnested arrays (sender, data and tokenAmounts).
/// Each variable array takes 1 more slot to store its length.
/// When abi encoded, excluding array contents,
/// Any2EVMMessage takes up a fixed number of 13 slots, 32 bytes each.
/// Assume 1 slot for sender
/// For structs that contain arrays, 1 more slot is added to the front, reaching a total of 14.
/// The fixed bytes does not cover struct data (this is represented by MESSAGE_FIXED_BYTES_PER_TOKEN)
uint256 public constant MESSAGE_FIXED_BYTES = 32 * 14;
uint256 public constant MESSAGE_FIXED_BYTES = 32 * 15;

/// @dev Each token transfer adds 1 RampTokenAmount
/// RampTokenAmount has 5 fields, 2 of which are bytes type, 1 Address, 1 uint256 and 1 uint32.
/// Each bytes type takes 1 slot for length, 1 slot for data and 1 slot for the offset.
/// address
/// uint256 amount takes 1 slot.
/// uint32 destGasAmount takes 1 slot.
uint256 public constant MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * ((2 * 3) + 3);
/// @dev Any2EVMTokensTransfer struct bytes length
/// 0x20
/// sourcePoolAddress_offset
/// destTokenAddress
/// destGasAmount
/// extraData_offset
/// amount
/// sourcePoolAddress_length
/// sourcePoolAddress_content // assume 1 slot
/// extraData_length // contents billed separately
uint256 public constant MESSAGE_FIXED_BYTES_PER_TOKEN = 32 * (4 + (3 + 2));

bytes32 internal constant ANY_2_EVM_MESSAGE_HASH = keccak256("Any2EVMMessageHashV1");
bytes32 internal constant EVM_2_ANY_MESSAGE_HASH = keccak256("EVM2AnyMessageHashV1");
Expand Down
2 changes: 1 addition & 1 deletion core/gethwrappers/ccip/generated/fee_quoter/fee_quoter.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ burn_with_from_mint_token_pool: ../../../contracts/solc/v0.8.24/BurnWithFromMint
ccip_encoding_utils: ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.abi ../../../contracts/solc/v0.8.24/ICCIPEncodingUtils/ICCIPEncodingUtils.bin a074f2ecf2749a1d5afc4cd9bfa48677f09c2be4e076776f87c6feb767432ecb
ccip_home: ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.abi ../../../contracts/solc/v0.8.24/CCIPHome/CCIPHome.bin 079b70ad36b4a9522518df82f01bdb8480fb9bb8de5791ef17ea1ddf044814be
ether_sender_receiver: ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.abi ../../../contracts/solc/v0.8.24/EtherSenderReceiver/EtherSenderReceiver.bin 09510a3f773f108a3c231e8d202835c845ded862d071ec54c4f89c12d868b8de
fee_quoter: ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.abi ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.bin 503823a939ff99fe3bdaaef7a89cd4bbe475e260d3921335dbf9c80d4f584b76
fee_quoter: ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.abi ../../../contracts/solc/v0.8.24/FeeQuoter/FeeQuoter.bin 7f1d7705617295aaba9f62211d38a06cf3099db47e6286cccf1e2412992a0042
lock_release_token_pool: ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.abi ../../../contracts/solc/v0.8.24/LockReleaseTokenPool/LockReleaseTokenPool.bin e6a8ec9e8faccb1da7d90e0f702ed72975964f97dc3222b54cfcca0a0ba3fea2
maybe_revert_message_receiver: ../../../contracts/solc/v0.8.24/MaybeRevertMessageReceiver/MaybeRevertMessageReceiver.abi ../../../contracts/solc/v0.8.24/MaybeRevertMessageReceiver/MaybeRevertMessageReceiver.bin d73956c26232ebcc4a5444429fa99cbefed960e323be9b5a24925885c2e477d5
message_hasher: ../../../contracts/solc/v0.8.24/MessageHasher/MessageHasher.abi ../../../contracts/solc/v0.8.24/MessageHasher/MessageHasher.bin ec2d3a92348d8e7b8f0d359b62a45157b9d2c750c01fbcf991826c4392f6e218
Expand Down

0 comments on commit 26e22eb

Please sign in to comment.