-
Notifications
You must be signed in to change notification settings - Fork 486
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
Allow for precompiles to have arbitrary addresses, potentially more than one. #1016
Open
bernardoaraujor
wants to merge
12
commits into
master
Choose a base branch
from
bar/precompiles-storage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
71e440d
add precompiles on-chain storage
bernardoaraujor 584f5a2
Precompiles uses StorageMap; add struct PrecompileLabel; add_precompi…
bernardoaraujor 5683cdb
taplo fmt
bernardoaraujor fa9a744
cargo fmt
bernardoaraujor 84f21ae
add PrecompilemodifierOrigin to pallet-ethereum mock.rs
bernardoaraujor eea6f64
impl<T> Deref for PrecompileLabel<T>
bernardoaraujor 428320f
fix pallet-evm test
bernardoaraujor 88dd7b4
simplify PrecompileLabel matching
bernardoaraujor 074f5bc
remove generic from PrecomileLabel
bernardoaraujor 093d3a9
switch to pallet-evm-precompile
bernardoaraujor 0961b8a
add weights to pallet-evm-precompile
bernardoaraujor e13ce6c
fmt
bernardoaraujor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
In which cases do you use the multiple addresses for a particular precompile? If the address of the a precompile changes, is it enough to just update the address is enough?
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.
I think mostly something like ERC20/asset. You can have lots of contracts of the same code.
No, because in this case the address will have their associated storages, which differentiate them.
And this is supposed not to happen -- a precompile's label is to remain static.
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.
This change is in the context of a new feature that will potentially be upstreamed later. We want to have specific precompiles that use traits like
frame_support::traits::tokens::fungibles::*
. For example, an ERC20-compatible precompile that usespallet-assets
to manage the tokens. In this case, different precompile addresses (that are associated with theFungibles
label) will map to differentAssetId
s.But for most use-cases where a single precompile address is sufficient, this won't be really useful. In those cases, just associate a single address (potentially hardcoded) to the precompile label and that's it.
I'm not sure I fully understand the question. With this implementation, you can't really "change" the address of a precompile. You can add a new precompile address with the same label, which would now make two instances of the same precompile. You can later remove the first address. Whatever dApp that expects the old precompile address would stop working at this point.
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.
Another point worth mentioning is that using this feature (on-chain precompile addresses) is totally optional.
You could still implement your own
PrecompileSet::execute()
so that it only executes precompiles with hardcoded addresses, the same wayFrontierPrecompiles<R>
does in its current form:https://github.com/paritytech/frontier/blob/58c568964dc32dd96153b7d113ac2df58d27de2b/template/runtime/src/precompiles.rs#L30-L47
A hybrid solution mixing both approaches (hardcoded + on-chain precompile addresses) is also possible.
The only breaking changes that this PR imposes is in case some runtime eventually decides to opt-in to on-chain precompile addresses via
pallet-evm-precompile
, a storage migration is necessary to populate storage with the previously hardcoded addresses.