Skip to content

Commit

Permalink
Move variable length types to end when ABI encoding packed
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Sep 21, 2023
1 parent 6dcff66 commit 3c2f4e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/controllers/GovernanceTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ contract GovernanceTimelock is IGovernanceTimelock {
++txCounter;
uint256 eta = block.timestamp + delay;

scheduledTransaction[txCounter] = keccak256(abi.encodePacked(_target, _value, _data, eta));
scheduledTransaction[txCounter] = keccak256(abi.encodePacked(_target, _value, eta, _data));
emit TransactionScheduled(txCounter, _target, _value, _data, eta);
}

Expand All @@ -102,7 +102,7 @@ contract GovernanceTimelock is IGovernanceTimelock {
}

/// @dev check the input params against hash
if (scheduledTransaction[_txId] != keccak256(abi.encodePacked(_target, _value, _data, _eta))) {
if (scheduledTransaction[_txId] != keccak256(abi.encodePacked(_target, _value, _eta, _data))) {
revert Error.INVALID_TX_INPUT();
}

Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Message.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ library MessageLibrary {
_message.dstChainId,
_message.nonce,
_message.target,
_message.callData,
_message.nativeValue,
_message.expiration
_message.expiration,
_message.callData
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/GovernanceTimelock.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract GovernanceTimelockTest is Setup {

assertEq(timelock.txCounter(), 1);
assertEq(
timelock.scheduledTransaction(1), keccak256(abi.encodePacked(address(42), uint256(1), bytes("42"), eta))
timelock.scheduledTransaction(1), keccak256(abi.encodePacked(address(42), uint256(1), eta, bytes("42")))
);
}

Expand Down

0 comments on commit 3c2f4e3

Please sign in to comment.