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

Reimplement TransactAsset with FungibleLedger and AssetConfig traits #563

Merged
merged 38 commits into from
Jun 30, 2022

Conversation

ghzlatarev
Copy link
Contributor

@ghzlatarev ghzlatarev commented May 24, 2022

Description

closes: #534

  • Replace FungiblesTransactor and LocalAssetTransactor tuple with our own AssetTransactor implementor called MultiAssetAdapter
  • MultiAssetAdapter uses the unified interface of FungibleLedger trait to implement only the withdraw_asset and deposit_asset functions from TransactAsset
  • The rest of the TransactAsset interface like can_check_in, teleport, etc are not required. Even though they were implemented in our old configuration they were not used.
  • An additional burn function and implementation had to be added to our FungiblesLedger trait. This implementation allows accounts to go down to 0, as that was the behavior of the old configuration.
  • ReducedToZero return results in can_withdraw implementation were considered an error, when in fact they are a success case, so switched that.
  • XCM tests were refactored to account for the new configuration
  • Refactored 1 manta-pay test which was supposed to fail because of attempting to mint more private assets than the available public assets of an account, but was actually minting the exact available amount. However since ReducedToZero was considered an error, this case was also holding up.

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Wrote unit tests.
  • Updated relevant documentation in the code.
  • Added one line describing your change in <branch>/CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer.
  • If runtime changes, need to update the version numbers properly:
    • authoring_version: The version of the authorship interface. An authoring node will not attempt to author blocks unless this is equal to its native runtime.
    • spec_version: The version of the runtime specification. A full node will not attempt to use its native runtime in substitute for the on-chain Wasm runtime unless all of spec_name, spec_version, and authoring_version are the same between Wasm and native.
    • impl_version: The version of the implementation of the specification. Nodes are free to ignore this; it serves only as an indication that the code is different; as long as the other two versions are the same then while the actual code may be different, it is nonetheless required to do the same thing. Non-consensus-breaking optimizations are about the only changes that could be made which would result in only the impl_version changing.
    • transaction_version: The version of the extrinsics interface. This number must be updated in the following circumstances: extrinsic parameters (number, order, or types) have been changed; extrinsics or pallets have been removed; or the pallet order in the construct_runtime! macro or extrinsic order in a pallet has been changed. You can run the metadata_diff.yml workflow for help. If this number is updated, then the spec_version must also be updated
  • Verify benchmarks & weights have been updated for any modified runtime logics
  • If importing a new pallet, choose a proper module index for it, and allow it in BaseFilter. Ensure every extrinsic works from front-end. If there's corresponding tool, ensure both work for each other.
  • If needed, update our Javascript/Typescript APIs. These APIs are officially used by exchanges or community developers.
  • If modifying existing runtime storage items, make sure to implement storage migrations for the runtime and test them with try-runtime. This includes migrations inherited from upstream changes, and you can search the diffs for modifications of #[pallet::storage] items to check for any.

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
primitives/src/assets.rs Outdated Show resolved Hide resolved
primitives/src/assets.rs Outdated Show resolved Hide resolved
primitives/src/assets.rs Outdated Show resolved Hide resolved
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
@ghzlatarev ghzlatarev requested review from stechu, Garandor and Dengjianping and removed request for stechu May 24, 2022 10:08
@ghzlatarev ghzlatarev marked this pull request as ready for review May 24, 2022 10:09
@ghzlatarev ghzlatarev self-assigned this May 24, 2022
@ghzlatarev ghzlatarev added the A-xcm Area: Issues and PRs related to Cross-Consensus Messaging (XCM) label May 24, 2022
@ghzlatarev ghzlatarev changed the title Refactor AssetTransactor with FungibleLedger and AssetConfig traits Reimplement TransactAsset with FungibleLedger and AssetConfig traits May 24, 2022
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
@ghzlatarev ghzlatarev requested a review from stechu June 10, 2022 11:28
@Garandor
Copy link
Contributor

merge conflicts to resolve

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Copy link
Contributor

@Garandor Garandor left a comment

Choose a reason for hiding this comment

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

LGTM, as it's an XCM PR I'd like to ask @Dengjianping and @stechu to review for approval here as well

pallets/asset-manager/src/lib.rs Outdated Show resolved Hide resolved
primitives/src/xcm.rs Outdated Show resolved Hide resolved
primitives/src/xcm.rs Outdated Show resolved Hide resolved
primitives/src/assets.rs Show resolved Hide resolved
runtime/calamari/Cargo.toml Outdated Show resolved Hide resolved
primitives/src/xcm.rs Show resolved Hide resolved
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
@Dengjianping
Copy link
Contributor

Please resolve clippy warnings.

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Dengjianping
Dengjianping previously approved these changes Jun 28, 2022
Copy link
Contributor

@Dengjianping Dengjianping left a comment

Choose a reason for hiding this comment

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

lgtm!
Great PR!

Copy link
Contributor

@Garandor Garandor left a comment

Choose a reason for hiding this comment

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

Forgot i never sent this review 🥇

CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>
Copy link
Contributor

@Dengjianping Dengjianping 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
Contributor

@Garandor Garandor left a comment

Choose a reason for hiding this comment

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

LGTM if you fix the changelog in #614 after merging this

@ghzlatarev ghzlatarev merged commit 0ef5274 into manta Jun 30, 2022
@ghzlatarev ghzlatarev deleted the ghzlatarev/refactor-transactor branch June 30, 2022 16:48
stechu pushed a commit that referenced this pull request Jul 11, 2022
…raits (#563)

* Inital refactor, does not compile

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Inital refactor, does not compile

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Inital refactor, does not compile

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Compiles

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Should work

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* AssetId and u32 thing

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Works with concrete Balance and AssetId

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Works with concrete Balance and AssetId

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Simplify and error handling

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Names

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Names

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Use new struct for AssetTransactor

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Clean up

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix runtime/common/Cargo.toml

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix tests

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Clean up

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Comments

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix integration test

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix manta-pay test, changelog, more clean up

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Add trace logs in TransactAsset impl

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Equalize Barrier impl between production and xcm-mock

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Rever the Barrier change to not explode the scope of the PR

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Add comments

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Taplo fmt

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix clippy

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* PR comments

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Revert how assets are registered

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Fix clippy

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* fix changelog

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Cover allow death case

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

* Cover allow death case

Signed-off-by: Georgi Zlatarev <georgi.zlatarev@manta.network>

Co-authored-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Shumo Chu <shumo.chu@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-xcm Area: Issues and PRs related to Cross-Consensus Messaging (XCM)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify AssetTransactor logic with the ConcreteFungibleLedger trait
5 participants