-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add compressed claim function to Quest contracts #244
Conversation
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.
LGTM - that new claim
without any calldata is crazy can you comment that some more? I don't fully understand how the L1 will account for that/how the gas used will be calculated.
Small nit Depricated
is spelled wrong a few places.
|
||
function getQuestId() public view virtual returns (string memory); | ||
|
||
function claim() external payable { |
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.
How does this get handled when settled to L1 and how does the gas used work in this call?
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.
We can still access calldata in this function via msg.data
or calldataload(offset)
in assembly, both of which are done here in this function.
So as you can see in the tests we need to send a raw tx call for this to work, we can't call the function normally. We send the raw tx call prefixed with the 4 byte claim()
function selector and then the rest of the bytes in the calldata can be accessed via msg.data[4:]
. So from a L1 perspective it's all the same: it's a transaction with calldata.
So essentially what this does is remove the need to abi encode the calldata as a dynamic bytes array saving us two words (because encoding a bytes array adds two words when abi encoded to encode its length and data start position) ((granted they are mostly zeros but any savings is good here)).
This will bring our calldata down from 212 bytes to 116 (with a referrer) a saving of 45.28%.
claim
function to the Quest and Quest1155 contracts via the abstract contractQuestClaimable
.txHashChainId
in quest creation.