Skip to content
This repository was archived by the owner on Jul 4, 2022. It is now read-only.

Commit 0e618fd

Browse files
author
aliX
authored
Chore/merge 3.0 into develop (#211)
* Use a StoredMap to indicate the existence of generic asset accounts to other pallets through frame_system::Module (#182) * Add asset info extra field for existential_deposit (#184) * Add asset info extra field for existential_deposit * create asset with zero existential deposit should fail * Implement existential deposit for generic asset (#186) * Keep trace of assets' significance for account ids and do purge accounts if the policy says so * Purge assets individually as soon as they become insignificant * Move imbalance handling of dust cleaning out of generic asset. * By querying the system module itself, Test the accounts are actually added to the system module * Add a flag to accounts that separates the existence of an account from its set of existing assets * Add Generic Asset migration logic and test it * Prevent an account to be reaped from the system module at this stage * Feature/185 ga locks (#192) * Key locks by asset id * Improve the test for locked assets * Add storage migration logic and test it * Fix and improve ensure_can_withdraw and add a test for it * Fix minimum_balance of MultiCurrencyAccounting and Currency for GA (#197) Fix minimum_balance of MultiCurrencyAccounting and Currency for GA to return the existential deposit of the relevant asset * Add use for Vec (#198) It turns out when using prml-generic-asset in cennznet, the vec that is used in the migration logic should be specified explicitly. * For a plug node, replace pallet_balances with generic_asset. (#205) * For a plug node, replace pallet_balances with generic_asset. * Update benchmarked weights * Fix benchmark tests according to the recent change in setting total_issuance
1 parent 704ea0a commit 0e618fd

File tree

22 files changed

+433
-209
lines changed

22 files changed

+433
-209
lines changed

Cargo.lock

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ pallet-indices = { version = "3.0.0", path = "../../../frame/indices" }
8282
pallet-timestamp = { version = "3.0.0", default-features = false, path = "../../../frame/timestamp" }
8383
pallet-contracts = { version = "3.0.0", path = "../../../frame/contracts" }
8484
frame-system = { version = "3.0.0", path = "../../../frame/system" }
85-
pallet-balances = { version = "3.0.0", path = "../../../frame/balances" }
8685
pallet-transaction-payment = { version = "3.0.0", path = "../../../frame/transaction-payment" }
8786
frame-support = { version = "3.0.0", default-features = false, path = "../../../frame/support" }
8887
pallet-im-online = { version = "3.0.0", default-features = false, path = "../../../frame/im-online" }
8988
pallet-authority-discovery = { version = "3.0.0", path = "../../../frame/authority-discovery" }
9089
pallet-staking = { version = "3.0.0", path = "../../../frame/staking" }
9190
pallet-grandpa = { version = "3.0.0", path = "../../../frame/grandpa" }
91+
prml-generic-asset = { version = "3.0.0", path = "../../../prml/generic-asset" }
9292

9393
# node-specific dependencies
9494
node-runtime = { version = "2.0.0", path = "../runtime" }

bin/node/cli/src/chain_spec.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ use sc_chain_spec::ChainSpecExtension;
2222
use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519};
2323
use serde::{Serialize, Deserialize};
2424
use node_runtime::{
25-
AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig,
25+
AuthorityDiscoveryConfig, BabeConfig, GenericAssetConfig, ContractsConfig, CouncilConfig,
2626
DemocracyConfig,GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus,
2727
StakingConfig, ElectionsConfig, IndicesConfig, SocietyConfig, SudoConfig, SystemConfig,
2828
TechnicalCommitteeConfig, wasm_binary_unwrap,
2929
};
3030
use node_runtime::Block;
31-
use node_runtime::constants::currency::*;
31+
use node_runtime::constants::{asset::*, currency::*};
3232
use sc_service::ChainType;
3333
use hex_literal::hex;
3434
use sc_telemetry::TelemetryEndpoints;
3535
use grandpa_primitives::{AuthorityId as GrandpaId};
3636
use sp_consensus_babe::{AuthorityId as BabeId};
3737
use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
38+
use prml_generic_asset::AssetInfo;
3839
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
3940
use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}};
4041

