From 0bb6631c3377c91d502136bd8fe9a04005a3cf97 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sat, 1 Nov 2025 20:00:31 +0100 Subject: [PATCH 1/2] fix: instant seal --- Cargo.lock | 1 + Cargo.toml | 2 + node/Cargo.toml | 1 + node/src/cli.rs | 17 ++ node/src/command.rs | 12 ++ node/src/service.rs | 272 ++++++++++++++++++++++++- parachain-runtime/src/assets_config.rs | 38 +++- parachain-runtime/src/lib.rs | 24 ++- runtime/src/assets_config.rs | 38 +++- runtime/src/lib.rs | 14 +- rust-toolchain.toml | 3 + zombienet.toml | 2 +- 12 files changed, 389 insertions(+), 35 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/Cargo.lock b/Cargo.lock index a380386..8dd3415 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5494,6 +5494,7 @@ dependencies = [ "cumulus-client-consensus-aura", "cumulus-client-consensus-common", "cumulus-client-consensus-proposer", + "cumulus-client-parachain-inherent", "cumulus-client-service", "cumulus-primitives-core", "cumulus-primitives-parachain-inherent", diff --git a/Cargo.toml b/Cargo.toml index 35736cb..388f725 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ codec = { package = "parity-scale-codec", version = "3.7.5", default-features = "derive", ] } futures = "0.3.31" +futures-timer = "3.0" hex-literal = { version = "0.4.1" } jsonrpsee = { version = "0.24.10", features = ["server"] } log = { version = "0.4.22", default-features = false } @@ -122,6 +123,7 @@ cumulus-client-consensus-proposer ={ git = "https://github.com/paritytech/polkad cumulus-client-consensus-aura = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1" } cumulus-client-consensus-common ={ git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1" } cumulus-client-service = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1" } +cumulus-client-parachain-inherent = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } diff --git a/node/Cargo.toml b/node/Cargo.toml index 791a3c8..25cc8f6 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -81,6 +81,7 @@ cumulus-client-collator = { workspace = true } cumulus-client-consensus-aura = { workspace = true } cumulus-client-consensus-common = { workspace = true } cumulus-client-consensus-proposer = { workspace = true } +cumulus-client-parachain-inherent = { workspace = true } cumulus-client-service = { workspace = true } cumulus-primitives-core = { workspace = true } cumulus-primitives-parachain-inherent = { workspace = true } diff --git a/node/src/cli.rs b/node/src/cli.rs index fc8d275..04df541 100644 --- a/node/src/cli.rs +++ b/node/src/cli.rs @@ -80,6 +80,23 @@ pub struct Cli { /// The number of seconds to delay before finalizing blocks. #[arg(long, default_value_t = 1)] pub finalize_delay_sec: u8, + + /// Start a dev node with instant seal. + /// + /// This is a dev option that enables instant sealing, meaning blocks are produced + /// immediately when transactions are received, rather than at fixed intervals. + /// Using this option won't result in starting or connecting to a parachain network. + /// The resulting node will work on its own, running the wasm blob and producing blocks + /// instantly upon receiving transactions. + #[arg(long)] + pub instant_seal: bool, +} + +impl Cli { + /// Returns true if instant seal mode is enabled. + pub fn is_instant_seal(&self) -> bool { + self.instant_seal + } } #[derive(Debug)] diff --git a/node/src/command.rs b/node/src/command.rs index e786b15..21d9cd0 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -222,6 +222,8 @@ pub fn run() -> Result<()> { let collator_options = cli.run.collator_options(); runner.run_node_until_exit(|config| async move { + // Check for solochain dev mode first (chain spec "Development") + // The solochain runtime doesn't have Aura, so it needs separate handling if config.chain_spec.name() == "Development" { return dev::new_full::>( config, @@ -231,6 +233,16 @@ pub fn run() -> Result<()> { .map_err(sc_cli::Error::Service); } + // Check for instant seal mode for parachain (requires parachain runtime with Aura) + if cli.is_instant_seal() { + return crate::service::start_dev_parachain_node( + config, + cli.finalize_delay_sec.into(), + ) + .await + .map_err(sc_cli::Error::Service); + } + let hwbench = (!cli.no_hardware_benchmarks) .then_some(config.database.path().map(|database_path| { let _ = std::fs::create_dir_all(database_path); diff --git a/node/src/service.rs b/node/src/service.rs index e5f43c8..6fe3fed 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -15,6 +15,7 @@ use cumulus_client_cli::CollatorOptions; use cumulus_client_collator::service::CollatorService; use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; +use cumulus_client_parachain_inherent::MockValidationDataInherentDataProvider; use cumulus_client_service::{ build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions, @@ -25,18 +26,24 @@ use cumulus_primitives_core::{ ParaId, }; use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; +use polkadot_primitives::{HeadData, UpgradeGoAhead}; // Substrate Imports +use codec::Encode; +use cumulus_primitives_core::CollectCollationInfo; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use prometheus_endpoint::Registry; use sc_client_api::Backend; -use sc_consensus::ImportQueue; +use sc_consensus::{ImportQueue, LongestChain}; +use sc_consensus_manual_seal::consensus::aura::AuraConsensusDataProvider; use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; use sc_network::{NetworkBackend, NetworkBlock}; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_transaction_pool_api::OffchainTransactionPoolFactory; +use sp_api::ProvideRuntimeApi; use sp_keystore::KeystorePtr; +use sp_runtime::traits::UniqueSaturatedInto; type ParachainExecutor = WasmExecutor; @@ -406,3 +413,266 @@ pub async fn start_parachain_node( Ok((task_manager, client)) } + +/// Creates the inherent data providers for dev mode (instant/manual seal). +/// +/// This function sets up the timestamp and parachain validation data providers +/// required for dev seal block production in a parachain environment without a relay chain. +fn create_dev_inherent_data_providers( + client: Arc, + para_id: ParaId, + slot_duration: sp_consensus_aura::SlotDuration, +) -> impl Fn( + Hash, + (), +) -> std::future::Ready< + Result< + (sp_timestamp::InherentDataProvider, MockValidationDataInherentDataProvider<()>), + Box, + >, +> + Send + + Sync { + move |parent_hash: Hash, ()| { + let current_para_head = client + .header(parent_hash) + .expect("Header lookup should succeed") + .expect("Header passed in as parent should be present in backend."); + + // Check if there's pending validation code that needs upgrade signal + let should_send_go_ahead = client + .runtime_api() + .collect_collation_info(parent_hash, ¤t_para_head) + .map(|info| info.new_validation_code.is_some()) + .unwrap_or_default(); + + let current_para_block_head = Some(HeadData(current_para_head.encode())); + let current_block_number = + UniqueSaturatedInto::::unique_saturated_into(current_para_head.number) + 1; + + // Create mock parachain validation data + let mocked_parachain = MockValidationDataInherentDataProvider::<()> { + current_para_block: current_block_number, + para_id, + current_para_block_head, + relay_blocks_per_para_block: 1, + para_blocks_per_relay_epoch: 10, + upgrade_go_ahead: should_send_go_ahead.then(|| { + log::info!("Detected pending validation code, sending go-ahead signal."); + UpgradeGoAhead::GoAhead + }), + ..Default::default() + }; + + // Create timestamp aligned to Aura slot timing + let timestamp = sp_timestamp::InherentDataProvider::new( + (slot_duration.as_millis() * current_block_number as u64).into(), + ); + + std::future::ready(Ok((timestamp, mocked_parachain))) + } +} + +/// Start a parachain node in dev mode with instant seal. +/// +/// This allows the parachain to run standalone without connecting to a relay chain, +/// useful for development and testing. +pub async fn start_dev_parachain_node( + mut config: Configuration, + finalize_delay_sec: u64, +) -> sc_service::error::Result { + // Since this is a dev node, prevent it from connecting to peers + config.network.default_peers_set.in_peers = 0; + config.network.default_peers_set.out_peers = 0; + + // Build client, backend, and other components manually + // We can't use new_partial() because it creates an Aura import queue + let telemetry = config + .telemetry_endpoints + .clone() + .filter(|x| !x.is_empty()) + .map(|endpoints| -> Result<_, sc_telemetry::Error> { + let worker = TelemetryWorker::new(16)?; + let telemetry = worker.handle().new_telemetry(endpoints); + Ok((worker, telemetry)) + }) + .transpose()?; + + let heap_pages = config + .executor + .default_heap_pages + .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ }); + + let executor = ParachainExecutor::builder() + .with_execution_method(config.executor.wasm_method) + .with_onchain_heap_alloc_strategy(heap_pages) + .with_offchain_heap_alloc_strategy(heap_pages) + .with_max_runtime_instances(config.executor.max_runtime_instances) + .with_runtime_cache_size(config.executor.runtime_cache_size) + .build(); + + let (client, backend, keystore_container, mut task_manager) = + sc_service::new_full_parts_record_import::( + &config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, + true, + )?; + let client = Arc::new(client); + + let mut telemetry = telemetry.map(|(worker, telemetry)| { + task_manager.spawn_handle().spawn("telemetry", None, worker.run()); + telemetry + }); + + let transaction_pool = Arc::from( + sc_transaction_pool::Builder::new( + task_manager.spawn_essential_handle(), + client.clone(), + config.role.is_authority().into(), + ) + .with_options(config.transaction_pool.clone()) + .with_prometheus(config.prometheus_registry()) + .build(), + ); + + // Create manual seal import queue (accepts all blocks without relay chain validation) + let import_queue = sc_consensus_manual_seal::import_queue( + Box::new(client.clone()), + &task_manager.spawn_essential_handle(), + config.prometheus_registry(), + ); + + let net_config = sc_network::config::FullNetworkConfiguration::< + _, + _, + sc_network::NetworkWorker, + >::new( + &config.network, + config.prometheus_config.as_ref().map(|cfg| cfg.registry.clone()), + ); + + let (network, system_rpc_tx, tx_handler_controller, sync_service) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + net_config, + block_announce_validator_builder: None, + warp_sync_config: None, + block_relay: None, + metrics: sc_network::NetworkWorker::::register_notification_metrics( + config.prometheus_config.as_ref().map(|config| &config.registry), + ), + })?; + + if config.offchain_worker.enabled { + use futures::FutureExt; + + let offchain_workers = + sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { + runtime_api_provider: client.clone(), + keystore: Some(keystore_container.keystore()), + offchain_db: backend.offchain_storage(), + transaction_pool: Some(OffchainTransactionPoolFactory::new( + transaction_pool.clone(), + )), + network_provider: Arc::new(network.clone()), + is_validator: config.role.is_authority(), + enable_http_requests: true, + custom_extensions: move |_| vec![], + })?; + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "offchain-work", + offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(), + ); + } + + let proposer = sc_basic_authorship::ProposerFactory::new( + task_manager.spawn_handle(), + client.clone(), + transaction_pool.clone(), + None, + None, + ); + + // Get slot duration from runtime + let slot_duration = sc_consensus_aura::slot_duration(&*client) + .expect("Slot duration is always present in Aura runtime; qed."); + + // The aura digest provider will provide digests that match the provided timestamp data. + // Without this, the AURA parachain runtime complains about slot mismatches. + let aura_digest_provider = AuraConsensusDataProvider::new_with_slot_duration(slot_duration); + + // Extract para_id from chain spec + let para_id = crate::chain_spec::Extensions::try_get(&*config.chain_spec) + .map(|e| e.para_id) + .ok_or("Could not find parachain ID in chain-spec.")?; + let para_id = ParaId::from(para_id); + + // Create inherent data providers with mocked relay chain data + let create_inherent_data_providers = + create_dev_inherent_data_providers(client.clone(), para_id, slot_duration); + + // Spawn instant seal consensus + let params = sc_consensus_manual_seal::InstantSealParams { + block_import: client.clone(), + env: proposer, + client: client.clone(), + pool: transaction_pool.clone(), + select_chain: LongestChain::new(backend.clone()), + consensus_data_provider: Some(Box::new(aura_digest_provider)), + create_inherent_data_providers, + }; + + let authorship_future = sc_consensus_manual_seal::run_instant_seal(params); + task_manager + .spawn_essential_handle() + .spawn_blocking("instant-seal", None, authorship_future); + + // Optional delayed finalization + if finalize_delay_sec > 0 { + let delayed_finalize_params = sc_consensus_manual_seal::DelayedFinalizeParams { + client: client.clone(), + spawn_handle: task_manager.spawn_handle(), + delay_sec: finalize_delay_sec, + }; + task_manager.spawn_essential_handle().spawn_blocking( + "delayed_finalize", + None, + sc_consensus_manual_seal::run_delayed_finalize(delayed_finalize_params), + ); + } + + let rpc_builder = { + let client = client.clone(); + let transaction_pool = transaction_pool.clone(); + + Box::new(move |_| { + let deps = + crate::rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone() }; + + crate::rpc::create_full(deps).map_err(Into::into) + }) + }; + + let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { + network, + client, + keystore: keystore_container.keystore(), + task_manager: &mut task_manager, + transaction_pool, + rpc_builder, + backend, + system_rpc_tx, + tx_handler_controller, + sync_service, + config, + telemetry: telemetry.as_mut(), + tracing_execute_block: None, + })?; + + Ok(task_manager) +} diff --git a/parachain-runtime/src/assets_config.rs b/parachain-runtime/src/assets_config.rs index 46b9fad..7e8e046 100644 --- a/parachain-runtime/src/assets_config.rs +++ b/parachain-runtime/src/assets_config.rs @@ -1,20 +1,38 @@ -use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent}; +use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent, EXISTENTIAL_DEPOSIT}; use frame_support::{ parameter_types, - traits::{AsEnsureOriginWithArg, ConstU128, ConstU32}, + traits::{AsEnsureOriginWithArg, ConstU32}, }; use frame_system::EnsureSigned; -pub const MILLICENTS: Balance = 1_000_000_000; -pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. -pub const DOLLARS: Balance = 100 * CENTS; +// Currency constants matching Paseo Asset Hub +const UNITS: Balance = 10_000_000_000; +const DOLLARS: Balance = UNITS; +const MILLICENTS: Balance = DOLLARS / 100_000; + +// System parachain deposit calculation matching Paseo +// Paseo uses: (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 +const fn system_para_deposit(items: u32, bytes: u32) -> Balance { + ((items as Balance) * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 100 +} parameter_types! { - pub const AssetDeposit: Balance = 100 * DOLLARS; - pub const ApprovalDeposit: Balance = 1 * DOLLARS; + // Matches Paseo Asset Hub: system_para_deposit(1, 190) + pub const AssetDeposit: Balance = system_para_deposit(1, 190); // 2_019_000_000 + + // Matches Paseo Asset Hub: system_para_deposit(1, 16) + pub const AssetAccountDeposit: Balance = system_para_deposit(1, 16); // 2_001_600_000 + + // Matches Paseo Asset Hub: ExistentialDeposit + pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT; // 100_000_000 + pub const StringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 10 * DOLLARS; - pub const MetadataDepositPerByte: Balance = 1 * DOLLARS; + + // Matches Paseo Asset Hub: system_para_deposit(1, 68) + pub const MetadataDepositBase: Balance = system_para_deposit(1, 68); // 2_006_800_000 + + // Matches Paseo Asset Hub: system_para_deposit(0, 1) + pub const MetadataDepositPerByte: Balance = system_para_deposit(0, 1); // 100_000 } impl pallet_assets::Config for Runtime { @@ -26,7 +44,7 @@ impl pallet_assets::Config for Runtime { type Currency = Balances; type ForceOrigin = frame_system::EnsureRoot; type AssetDeposit = AssetDeposit; - type AssetAccountDeposit = ConstU128; + type AssetAccountDeposit = AssetAccountDeposit; type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; type ApprovalDeposit = ApprovalDeposit; diff --git a/parachain-runtime/src/lib.rs b/parachain-runtime/src/lib.rs index 87bbbf3..3714365 100644 --- a/parachain-runtime/src/lib.rs +++ b/parachain-runtime/src/lib.rs @@ -166,9 +166,9 @@ pub struct WeightToFee; impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { - // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1 MILLIUNIT: - // We map to 1/10 of that, or 1/10 MILLIUNIT - let p = MILLIUNIT / 10; + // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1 MILLICENT: + // We map to 1/10 of that, or 1/10 MILLICENT + let p = MILLICENTS / 10; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { degree: 1, @@ -239,13 +239,17 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; -// Unit = the base number of indivisible units for balances -pub const UNIT: Balance = 1_000_000_000_000; -pub const MILLIUNIT: Balance = 1_000_000_000; -pub const MICROUNIT: Balance = 1_000_000; - -/// The existential deposit. Set to 1/10 of the Connected Relay Chain. -pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; +// Currency constants matching Paseo Asset Hub +// Based on Paseo: UNITS = 10_000_000_000 (10^10) +pub const UNITS: Balance = 10_000_000_000; +pub const DOLLARS: Balance = UNITS; +pub const CENTS: Balance = DOLLARS / 100; +pub const MILLICENTS: Balance = CENTS / 1_000; +pub const MICROUNIT: Balance = CENTS / 10_000; + +/// The existential deposit matching Paseo Asset Hub system parachain. +/// Paseo Asset Hub: SYSTEM_PARA_EXISTENTIAL_DEPOSIT / 10 = CENTS +pub const EXISTENTIAL_DEPOSIT: Balance = CENTS; // 100_000_000 /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is /// used to limit the maximal weight of a single extrinsic. diff --git a/runtime/src/assets_config.rs b/runtime/src/assets_config.rs index 46b9fad..7e8e046 100644 --- a/runtime/src/assets_config.rs +++ b/runtime/src/assets_config.rs @@ -1,20 +1,38 @@ -use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent}; +use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent, EXISTENTIAL_DEPOSIT}; use frame_support::{ parameter_types, - traits::{AsEnsureOriginWithArg, ConstU128, ConstU32}, + traits::{AsEnsureOriginWithArg, ConstU32}, }; use frame_system::EnsureSigned; -pub const MILLICENTS: Balance = 1_000_000_000; -pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. -pub const DOLLARS: Balance = 100 * CENTS; +// Currency constants matching Paseo Asset Hub +const UNITS: Balance = 10_000_000_000; +const DOLLARS: Balance = UNITS; +const MILLICENTS: Balance = DOLLARS / 100_000; + +// System parachain deposit calculation matching Paseo +// Paseo uses: (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 +const fn system_para_deposit(items: u32, bytes: u32) -> Balance { + ((items as Balance) * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 100 +} parameter_types! { - pub const AssetDeposit: Balance = 100 * DOLLARS; - pub const ApprovalDeposit: Balance = 1 * DOLLARS; + // Matches Paseo Asset Hub: system_para_deposit(1, 190) + pub const AssetDeposit: Balance = system_para_deposit(1, 190); // 2_019_000_000 + + // Matches Paseo Asset Hub: system_para_deposit(1, 16) + pub const AssetAccountDeposit: Balance = system_para_deposit(1, 16); // 2_001_600_000 + + // Matches Paseo Asset Hub: ExistentialDeposit + pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT; // 100_000_000 + pub const StringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 10 * DOLLARS; - pub const MetadataDepositPerByte: Balance = 1 * DOLLARS; + + // Matches Paseo Asset Hub: system_para_deposit(1, 68) + pub const MetadataDepositBase: Balance = system_para_deposit(1, 68); // 2_006_800_000 + + // Matches Paseo Asset Hub: system_para_deposit(0, 1) + pub const MetadataDepositPerByte: Balance = system_para_deposit(0, 1); // 100_000 } impl pallet_assets::Config for Runtime { @@ -26,7 +44,7 @@ impl pallet_assets::Config for Runtime { type Currency = Balances; type ForceOrigin = frame_system::EnsureRoot; type AssetDeposit = AssetDeposit; - type AssetAccountDeposit = ConstU128; + type AssetAccountDeposit = AssetAccountDeposit; type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; type ApprovalDeposit = ApprovalDeposit; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 74afd70..a03f926 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -128,9 +128,17 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX); -// Unit = the base number of indivisible units for balances -const MILLIUNIT: Balance = 1_000_000_000; -pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; +// Currency constants matching Paseo Asset Hub +// Based on Paseo: UNITS = 10_000_000_000 (10^10) +const UNITS: Balance = 10_000_000_000; +const DOLLARS: Balance = UNITS; +const CENTS: Balance = DOLLARS / 100; +#[allow(dead_code)] +const MILLICENTS: Balance = CENTS / 1_000; + +// Existential deposit matching Paseo Asset Hub system parachain +// Paseo Asset Hub: SYSTEM_PARA_EXISTENTIAL_DEPOSIT / 10 +pub const EXISTENTIAL_DEPOSIT: Balance = CENTS; // 100_000_000 impl pallet_insecure_randomness_collective_flip::Config for Runtime {} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..43e5784 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.90.0" +components = ["rustfmt", "clippy"] diff --git a/zombienet.toml b/zombienet.toml index c9aa417..994e197 100644 --- a/zombienet.toml +++ b/zombienet.toml @@ -10,7 +10,7 @@ # zombienet spawn --provider native zombienet.toml [relaychain] -chain = "rococo-local" +chain = "paseo-local" command = "polkadot" [[relaychain.nodes]] From 0a1fbfd42e330487caa9d947cec5ee54524b67c0 Mon Sep 17 00:00:00 2001 From: Daanvdplas Date: Sun, 2 Nov 2025 15:09:13 +0100 Subject: [PATCH 2/2] fix: ci --- Cargo.toml | 3 +-- parachain-runtime/src/assets_config.rs | 15 ++------------- parachain-runtime/src/lib.rs | 13 +++++-------- runtime/src/assets_config.rs | 15 ++------------- runtime/src/lib.rs | 4 ---- rust-toolchain.toml | 3 --- 6 files changed, 10 insertions(+), 43 deletions(-) delete mode 100644 rust-toolchain.toml diff --git a/Cargo.toml b/Cargo.toml index 388f725..c3ea76d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ codec = { package = "parity-scale-codec", version = "3.7.5", default-features = "derive", ] } futures = "0.3.31" -futures-timer = "3.0" hex-literal = { version = "0.4.1" } jsonrpsee = { version = "0.24.10", features = ["server"] } log = { version = "0.4.22", default-features = false } @@ -138,4 +137,4 @@ cumulus-primitives-utility = { git = "https://github.com/paritytech/polkadot-sdk cumulus-relay-chain-interface = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1" } pallet-collator-selection = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } parachain-info = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", package = "staging-parachain-info", default-features = false } -parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } \ No newline at end of file +parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", rev = "9136565addc23a552f6960a7581f13c8dfc651f1", default-features = false } diff --git a/parachain-runtime/src/assets_config.rs b/parachain-runtime/src/assets_config.rs index 7e8e046..20a487e 100644 --- a/parachain-runtime/src/assets_config.rs +++ b/parachain-runtime/src/assets_config.rs @@ -5,33 +5,22 @@ use frame_support::{ }; use frame_system::EnsureSigned; -// Currency constants matching Paseo Asset Hub const UNITS: Balance = 10_000_000_000; const DOLLARS: Balance = UNITS; const MILLICENTS: Balance = DOLLARS / 100_000; -// System parachain deposit calculation matching Paseo -// Paseo uses: (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 +// System parachain deposit formula: +// (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 const fn system_para_deposit(items: u32, bytes: u32) -> Balance { ((items as Balance) * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 100 } parameter_types! { - // Matches Paseo Asset Hub: system_para_deposit(1, 190) pub const AssetDeposit: Balance = system_para_deposit(1, 190); // 2_019_000_000 - - // Matches Paseo Asset Hub: system_para_deposit(1, 16) pub const AssetAccountDeposit: Balance = system_para_deposit(1, 16); // 2_001_600_000 - - // Matches Paseo Asset Hub: ExistentialDeposit pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT; // 100_000_000 - pub const StringLimit: u32 = 50; - - // Matches Paseo Asset Hub: system_para_deposit(1, 68) pub const MetadataDepositBase: Balance = system_para_deposit(1, 68); // 2_006_800_000 - - // Matches Paseo Asset Hub: system_para_deposit(0, 1) pub const MetadataDepositPerByte: Balance = system_para_deposit(0, 1); // 100_000 } diff --git a/parachain-runtime/src/lib.rs b/parachain-runtime/src/lib.rs index 3714365..93593a4 100644 --- a/parachain-runtime/src/lib.rs +++ b/parachain-runtime/src/lib.rs @@ -166,8 +166,8 @@ pub struct WeightToFee; impl WeightToFeePolynomial for WeightToFee { type Balance = Balance; fn polynomial() -> WeightToFeeCoefficients { - // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1 MILLICENT: - // We map to 1/10 of that, or 1/10 MILLICENT + // In Rococo, extrinsic base weight (smallest non-zero weight) maps to 1 MILLICENTS. + // We map to 1/10 of that, or 1/10 MILLICENTS. let p = MILLICENTS / 10; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); smallvec![WeightToFeeCoefficient { @@ -239,16 +239,13 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; -// Currency constants matching Paseo Asset Hub -// Based on Paseo: UNITS = 10_000_000_000 (10^10) pub const UNITS: Balance = 10_000_000_000; pub const DOLLARS: Balance = UNITS; pub const CENTS: Balance = DOLLARS / 100; pub const MILLICENTS: Balance = CENTS / 1_000; pub const MICROUNIT: Balance = CENTS / 10_000; -/// The existential deposit matching Paseo Asset Hub system parachain. -/// Paseo Asset Hub: SYSTEM_PARA_EXISTENTIAL_DEPOSIT / 10 = CENTS +/// The existential deposit for a system parachain. pub const EXISTENTIAL_DEPOSIT: Balance = CENTS; // 100_000_000 /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is @@ -382,8 +379,8 @@ impl pallet_balances::Config for Runtime { } parameter_types! { - /// Relay Chain `TransactionByteFee` / 10 - pub const TransactionByteFee: Balance = 10 * MICROUNIT; + /// Transaction byte fee scaled for system parachains. + pub const TransactionByteFee: Balance = MILLICENTS / 2; } impl pallet_transaction_payment::Config for Runtime { diff --git a/runtime/src/assets_config.rs b/runtime/src/assets_config.rs index 7e8e046..20a487e 100644 --- a/runtime/src/assets_config.rs +++ b/runtime/src/assets_config.rs @@ -5,33 +5,22 @@ use frame_support::{ }; use frame_system::EnsureSigned; -// Currency constants matching Paseo Asset Hub const UNITS: Balance = 10_000_000_000; const DOLLARS: Balance = UNITS; const MILLICENTS: Balance = DOLLARS / 100_000; -// System parachain deposit calculation matching Paseo -// Paseo uses: (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 +// System parachain deposit formula: +// (items * 20 * DOLLARS + bytes * 100 * MILLICENTS) / 100 const fn system_para_deposit(items: u32, bytes: u32) -> Balance { ((items as Balance) * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS) / 100 } parameter_types! { - // Matches Paseo Asset Hub: system_para_deposit(1, 190) pub const AssetDeposit: Balance = system_para_deposit(1, 190); // 2_019_000_000 - - // Matches Paseo Asset Hub: system_para_deposit(1, 16) pub const AssetAccountDeposit: Balance = system_para_deposit(1, 16); // 2_001_600_000 - - // Matches Paseo Asset Hub: ExistentialDeposit pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT; // 100_000_000 - pub const StringLimit: u32 = 50; - - // Matches Paseo Asset Hub: system_para_deposit(1, 68) pub const MetadataDepositBase: Balance = system_para_deposit(1, 68); // 2_006_800_000 - - // Matches Paseo Asset Hub: system_para_deposit(0, 1) pub const MetadataDepositPerByte: Balance = system_para_deposit(0, 1); // 100_000 } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index a03f926..7d16aa8 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -128,16 +128,12 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX); -// Currency constants matching Paseo Asset Hub -// Based on Paseo: UNITS = 10_000_000_000 (10^10) const UNITS: Balance = 10_000_000_000; const DOLLARS: Balance = UNITS; const CENTS: Balance = DOLLARS / 100; #[allow(dead_code)] const MILLICENTS: Balance = CENTS / 1_000; -// Existential deposit matching Paseo Asset Hub system parachain -// Paseo Asset Hub: SYSTEM_PARA_EXISTENTIAL_DEPOSIT / 10 pub const EXISTENTIAL_DEPOSIT: Balance = CENTS; // 100_000_000 impl pallet_insecure_randomness_collective_flip::Config for Runtime {} diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 43e5784..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "1.90.0" -components = ["rustfmt", "clippy"]