Skip to content

Commit

Permalink
Migrate back to Substrate master (paritytech#528)
Browse files Browse the repository at this point in the history
* migrate back to Substrate master

* fmt

* clippy
  • Loading branch information
svyatonik authored and serban300 committed Apr 8, 2024
1 parent 7866a49 commit eff38a4
Show file tree
Hide file tree
Showing 32 changed files with 307 additions and 307 deletions.
42 changes: 21 additions & 21 deletions bridges/bin/millau/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@ pallet-message-lane-rpc = { path = "../../../modules/message-lane/rpc" }

# Substrate Dependencies

frame-benchmarking = "2.0"
frame-benchmarking-cli = "2.0"
sc-basic-authorship = "0.8"
sc-cli = "0.8"
sc-client-api = "2.0"
sc-consensus = "0.8"
sc-consensus-aura = "0.8"
sc-executor = "0.8"
sc-finality-grandpa = "0.8"
sc-finality-grandpa-rpc = "0.8"
sc-service = "0.8"
sc-rpc = "2.0"
sc-transaction-pool = "2.0"
sp-consensus = "0.8"
sp-consensus-aura = "0.8"
sp-core = "2.0"
sp-inherents = "2.0"
sp-finality-grandpa = "2.0"
sp-runtime = "2.0"
substrate-frame-rpc-system = "2.0"
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-basic-authorship = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-finality-grandpa-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-service = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-rpc = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sc-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" }

[build-dependencies]
build-script-utils = { package = "substrate-build-script-utils", version = "2.0" }
frame-benchmarking-cli = "2.0"
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
vergen = "3.1.0"

[features]
Expand Down
8 changes: 5 additions & 3 deletions bridges/bin/millau/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ pub fn run() -> sc_cli::Result<()> {
}
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config),
runner.run_node_until_exit(|config| async move {
match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config),
}
})
}
}
Expand Down
83 changes: 41 additions & 42 deletions bridges/bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
// =====================================================================================
// =====================================================================================

use bp_message_lane::{LaneId, MessageNonce};
use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE};
use millau_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::{ExecutorProvider, RemoteBackend};
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
use sc_finality_grandpa::SharedVoterState;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_core::storage::StorageKey;
use sp_inherents::InherentDataProviders;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -65,15 +62,21 @@ pub fn new_partial(
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
sc_consensus_aura::AuraBlockImport<
Block,
FullClient,
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
AuraPair,
>,
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
),
>,
ServiceError,
> {
let inherent_data_providers = sp_inherents::InherentDataProviders::new();

let (client, backend, keystore, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
let client = Arc::new(client);

let select_chain = sc_consensus::LongestChain::new(backend.clone());
Expand All @@ -93,9 +96,8 @@ pub fn new_partial(

let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
aura_block_import,
Some(Box::new(grandpa_block_import.clone())),
None,
aura_block_import.clone(),
Some(Box::new(grandpa_block_import)),
client.clone(),
inherent_data_providers.clone(),
&task_manager.spawn_handle(),
Expand All @@ -108,11 +110,11 @@ pub fn new_partial(
backend,
task_manager,
import_queue,
keystore,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (grandpa_block_import, grandpa_link),
other: (aura_block_import, grandpa_link),
})
}

Expand All @@ -123,15 +125,13 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
backend,
mut task_manager,
import_queue,
keystore,
keystore_container,
select_chain,
transaction_pool,
inherent_data_providers,
other: (block_import, grandpa_link),
} = new_partial(&config)?;

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

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -141,8 +141,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: None,
block_announce_validator_builder: None,
finality_proof_request_builder: None,
finality_proof_provider: Some(finality_proof_provider),
})?;

if config.offchain_worker.enabled {
Expand All @@ -157,12 +155,18 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {

let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks: Option<()> = None;
let name = config.network.node_name.clone();
let enable_grandpa = !config.disable_grandpa;
let prometheus_registry = config.prometheus_registry().cloned();
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();

let rpc_extensions_builder = {
use bp_message_lane::{LaneId, MessageNonce};
use bp_runtime::{InstanceId, RIALTO_BRIDGE_INSTANCE};
use sc_finality_grandpa::FinalityProofProvider as GrandpaFinalityProofProvider;
use sp_core::storage::StorageKey;

// This struct is here to ease update process.

/// Millau runtime from message-lane RPC point of view.
Expand Down Expand Up @@ -232,7 +236,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore.clone(),
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
Expand All @@ -246,21 +250,26 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
})?;

if role.is_authority() {
let proposer =
sc_basic_authorship::ProposerFactory::new(client.clone(), transaction_pool, prometheus_registry.as_ref());
let proposer = sc_basic_authorship::ProposerFactory::new(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry.as_ref(),
);

let can_author_with = sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());

let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
client.clone(),
select_chain,
block_import,
proposer,
network.clone(),
inherent_data_providers.clone(),
inherent_data_providers,
force_authoring,
keystore.clone(),
backoff_authoring_blocks,
keystore_container.sync_keystore(),
can_author_with,
)?;

