-
Notifications
You must be signed in to change notification settings - Fork 50
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
Generic transaction decompressor #180
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This decompressor contract can handle compressed sequence transactions; everything can be compressed (nonce, address, transactions, signature). The compression methods are:
2**N
,2**N - 1
,10**N * X
, etc.)Current gas savings for compressed data are:
The decompressor is written in huff as it does not need to be trusted; it has no special permissions. It works as a state machine that has the only task of inflating the transactions.
It additionally can:
Notice that, in an attempt to reduce gas costs, the contract does not have standard Solidity selectors; it instead only uses the first single byte as a selector. The following methods do exist:
0x00
: Decompress and execute a transaction0x01
: Decompress and execute many transactions0x02
: Read the cached address on index (takes 32 bytes as a parameter)0x03
: Read the cached bytes32 on index (takes 32 bytes as a parameter)0x04
: Returns the count of cached values (packed, uses 16 bytes for each)0x05
: Reads N storage slots (takes 32 x N parameters, without size prefix)0x06
: Decompress and return the execution data of a transaction0x07
: Decompress and return the execution data of many transactionsAny other selector will lead to undefined behavior. Similarly, the contract uses
CALLVALUE
as a replacement forPUSH0
, so it MUST be called withmsg.value == 0
; the contract does not validate it, sending funds to it will result in undefined behavior.