Skip to content

Commit

Permalink
feat(devnet): activate async backing (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Aug 8, 2024
1 parent 85a7218 commit bd47069
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 13 deletions.
2 changes: 1 addition & 1 deletion networks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ cargo install --git https://github.com/r0gue-io/pop-cli
You can spawn a local network as follows:

```shell
pop up parachain -f ./networks/paseo.toml
pop up parachain -f ./networks/testnet.toml
```
File renamed without changes.
40 changes: 40 additions & 0 deletions networks/testnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# pop up parachain -f ./tests/networks/pop.toml

[relaychain]
chain = "paseo-local"

[relaychain.runtime_genesis_patch.balances]
balances = [
# Pop sovereign account
["5Ec4AhPKXY9B4ayGshkz2wFMh7N8gP7XKfAvtt1cigpG9FkJ", 60000000000000000],
]

[[relaychain.nodes]]
name = "alice"
rpc_port = 8833
validator = true

[[relaychain.nodes]]
name = "bob"
validator = true

[[parachains]]
id = 4001
chain = "testnet"
default_command = "./target/release/pop-node"

[parachains.genesis_overrides.balances]
balances = [
# Dev accounts
["5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", 10000000000000000],
["5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", 10000000000000000],
["5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", 10000000000000000],
["5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy", 10000000000000000],
["5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw", 10000000000000000],
["5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL", 10000000000000000],
]

[[parachains.collators]]
name = "pop"
rpc_port = 9944
args = ["-lruntime::contracts=debug", "-lpopapi::extension=debug"]
2 changes: 1 addition & 1 deletion node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub fn testnet_config(relay: Relay) -> TestnetChainSpec {

#[allow(deprecated)]
TestnetChainSpec::builder(
pop_runtime_devnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
pop_runtime_testnet::WASM_BINARY.expect("WASM binary was not built, please build it!"),
extensions,
)
.with_name("Pop Network Testnet")
Expand Down
6 changes: 4 additions & 2 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ impl RuntimeResolver for PathBuf {

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Ok(match id {
"dev" | "dev-paseo" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
"test" | "pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
"dev" | "devnet" | "dev-paseo" => {
Box::new(chain_spec::development_config(Relay::PaseoLocal))
},
"test" | "testnet" | "pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
"" | "local" => Box::new(chain_spec::development_config(Relay::PaseoLocal)),
path => {
let path: PathBuf = path.into();
Expand Down
7 changes: 3 additions & 4 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight};
// Cumulus types re-export
// These types are shared between the devnet and testnet runtimes
pub use parachains_common::{AccountId, AuraId, Balance, Block, BlockNumber, Hash, Signature};
pub use polkadot_primitives::MAX_POV_SIZE;

/// Nonce for an account
pub type Nonce = u32;
Expand Down Expand Up @@ -40,10 +41,8 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);

/// We allow for 2 seconds of compute with a 6-second average block.
pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
polkadot_primitives::MAX_POV_SIZE as u64,
);
pub const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), MAX_POV_SIZE as u64);

// Unit = the base number of indivisible units for balances
pub const UNIT: Balance = 10_000_000_000; // 10 decimals
Expand Down
22 changes: 18 additions & 4 deletions runtime/devnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
pub use pop_runtime_common::{
deposit, AuraId, Balance, BlockNumber, Hash, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
BLOCK_PROCESSING_VELOCITY, DAYS, EXISTENTIAL_DEPOSIT, HOURS, MAXIMUM_BLOCK_WEIGHT, MICROUNIT,
MILLISECS_PER_BLOCK, MILLIUNIT, MINUTES, NORMAL_DISPATCH_RATIO,
RELAY_CHAIN_SLOT_DURATION_MILLIS, SLOT_DURATION, UNINCLUDED_SEGMENT_CAPACITY, UNIT,
BLOCK_PROCESSING_VELOCITY, EXISTENTIAL_DEPOSIT, MICROUNIT, MILLIUNIT, NORMAL_DISPATCH_RATIO,
RELAY_CHAIN_SLOT_DURATION_MILLIS, UNIT,
};
pub use sp_runtime::{MultiAddress, Perbill, Permill};

Expand Down Expand Up @@ -296,6 +295,9 @@ impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
#[cfg(feature = "experimental")]
type MinimumPeriod = ConstU64<0>;
#[cfg(not(feature = "experimental"))]
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
type WeightInfo = ();
}
Expand Down Expand Up @@ -353,6 +355,18 @@ parameter_types! {
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
}

// Async backing
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
pop_runtime_common::MAX_POV_SIZE as u64,
);
const MILLISECS_PER_BLOCK: u64 = 6_000;
const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
const HOURS: BlockNumber = MINUTES * 60;
const DAYS: BlockNumber = HOURS * 24;

type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
Expand Down Expand Up @@ -440,7 +454,7 @@ impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
type AllowMultipleBlocksPerSlot = ConstBool<true>;
#[cfg(feature = "experimental")]
type SlotDuration = ConstU64<SLOT_DURATION>;
}
Expand Down
5 changes: 4 additions & 1 deletion runtime/testnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
// Note: SlotDuration potentially enabled here due to devnet runtime and Rust's feature
// unification, requiring the setting of a backwards compatible value.
// See https://github.com/paritytech/polkadot-sdk/blob/09df373db9cd5dfed82c5cdb0736d417d54249e6/substrate/frame/aura/src/lib.rs#L262
#[cfg(feature = "experimental")]
type SlotDuration = ConstU64<SLOT_DURATION>;
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Runtime>;
}

parameter_types! {
Expand Down

0 comments on commit bd47069

Please sign in to comment.