Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2eb5d82
implement as not-dyn generic + part of PartialComponent
gui1117 Mar 28, 2025
e435d70
make statement store optional and not part of polkadot partial
gui1117 Mar 28, 2025
92057c9
also in manual seal
gui1117 Mar 28, 2025
cad2edc
add cli arg + remove from manual seal
gui1117 Apr 28, 2025
fd3a8ea
Merge remote-tracking branch 'origin/master' into gui-statement-store…
gui1117 Apr 28, 2025
4a63575
enable by default
gui1117 Apr 28, 2025
c8a0be6
fmt
gui1117 Apr 28, 2025
e556e9e
Update from github-actions[bot] running command 'prdoc --audience nod…
github-actions[bot] Apr 29, 2025
886ee56
prdoc + remove unused
gui1117 Apr 29, 2025
8909fb2
Merge branch 'master' into gui-statement-store-in-omni-node
gui1117 Apr 29, 2025
e92ee61
Merge remote-tracking branch 'origin/master' into gui-statement-store…
gui1117 May 6, 2025
90dd3a2
network GOOD + host functions WIP
gui1117 May 31, 2025
3ddf39a
actually only register host fn for offchain worker
gui1117 May 31, 2025
928d88f
zero size statement store when disabled
gui1117 May 31, 2025
263ced1
enable if runtime API present at best hash
gui1117 May 31, 2025
7d3ffc8
remove zero size statement store, inexistence is handled good.
gui1117 May 31, 2025
5ced8b5
some todo
gui1117 May 31, 2025
8710f06
register metrics
gui1117 Jun 2, 2025
bd71ce2
log warning when ValidateStatement exists but statement store disabled
gui1117 Jun 2, 2025
aab795e
Merge remote-tracking branch 'origin/master' into gui-statement-store…
gui1117 Jun 2, 2025
31f4e62
fix usage of modified api in test
gui1117 Jun 3, 2025
ae45a8b
implement test
gui1117 Jun 3, 2025
1445aa9
additional inner comments
gui1117 Jun 3, 2025
ce63cef
taplo format
gui1117 Jun 3, 2025
424ec19
address issues
gui1117 Jun 6, 2025
4b764ab
fix some broken usage + clippy
gui1117 Jun 6, 2025
d54947d
disable test in ci, by wrapping in module
gui1117 Jun 6, 2025
2d8fd4a
Apply suggestions from code review
gui1117 Jun 7, 2025
bf1c26a
format + fix
gui1117 Jun 7, 2025
1cb4e2d
Merge branch 'master' into gui-statement-store-in-omni-node
gui1117 Jun 10, 2025
e0f5921
Update cumulus/polkadot-omni-node/lib/src/common/statement_store.rs
gui1117 Jun 17, 2025
94a87c4
Update cumulus/polkadot-omni-node/lib/src/common/statement_store.rs
gui1117 Jun 17, 2025
8100ca8
nits
gui1117 Jun 17, 2025
6e74940
refactor zombienet test
gui1117 Jun 17, 2025
494be5d
fmt
gui1117 Jun 17, 2025
ade2a18
Merge branch 'master' into gui-statement-store-in-omni-node
gui1117 Jun 17, 2025
2d61b75
bump major for people westend runtime
gui1117 Jun 17, 2025
aba9bf9
Merge remote-tracking branch 'origin/master' into gui-statement-store…
gui1117 Jun 23, 2025
28afb7a
use cli arg: enable_statement_store
gui1117 Jun 23, 2025
32200e4
fmt
gui1117 Jun 23, 2025
b50d9b3
doc
gui1117 Jun 23, 2025
807f37d
prdoc
gui1117 Jun 23, 2025
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
9 changes: 9 additions & 0 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions cumulus/client/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ pub struct BuildNetworkParams<
pub spawn_handle: SpawnTaskHandle,
pub import_queue: IQ,
pub sybil_resistance_level: CollatorSybilResistance,
pub metrics: sc_network::NotificationMetrics,
}

