Skip to content

Commit

Permalink
feat: upgrade asset manager (#814)
Browse files Browse the repository at this point in the history
* feat: add asset-manager changes

Signed-off-by: Brandon H. Gomes <[email protected]>

* Compiles and tests pass, cleaned warnings

Signed-off-by: Georgi Zlatarev <[email protected]>

* Split Dolphin and Calamari AssetId types

Signed-off-by: Georgi Zlatarev <[email protected]>

* Migration code for asset-manager and assets pallets, needs cleanup and invariants checkes, but works.

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add invariant checks

Signed-off-by: Georgi Zlatarev <[email protected]>

* Update

Signed-off-by: Georgi Zlatarev <[email protected]>

* Migrate Accounts storage double map with storage aliasing

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add equivalence checks before and after migration

Signed-off-by: Georgi Zlatarev <[email protected]>

* Remove post-upgrade check that old storage is empty

Signed-off-by: Georgi Zlatarev <[email protected]>

* Clean up and formatting

Signed-off-by: Georgi Zlatarev <[email protected]>

* Revert default AssetRegistryMetadata. Fix benchmarks

Signed-off-by: Georgi Zlatarev <[email protected]>

* Clean up and docs

Signed-off-by: Georgi Zlatarev <[email protected]>

* Cleanup

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix clippy

Signed-off-by: Georgi Zlatarev <[email protected]>

* Address review comments. Incremenet storage version of both pallets and check for correctness

Signed-off-by: Georgi Zlatarev <[email protected]>

* Use MaybeSerializeDesirialize from sp-runtime

Signed-off-by: Georgi Zlatarev <[email protected]>

* Improve asset-manager benchmarking code

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix clippy, rmeove pallet-assets from pallet-asset-manager cargo.toml

Signed-off-by: Georgi Zlatarev <[email protected]>

* Use more explicitly named trait for asset metadata defaults for testing - TestingDefault

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix docs

Signed-off-by: Georgi Zlatarev <[email protected]>

* Migrate AssetRegistryMetadata

Signed-off-by: Georgi Zlatarev <[email protected]>

* Bump AssetManager StorageVersion in pallet

Signed-off-by: Georgi Zlatarev <[email protected]>

* Use AtLeast32BitUnsigned instead of local impl of CheckedIncrement

Signed-off-by: Georgi Zlatarev <[email protected]>

* taplo fmt

Signed-off-by: Georgi Zlatarev <[email protected]>

* Use One trait

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix tests

Signed-off-by: Georgi Zlatarev <[email protected]>

* Rename try_ name to more explicit and clean up docs

Signed-off-by: Georgi Zlatarev <[email protected]>

* clean up asset-manager benchmarking code, removed redundant GenesisConfig impl and #[pallet::generate_store(pub(super) trait Store)] in pallet-asset-manager, remove unnecessary comments, use StandardAssetId in pallet-manta-pay benchmarking

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix clippy and asset-manager benchamrking tests

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add missing doccoment in old asset-manager migration code

Signed-off-by: Georgi Zlatarev <[email protected]>

* Refactor AssetIdMigration generics and get rid of magic numbers'

* Missing doccoments related to xtokents and xcm

Signed-off-by: Georgi Zlatarev <[email protected]>

* More missing dcocoments

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add progress logs to AssetId migration

Signed-off-by: Georgi Zlatarev <[email protected]>

* Add #[compact] to all AssetId extrinsic params'
:

Signed-off-by: Georgi Zlatarev <[email protected]>

* Remove evm_address field from metadata

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix clippy

Signed-off-by: Georgi Zlatarev <[email protected]>

* Fix pre-runtime hook storage version check for pallet-assets

Signed-off-by: Georgi Zlatarev <[email protected]>

Signed-off-by: Brandon H. Gomes <[email protected]>
Signed-off-by: Georgi Zlatarev <[email protected]>
Co-authored-by: Georgi Zlatarev <[email protected]>
  • Loading branch information
bhgomes and ghzlatarev authored Nov 8, 2022
1 parent bfa08d6 commit 0365ac7
Show file tree
Hide file tree
Showing 41 changed files with 2,441 additions and 1,436 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 27 additions & 27 deletions node/src/chain_specs/calamari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use calamari_runtime::{
currency::KMA, opaque::SessionKeys, CouncilConfig, DemocracyConfig, GenesisConfig,
ParachainStakingConfig, TechnicalCommitteeConfig,
};
use session_key_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed};
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
/// Calamari Protocol Identifier
pub const CALAMARI_PROTOCOL_ID: &str = "calamari";

