Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(devnet): activate async backing #143

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Daanvdplas marked this conversation as resolved.
Show resolved Hide resolved

[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
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ 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)),
evilrobot-01 marked this conversation as resolved.
Show resolved Hide resolved
"test" | "pop-paseo" => Box::new(chain_spec::testnet_config(Relay::Paseo)),
"test" | "pop-paseo" | "testnet" => 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 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 @@
/// 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 @@ -334,7 +336,7 @@

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;

Check warning on line 339 in runtime/devnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

warning: use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024. --> runtime/devnet/src/lib.rs:339:57 | 339 | type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>; | ^^^^^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand All @@ -353,6 +355,18 @@
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 @@
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 @@ -337,7 +337,7 @@

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;

Check warning on line 340 in runtime/testnet/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

warning: use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024. --> runtime/testnet/src/lib.rs:340:57 | 340 | type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>; | ^^^^^^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default
type WeightToFee = WeightToFee;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
Expand Down Expand Up @@ -444,8 +444,11 @@
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
Loading