Expand All @@ -272,7 +281,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if role.is_authority() {
Some(keystore as sp_core::traits::BareCryptoStorePtr)
Some(keystore_container.sync_keystore())
} else {
None
};
Expand All @@ -298,7 +307,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
config: grandpa_config,
link: grandpa_link,
network,
inherent_data_providers,
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry,
Expand All @@ -311,7 +319,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
.spawn_essential_handle()
.spawn_blocking("grandpa-voter", sc_finality_grandpa::run_grandpa_voter(grandpa_config)?);
} else {
sc_finality_grandpa::setup_disabled_grandpa(client, &inherent_data_providers, network)?;
sc_finality_grandpa::setup_disabled_grandpa(network)?;
}

network_starter.start_network();
Expand All @@ -320,9 +328,11 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {

/// Builds a new service for a light client.
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
let (client, backend, keystore, mut task_manager, on_demand) =
let (client, backend, keystore_container, mut task_manager, on_demand) =
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;

let select_chain = sc_consensus::LongestChain::new(backend.clone());

let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
config.transaction_pool.clone(),
config.prometheus_registry(),
Expand All @@ -331,29 +341,20 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
on_demand.clone(),
));

let grandpa_block_import = sc_finality_grandpa::light_block_import(
client.clone(),
backend.clone(),
&(client.clone() as Arc<_>),
Arc::new(on_demand.checker().clone()) as Arc<_>,
)?;
let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
let (grandpa_block_import, _) =
sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;

let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
sc_consensus_aura::slot_duration(&*client)?,
grandpa_block_import,
None,
Some(Box::new(finality_proof_import)),
grandpa_block_import.clone(),
Some(Box::new(grandpa_block_import)),
client.clone(),
InherentDataProviders::new(),
&task_manager.spawn_handle(),
config.prometheus_registry(),
sp_consensus::NeverCanAuthor,
)?;

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

let (network, network_status_sinks, system_rpc_tx, network_starter) =
sc_service::build_network(sc_service::BuildNetworkParams {
config: &config,
Expand All @@ -363,8 +364,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: Some(on_demand.clone()),
block_announce_validator_builder: None,
finality_proof_request_builder: Some(finality_proof_request_builder),
finality_proof_provider: Some(finality_proof_provider),
})?;

if config.offchain_worker.enabled {
Expand All @@ -386,7 +385,7 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(),
config,
client,
keystore,
keystore: keystore_container.sync_keystore(),
backend,
network,
network_status_sinks,
Expand Down
50 changes: 25 additions & 25 deletions bridges/bin/millau/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ pallet-substrate-bridge = { path = "../../../modules/substrate", default-feature

# Substrate Dependencies

frame-executive = { version = "2.0", default-features = false }
frame-support = { version = "2.0", default-features = false }
frame-system = { version = "2.0", default-features = false }
frame-system-rpc-runtime-api = { version = "2.0", default-features = false }
pallet-aura = { version = "2.0", default-features = false }
pallet-balances = { version = "2.0", default-features = false }
pallet-grandpa = { version = "2.0", default-features = false }
pallet-randomness-collective-flip = { version = "2.0", default-features = false }
pallet-session = { version = "2.0", default-features = false }
pallet-sudo = { version = "2.0", default-features = false }
pallet-timestamp = { version = "2.0", default-features = false }
pallet-transaction-payment = { version = "2.0", default-features = false }
sp-api = { version = "2.0", default-features = false }
sp-block-builder = { version = "2.0", default-features = false }
sp-consensus-aura = { version = "0.8", default-features = false }
sp-core = { version = "2.0", default-features = false }
sp-inherents = { version = "2.0", default-features = false }
sp-finality-grandpa = { version = "2.0", default-features = false }
sp-offchain = { version = "2.0", default-features = false }
sp-runtime = { version = "2.0", default-features = false }
sp-session = { version = "2.0", default-features = false }
sp-std = { version = "2.0", default-features = false }
sp-transaction-pool = { version = "2.0", default-features = false }
sp-trie = { version = "2.0", default-features = false }
sp-version = { version = "2.0", default-features = false }
frame-executive = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-block-builder = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-inherents = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-offchain = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-session = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }
sp-version = { git = "https://github.com/paritytech/substrate.git", branch = "master" , default-features = false }

[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "2.0.0" }
Expand Down
3 changes: 1 addition & 2 deletions bridges/bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ parameter_types! {
}

impl pallet_transaction_payment::Trait for Runtime {
type Currency = pallet_balances::Module<Runtime>;
type OnTransactionPayment = ();
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
Expand Down
Loading

0 comments on commit eff38a4

Please sign in to comment.