/// Build the network service, the network status sinks and an RPC sender.
Expand All @@ -475,6 +476,7 @@ pub async fn build_network<'a, Block, Client, RCInterface, IQ, Network>(
relay_chain_interface,
import_queue,
sybil_resistance_level,
metrics,
}: BuildNetworkParams<'a, Block, Client, Network, RCInterface, IQ>,
) -> sc_service::error::Result<(
Arc<dyn NetworkService>,
Expand Down Expand Up @@ -533,9 +535,6 @@ where
Box::new(block_announce_validator) as Box<_>
},
};
let metrics = Network::register_notification_metrics(
parachain_config.prometheus_config.as_ref().map(|config| &config.registry),
);

sc_service::build_network(sc_service::BuildNetworkParams {
config: parachain_config,
Expand Down
2 changes: 2 additions & 0 deletions cumulus/parachains/runtimes/people/people-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ sp-keyring = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-statement-store = { workspace = true }
sp-storage = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
Expand Down Expand Up @@ -141,6 +142,7 @@ std = [
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-statement-store/std",
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
Expand Down
37 changes: 37 additions & 0 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ use sp_runtime::{
ApplyExtrinsicResult,
};
pub use sp_runtime::{MultiAddress, Perbill, Permill, RuntimeDebug};
use sp_statement_store::{
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
SignatureVerificationResult, Statement,
};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
Expand Down Expand Up @@ -1136,6 +1140,39 @@ impl_runtime_apis! {
ParachainInfo::parachain_id()
}
}

impl sp_statement_store::runtime_api::ValidateStatement<Block> for Runtime {
fn validate_statement(
_source: StatementSource,
statement: Statement,
) -> Result<ValidStatement, InvalidStatement> {
let account = match statement.verify_signature() {
SignatureVerificationResult::Valid(account) => account.into(),
SignatureVerificationResult::Invalid => {
log::debug!("Bad statement signature.");
return Err(InvalidStatement::BadProof)
},
SignatureVerificationResult::NoSignature => {
log::debug!("Missing statement signature.");
return Err(InvalidStatement::NoProof)
},
};

// For now just allow validators to store some statements.
// In the future we will allow people.
if pallet_session::Validators::<Runtime>::get().contains(&account) {
Ok(ValidStatement {
max_count: 2,
max_size: 1024,
})
} else {
Ok(ValidStatement {
max_count: 0,
max_size: 0,
})
}
}
}
}

cumulus_pallet_parachain_system::register_validate_block! {
Expand Down
5 changes: 5 additions & 0 deletions cumulus/polkadot-omni-node/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ sc-client-db = { workspace = true, default-features = true }
sc-consensus = { workspace = true, default-features = true }
sc-consensus-manual-seal = { workspace = true, default-features = true }
sc-executor = { workspace = true, default-features = true }
sc-keystore = { workspace = true, default-features = true }
sc-network = { workspace = true, default-features = true }
sc-network-statement = { workspace = true, default-features = true }
sc-network-sync = { workspace = true, default-features = true }
sc-offchain = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sc-runtime-utilities = { workspace = true, default-features = true }
sc-service = { workspace = true, default-features = false }
sc-statement-store = { workspace = true, default-features = true }
sc-sysinfo = { workspace = true, default-features = true }
sc-telemetry = { workspace = true, default-features = true }
sc-tracing = { workspace = true, default-features = true }
Expand All @@ -71,6 +75,7 @@ sp-keystore = { workspace = true, default-features = true }
sp-offchain = { workspace = true, default-features = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true, default-features = true }
sp-statement-store = { workspace = true, default-features = true }
sp-storage = { workspace = true, default-features = true }
sp-timestamp = { workspace = true, default-features = true }
sp-transaction-pool = { workspace = true, default-features = true }
Expand Down
8 changes: 8 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ pub struct Cli<Config: CliConfig> {
#[arg(raw = true)]
pub relay_chain_args: Vec<String>,

/// Enable the statement store.
///
/// The statement store is a store for statements validated using the runtime API
/// `validate_statement`. It should be enabled for chains that provide this runtime API.
#[arg(long)]
pub enable_statement_store: bool,

#[arg(skip)]
pub(crate) _phantom: PhantomData<Config>,
}
Expand Down Expand Up @@ -232,6 +239,7 @@ impl<Config: CliConfig> Cli<Config> {
.unwrap_or(self.authoring),
export_pov: self.export_pov_to_path.clone(),
max_pov_percentage: self.run.experimental_max_pov_percentage,
enable_statement_store: self.enable_statement_store,
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub mod command;
pub mod rpc;
pub mod runtime;
pub mod spec;
pub(crate) mod statement_store;
pub mod types;

use crate::cli::AuthoringPolicy;
Expand All @@ -41,6 +42,7 @@ use sp_runtime::{
OpaqueExtrinsic,
};
use sp_session::SessionKeys;
use sp_statement_store::runtime_api::ValidateStatement;
use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
use std::{fmt::Debug, path::PathBuf, str::FromStr};

Expand Down Expand Up @@ -73,6 +75,7 @@ pub trait NodeRuntimeApi<Block: BlockT>:
+ OffchainWorkerApi<Block>
+ CollectCollationInfo<Block>
+ GetCoreSelectorApi<Block>
+ ValidateStatement<Block>
+ GetParachainInfo<Block>
+ RelayParentOffsetApi<Block>
+ Sized
Expand All @@ -89,6 +92,7 @@ impl<T, Block: BlockT> NodeRuntimeApi<Block> for T where
+ GetCoreSelectorApi<Block>
+ RelayParentOffsetApi<Block>
+ CollectCollationInfo<Block>
+ ValidateStatement<Block>
+ GetParachainInfo<Block>
{
}
Expand Down Expand Up @@ -123,4 +127,7 @@ pub struct NodeExtraArgs {
/// The maximum percentage of the maximum PoV size that the collator can use.
/// It will be removed once <https://github.com/paritytech/polkadot-sdk/issues/6020> is fixed.
pub max_pov_percentage: Option<u32>,

/// If true then the statement store will be enabled.
pub enable_statement_store: bool,
}
13 changes: 11 additions & 2 deletions cumulus/polkadot-omni-node/lib/src/common/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use crate::common::{
ConstructNodeRuntimeApi,
};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_rpc::dev::{Dev, DevApiServer};
use sc_rpc::{
dev::{Dev, DevApiServer},
statement::{StatementApiServer, StatementStore},
};
use sp_runtime::traits::Block as BlockT;
use std::{marker::PhantomData, sync::Arc};
use substrate_frame_rpc_system::{System, SystemApiServer};
Expand All @@ -32,11 +35,12 @@ use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer
/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpsee::RpcModule<()>;

pub(crate) trait BuildRpcExtensions<Client, Backend, Pool> {
pub(crate) trait BuildRpcExtensions<Client, Backend, Pool, StatementStore> {
fn build_rpc_extensions(
client: Arc<Client>,
backend: Arc<Backend>,
pool: Arc<Pool>,
statement_store: Option<Arc<StatementStore>>,
) -> sc_service::error::Result<RpcExtension>;
}

Expand All @@ -47,6 +51,7 @@ impl<Block: BlockT, RuntimeApi>
ParachainClient<Block, RuntimeApi>,
ParachainBackend<Block>,
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient<Block, RuntimeApi>>,
sc_statement_store::Store,
> for BuildParachainRpcExtensions<Block, RuntimeApi>
where
RuntimeApi:
Expand All @@ -60,13 +65,17 @@ where
pool: Arc<
sc_transaction_pool::TransactionPoolHandle<Block, ParachainClient<Block, RuntimeApi>>,
>,
statement_store: Option<Arc<sc_statement_store::Store>>,
) -> sc_service::error::Result<RpcExtension> {
let build = || -> Result<RpcExtension, Box<dyn std::error::Error + Send + Sync>> {
let mut module = RpcExtension::new(());

module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(StateMigration::new(client.clone(), backend).into_rpc())?;
if let Some(statement_store) = statement_store {
module.merge(StatementStore::new(statement_store).into_rpc())?;
}
module.merge(Dev::new(client).into_rpc())?;

Ok(module)
Expand Down
44 changes: 42 additions & 2 deletions cumulus/polkadot-omni-node/lib/src/common/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
common::{
command::NodeCommandRunner,
rpc::BuildRpcExtensions,
statement_store::{build_statement_store, new_statement_handler_proto},
types::{
ParachainBackend, ParachainBlockImport, ParachainClient, ParachainHostFunctions,
ParachainService,
Expand All @@ -44,6 +45,7 @@ use sc_consensus::DefaultImportQueue;
use sc_executor::{HeapAllocStrategy, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::{config::FullNetworkConfiguration, NetworkBackend, NetworkBlock};
use sc_service::{Configuration, ImportQueue, PartialComponents, TaskManager};
use sc_statement_store::Store;
use sc_sysinfo::HwBench;
use sc_telemetry::{TelemetryHandle, TelemetryWorker};
use sc_tracing::tracing::Instrument;
Expand Down Expand Up @@ -277,6 +279,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
ParachainClient<Self::Block, Self::RuntimeApi>,
ParachainBackend<Self::Block>,
TransactionPoolHandle<Self::Block, ParachainClient<Self::Block, Self::RuntimeApi>>,
Store,
>;

type StartConsensus: StartConsensus<
Expand Down Expand Up @@ -333,11 +336,19 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
let prometheus_registry = parachain_config.prometheus_registry().cloned();
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();
let net_config = FullNetworkConfiguration::<_, _, Net>::new(
let mut net_config = FullNetworkConfiguration::<_, _, Net>::new(
&parachain_config.network,
prometheus_registry.clone(),
);

let metrics = Net::register_notification_metrics(
parachain_config.prometheus_config.as_ref().map(|config| &config.registry),
);

let statement_handler_proto = node_extra_args.enable_statement_store.then(|| {
new_statement_handler_proto(&*client, &parachain_config, &metrics, &mut net_config)
});

let (network, system_rpc_tx, tx_handler_controller, sync_service) =
build_network(BuildNetworkParams {
parachain_config: &parachain_config,
Expand All @@ -349,10 +360,37 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
relay_chain_interface: relay_chain_interface.clone(),
import_queue: params.import_queue,
sybil_resistance_level: Self::SYBIL_RESISTANCE,
metrics,
})
.await?;

let statement_store = statement_handler_proto
.map(|statement_handler_proto| {
build_statement_store(
&parachain_config,
&mut task_manager,
client.clone(),
network.clone(),
sync_service.clone(),
params.keystore_container.local_keystore(),
statement_handler_proto,
)
})
.transpose()?;

if parachain_config.offchain_worker.enabled {
let custom_extensions = {
let statement_store = statement_store.clone();
move |_hash| {
if let Some(statement_store) = &statement_store {
vec![Box::new(statement_store.clone().as_statement_store_ext())
as Box<_>]
} else {
vec![]
}
}
};

let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
Expand All @@ -364,7 +402,7 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
network_provider: Arc::new(network.clone()),
is_validator: parachain_config.role.is_authority(),
enable_http_requests: true,
custom_extensions: move |_| vec![],
custom_extensions,
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
Expand All @@ -377,12 +415,14 @@ pub(crate) trait NodeSpec: BaseNodeSpec {
let client = client.clone();
let transaction_pool = transaction_pool.clone();
let backend_for_rpc = backend.clone();
let statement_store = statement_store.clone();

Box::new(move |_| {
Self::BuildRpcExtensions::build_rpc_extensions(
client.clone(),
backend_for_rpc.clone(),
transaction_pool.clone(),
statement_store.clone(),
)
})
};
Expand Down
Loading
Loading