From 85161c81d346252ae81aea31890f07dd4e68b0e0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 29 May 2024 15:50:00 +0200 Subject: [PATCH] fix async genesis config --- Cargo.lock | 1 + nodes/parachain/Cargo.toml | 1 + nodes/parachain/src/chain_spec/politest.rs | 30 ++++++++++++------- ...pless-rococo-statemint-polimec-penpal.toml | 12 ++++---- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d85799bb..d63627496 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8422,6 +8422,7 @@ dependencies = [ "macros", "pallet-funding", "pallet-transaction-payment-rpc", + "polimec-common", "polimec-runtime", "politest-runtime", "polkadot-cli", diff --git a/nodes/parachain/Cargo.toml b/nodes/parachain/Cargo.toml index 522a5c9c8..830078b11 100644 --- a/nodes/parachain/Cargo.toml +++ b/nodes/parachain/Cargo.toml @@ -25,6 +25,7 @@ politest-runtime.workspace = true polimec-runtime.workspace = true pallet-funding.workspace = true macros = { workspace = true } +polimec-common.workspace = true # Substrate frame-benchmarking.workspace = true diff --git a/nodes/parachain/src/chain_spec/politest.rs b/nodes/parachain/src/chain_spec/politest.rs index c4e33ab87..5f5a39e21 100644 --- a/nodes/parachain/src/chain_spec/politest.rs +++ b/nodes/parachain/src/chain_spec/politest.rs @@ -31,6 +31,7 @@ use politest_runtime::{ use sc_service::ChainType; use sp_core::{crypto::UncheckedInto, sr25519}; use sp_runtime::{traits::AccountIdConversion, Perbill, Percent}; +use polimec_common::USD_UNIT; use crate::chain_spec::{get_account_id_from_seed, GenericChainSpec, DEFAULT_PARA_ID}; @@ -299,6 +300,8 @@ mod testing_helpers { traits::{ConstU32, Get, PhantomData}, BoundedVec, FixedPointNumber, }; + use pallet_funding::traits::ProvideAssetPrice; + use polimec_common::USD_DECIMALS; pub const IPFS_CID: &str = "QmeuJ24ffwLAZppQcgcggJs3n689bewednYkuc8Bx5Gngz"; pub const ASSET_DECIMALS: u8 = 10; @@ -316,7 +319,7 @@ mod testing_helpers { pub fn bounded_symbol() -> BoundedVec> { BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap() } - pub fn ipfs_hash() -> BoundedVec> { + pub fn ipfs_hash() -> BoundedVec> { BoundedVec::try_from(IPFS_CID.as_bytes().to_vec()).unwrap() } pub fn default_weights() -> Vec { @@ -324,6 +327,11 @@ mod testing_helpers { } pub fn project_metadata(issuer: AccountId) -> ProjectMetadataOf { + let decimal_aware_price = PriceProviderOf::::calculate_decimals_aware_price( + PriceOf::::from_float(10.0), + USD_DECIMALS, + ASSET_DECIMALS, + ).unwrap(); ProjectMetadata { token_information: CurrencyMetadata { name: bounded_name(), @@ -333,16 +341,17 @@ mod testing_helpers { mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, total_allocation_size: 1_000_000 * ASSET_UNIT, auction_round_allocation_percentage: Percent::from_percent(50u8), - minimum_price: PriceOf::::from_float(10.0), + minimum_price: decimal_aware_price, + bidding_ticket_sizes: BiddingTicketSizes { - professional: TicketSize::new(Some(5000 * USD_UNIT), None), - institutional: TicketSize::new(Some(5000 * USD_UNIT), None), + professional: TicketSize::new(5000 * USD_UNIT, None), + institutional: TicketSize::new(5000 * USD_UNIT, None), phantom: Default::default(), }, contributing_ticket_sizes: ContributingTicketSizes { - retail: TicketSize::new(None, None), - professional: TicketSize::new(None, None), - institutional: TicketSize::new(None, None), + retail: TicketSize::new(100 * USD_UNIT, None), + professional: TicketSize::new(100 * USD_UNIT, None), + institutional: TicketSize::new(100 * USD_UNIT, None), phantom: Default::default(), }, participation_currencies: vec![AcceptedFundingAsset::USDT].try_into().unwrap(), @@ -404,27 +413,28 @@ fn testing_genesis( use sp_runtime::bounded_vec; use testing_helpers::*; + let genesis_inst = GenesisInstantiator::new(None); // only used to generate some values, and not for chain interactions let default_project_metadata = project_metadata(ISSUER.into()); let min_price = default_project_metadata.minimum_price; let usdt_funding_amount = default_project_metadata.minimum_price.checked_mul_int(default_project_metadata.total_allocation_size).unwrap(); let evaluations = default_evaluations(); - let bids = GenesisInstantiator::generate_bids_from_total_usd( + let bids = genesis_inst.generate_bids_from_total_usd( Percent::from_percent(40u8) * usdt_funding_amount, min_price, default_weights(), default_bidders(), default_bidder_multipliers(), ); - let community_contributions = GenesisInstantiator::generate_contributions_from_total_usd( + let community_contributions = genesis_inst.generate_contributions_from_total_usd( Percent::from_percent(50u8) * usdt_funding_amount, min_price, default_weights(), default_community_contributors(), default_community_contributor_multipliers(), ); - let remainder_contributions = GenesisInstantiator::generate_contributions_from_total_usd( + let remainder_contributions = genesis_inst.generate_contributions_from_total_usd( Percent::from_percent(5u8) * usdt_funding_amount, min_price, default_weights(), diff --git a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml index de5cf515f..197c6e78f 100644 --- a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml +++ b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml @@ -3,7 +3,7 @@ timeout = 1000 provider = "native" [relaychain] -default_command = "../polkadot/target/release/polkadot" +default_command = "/usr/local/bin/polkadot" chain = "rococo-local" @@ -28,18 +28,18 @@ chain = "rococo-local" [[parachains]] id = 1000 -chain = "statemint-local" +chain = "asset-hub-rococo-dev" [[parachains.collators]] name = "statemint-dev" - command = "../cumulus/target/release/polkadot-parachain" + command = "../polkadot-sdk/target/release/polkadot-parachain" args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 7777 [[parachains]] id = 3344 -chain = "polimec-testing" +chain = "politest-populated" [[parachains.collators]] name = "polimec-testing" command = "./target/release/polimec-node" @@ -48,9 +48,9 @@ chain = "polimec-testing" [[parachains]] id = 3000 -chain = "penpal-polkadot-3000" +chain = "penpal-rococo-3000" [[parachains.collators]] name = "penpal-collator" - command = "../cumulus/target/release/polkadot-parachain" + command = "../polkadot-sdk/target/release/polkadot-parachain" args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 9999 \ No newline at end of file