Skip to content

Commit

Permalink
chore: other upgrade changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvdplas committed Dec 18, 2024
1 parent 836a78a commit 45b2cf6
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 64 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ members = [
resolver = "2"

[workspace.dependencies]
clap = { version = "4.4.18", features = [ "derive" ] }
clap = { version = "4.5.1", features = [ "derive" ] }
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
"derive",
] }
contract-build = "4.1.1"
docify = "0.2.8"
enumflags2 = "0.7.9"
env_logger = "0.11.5"
futures = "0.3.28"
futures = "0.3.30"
hex = "0.4.3"
hex-literal = "0.4.1"
impl-trait-for-tuples = "0.2.2"
Expand All @@ -51,12 +52,12 @@ scale-info = { version = "2.11.1", default-features = false, features = [
"derive",
] }
serde = "1.0.197"
serde_json = "1.0.114"
serde_json = "1.0.121"
smallvec = "1.11.2"
subxt = "0.34.0"
subxt-signer = "0.34.0"
tokio = { version = "1.36", features = [ "macros", "rt-multi-thread", "time" ] }
tracing-subscriber = { version = "0.3", default-features = false }
tracing-subscriber = { version = "0.3.18", default-features = false }

# Build
substrate-build-script-utils = "11.0.0"
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ version = "0.2.0-alpha"
[dependencies]
clap.workspace = true
codec.workspace = true
docify.workspace = true
futures.workspace = true
jsonrpsee = { workspace = true, features = [ "server" ] }
log.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use std::{sync::Arc, time::Duration};
use cumulus_client_cli::CollatorOptions;
// Cumulus Imports
use cumulus_client_collator::service::CollatorService;
#[docify::export(lookahead_collator)]
use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams};
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
};
#[docify::export(cumulus_primitives)]
use cumulus_primitives_core::{
relay_chain::{CollatorPair, ValidationCode},
ParaId,
Expand Down
14 changes: 7 additions & 7 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ version = "0.0.0"
targets = [ "x86_64-unknown-linux-gnu" ]

[dependencies]
codec = { workspace = true, default-features = false, features = [ "derive" ] }
scale-info = { workspace = true, default-features = false, features = [ "derive" ] }
codec = { workspace = true, features = [ "derive" ] }
docify.workspace = true
scale-info = { workspace = true, features = [ "derive" ] }

# Substrate
frame-support = { workspace = true, default-features = false }
sp-runtime = { workspace = true, default-features = false }
sp-std = { workspace = true, default-features = false }
frame-support.workspace = true
sp-runtime.workspace = true

parachains-common = { workspace = true, default-features = false }
polkadot-primitives = { workspace = true, default-features = false }
parachains-common.workspace = true
polkadot-primitives.workspace = true

[features]
default = [ "std" ]
Expand Down
52 changes: 29 additions & 23 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ use sp_runtime::Perbill;
/// Nonce for an account
pub type Nonce = u32;

/// This determines the average expected block time that we are targeting.
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
/// up by `pallet_aura` to implement `fn slot_duration()`.
///
/// Change this to adjust the block time.
pub const MILLISECS_PER_BLOCK: u64 = 6000;

// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;

/// Relay chain slot duration, in milliseconds.
// Value is 6000 millisecs. If `MILLISECS_PER_BLOCK` changes this needs addressing.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
#[docify::export]
mod block_times {
/// This determines the average expected block time that we are targeting.
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
/// up by `pallet_aura` to implement `fn slot_duration()`.
///
/// Change this to adjust the block time.
pub const MILLISECS_PER_BLOCK: u64 = 6000;
/// The duration of a slot.
// NOTE: Currently it is not possible to change the slot duration after the chain has started.
// Attempting to do so will brick block production.
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
}
pub use block_times::*;

// Time is measured by number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
Expand All @@ -39,6 +39,7 @@ 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.
#[docify::export(max_block_weight)]
pub const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64);

