Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1,967 changes: 1,002 additions & 965 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
clap = { version = "4.3.12", features = ["derive"] }
futures = "0.3.28"
jsonrpsee = { version = "0.16.2", features = ["server"] }
serde_json = "1.0.103"

Expand Down Expand Up @@ -39,10 +40,12 @@ sc-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch
sc-consensus-grandpa-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-telemetry = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
3 changes: 2 additions & 1 deletion bin/millau/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ fn testnet_genesis(
RuntimeGenesisConfig {
system: SystemConfig {
code: WASM_BINARY.expect("Millau development WASM not available").to_vec(),
..Default::default()
},
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 50)).collect(),
},
aura: AuraConfig { authorities: Vec::new() },
beefy: BeefyConfig::default(),
grandpa: GrandpaConfig { authorities: Vec::new() },
grandpa: GrandpaConfig { authorities: Vec::new(), ..Default::default() },
sudo: SudoConfig { key: Some(root_key) },
session: SessionConfig {
keys: initial_authorities
Expand Down
9 changes: 2 additions & 7 deletions bin/millau/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{
};
use frame_benchmarking_cli::BenchmarkCmd;
use millau_runtime::{Block, RuntimeApi};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;

impl SubstrateCli for Cli {
Expand Down Expand Up @@ -53,10 +53,6 @@ impl SubstrateCli for Cli {
"millau-bridge-node".into()
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&millau_runtime::VERSION
}

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(Box::new(
match id {
Expand All @@ -83,8 +79,7 @@ pub fn run() -> sc_cli::Result<()> {
match cmd {
BenchmarkCmd::Pallet(cmd) =>
if cfg!(feature = "runtime-benchmarks") {
runner
.sync_run(|config| cmd.run::<Block, service::ExecutorDispatch>(config))
runner.sync_run(|config| cmd.run::<Block, ()>(config))
} else {
println!(
"Benchmarking wasn't enabled when building the node. \
Expand Down
48 changes: 37 additions & 11 deletions bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

use jsonrpsee::RpcModule;
use millau_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::BlockBackend;
use sc_client_api::{Backend, BlockBackend};
use sc_consensus_aura::{CompatibilityMode, ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_grandpa::SharedVoterState;
pub use sc_executor::NativeElseWasmExecutor;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use std::{sync::Arc, time::Duration};

Expand Down Expand Up @@ -127,6 +128,7 @@ pub fn new_partial(

let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import(
client.clone(),
512,
&client,
select_chain.clone(),
telemetry.as_ref().map(|x| x.handle()),
Expand Down Expand Up @@ -223,6 +225,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
);
net_config.add_request_response_protocol(beefy_req_resp_cfg);

let role = config.role.clone();
let warp_sync = Arc::new(sc_consensus_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
Expand All @@ -242,15 +245,28 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
})?;

if config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&config,
task_manager.spawn_handle(),
client.clone(),
network.clone(),
use futures::FutureExt;

task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
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: network.clone(),
is_validator: role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
}

let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks: Option<()> = None;
let name = config.network.node_name.clone();
Expand All @@ -277,7 +293,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let shared_voter_state = shared_voter_state.clone();

let finality_proof_provider = GrandpaFinalityProofProvider::new_for_service(
backend,
backend.clone(),
Some(shared_authority_set.clone()),
);

Expand Down Expand Up @@ -308,7 +324,16 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
.into_rpc(),
)
.map_err(map_err)?;
io.merge(Mmr::new(client.clone()).into_rpc()).map_err(map_err)?;
io.merge(
Mmr::new(
client.clone(),
backend
.offchain_storage()
.ok_or("Backend doesn't provide the required offchain storage")?,
)
.into_rpc(),
)
.map_err(map_err)?;
Ok(io)
})
};
Expand All @@ -332,7 +357,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
transaction_pool.clone(),
prometheus_registry.as_ref(),
telemetry.as_ref().map(|x| x.handle()),
);
Expand Down Expand Up @@ -411,7 +436,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let grandpa_config = sc_consensus_grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333),
justification_period: 512,
justification_generation_period: 512,
name: Some(name),
observer_enabled: false,
keystore,
Expand All @@ -436,6 +461,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
prometheus_registry,
shared_voter_state,
telemetry: telemetry.as_ref().map(|x| x.handle()),
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool),
};

// the GRANDPA voter task is considered infallible, i.e.
Expand Down
28 changes: 12 additions & 16 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ pub type AccountIndex = u32;
/// Balance of an account.
pub type Balance = bp_millau::Balance;

/// Index of a transaction in the chain.
pub type Index = bp_millau::Index;
/// Nonce of a transaction in the chain.
pub type Nonce = bp_millau::Nonce;

/// A hash of some data used by the chain.
pub type Hash = bp_millau::Hash;
Expand Down Expand Up @@ -184,15 +184,13 @@ impl frame_system::Config for Runtime {
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = IdentityLookup<AccountId>;
/// The index type for storing how many extrinsics an account has signed.
type Index = Index;
/// The index type for blocks.
type BlockNumber = BlockNumber;
type Nonce = Nonce;
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
type Hashing = Hashing;
/// The header type.
type Header = generic::Header<BlockNumber, Hashing>;
type Block = Block;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
Expand Down Expand Up @@ -240,6 +238,7 @@ impl pallet_beefy::Config for Runtime {
type WeightInfo = ();
type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
type MaxNominators = ConstU32<256>;
}

impl pallet_grandpa::Config for Runtime {
Expand All @@ -250,6 +249,7 @@ impl pallet_grandpa::Config for Runtime {
type MaxSetIdSessionEntries = ConstU64<0>;
type KeyOwnerProof = sp_core::Void;
type EquivocationReportSystem = ();
type MaxNominators = ConstU32<256>;
}

/// MMR helper types.
Expand Down Expand Up @@ -525,12 +525,8 @@ impl pallet_utility::Config for Runtime {
}

construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
pub enum Runtime {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
Utility: pallet_utility,

Expand All @@ -543,7 +539,7 @@ construct_runtime!(

// Consensus support.
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config<T>, Event},
ShiftSessionManager: pallet_shift_session_manager::{Pallet},

// BEEFY Bridges support.
Expand All @@ -565,7 +561,7 @@ construct_runtime!(
BridgeRialtoParachainMessages: pallet_bridge_messages::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},

// Pallet for sending XCM.
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 99,
XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 99,
}
);

Expand Down Expand Up @@ -691,8 +687,8 @@ impl_runtime_apis! {
}
}

impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
fn account_nonce(account: AccountId) -> Index {
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
fn account_nonce(account: AccountId) -> Nonce {
System::account_nonce(account)
}
}
Expand Down
4 changes: 3 additions & 1 deletion bin/millau/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub type Barrier = (
pub type OnMillauBlobDispatcher = xcm_builder::BridgeBlobDispatcher<
crate::xcm_config::XcmRouter,
crate::xcm_config::UniversalLocation,
(),
>;

/// XCM weigher type.
Expand Down Expand Up @@ -250,11 +251,12 @@ mod tests {
};
use codec::Encode;
use pallet_bridge_messages::OutboundLanes;
use sp_runtime::BuildStorage;
use xcm_executor::XcmExecutor;

fn new_test_ext() -> sp_io::TestExternalities {
sp_io::TestExternalities::new(
frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap(),
frame_system::GenesisConfig::<Runtime>::default().build_storage().unwrap(),
)
}

Expand Down
6 changes: 5 additions & 1 deletion bin/rialto-parachain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,16 @@ fn testnet_genesis(
code: rialto_parachain_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
balances: rialto_parachain_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
},
sudo: rialto_parachain_runtime::SudoConfig { key: Some(root_key) },
parachain_info: rialto_parachain_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: rialto_parachain_runtime::ParachainInfoConfig {
parachain_id: id,
..Default::default()
},
aura: rialto_parachain_runtime::AuraConfig { authorities: initial_authorities },
aura_ext: Default::default(),
bridge_millau_messages: BridgeMillauMessagesConfig {
Expand Down
39 changes: 1 addition & 38 deletions bin/rialto-parachain/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use crate::chain_spec;
use clap::Parser;
use cumulus_client_cli::{ExportGenesisStateCommand, ExportGenesisWasmCommand};
use std::path::PathBuf;

/// Sub-commands supported by the collator.
Expand Down Expand Up @@ -57,44 +58,6 @@ pub enum Subcommand {
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}

/// Command for exporting the genesis state of the parachain
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {
/// Output file name or stdout if unspecified.
#[clap(action)]
pub output: Option<PathBuf>,

/// Id of the parachain this state is for.
///
/// Default: 100
#[clap(long, conflicts_with = "chain")]
pub parachain_id: Option<u32>,

/// Write output in binary. Default is to write in hex.
#[clap(short, long)]
pub raw: bool,

/// The name of the chain for that the genesis state should be exported.
#[clap(long, conflicts_with = "parachain-id")]
pub chain: Option<String>,
}

/// Command for exporting the genesis wasm file.
#[derive(Debug, Parser)]
pub struct ExportGenesisWasmCommand {
/// Output file name or stdout if unspecified.
#[clap(action)]
pub output: Option<PathBuf>,

/// Write output in binary. Default is to write in hex.
#[clap(short, long)]
pub raw: bool,

/// The name of the chain for that the genesis wasm file should be exported.
#[clap(long)]
pub chain: Option<String>,
}

#[derive(Debug, Parser)]
#[clap(
propagate_version = true,
Expand Down
Loading