Skip to content
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

feat(AU): charge storage fee and add initial CE #1058

Merged
merged 16 commits into from
Oct 24, 2023

Conversation

ashutoshvarma
Copy link
Member

@ashutoshvarma ashutoshvarma commented Oct 15, 2023

Fix #1045
Ref #1055 (CE part)

Pull Request Summary

  • Charge storage fee for creating AU mappings (Account Unification CE and Precompile #1055), simply charge a fixed storage cost and burn it before creating mappings.
  • Add a new CE for exposing mappings from pallet-unified-accounts to be consumed by pallet-contracts contracts
  • Refactor & reuse wasm contract util methods from xcm-simulator to a separate crate - astar-test-utils and use common wasm contracts folder.
    • Reasoning: The same logic was duplicated and used by xcm simulator and integration tests.

TODO

  • add integration test for CE
  • figure out ideal value for storage fee
  • update & re-run benchmarks

@ashutoshvarma ashutoshvarma added shibuya related to shibuya runtime This PR/Issue is related to the topic “runtime”. AU Account Unification labels Oct 15, 2023
@ashutoshvarma ashutoshvarma marked this pull request as ready for review October 16, 2023 13:07
@ashutoshvarma ashutoshvarma changed the title feat: charge storage fee for AU mappings and add initial CE for AU feat(AU): charge storage fee and add initial CE Oct 16, 2023
Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the pallet side 👍, left some minor comments/suggestions.

chain-extensions/unified-accounts/src/lib.rs Show resolved Hide resolved
tests/integration/src/setup.rs Outdated Show resolved Hide resolved
tests/integration/src/unified_accounts.rs Outdated Show resolved Hide resolved
pallets/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
chain-extensions/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@shaunxw shaunxw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UA pallet benchmark needs an update.

chain-extensions/unified-accounts/Cargo.toml Show resolved Hide resolved
pallets/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
tests/integration/src/xvm.rs Show resolved Hide resolved
tests/utils/src/lib.rs Show resolved Hide resolved
tests/utils/src/lib.rs Show resolved Hide resolved
PierreOssun
PierreOssun previously approved these changes Oct 19, 2023
Copy link
Member

@PierreOssun PierreOssun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@shaunxw shaunxw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Small suggestions.

chain-extensions/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
chain-extensions/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
shaunxw
shaunxw previously approved these changes Oct 23, 2023
Copy link
Member

@shaunxw shaunxw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Dinonard could you also have a final review? Thanks!

Comment on lines 74 to 75
// write to buffer
(evm_address, is_mapped).using_encoded(|r| env.write(r, false, None))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look really Rust-like to me.
Returning an enum would be more appropriate: (Mapped(address), Default(address)).
That also makes it more extensible for the future (not sure how we'd need it, but in general).

Anyhow, if others are ok with the proposed solution, you can ignore this comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the rust way too.
I'll update the PR tomorrow with changes.

cc: @PierreOssun @shaunxw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, the enum one looks better.

@PierreOssun the CE interface in ink! can get the decoded enum type without extra work in SDK right? Pls correct me if I'm wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the CE with enum, please have a look

the CE interface in ink! can get the decoded enum type without extra work in SDK right?

Yes, as long as it supports scale decode it'll be fine, I've updated the test ink! contracts here.

Dinonard
Dinonard previously approved these changes Oct 24, 2023
Copy link
Member

@Dinonard Dinonard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one minor comment.

chain-extensions/types/unified-accounts/src/lib.rs Outdated Show resolved Hide resolved
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
primitives/src/xcm 66% 0%
pallets/block-reward/src 85% 0%
chain-extensions/unified-accounts/src 0% 0%
chain-extensions/pallet-assets/src 0% 0%
precompiles/dapps-staking/src 93% 0%
chain-extensions/types/assets/src 0% 0%
pallets/dapps-staking/src 81% 0%
chain-extensions/types/unified-accounts/src 0% 0%
chain-extensions/xvm/src 0% 0%
precompiles/assets-erc20/src 76% 0%
primitives/src 62% 0%
pallets/contracts-migration/src 0% 0%
pallets/ethereum-checked/src 48% 0%
pallets/xvm/src 40% 0%
precompiles/sr25519/src 79% 0%
precompiles/substrate-ecdsa/src 78% 0%
precompiles/utils/src 55% 0%
precompiles/utils/macro/src 0% 0%
chain-extensions/types/dapps-staking/src 0% 0%
precompiles/xcm/src 75% 0%
pallets/dapps-staking/src/pallet 85% 0%
chain-extensions/dapps-staking/src 0% 0%
pallets/collator-selection/src 69% 0%
pallets/dynamic-evm-base-fee/src 81% 0%
pallets/xc-asset-config/src 53% 0%
chain-extensions/types/xvm/src 0% 0%
pallets/unified-accounts/src 81% 0%
precompiles/utils/src/testing 38% 0%
precompiles/xvm/src 75% 0%
Summary 56% (2196 / 3926) 0% (0 / 0)

Minimum allowed line rate is 50%

@ashutoshvarma ashutoshvarma merged commit ebbc59d into master Oct 24, 2023
8 checks passed
@ashutoshvarma ashutoshvarma deleted the feat/au-storage-fee-and-ce branch October 24, 2023 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AU Account Unification runtime This PR/Issue is related to the topic “runtime”. shibuya related to shibuya
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charge storage deposit for creating account mappings
4 participants