Skip to content

Commit

Permalink
fix async genesis config
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed May 29, 2024
1 parent 0d86ab1 commit 85161c8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 20 additions & 10 deletions nodes/parachain/src/chain_spec/politest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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;
Expand All @@ -316,14 +319,19 @@ mod testing_helpers {
pub fn bounded_symbol() -> BoundedVec<u8, ConstU32<64>> {
BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap()
}
pub fn ipfs_hash() -> BoundedVec<u8, ConstU32<64>> {
pub fn ipfs_hash() -> BoundedVec<u8, ConstU32<96>> {
BoundedVec::try_from(IPFS_CID.as_bytes().to_vec()).unwrap()
}
pub fn default_weights() -> Vec<u8> {
vec![20u8, 15u8, 10u8, 25u8, 30u8]
}

pub fn project_metadata(issuer: AccountId) -> ProjectMetadataOf<politest_runtime::Runtime> {
let decimal_aware_price = PriceProviderOf::<politest_runtime::Runtime>::calculate_decimals_aware_price(
PriceOf::<politest_runtime::Runtime>::from_float(10.0),
USD_DECIMALS,
ASSET_DECIMALS,
).unwrap();
ProjectMetadata {
token_information: CurrencyMetadata {
name: bounded_name(),
Expand All @@ -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::<politest_runtime::Runtime>::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(),
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ timeout = 1000
provider = "native"

[relaychain]
default_command = "../polkadot/target/release/polkadot"
default_command = "/usr/local/bin/polkadot"
chain = "rococo-local"


Expand All @@ -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"
Expand All @@ -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

0 comments on commit 85161c8

Please sign in to comment.