-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize gas usage with common techniques and refactor code structure #341
base: master
Are you sure you want to change the base?
Conversation
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
Changes to gas cost
🧾 Summary (20% most significant diffs)
Full diff report 👇
|
assembly { | ||
// Compute the digest. | ||
mstore(0x00, 0x1901000000000000000000000000000000000000000000000000000000000000) // Store "\x19\x01". | ||
mstore(0x2, digest) // Store the domain separator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe align with other hex values:
mstore(0x2, digest) // Store the domain separator. | |
mstore(0x02, digest) // Store the domain separator. |
digest = _getDomainSeparator(); | ||
|
||
// solhint-disable no-inline-assembly | ||
assembly { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those inline assemblies copied from some standard library? How much gas does it save?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use OZ's 712 implementation?
@@ -45,6 +45,7 @@ contract SignatureValidatorTest is Test { | |||
assertFalse(SignatureValidator.validateSignature(vm.addr(walletAdminPrivateKey), otherDigest, signature)); | |||
} | |||
|
|||
/// forge-config: default.allow_internal_expect_revert = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the setting for? Where is it checked?
bytes memory strategyData = abi.encode(UNISWAP_SWAP_ROUTER_02_ADDRESS, makerSpecificData); | ||
bytes memory strategyData = abi.encode(UNISWAP_SWAP_ROUTER_02_ADDRESS, order.makerToken, order.makerTokenAmount - fee, makerSpecificData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why added these two parameters? Is it because the change of executeStrategy
interface?
Can you still run |
Yes, it works fine after enabling the |
via-ir
setting.optimizer_runs
from 1,000 to 65,536.executeStrategy
function.getEIP712Hash
function of EIP-712 using assembly code.