Skip to content

Commit

Permalink
fix: add check for payload size
Browse files Browse the repository at this point in the history
  • Loading branch information
ameeshaagrawal committed Jun 18, 2024
1 parent 9f35b33 commit 8640a08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ It is recommended to setup the ide to work with solidity development. In case of
| InsufficientFees() | 0x8d53e553 |
| InvalidMsgValue() | 0x1841b4e1 |
| FeesTooHigh() | 0xc9034e18 |
| PayloadTooLarge() | 0x492f620d |
| InvalidBatchSize() | 0x7862e959 |
| InsufficientMessageLength() | 0xbcfdc01d |
| InvalidPacketLength() | 0x5a375a8e |
Expand Down
5 changes: 5 additions & 0 deletions contracts/ExecutionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {FEES_UPDATE_SIG_IDENTIFIER, RELATIVE_NATIVE_TOKEN_PRICE_UPDATE_SIG_IDENT
* access control.
*/
contract ExecutionManager is IExecutionManager, AccessControlExtended {
uint256 private constant PAYLOAD_LIMIT = 5000;

ISignatureVerifier public immutable signatureVerifier__;
ISocket public immutable socket__;
uint32 public immutable chainSlug;
Expand Down Expand Up @@ -155,6 +157,8 @@ contract ExecutionManager is IExecutionManager, AccessControlExtended {

error OnlySocket();

error PayloadTooLarge();

/**
* @dev Constructor for ExecutionManager contract
* @param owner_ address of the contract owner
Expand Down Expand Up @@ -324,6 +328,7 @@ contract ExecutionManager is IExecutionManager, AccessControlExtended {
bytes32 executionParams_,
uint32 siblingChainSlug_
) internal view returns (uint128) {
if (payloadSize_ > PAYLOAD_LIMIT) revert PayloadTooLarge();
uint256 totalNativeValue = _calculateExecutionFees(
msgGasLimit,
payloadSize_,
Expand Down
12 changes: 10 additions & 2 deletions test/managers/ExecutionManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ contract ExecutionManagerTest is Setup {
}

function testPayAndCheckFeesWithExecutionFeeTooHigh() public {
uint256 minMsgGasLimit = 100000;
uint256 payloadSize = type(uint128).max;
uint256 minMsgGasLimit = type(uint128).max;
uint256 payloadSize = 1000;
uint256 msgValue = 1000;
uint8 paramType = 1;
bytes32 executionParams = bytes32(
Expand All @@ -321,6 +321,14 @@ contract ExecutionManagerTest is Setup {
executionParams,
_b.chainSlug
);

vm.expectRevert(ExecutionManager.PayloadTooLarge.selector);
_a.executionManager__.getMinFees(
minMsgGasLimit,
6000,
executionParams,
_b.chainSlug
);
}

function testPayAndCheckFeesWithMsgValueTooHigh() public {
Expand Down

0 comments on commit 8640a08

Please sign in to comment.