-
Notifications
You must be signed in to change notification settings - Fork 374
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
Automatic EVM revert code registration for XC20 #1001
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.
Looks good!
primitives/src/lib.rs
Outdated
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(()) | ||
} | ||
} |
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'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?
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.
Good catch, and reminder!
I had written down to redo the benchmarks and just didn't 🙈
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.
Solved.
/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 |
* 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
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