Automatic EVM revert code registration for XC20#1001
Merged
Conversation
Dinonard
commented
Aug 10, 2023
shaunxw
reviewed
Aug 10, 2023
Comment on lines
+82
to
+101
| pub struct EvmRevertCodeHandler<A, R>(PhantomData<(A, R)>); | ||
| impl<A, R> AssetsCallback<AssetId, AccountId> for EvmRevertCodeHandler<A, R> | ||
| where | ||
| A: AddressToAssetId<AssetId>, | ||
| R: pallet_evm::Config, | ||
| { | ||
| fn created(id: &AssetId, _: &AccountId) -> Result<(), ()> { | ||
| let address = A::asset_id_to_address(*id); | ||
| // In case of collision, we need to cancel the asset creation. | ||
| ensure!(!pallet_evm::AccountCodes::<R>::contains_key(&address), ()); | ||
| pallet_evm::AccountCodes::<R>::insert(address, EVM_REVERT_CODE.to_vec()); | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn destroyed(id: &AssetId) -> Result<(), ()> { | ||
| let address = A::asset_id_to_address(*id); | ||
| pallet_evm::AccountCodes::<R>::remove(address); | ||
| Ok(()) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
I'm not sure how the callback weights are taken into account inside pallet_assets (I couldn't find anything in code), but since we are doing DB writes who will be paying for it?
Contributor
Author
There was a problem hiding this comment.
Good catch, and reminder!
I had written down to redo the benchmarks and just didn't 🙈
Contributor
Author
|
/bench astar-dev pallet_assets |
|
Benchmarks job is scheduled at https://github.com/AstarNetwork/Astar/actions/runs/5830181829. |
|
Benchmarks have been finished. |
Minimum allowed line rate is |
shaunxw
approved these changes
Aug 11, 2023
ashutoshvarma
approved these changes
Aug 11, 2023
PierreOssun
pushed a commit
that referenced
this pull request
Aug 15, 2023
* Automatic EVM revert code registration for XC20 * Add negative test * Fmt fix * Add EVM module * Asset benchmarks * Cleanup xc asset config * Update asset benchmarks * Fix tests features
This file contains hidden or 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.
Pull Request Summary
Adds support for automatic EVM revert code registration for XC20.
Each time a new asset is created, an attempt will be made to insert the revert code.
If it succeeds, smart contracts will be able to immediately access the asset.
In case of failure, whole asset registration process is reverted.
Docs update: AstarNetwork/astar-docs#411
Removed some deprecated & unused code.
Check list