Skip to content

Commit

Permalink
deps: update substrate to release-polkadot-v1.11.0 (#1430)
Browse files Browse the repository at this point in the history
* runtime part

* client changes

* allow unsafe node key generation

* fmt cargo

* prettier

* remove unused dep

* deprecated currencyAdapter

* fmt

* remove sp-std
  • Loading branch information
girazoki authored May 20, 2024
1 parent 6250ae7 commit b2b0083
Show file tree
Hide file tree
Showing 9 changed files with 937 additions and 437 deletions.
1,151 changes: 817 additions & 334 deletions Cargo.lock

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ prometheus-endpoint = { workspace = true }
sc-client-api = { workspace = true }
sc-consensus-aura = { workspace = true }
sc-network = { workspace = true }
sc-network-common = { workspace = true }
sc-network-sync = { workspace = true }
sc-rpc = { workspace = true }
sc-service = { workspace = true }
Expand Down
20 changes: 8 additions & 12 deletions client/rpc/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use std::sync::Arc;

use jsonrpsee::core::RpcResult;
// Substrate
use sc_network::{NetworkPeers, NetworkService};
use sc_network_common::ExHashT;
use sc_network::{service::traits::NetworkService, NetworkPeers};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block as BlockT;
Expand All @@ -32,27 +31,24 @@ use fp_rpc::EthereumRuntimeRPCApi;
use crate::internal_err;

/// Net API implementation.
pub struct Net<B: BlockT, C, H: ExHashT> {
pub struct Net<B: BlockT, C> {
client: Arc<C>,
network: Arc<NetworkService<B, H>>,
network: Arc<dyn NetworkService>,
peer_count_as_hex: bool,
_phantom_data: std::marker::PhantomData<B>,
}

impl<B: BlockT, C, H: ExHashT> Net<B, C, H> {
pub fn new(
client: Arc<C>,
network: Arc<NetworkService<B, H>>,
peer_count_as_hex: bool,
) -> Self {
impl<B: BlockT, C> Net<B, C> {
pub fn new(client: Arc<C>, network: Arc<dyn NetworkService>, peer_count_as_hex: bool) -> Self {
Self {
client,
network,
peer_count_as_hex,
_phantom_data: Default::default(),
}
}
}

impl<B, C, H: ExHashT> NetApiServer for Net<B, C, H>
impl<B, C> NetApiServer for Net<B, C>
where
B: BlockT,
C: ProvideRuntimeApi<B>,
Expand Down
5 changes: 2 additions & 3 deletions template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ pub fn run() -> sc_cli::Result<()> {

let runner = cli.create_runner(cmd)?;
match cmd {
BenchmarkCmd::Pallet(cmd) => {
runner.sync_run(|config| cmd.run::<Hashing, ()>(config))
}
BenchmarkCmd::Pallet(cmd) => runner
.sync_run(|config| cmd.run_with_spec::<Hashing, ()>(Some(config.chain_spec))),
BenchmarkCmd::Block(cmd) => runner.sync_run(|mut config| {
let (client, _, _, _, _) = service::new_chain_ops(&mut config, &cli.eth)?;
cmd.run(client)
Expand Down
4 changes: 2 additions & 2 deletions template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sc_client_api::{
client::BlockchainEvents,
AuxStore, UsageProvider,
};
use sc_network::NetworkService;
use sc_network::service::traits::NetworkService;
use sc_network_sync::SyncingService;
use sc_rpc::SubscriptionTaskExecutor;
use sc_transaction_pool::{ChainApi, Pool};
Expand Down Expand Up @@ -40,7 +40,7 @@ pub struct EthDeps<B: BlockT, C, P, A: ChainApi, CT, CIDP> {
/// Whether to enable dev signer
pub enable_dev_signer: bool,
/// Network service
pub network: Arc<NetworkService<B, B::Hash>>,
pub network: Arc<dyn NetworkService>,
/// Chain syncing service
pub sync: Arc<SyncingService<B>>,
/// Frontier Backend.
Expand Down
31 changes: 24 additions & 7 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ConstructRuntimeApi;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_core::U256;
use sp_runtime::traits::Block as BlockT;

// Runtime
use frontier_template_runtime::{opaque::Block, Hash, TransactionConverter};

Expand Down Expand Up @@ -258,7 +260,7 @@ where
}

/// Builds a new service for a full client.
pub async fn new_full<RuntimeApi, Executor>(
pub async fn new_full<RuntimeApi, Executor, N>(
mut config: Configuration,
eth_config: EthConfiguration,
sealing: Option<Sealing>,
Expand All @@ -268,6 +270,7 @@ where
RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi: RuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static,
N: sc_network::NetworkBackend<Block, <Block as BlockT>::Hash>,
{
let build_import_queue = if sealing.is_some() {
build_manual_seal_import_queue::<RuntimeApi, Executor>
Expand All @@ -292,13 +295,24 @@ where
fee_history_cache_limit,
} = new_frontier_partial(&eth_config)?;

let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
let mut net_config =
sc_network::config::FullNetworkConfiguration::<_, _, N>::new(&config.network);
let peer_store_handle = net_config.peer_store_handle();
let metrics = N::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
);

let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
&client.block_hash(0)?.expect("Genesis block exists; qed"),
&config.chain_spec,
);

let (grandpa_protocol_config, grandpa_notification_service) =
sc_consensus_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone());
sc_consensus_grandpa::grandpa_peers_set_config::<_, N>(
grandpa_protocol_name.clone(),
metrics.clone(),
peer_store_handle,
);

let warp_sync_params = if sealing.is_some() {
None
Expand All @@ -324,6 +338,7 @@ where
block_announce_validator_builder: None,
warp_sync_params,
block_relay: None,
metrics,
})?;

if config.offchain_worker.enabled {
Expand All @@ -338,7 +353,7 @@ where
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
network_provider: Arc::new(network.clone()),
enable_http_requests: true,
custom_extensions: |_| vec![],
})
Expand Down Expand Up @@ -697,9 +712,11 @@ pub async fn build_full(
eth_config: EthConfiguration,
sealing: Option<Sealing>,
) -> Result<TaskManager, ServiceError> {
new_full::<frontier_template_runtime::RuntimeApi, TemplateRuntimeExecutor>(
config, eth_config, sealing,
)
new_full::<
frontier_template_runtime::RuntimeApi,
TemplateRuntimeExecutor,
sc_network::NetworkWorker<_, _>,
>(config, eth_config, sealing)
.await
}

Expand Down
21 changes: 13 additions & 8 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate alloc;
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use alloc::{boxed::Box, vec::Vec};
use alloc::{boxed::Box, vec, vec::Vec};
use core::marker::PhantomData;
use scale_codec::{Decode, Encode};
use sp_api::impl_runtime_apis;
Expand All @@ -39,12 +39,13 @@ use frame_support::weights::constants::ParityDbWeight as RuntimeDbWeight;
use frame_support::weights::constants::RocksDbWeight as RuntimeDbWeight;
use frame_support::{
derive_impl,
genesis_builder_helper::{build_config, create_default_config},
genesis_builder_helper::{build_state, get_preset},
parameter_types,
traits::{ConstBool, ConstU32, ConstU64, ConstU8, FindAuthor, OnFinalize, OnTimestampSet},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, IdentityFee, Weight},
};
use pallet_transaction_payment::{ConstFeeMultiplier, CurrencyAdapter};
use pallet_transaction_payment::{ConstFeeMultiplier, FungibleAdapter};
use sp_genesis_builder::PresetId;
// Frontier
use fp_account::EthereumSignature;
use fp_evm::weight_per_gas;
Expand Down Expand Up @@ -305,7 +306,7 @@ parameter_types! {

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type OnChargeTransaction = FungibleAdapter<Balances, ()>;
type WeightToFee = IdentityFee<Balance>;
type LengthToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ConstFeeMultiplier<FeeMultiplier>;
Expand Down Expand Up @@ -656,12 +657,16 @@ impl_runtime_apis! {
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn create_default_config() -> Vec<u8> {
create_default_config::<RuntimeGenesisConfig>()
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn build_config(config: Vec<u8>) -> sp_genesis_builder::Result {
build_config::<RuntimeGenesisConfig>(config)
fn get_preset(id: &Option<PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
vec![]
}
}

Expand Down
1 change: 1 addition & 0 deletions ts-tests/tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export async function startFrontierNode(provider?: string): Promise<{
`--rpc-port=${RPC_PORT}`,
`--frontier-backend-type=${FRONTIER_BACKEND_TYPE}`,
`--tmp`,
`--unsafe-force-node-key-generation`,
];
const binary = spawn(cmd, args);

Expand Down

0 comments on commit b2b0083

Please sign in to comment.