Skip to content

Commit

Permalink
fix: upgrade to polkadot2412 and use fork-aware txpool (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
th7nder authored Dec 19, 2024
1 parent ff84bc1 commit 2fbacbd
Show file tree
Hide file tree
Showing 9 changed files with 5,634 additions and 4,594 deletions.
10,002 changes: 5,518 additions & 4,484 deletions Cargo.lock

Large diffs are not rendered by default.

166 changes: 83 additions & 83 deletions Cargo.toml

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub type Service = PartialComponents<
ParachainBackend,
(),
sc_consensus::DefaultImportQueue<Block>,
sc_transaction_pool::FullPool<Block, ParachainClient>,
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient>,
(
ParachainBlockImport,
Option<Telemetry>,
Expand Down Expand Up @@ -111,12 +111,15 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
telemetry
});

let transaction_pool = sc_transaction_pool::BasicPool::new_full(
config.transaction_pool.clone(),
config.role.is_authority().into(),
config.prometheus_registry(),
task_manager.spawn_essential_handle(),
client.clone(),
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(),
);

let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
Expand Down Expand Up @@ -177,7 +180,7 @@ fn start_consensus(
telemetry: Option<TelemetryHandle>,
task_manager: &TaskManager,
relay_chain_interface: Arc<dyn RelayChainInterface>,
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
transaction_pool: Arc<sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient>>,
keystore: KeystorePtr,
relay_chain_slot_duration: Duration,
para_id: ParaId,
Expand Down Expand Up @@ -293,9 +296,7 @@ pub async fn start_parachain_node(
if parachain_config.offchain_worker.enabled {
use futures::FutureExt;

task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(params.keystore_container.keystore()),
Expand All @@ -307,9 +308,13 @@ pub async fn start_parachain_node(
is_validator: parachain_config.role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
offchain_workers
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/randomness/src/inherent.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use codec::Encode;
use sp_inherents::{InherentIdentifier, IsFatalError};
use sp_runtime::RuntimeString;
extern crate alloc;

/// BABE VRF Inherent Identifier
pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babe_vrf";

#[derive(Encode)]
#[cfg_attr(feature = "std", derive(Debug, codec::Decode))]
pub enum InherentError {
Other(RuntimeString),
Other(alloc::borrow::Cow<'static, str>),
}

impl IsFatalError for InherentError {
Expand Down
8 changes: 3 additions & 5 deletions pallets/randomness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ pub mod pallet {
fn is_inherent_required(_: &InherentData) -> Result<Option<Self::Error>, Self::Error> {
// Return Ok(Some(_)) unconditionally because this inherent is required in every block
// If it is not found, throw a VrfInherentRequired error.
Ok(Some(InherentError::Other(
sp_runtime::RuntimeString::Borrowed(
"Inherent required to set babe randomness results",
),
)))
Ok(Some(InherentError::Other(alloc::borrow::Cow::Borrowed(
"Inherent required to set babe randomness results",
))))
}

fn create_inherent(_data: &InherentData) -> Option<Self::Call> {
Expand Down
3 changes: 3 additions & 0 deletions runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl pallet_balances::Config for Runtime {
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
type MaxFreezes = ConstU32<0>;
type DoneSlashHandler = ();
}

parameter_types! {
Expand All @@ -171,6 +172,7 @@ impl pallet_transaction_payment::Config for Runtime {
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightInfo = ();
}

impl pallet_sudo::Config for Runtime {
Expand All @@ -197,6 +199,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type SelectCore = cumulus_pallet_parachain_system::DefaultCoreSelector<Runtime>;
}

impl parachain_info::Config for Runtime {}
Expand Down
10 changes: 5 additions & 5 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sp_core::{crypto::KeyTypeId, hex2array, Get, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
generic, impl_opaque_keys,
traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
Expand Down Expand Up @@ -159,14 +159,14 @@ impl_opaque_keys! {

#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polka-storage-runtime"),
impl_name: create_runtime_str!("polka-storage-runtime"),
spec_name: alloc::borrow::Cow::Borrowed("polka-storage-runtime"),
impl_name: alloc::borrow::Cow::Borrowed("polka-storage-runtime"),
authoring_version: 1,
spec_version: 1,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
state_version: 1,
system_version: 1,
};

#[docify::export]
Expand Down Expand Up @@ -611,7 +611,7 @@ impl_runtime_apis! {

fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch};
use super::*;

Expand Down
Binary file modified storagext/lib/artifacts/metadata.scale
Binary file not shown.
2 changes: 1 addition & 1 deletion zombienet/local-testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ id = 1000

# run charlie as parachain collator
[[parachains.collators]]
args = ["--detailed-log-output", "-lparachain=debug,xcm=trace,runtime=trace"]
args = ["--detailed-log-output", "--pool-type=fork-aware", "-lparachain=debug,xcm=trace,runtime=trace,txpool=debug,basic-authorship=debug"]
command = "target/release/polka-storage-node"
name = "charlie"
validator = true
Expand Down

0 comments on commit 2fbacbd

Please sign in to comment.