File tree Expand file tree Collapse file tree 2 files changed +53
-39
lines changed
Expand file tree Collapse file tree 2 files changed +53
-39
lines changed Original file line number Diff line number Diff line change @@ -11,26 +11,33 @@ library QuoteSignLib {
1111
1212 /// @notice Compute the keccak of all `SignedQuoteParams` fields
1313 function hash (SignedQuoteParams calldata p ) internal pure returns (bytes32 ) {
14- return
15- keccak256 (
16- abi.encode (
17- p.srcEid,
18- p.dstEid,
19- p.destinationHandler,
20- p.amountLD,
21- p.nonce,
22- p.deadline,
23- p.maxBpsToSponsor,
24- p.finalRecipient,
25- p.finalToken,
26- p.destinationDex,
27- p.lzReceiveGasLimit,
28- p.lzComposeGasLimit,
29- p.accountCreationMode,
30- p.executionMode,
31- keccak256 (p.actionData) // Hash the actionData to keep signature size reasonable
32- )
33- );
14+ // We split the hashing into two parts to avoid "stack too deep" error
15+ bytes32 hash1 = keccak256 (
16+ abi.encode (
17+ p.srcEid,
18+ p.dstEid,
19+ p.destinationHandler,
20+ p.amountLD,
21+ p.nonce,
22+ p.deadline,
23+ p.maxBpsToSponsor,
24+ p.finalRecipient
25+ )
26+ );
27+
28+ bytes32 hash2 = keccak256 (
29+ abi.encode (
30+ p.finalToken,
31+ p.destinationDex,
32+ p.lzReceiveGasLimit,
33+ p.lzComposeGasLimit,
34+ p.accountCreationMode,
35+ p.executionMode,
36+ keccak256 (p.actionData) // Hash the actionData to keep signature size reasonable
37+ )
38+ );
39+
40+ return keccak256 (abi.encode (hash1, hash2));
3441 }
3542
3643 /// @notice Recover the signer for the given params and signature.
Original file line number Diff line number Diff line change @@ -19,25 +19,32 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
1919library DebugQuoteSignLib {
2020 /// @notice Compute the keccak of all `SignedQuoteParams` fields. Accept memory arg
2121 function hashMemory (SignedQuoteParams memory p ) internal pure returns (bytes32 ) {
22- return
23- keccak256 (
24- abi.encode (
25- p.srcEid,
26- p.dstEid,
27- p.destinationHandler,
28- p.amountLD,
29- p.nonce,
30- p.deadline,
31- p.maxBpsToSponsor,
32- p.finalRecipient,
33- p.finalToken,
34- p.lzReceiveGasLimit,
35- p.lzComposeGasLimit,
36- p.accountCreationMode,
37- p.executionMode,
38- keccak256 (p.actionData) // Hash the actionData to keep signature size reasonable
39- )
40- );
22+ bytes32 hash1 = keccak256 (
23+ abi.encode (
24+ p.srcEid,
25+ p.dstEid,
26+ p.destinationHandler,
27+ p.amountLD,
28+ p.nonce,
29+ p.deadline,
30+ p.maxBpsToSponsor,
31+ p.finalRecipient
32+ )
33+ );
34+
35+ bytes32 hash2 = keccak256 (
36+ abi.encode (
37+ p.finalToken,
38+ p.destinationDex,
39+ p.lzReceiveGasLimit,
40+ p.lzComposeGasLimit,
41+ p.accountCreationMode,
42+ p.executionMode,
43+ keccak256 (p.actionData) // Hash the actionData to keep signature size reasonable
44+ )
45+ );
46+
47+ return keccak256 (abi.encode (hash1, hash2));
4148 }
4249
4350 /// @notice Sign the quote using Foundry's Vm cheatcode and return concatenated bytes signature (r,s,v).
You can’t perform that action at this time.
0 commit comments