-
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
[DRAFT] SMA 1: Append initial validation data to bytecode #119
Closed
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
Co-authored-by: adam-alchemy <[email protected]>
…on function definition (#61)
Zer0dot
changed the title
[DRAFT] Semi-Modular: Append initial validation data to bytecode
[DRAFT] SMA 1: Append initial validation data to bytecode
Jul 31, 2024
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.
Motivation
The goal is to create a semi-modular account which would enable much cheaper deployments at a larger scale. To achieve this, a few options should be explored.
Append initial validation data, meant to be used with a specifically tailored (stateless? purpose-built?) validation, then fallback to that validation in cases where a validation is missing.
Add immutable validation data to account implementations for relevant validations-- potentially streamlining a pipeline to deploy more implementations with different immutable validations.
Hardcode specific validation behaviour into the account, this could be the most efficient, but it may result in fragmentation of account implementations, so I would only explore this option if we are certain we would only need one or two different variants, and the loss in flexibility is worth it.
Solution
This PR, although the branch is vaguely named (sorry) tackles the first option. We append a validation and its relevant, arbitrarily encoded data (which it will then decode according to its own schema) to the proxy bytecode upon deployment.
This allows us to skip the initialization phase entirely, and results in significant gas savings on deployment, but increased gas in cases where the fallback validation should be used.
The reasoning behind using
abi.encodePacked()
for appended bytecode rather than a standard abi-encoded byte array is that, since this is an immutable validation, only that specific validation needs access to this data, so we don't lose any flexibility by requiring that the data be encoded according to that validation's decoding scheme.In other words, because the relevant validation knows the parameters it needs, we can safely abi.encodePacked those parameters in most cases. Validations can still require that appended data be encoded using normal abi-encoding, though, as complex dynamic types would result in complex decoding schemes.