mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Substrate 3.0 (#232)
* Update substrate deps to 3.0.0 and 0.9.0 * Update substrate wasm tools * Fixing errors for 3.0.0 compat * Fixing more errors for 3.0.0 compat * Use MultiAddress for test runtime * Fmt * Fix node test * Pin Funty * Update AccountInfo struct * Add comment about funty pin
This commit is contained in:
+18
-18
@@ -18,25 +18,25 @@ log = "0.4.13"
|
||||
structopt = "0.3.21"
|
||||
parking_lot = "0.11.1"
|
||||
|
||||
sc-cli = { version = "0.8.1", features = ["wasmtime"] }
|
||||
sp-core = "2.0.1"
|
||||
sc-executor = { version = "0.8.1", features = ["wasmtime"] }
|
||||
sc-service = { version = "0.8.1", features = ["wasmtime"] }
|
||||
sp-inherents = "2.0.1"
|
||||
sc-transaction-pool = "2.0.1"
|
||||
sp-transaction-pool = "2.0.1"
|
||||
sc-network = "0.8.1"
|
||||
sc-consensus-aura = "0.8.1"
|
||||
sp-consensus-aura = "0.8.1"
|
||||
sp-consensus = "0.8.1"
|
||||
sc-consensus = "0.8.1"
|
||||
sc-finality-grandpa = "0.8.1"
|
||||
sp-finality-grandpa = "2.0.1"
|
||||
sc-client-api = "2.0.1"
|
||||
sp-runtime = "2.0.1"
|
||||
sc-basic-authorship = "0.8.1"
|
||||
sc-cli = { version = "0.9.0", features = ["wasmtime"] }
|
||||
sp-core = "3.0.0"
|
||||
sc-executor = { version = "0.9.0", features = ["wasmtime"] }
|
||||
sc-service = { version = "0.9.0", features = ["wasmtime"] }
|
||||
sp-inherents = "3.0.0"
|
||||
sc-transaction-pool = "3.0.0"
|
||||
sp-transaction-pool = "3.0.0"
|
||||
sc-network = "0.9.0"
|
||||
sc-consensus-aura = "0.9.0"
|
||||
sp-consensus-aura = "0.9.0"
|
||||
sp-consensus = "0.9.0"
|
||||
sc-consensus = "0.9.0"
|
||||
sc-finality-grandpa = "0.9.0"
|
||||
sp-finality-grandpa = "3.0.0"
|
||||
sc-client-api = "3.0.0"
|
||||
sp-runtime = "3.0.0"
|
||||
sc-basic-authorship = "0.9.0"
|
||||
|
||||
test-node-runtime = { path = "runtime" }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-build-script-utils = "2.0.1"
|
||||
substrate-build-script-utils = "3.0.0"
|
||||
|
||||
@@ -11,35 +11,35 @@ repository = "https://github.com/paritytech/substrate/"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.5", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
|
||||
frame-executive = { version = "2.0.0", default-features = false }
|
||||
frame-support = { version = "2.0.0", default-features = false }
|
||||
frame-system = { version = "2.0.0", default-features = false }
|
||||
pallet-aura = { version = "2.0.0", default-features = false }
|
||||
pallet-balances = { version = "2.0.0", default-features = false }
|
||||
pallet-grandpa = { version = "2.0.0", default-features = false }
|
||||
pallet-randomness-collective-flip = { version = "2.0.0", default-features = false }
|
||||
pallet-staking = { version = "2.0.0", default-features = false }
|
||||
pallet-sudo = { version = "2.0.0", default-features = false }
|
||||
pallet-timestamp = { version = "2.0.0", default-features = false }
|
||||
pallet-transaction-payment = { version = "2.0.0", default-features = false }
|
||||
frame-executive = { version = "3.0.0", default-features = false }
|
||||
frame-support = { version = "3.0.0", default-features = false }
|
||||
frame-system = { version = "3.0.0", default-features = false }
|
||||
pallet-aura = { version = "3.0.0", default-features = false }
|
||||
pallet-balances = { version = "3.0.0", default-features = false }
|
||||
pallet-grandpa = { version = "3.0.0", default-features = false }
|
||||
pallet-randomness-collective-flip = { version = "3.0.0", default-features = false }
|
||||
pallet-staking = { version = "3.0.0", default-features = false }
|
||||
pallet-sudo = { version = "3.0.0", default-features = false }
|
||||
pallet-timestamp = { version = "3.0.0", default-features = false }
|
||||
pallet-transaction-payment = { version = "3.0.0", default-features = false }
|
||||
serde = { version = "1.0.116", optional = true, features = ["derive"] }
|
||||
sp-api = { version = "2.0.0", default-features = false }
|
||||
sp-block-builder = { version = "2.0.0", default-features = false }
|
||||
sp-consensus-aura = { version = "0.8.0", default-features = false }
|
||||
sp-core = { version = "2.0.0", default-features = false }
|
||||
sp-inherents = { version = "2.0.0", default-features = false }
|
||||
sp-io = { version = "2.0.0", default-features = false }
|
||||
sp-offchain = { version = "2.0.0", default-features = false }
|
||||
sp-runtime = { version = "2.0.0", default-features = false }
|
||||
sp-session = { version = "2.0.0", default-features = false }
|
||||
sp-std = { version = "2.0.0", default-features = false }
|
||||
sp-transaction-pool = { version = "2.0.0", default-features = false }
|
||||
sp-version = { version = "2.0.0", default-features = false }
|
||||
sp-api = { version = "3.0.0", default-features = false }
|
||||
sp-block-builder = { version = "3.0.0", default-features = false }
|
||||
sp-consensus-aura = { version = "0.9.0", default-features = false }
|
||||
sp-core = { version = "3.0.0", default-features = false }
|
||||
sp-inherents = { version = "3.0.0", default-features = false }
|
||||
sp-io = { version = "3.0.0", default-features = false }
|
||||
sp-offchain = { version = "3.0.0", default-features = false }
|
||||
sp-runtime = { version = "3.0.0", default-features = false }
|
||||
sp-session = { version = "3.0.0", default-features = false }
|
||||
sp-std = { version = "3.0.0", default-features = false }
|
||||
sp-transaction-pool = { version = "3.0.0", default-features = false }
|
||||
sp-version = { version = "3.0.0", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder-runner = "1.0.6"
|
||||
substrate-wasm-builder = "3.0.0"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@@ -14,12 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use substrate_wasm_builder_runner::WasmBuilder;
|
||||
use substrate_wasm_builder::WasmBuilder;
|
||||
|
||||
fn main() {
|
||||
WasmBuilder::new()
|
||||
.with_current_project()
|
||||
.with_wasm_builder_from_crates("1.0.11")
|
||||
.export_heap_base()
|
||||
.import_memory()
|
||||
.build()
|
||||
|
||||
@@ -41,12 +41,11 @@ use sp_runtime::{
|
||||
generic,
|
||||
impl_opaque_keys,
|
||||
traits::{
|
||||
AccountIdLookup,
|
||||
BlakeTwo256,
|
||||
Block as BlockT,
|
||||
IdentifyAccount,
|
||||
IdentityLookup,
|
||||
NumberFor,
|
||||
Saturating,
|
||||
Verify,
|
||||
},
|
||||
transaction_validity::{
|
||||
@@ -169,29 +168,32 @@ pub fn native_version() -> NativeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const BlockHashCount: BlockNumber = 2400;
|
||||
/// We allow for 2 seconds of compute with a 6 second average block time.
|
||||
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
/// Assume 10% of weight for average on_initialize calls.
|
||||
pub MaximumExtrinsicWeight: Weight =
|
||||
AvailableBlockRatio::get().saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT)
|
||||
* MaximumBlockWeight::get();
|
||||
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
|
||||
::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
|
||||
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
|
||||
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = ();
|
||||
/// Block & extrinsics weights: base values and limits.
|
||||
type BlockWeights = BlockWeights;
|
||||
/// The maximum length of a block (in bytes).
|
||||
type BlockLength = BlockLength;
|
||||
/// The identifier used to distinguish between accounts.
|
||||
type AccountId = AccountId;
|
||||
/// The aggregated dispatch type that is available for extrinsics.
|
||||
type Call = Call;
|
||||
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
|
||||
type Lookup = IdentityLookup<AccountId>;
|
||||
type Lookup = AccountIdLookup<AccountId, ()>;
|
||||
/// The index type for storing how many extrinsics an account has signed.
|
||||
type Index = Index;
|
||||
/// The index type for blocks.
|
||||
@@ -208,26 +210,14 @@ impl frame_system::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||
type BlockHashCount = BlockHashCount;
|
||||
/// Maximum weight of each block.
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
/// The weight of database operations that the runtime can invoke.
|
||||
type DbWeight = RocksDbWeight;
|
||||
/// The weight of the overhead invoked on the block import process, independent of the
|
||||
/// extrinsics included in that block.
|
||||
type BlockExecutionWeight = BlockExecutionWeight;
|
||||
/// The base weight of any extrinsic processed by the runtime, independent of the
|
||||
/// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)
|
||||
type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
|
||||
/// The maximum weight that a single extrinsic of `Normal` dispatch class can have,
|
||||
/// idependent of the logic of that extrinsics. (Roughly max block weight - average on
|
||||
/// initialize cost).
|
||||
type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
|
||||
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
/// Portion of the block weight that is available to all normal transactions.
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
/// Version of the runtime.
|
||||
type Version = Version;
|
||||
/// Converts a module to the index of the module in `construct_runtime!`.
|
||||
///
|
||||
/// This type is being generated by `construct_runtime!`.
|
||||
type PalletInfo = PalletInfo;
|
||||
/// What to do if a new account is created.
|
||||
type OnNewAccount = ();
|
||||
/// What to do if an account is fully reaped from the system.
|
||||
@@ -236,15 +226,15 @@ impl frame_system::Trait for Runtime {
|
||||
type AccountData = pallet_balances::AccountData<Balance>;
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo = ();
|
||||
/// Provides information about the pallet setup in the runtime.
|
||||
type PalletInfo = PalletInfo;
|
||||
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
|
||||
type SS58Prefix = SS58Prefix;
|
||||
}
|
||||
|
||||
impl pallet_aura::Trait for Runtime {
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
|
||||
@@ -266,7 +256,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
@@ -278,7 +268,7 @@ parameter_types! {
|
||||
pub const ExistentialDeposit: u128 = 500;
|
||||
}
|
||||
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
impl pallet_balances::Config for Runtime {
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
/// The ubiquitous event type.
|
||||
@@ -294,15 +284,14 @@ parameter_types! {
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = pallet_balances::Module<Runtime>;
|
||||
type OnTransactionPayment = ();
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
@@ -316,7 +305,7 @@ construct_runtime!(
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
Aura: pallet_aura::{Module, Config<T>, Inherent},
|
||||
Aura: pallet_aura::{Module, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
@@ -325,7 +314,7 @@ construct_runtime!(
|
||||
);
|
||||
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = AccountId;
|
||||
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
|
||||
/// Block header type as expected by this runtime.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// Block type as expected by this runtime.
|
||||
|
||||
@@ -67,7 +67,8 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
|
||||
}
|
||||
|
||||
pub fn development_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY;
|
||||
let wasm_binary =
|
||||
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
@@ -106,7 +107,8 @@ pub fn development_config() -> Result<ChainSpec, String> {
|
||||
}
|
||||
|
||||
pub fn local_testnet_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY;
|
||||
let wasm_binary =
|
||||
WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
|
||||
@@ -87,11 +87,14 @@ 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),
|
||||
async move {
|
||||
match config.role {
|
||||
Role::Light => service::new_light(config),
|
||||
_ => service::new_full(config),
|
||||
}
|
||||
.map(|service| service.0)
|
||||
.map_err(sc_cli::Error::Service)
|
||||
}
|
||||
.map(|service| service.0)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+70
-64
@@ -23,10 +23,7 @@ use sc_client_api::{
|
||||
};
|
||||
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,
|
||||
@@ -67,20 +64,30 @@ pub fn new_partial(
|
||||
sp_consensus::DefaultImportQueue<Block, FullClient>,
|
||||
sc_transaction_pool::FullPool<Block, FullClient>,
|
||||
(
|
||||
sc_finality_grandpa::GrandpaBlockImport<
|
||||
FullBackend,
|
||||
sc_consensus_aura::AuraBlockImport<
|
||||
Block,
|
||||
FullClient,
|
||||
FullSelectChain,
|
||||
sc_finality_grandpa::GrandpaBlockImport<
|
||||
FullBackend,
|
||||
Block,
|
||||
FullClient,
|
||||
FullSelectChain,
|
||||
>,
|
||||
AuraPair,
|
||||
>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
),
|
||||
>,
|
||||
ServiceError,
|
||||
> {
|
||||
if config.keystore_remote.is_some() {
|
||||
return Err(ServiceError::Other(format!(
|
||||
"Remote Keystores are not supported."
|
||||
)))
|
||||
}
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore, task_manager) =
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
@@ -88,6 +95,7 @@ pub fn new_partial(
|
||||
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
config.role.is_authority().into(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
@@ -106,9 +114,8 @@ pub fn new_partial(
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import,
|
||||
aura_block_import.clone(),
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
@@ -121,32 +128,34 @@ 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),
|
||||
})
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(
|
||||
config: Configuration,
|
||||
mut config: Configuration,
|
||||
) -> Result<(TaskManager, RpcHandlers), ServiceError> {
|
||||
let PartialComponents {
|
||||
client,
|
||||
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());
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
@@ -157,8 +166,6 @@ pub fn new_full(
|
||||
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 {
|
||||
@@ -173,29 +180,32 @@ pub fn new_full(
|
||||
|
||||
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_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore.clone(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
||||
rpc_extensions_builder: Box::new(|_, _| ()),
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
backend,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
config,
|
||||
})?;
|
||||
let rpc_extensions_builder = Box::new(|_, _| ());
|
||||
|
||||
let (rpc_handlers, telemetry_connection_notifier) =
|
||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
rpc_extensions_builder,
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
backend,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
config,
|
||||
})?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
prometheus_registry.as_ref(),
|
||||
@@ -204,7 +214,7 @@ pub fn new_full(
|
||||
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,
|
||||
@@ -213,7 +223,8 @@ pub fn new_full(
|
||||
network.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
force_authoring,
|
||||
keystore.clone(),
|
||||
backoff_authoring_blocks,
|
||||
keystore_container.sync_keystore(),
|
||||
can_author_with,
|
||||
)?;
|
||||
|
||||
@@ -227,7 +238,7 @@ pub fn new_full(
|
||||
// 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
|
||||
};
|
||||
@@ -252,8 +263,8 @@ pub fn new_full(
|
||||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
inherent_data_providers,
|
||||
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
|
||||
telemetry_on_connect: telemetry_connection_notifier
|
||||
.map(|x| x.on_connect_stream()),
|
||||
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
@@ -265,12 +276,6 @@ pub fn new_full(
|
||||
"grandpa-voter",
|
||||
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?,
|
||||
);
|
||||
} else {
|
||||
sc_finality_grandpa::setup_disabled_grandpa(
|
||||
client,
|
||||
&inherent_data_providers,
|
||||
network,
|
||||
)?;
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
@@ -279,11 +284,18 @@ pub fn new_full(
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(
|
||||
config: Configuration,
|
||||
mut config: Configuration,
|
||||
) -> Result<(TaskManager, RpcHandlers), 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)?;
|
||||
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.push(sc_finality_grandpa::grandpa_peers_set_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(),
|
||||
@@ -292,21 +304,21 @@ pub fn new_light(
|
||||
on_demand.clone(),
|
||||
));
|
||||
|
||||
let grandpa_block_import = sc_finality_grandpa::light_block_import(
|
||||
let (grandpa_block_import, _) = sc_finality_grandpa::block_import(
|
||||
client.clone(),
|
||||
backend.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
Arc::new(on_demand.checker().clone()) as Arc<_>,
|
||||
select_chain.clone(),
|
||||
)?;
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
grandpa_block_import.clone(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
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)),
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
InherentDataProviders::new(),
|
||||
&task_manager.spawn_handle(),
|
||||
@@ -314,9 +326,6 @@ pub fn new_light(
|
||||
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,
|
||||
@@ -326,8 +335,6 @@ pub fn new_light(
|
||||
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 {
|
||||
@@ -346,10 +353,9 @@ pub fn new_light(
|
||||
task_manager: &mut task_manager,
|
||||
on_demand: Some(on_demand),
|
||||
rpc_extensions_builder: Box::new(|_, _| ()),
|
||||
telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(),
|
||||
config,
|
||||
client,
|
||||
keystore,
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
backend,
|
||||
network,
|
||||
network_status_sinks,
|
||||
@@ -358,5 +364,5 @@ pub fn new_light(
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
Ok((task_manager, rpc_handlers))
|
||||
Ok((task_manager, rpc_handlers.0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user