Expand All @@ -55,14 +56,19 @@ pub const fn deposit(items: u32, bytes: u32) -> Balance {
/// The existential deposit. Set to 1/1_000 of the Connected Relay Chain.
pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT;

// Async backing
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;

/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
#[docify::export]
mod async_backing_params {
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
/// How many parachain blocks are processed by the relay chain per parent. Limits the
/// number of blocks authored per slot.
pub const BLOCK_PROCESSING_VELOCITY: u32 = 1;
/// Relay chain slot duration, in milliseconds.
// Value is 6000 millisecs. If `MILLISECS_PER_BLOCK` changes this needs addressing.
pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
}
pub use async_backing_params::*;

/// Proxy commons for Pop runtimes
pub mod proxy {
Expand Down
3 changes: 1 addition & 2 deletions runtime/devnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ substrate-wasm-builder.workspace = true

[dependencies]
codec.workspace = true
docify.workspace = true
hex-literal.workspace = true
log.workspace = true
scale-info.workspace = true
Expand Down Expand Up @@ -66,7 +67,6 @@ sp-mmr-primitives.workspace = true
sp-offchain.workspace = true
sp-runtime.workspace = true
sp-session.workspace = true
sp-std.workspace = true
sp-transaction-pool.workspace = true
sp-version.workspace = true

Expand Down Expand Up @@ -171,7 +171,6 @@ std = [
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"xcm-builder/std",
Expand Down
2 changes: 1 addition & 1 deletion runtime/devnet/src/config/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::vec::Vec;
use core::marker::PhantomData;

use codec::Decode;
Expand All @@ -7,7 +8,6 @@ pub(crate) use pallet_api::Extension;
use pallet_api::{extension::*, Read};
use sp_core::ConstU8;
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
use versioning::*;

use crate::{
Expand Down
4 changes: 3 additions & 1 deletion runtime/devnet/src/config/contracts.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::core::marker::PhantomData;

use frame_support::{
parameter_types,
traits::{ConstBool, ConstU32, Nothing, Randomness},
Expand All @@ -22,7 +24,7 @@ fn schedule<T: pallet_contracts::Config>() -> pallet_contracts::Schedule<T> {

// randomness-collective-flip is insecure. Provide dummy randomness as placeholder for the
// deprecated trait. https://github.com/paritytech/polkadot-sdk/blob/9bf1a5e23884921498b381728bfddaae93f83744/substrate/frame/contracts/mock-network/src/parachain/contracts_config.rs#L45
pub struct DummyRandomness<T: pallet_contracts::Config>(sp_std::marker::PhantomData<T>);
pub struct DummyRandomness<T: pallet_contracts::Config>(PhantomData<T>);

impl<T: pallet_contracts::Config> Randomness<T::Hash, BlockNumberFor<T>> for DummyRandomness<T> {
fn random(_subject: &[u8]) -> (T::Hash, BlockNumberFor<T>) {
Expand Down
3 changes: 2 additions & 1 deletion runtime/devnet/src/config/ismp.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use alloc::vec::Vec;

use frame_support::traits::Get;
use frame_system::EnsureRoot;
use ismp::{error::Error, host::StateMachine, module::IsmpModule, router::IsmpRouter};
use ismp_parachain::ParachainConsensusClient;
use sp_std::prelude::*;

use crate::{
AccountId, Balance, Balances, Ismp, IsmpParachain, ParachainInfo, Runtime, RuntimeEvent,
Expand Down
29 changes: 24 additions & 5 deletions runtime/devnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub mod config;
mod weights;

extern crate alloc;
use alloc::vec::Vec;

// ISMP imports
use ::ismp::{
consensus::{ConsensusClientId, StateMachineHeight, StateMachineId},
Expand Down Expand Up @@ -65,7 +68,6 @@ use sp_runtime::{
ApplyExtrinsicResult,
};
pub use sp_runtime::{ExtrinsicInclusionMode, MultiAddress, Perbill, Permill};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
Expand Down Expand Up @@ -351,6 +353,7 @@ parameter_types! {
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
}

#[docify::export]
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
Expand Down Expand Up @@ -439,6 +442,7 @@ impl pallet_session::Config for Runtime {
type WeightInfo = ();
}

#[docify::export(aura_config)]
impl pallet_aura::Config for Runtime {
type AllowMultipleBlocksPerSlot = ConstBool<true>;
type AuthorityId = AuraId;
Expand Down Expand Up @@ -655,11 +659,27 @@ mod benches {
);
}

// We move some impls outside so we can easily use them with `docify`.
impl Runtime {
#[docify::export]
fn impl_slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

#[docify::export]
fn impl_can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

impl_runtime_apis! {

impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
Runtime::impl_slot_duration()
}

fn authorities() -> Vec<AuraId> {
Expand Down Expand Up @@ -866,7 +886,7 @@ impl_runtime_apis! {
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
Runtime::impl_can_build_upon(included_hash, slot)
}
}

Expand Down Expand Up @@ -1064,10 +1084,9 @@ impl_runtime_apis! {
IsmpParachain::current_relay_chain_state()
}
}


}

#[docify::export(register_validate_block)]
cumulus_pallet_parachain_system::register_validate_block! {
Runtime = Runtime,
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
Expand Down
3 changes: 1 addition & 2 deletions runtime/mainnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ substrate-wasm-builder.workspace = true

[dependencies]
codec.workspace = true
docify.workspace = true
scale-info.workspace = true
smallvec.workspace = true

Expand Down Expand Up @@ -55,7 +56,6 @@ sp-io.workspace = true
sp-offchain.workspace = true
sp-runtime.workspace = true
sp-session.workspace = true
sp-std.workspace = true
sp-transaction-pool.workspace = true
sp-version.workspace = true

Expand Down Expand Up @@ -139,7 +139,6 @@ std = [
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"xcm-builder/std",
Expand Down
Loading

0 comments on commit 45b2cf6

Please sign in to comment.