Expand Down Expand Up @@ -60,16 +60,16 @@ pub fn calamari_development_config() -> CalamariChainSpec {
move || {
calamari_dev_genesis(
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
SessionKeys::new(get_collator_keys_from_seed("Alice")),
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
)],
// Delegations
vec![],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
],
)
},
Expand All @@ -95,39 +95,39 @@ pub fn calamari_local_config() -> CalamariChainSpec {
calamari_dev_genesis(
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
SessionKeys::new(get_collator_keys_from_seed("Alice")),
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
SessionKeys::new(get_collator_keys_from_seed("Bob")),
unchecked_account_id::<sr25519::Public>("Bob"),
SessionKeys::new(unchecked_collator_keys("Bob")),
),
(
get_account_id_from_seed::<sr25519::Public>("Charlie"),
SessionKeys::new(get_collator_keys_from_seed("Charlie")),
unchecked_account_id::<sr25519::Public>("Charlie"),
SessionKeys::new(unchecked_collator_keys("Charlie")),
),
(
get_account_id_from_seed::<sr25519::Public>("Dave"),
SessionKeys::new(get_collator_keys_from_seed("Dave")),
unchecked_account_id::<sr25519::Public>("Dave"),
SessionKeys::new(unchecked_collator_keys("Dave")),
),
(
get_account_id_from_seed::<sr25519::Public>("Eve"),
SessionKeys::new(get_collator_keys_from_seed("Eve")),
unchecked_account_id::<sr25519::Public>("Eve"),
SessionKeys::new(unchecked_collator_keys("Eve")),
),
],
// Delegations
vec![],
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Charlie"),
unchecked_account_id::<sr25519::Public>("Dave"),
unchecked_account_id::<sr25519::Public>("Eve"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Charlie//stash"),
unchecked_account_id::<sr25519::Public>("Dave//stash"),
unchecked_account_id::<sr25519::Public>("Eve//stash"),
],
)
},
Expand Down
58 changes: 29 additions & 29 deletions node/src/chain_specs/dolphin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::command::{DOLPHIN_ON_BAIKAL_PARACHAIN_ID, DOLPHIN_PARACHAIN_ID};
use dolphin_runtime::{
opaque::SessionKeys, CouncilConfig, DemocracyConfig, GenesisConfig, TechnicalCommitteeConfig,
};
use session_key_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed};
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
/// Dolphin Protocol Identifier
pub const DOLPHIN_PROTOCOL_ID: &str = "dolphin";
/// Kusama Relaychain Local Network Identifier
Expand Down Expand Up @@ -54,15 +54,15 @@ pub fn dolphin_development_config() -> DolphinChainSpec {
move || {
dolphin_dev_genesis(
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
SessionKeys::new(get_collator_keys_from_seed("Alice")),
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
)],
get_account_id_from_seed::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
],
)
},
Expand All @@ -88,38 +88,38 @@ pub fn dolphin_local_config() -> DolphinChainSpec {
dolphin_dev_genesis(
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
SessionKeys::new(get_collator_keys_from_seed("Alice")),
unchecked_account_id::<sr25519::Public>("Alice"),
SessionKeys::new(unchecked_collator_keys("Alice")),
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
SessionKeys::new(get_collator_keys_from_seed("Bob")),
unchecked_account_id::<sr25519::Public>("Bob"),
SessionKeys::new(unchecked_collator_keys("Bob")),
),
(
get_account_id_from_seed::<sr25519::Public>("Charlie"),
SessionKeys::new(get_collator_keys_from_seed("Charlie")),
unchecked_account_id::<sr25519::Public>("Charlie"),
SessionKeys::new(unchecked_collator_keys("Charlie")),
),
(
get_account_id_from_seed::<sr25519::Public>("Dave"),
SessionKeys::new(get_collator_keys_from_seed("Dave")),
unchecked_account_id::<sr25519::Public>("Dave"),
SessionKeys::new(unchecked_collator_keys("Dave")),
),
(
get_account_id_from_seed::<sr25519::Public>("Eve"),
SessionKeys::new(get_collator_keys_from_seed("Eve")),
unchecked_account_id::<sr25519::Public>("Eve"),
SessionKeys::new(unchecked_collator_keys("Eve")),
),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Charlie"),
unchecked_account_id::<sr25519::Public>("Dave"),
unchecked_account_id::<sr25519::Public>("Eve"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Charlie//stash"),
unchecked_account_id::<sr25519::Public>("Dave//stash"),
unchecked_account_id::<sr25519::Public>("Eve//stash"),
],
)
},
Expand Down
46 changes: 23 additions & 23 deletions node/src/chain_specs/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use super::*;
use crate::command::MANTA_PARACHAIN_ID;
use manta_runtime::opaque::SessionKeys;
use session_key_primitives::helpers::{get_account_id_from_seed, get_collator_keys_from_seed};
use session_key_primitives::util::{unchecked_account_id, unchecked_collator_keys};
/// Manta Protocol Identifier
pub const MANTA_PROTOCOL_ID: &str = "manta";

