Skip to content

Commit

Permalink
Upgrade Polkadot to v1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
keithtensor committed Sep 16, 2024
1 parent 80c768f commit 075c51e
Show file tree
Hide file tree
Showing 10 changed files with 869 additions and 508 deletions.
1,155 changes: 753 additions & 402 deletions Cargo.lock

Large diffs are not rendered by default.

145 changes: 73 additions & 72 deletions Cargo.toml

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ where
self.inner.check_block(block).await.map_err(Into::into)
}

async fn import_block(
&mut self,
block: BlockImportParams<B>,
) -> Result<ImportResult, Self::Error> {
async fn import_block(&self, block: BlockImportParams<B>) -> Result<ImportResult, Self::Error> {
// We validate that there are only one frontier log. No other
// actions are needed and mapping syncing is delegated to a separate
// worker.
Expand Down
3 changes: 2 additions & 1 deletion client/rpc/src/eth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ where
let current_number = self.client.info().best_number;
let highest_number = self
.sync
.best_seen_block()
.status()
.await
.map_err(|_| internal_err("fetch best_seen_block failed"))?
.best_seen_block
.unwrap_or(current_number);

let current_number = UniqueSaturatedInto::<u128>::unique_saturated_into(current_number);
Expand Down
37 changes: 26 additions & 11 deletions client/rpc/src/eth_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ use sc_client_api::{
};
use sc_network_sync::SyncingService;
use sc_rpc::{
utils::{pipe_from_stream, to_sub_message},
utils::{BoundedVecDeque, PendingSubscription, Subscription},
SubscriptionTaskExecutor,
};
use sc_service::config::RpcSubscriptionIdProvider;
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool, TxHash};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
Expand All @@ -48,13 +49,14 @@ use fc_rpc_core::{
use fc_storage::StorageOverride;
use fp_rpc::EthereumRuntimeRPCApi;

#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct EthereumSubIdProvider;
impl IdProvider for EthereumSubIdProvider {
fn next_id(&self) -> jsonrpsee::types::SubscriptionId<'static> {
format!("0x{}", hex::encode(rand::random::<u128>().to_le_bytes())).into()
}
}
impl RpcSubscriptionIdProvider for EthereumSubIdProvider {}

/// Eth pub-sub API implementation.
pub struct EthPubSub<B: BlockT, P, C, BE> {
Expand Down Expand Up @@ -197,7 +199,12 @@ where
// Best imported block.
let current_number = self.client.info().best_number;
// Get the target block to sync.
let highest_number = self.sync.best_seen_block().await.ok().flatten();
let highest_number = self
.sync
.status()
.await
.ok()
.and_then(|status| status.best_seen_block);

PubSubSyncing::Syncing(SyncingStatus {
starting_block: self.starting_block,
Expand Down Expand Up @@ -238,22 +245,28 @@ where
Kind::NewHeads => {
let stream = block_notification_stream
.filter_map(move |notification| pubsub.notify_header(notification));
pipe_from_stream(pending, stream).await
PendingSubscription::from(pending)
.pipe_from_stream(stream, BoundedVecDeque::new(16))
.await
}
Kind::Logs => {
let stream = block_notification_stream
.filter_map(move |notification| {
pubsub.notify_logs(notification, &filtered_params)
})
.flat_map(futures::stream::iter);
pipe_from_stream(pending, stream).await
PendingSubscription::from(pending)
.pipe_from_stream(stream, BoundedVecDeque::new(16))
.await
}
Kind::NewPendingTransactions => {
let pool = pubsub.pool.clone();
let stream = pool
.import_notification_stream()
.filter_map(move |hash| pubsub.pending_transaction(&hash));
pipe_from_stream(pending, stream).await;
PendingSubscription::from(pending)
.pipe_from_stream(stream, BoundedVecDeque::new(16))
.await;
}
Kind::Syncing => {
let Ok(sink) = pending.accept().await else {
Expand All @@ -263,8 +276,10 @@ where
// Because import notifications are only emitted when the node is synced or
// in case of reorg, the first event is emitted right away.
let syncing_status = pubsub.syncing_status().await;
let msg = to_sub_message(&sink, &PubSubResult::SyncingStatus(syncing_status));
let _ = sink.send(msg).await;
let subscription = Subscription::from(sink);
let _ = subscription
.send(&PubSubResult::SyncingStatus(syncing_status))
.await;

// When the node is not under a major syncing (i.e. from genesis), react
// normally to import notifications.
Expand All @@ -276,9 +291,9 @@ where
let syncing_status = pubsub.sync.is_major_syncing();
if syncing_status != last_syncing_status {
let syncing_status = pubsub.syncing_status().await;
let msg =
to_sub_message(&sink, &PubSubResult::SyncingStatus(syncing_status));
let _ = sink.send(msg).await;
let _ = subscription
.send(&PubSubResult::SyncingStatus(syncing_status))
.await;
}
last_syncing_status = syncing_status;
}
Expand Down
1 change: 1 addition & 0 deletions frame/evm/precompile/bls12377/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ark-std = { workspace = true }

# Frontier
fp-evm = { workspace = true }
paste = "1.0.15"

[dev-dependencies]
# Frontier
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[toolchain]
# Stable
channel = "1.77.0" # rustc 1.77.0 (aedd173a2 2024-03-21)
channel = "1.79.0" # rustc 1.79.0 (129f3b996 2024-06-10)
# Nightly
#channel = "nightly-2024-02-05" # rustc 1.78.0-nightly (f067fd608 2024-02-05)
components = ["cargo", "clippy", "rustc", "rustfmt", "rust-src", "rust-docs"]
Expand Down
1 change: 1 addition & 0 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ futures = { workspace = true }
hex-literal = { workspace = true }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
log = { workspace = true }
quote = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
serde_json = { workspace = true, features = ["arbitrary_precision"] }

Expand Down
6 changes: 1 addition & 5 deletions template/node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use sc_client_api::{
};
use sc_consensus_manual_seal::rpc::EngineCommand;
use sc_rpc::SubscriptionTaskExecutor;
use sc_rpc_api::DenyUnsafe;
use sc_service::TransactionPool;
use sc_transaction_pool::ChainApi;
use sp_api::{CallApiAt, ProvideRuntimeApi};
Expand All @@ -32,8 +31,6 @@ pub struct FullDeps<B: BlockT, C, P, A: ChainApi, CT, CIDP> {
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// Manual seal command sink
pub command_sink: Option<mpsc::Sender<EngineCommand<Hash>>>,
/// Ethereum-compatibility specific dependencies.
Expand Down Expand Up @@ -88,12 +85,11 @@ where
let FullDeps {
client,
pool,
deny_unsafe,
command_sink,
eth,
} = deps;

io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
io.merge(System::new(client.clone(), pool).into_rpc())?;
io.merge(TransactionPayment::new(client).into_rpc())?;

if let Some(command_sink) = command_sink {
Expand Down
22 changes: 10 additions & 12 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sc_client_api::{Backend as BackendT, BlockBackend};
use sc_consensus::{BasicQueue, BoxBlockImport};
use sc_consensus_grandpa::BlockNumberOps;
use sc_executor::HostFunctions as HostFunctionsT;
use sc_network_sync::strategy::warp::{WarpSyncParams, WarpSyncProvider};
use sc_network_sync::strategy::warp::{WarpSyncConfig, WarpSyncProvider};
use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker};
use sc_transaction_pool::FullPool;
Expand Down Expand Up @@ -103,7 +103,7 @@ where
})
.transpose()?;

let executor = sc_service::new_wasm_executor(config);
let executor = sc_service::new_wasm_executor(&config.executor);

let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::<B, RA, _>(
config,
Expand Down Expand Up @@ -310,12 +310,11 @@ where
fee_history_cache_limit,
} = new_frontier_partial(&eth_config)?;

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

let grandpa_protocol_name = sc_consensus_grandpa::protocol_standard_name(
&client
Expand All @@ -331,7 +330,7 @@ where
peer_store_handle,
);

let warp_sync_params = if sealing.is_some() {
let warp_sync_config = if sealing.is_some() {
None
} else {
net_config.add_notification_protocol(grandpa_protocol_config);
Expand All @@ -341,7 +340,7 @@ where
grandpa_link.shared_authority_set().clone(),
Vec::new(),
));
Some(WarpSyncParams::WithProvider(warp_sync))
Some(WarpSyncConfig::WithProvider(warp_sync))
};

let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) =
Expand All @@ -353,7 +352,7 @@ where
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_params,
warp_sync_config,
block_relay: None,
metrics,
})?;
Expand Down Expand Up @@ -399,7 +398,7 @@ where
let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks);

// for ethereum-compatibility rpc.
config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));
config.rpc.id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider));

let rpc_builder = {
let client = client.clone();
Expand Down Expand Up @@ -438,7 +437,7 @@ where
Ok((slot, timestamp, dynamic_fee))
};

Box::new(move |deny_unsafe, subscription_task_executor| {
Box::new(move |subscription_task_executor| {
let eth_deps = crate::rpc::EthDeps {
client: client.clone(),
pool: pool.clone(),
Expand All @@ -465,7 +464,6 @@ where
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
deny_unsafe,
command_sink: if sealing.is_some() {
Some(command_sink.clone())
} else {
Expand Down

0 comments on commit 075c51e

Please sign in to comment.