@@ -250,14 +251,24 @@ pub fn testnet_genesis(
250251
code: wasm_binary_unwrap().to_vec(),
251252
changes_trie_config: Default::default(),
252253
}),
253-
pallet_balances: Some(BalancesConfig {
254-
balances: endowed_accounts.iter().cloned()
255-
.map(|x| (x, ENDOWMENT))
256-
.collect()
257-
}),
258254
pallet_indices: Some(IndicesConfig {
259255
indices: vec![],
260256
}),
257+
prml_generic_asset: Some(GenericAssetConfig {
258+
assets: vec![PLUG_ASSET_ID,],
259+
// Grant root key full permissions (mint,burn,update) on the following assets
260+
permissions: vec![
261+
(PLUG_ASSET_ID, endowed_accounts[0].clone()),
262+
],
263+
initial_balance: ENDOWMENT,
264+
endowed_accounts: endowed_accounts.clone(),
265+
next_asset_id: NEXT_ASSET_ID,
266+
staking_asset_id: STAKING_ASSET_ID,
267+
spending_asset_id: SPENDING_ASSET_ID,
268+
asset_meta: vec![
269+
(PLUG_ASSET_ID, AssetInfo::new(b"PLUG".to_vec(), 4, 1)),
270+
],
271+
}),
261272
pallet_session: Some(SessionConfig {
262273
keys: initial_authorities.iter().map(|x| {
263274
(x.0.clone(), x.0.clone(), session_keys(

bin/node/cli/src/service.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ mod tests {
487487
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport,
488488
};
489489
use node_primitives::{Block, DigestItem, Signature};
490-
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address};
490+
use node_runtime::{Call, GenericAsset, GenericAssetCall, UncheckedExtrinsic, Address};
491491
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
492492
use codec::Encode;
493493
use sp_core::{
@@ -650,7 +650,7 @@ mod tests {
650650
},
651651
|service, _| {
652652
let amount = 5 * CENTS;
653-
let to: Address = AccountPublic::from(bob.public()).into_account().into();
653+
let to = AccountPublic::from(bob.public()).into_account();
654654
let from: Address = AccountPublic::from(charlie.public()).into_account().into();
655655
let genesis_hash = service.client().block_hash(0).unwrap().unwrap();
656656
let best_block_id = BlockId::number(service.client().chain_info().best_number);
@@ -660,7 +660,11 @@ mod tests {
660660
};
661661
let signer = charlie.clone();
662662

663-
let function = Call::Balances(BalancesCall::transfer(to.into(), amount));
663+
let function = Call::GenericAsset(GenericAssetCall::transfer(
664+
GenericAsset::spending_asset_id(),
665+
to,
666+
amount,
667+
));
664668

665669
let check_spec_version = frame_system::CheckSpecVersion::new();
666670
let check_tx_version = frame_system::CheckTxVersion::new();

bin/node/executor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ criterion = "0.3.0"
2929
frame-support = { version = "3.0.0", path = "../../../frame/support" }
3030
frame-system = { version = "3.0.0", path = "../../../frame/system" }
3131
node-testing = { version = "2.0.0", path = "../testing" }
32-
pallet-balances = { version = "3.0.0", path = "../../../frame/balances" }
3332
pallet-contracts = { version = "3.0.0", path = "../../../frame/contracts" }
3433
pallet-grandpa = { version = "3.0.0", path = "../../../frame/grandpa" }
3534
pallet-im-online = { version = "3.0.0", path = "../../../frame/im-online" }
@@ -38,6 +37,7 @@ pallet-session = { version = "3.0.0", path = "../../../frame/session" }
3837
pallet-timestamp = { version = "3.0.0", path = "../../../frame/timestamp" }
3938
pallet-transaction-payment = { version = "3.0.0", path = "../../../frame/transaction-payment" }
4039
pallet-treasury = { version = "3.0.0", path = "../../../frame/treasury" }
40+
prml-generic-asset = { version = "3.0.0", path = "../../../prml/generic-asset" }
4141
sp-application-crypto = { version = "3.0.0", path = "../../../primitives/application-crypto" }
4242
sp-consensus-babe = { version = "0.9.0", path = "../../../primitives/consensus/babe" }
4343
sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" }

bin/node/executor/benches/bench.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
2020
use node_executor::Executor;
2121
use node_primitives::{BlockNumber, Hash};
2222
use node_runtime::{
23-
Block, BuildStorage, Call, CheckedExtrinsic, GenesisConfig, Header, UncheckedExtrinsic,
23+
Block, BuildStorage, Call, CheckedExtrinsic, GenericAsset, GenericAssetCall, GenesisConfig,
24+
Header, UncheckedExtrinsic,
2425
};
2526
use node_runtime::constants::currency::*;
2627
use node_testing::keyring::*;
@@ -153,7 +154,11 @@ fn test_blocks(genesis_config: &GenesisConfig, executor: &NativeExecutor<Executo
153154
block1_extrinsics.extend((0..20).map(|i| {
154155
CheckedExtrinsic {
155156
signed: Some((alice(), signed_extra(i, 0))),
156-
function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 1 * DOLLARS)),
157+
function: Call::GenericAsset(GenericAssetCall::transfer(
158+
GenericAsset::spending_asset_id(),
159+
bob(),
160+
1 * DOLLARS,
161+
)),
157162
}
158163
}));
159164
let block1 = construct_block(

0 commit comments

Comments
 (0)