Expand Down Expand Up @@ -60,15 +60,15 @@ pub fn manta_development_config() -> MantaChainSpec {
move || {
manta_dev_genesis(
vec![(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice").0,
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_collator_keys("Alice").0,
)],
get_account_id_from_seed::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
],
)
},
Expand All @@ -94,26 +94,26 @@ pub fn manta_local_config() -> MantaChainSpec {
manta_dev_genesis(
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_collator_keys_from_seed("Alice").0,
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_collator_keys("Alice").0,
),
(
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_collator_keys_from_seed("Bob").0,
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_collator_keys("Bob").0,
),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
unchecked_account_id::<sr25519::Public>("Alice"),
unchecked_account_id::<sr25519::Public>("Bob"),
unchecked_account_id::<sr25519::Public>("Charlie"),
unchecked_account_id::<sr25519::Public>("Dave"),
unchecked_account_id::<sr25519::Public>("Eve"),
unchecked_account_id::<sr25519::Public>("Alice//stash"),
unchecked_account_id::<sr25519::Public>("Bob//stash"),
unchecked_account_id::<sr25519::Public>("Charlie//stash"),
unchecked_account_id::<sr25519::Public>("Dave//stash"),
unchecked_account_id::<sr25519::Public>("Eve//stash"),
],
)
},
Expand Down
36 changes: 19 additions & 17 deletions pallets/asset-manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
[package]
authors = ['Manta Network']
authors = ["Manta Network"]
edition = "2021"
homepage = 'https://manta.network'
license = 'GPL-3.0'
homepage = "https://manta.network"
license = "GPL-3.0"
name = "pallet-asset-manager"
repository = 'https://github.com/Manta-Network/Manta/'
version = '3.4.3'

[dependencies]
codec = { package = "parity-scale-codec", version = '3.1.2', default-features = false }
frame-benchmarking = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.26", default-features = false, optional = true }
codec = { package = "parity-scale-codec", version = "3.1.2", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false, optional = true }
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false }
log = { version = "0.4.0", default-features = false }
manta-primitives = { path = "../../primitives/manta", default-features = false }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", default-features = false }
xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.26" }
xcm = { git = "https://github.com/paritytech/polkadot.git", default-features = false, branch = "release-v0.9.26" }

# 3rd party dependencies
orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.26" }

[dev-dependencies]
pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.26" }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.26" }
pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }

[features]
default = ["std"]
runtime-benchmarks = [
'frame-benchmarking',
'frame-support/runtime-benchmarks',
'frame-system/runtime-benchmarks',
'manta-primitives/runtime-benchmarks',
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"manta-primitives/runtime-benchmarks",
]
std = [
"codec/std",
"scale-info/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-std/std",
"log/std",
"manta-primitives/std",
"orml-traits/std",
'log/std',
'xcm/std',
"scale-info/std",
"sp-runtime/std",
"sp-std/std",
"sp-arithmetic/std",
"xcm/std",
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
Loading

0 comments on commit 0365ac7

Please sign in to comment.