Skip to content

Commit

Permalink
Upgrade polkadot-sdk to stable2409 (#1504)
Browse files Browse the repository at this point in the history
* Upgrade Polkadot to v1.16.0

* cargo fmt

* Remove duplicated attribute

* Fix clippy

* Update to polkadot-stable2409

* Use branch instead of tag
  • Loading branch information
keithtensor authored Oct 8, 2024
1 parent f35b0c7 commit aacf5a4
Show file tree
Hide file tree
Showing 21 changed files with 418 additions and 432 deletions.
560 changes: 275 additions & 285 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.

6 changes: 3 additions & 3 deletions client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ fn commitment_create() {

// Test client.
let (c, _) = TestClientBuilder::new().build_with_native_executor::<RuntimeApi, _>(None);
let mut client = Arc::new(c);
let client = Arc::new(c);

// Get some transaction status.
let t1 = fp_rpc::TransactionStatus::default();
Expand Down Expand Up @@ -612,7 +612,7 @@ fn commitment_update() {

// Test client.
let (c, _) = TestClientBuilder::new().build_with_native_executor::<RuntimeApi, _>(None);
let mut client = Arc::new(c);
let client = Arc::new(c);

// Get some transaction status.
let t1 = fp_rpc::TransactionStatus::default();
Expand Down Expand Up @@ -748,7 +748,7 @@ fn mapping_read_works() {

// Test client.
let (c, _) = TestClientBuilder::new().build_with_native_executor::<RuntimeApi, _>(None);
let mut client = Arc::new(c);
let client = Arc::new(c);

// Get some transaction status.
let t1 = fp_rpc::TransactionStatus::default();
Expand Down
4 changes: 0 additions & 4 deletions client/cli/src/frontier_db_cmd/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ pub trait FrontierDbMessage {
format!("Operation not allowed for non-empty Key `{:?}`", key).into()
}

fn one_to_many_error(&self) -> sc_cli::Error {
"One-to-many operation not allowed".into()
}

#[cfg(not(test))]
fn confirmation_prompt<K: core::fmt::Debug, V: core::fmt::Debug>(
&self,
Expand Down
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
2 changes: 1 addition & 1 deletion client/db/src/kv/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ mod tests {
.build_with_native_executor::<substrate_test_runtime_client::runtime::RuntimeApi, _>(
None,
);
let mut client = Arc::new(client);
let client = Arc::new(client);

// Genesis block
let chain_info = client.chain_info();
Expand Down
4 changes: 2 additions & 2 deletions client/mapping-sync/src/kv/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));

Expand Down Expand Up @@ -388,7 +388,7 @@ mod tests {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));

Expand Down
20 changes: 10 additions & 10 deletions client/mapping-sync/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ mod test {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
// Indexer backend
Expand Down Expand Up @@ -750,7 +750,7 @@ mod test {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
// Indexer backend
Expand Down Expand Up @@ -954,7 +954,7 @@ mod test {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
// Indexer backend
Expand Down Expand Up @@ -1120,7 +1120,7 @@ mod test {
// Client
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
// Overrides
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
// Indexer backend
Expand Down Expand Up @@ -1266,7 +1266,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
Expand Down Expand Up @@ -1367,7 +1367,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
Expand Down Expand Up @@ -1482,7 +1482,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
Expand Down Expand Up @@ -1583,7 +1583,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
Expand Down Expand Up @@ -1698,7 +1698,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
Expand Down Expand Up @@ -1799,7 +1799,7 @@ mod test {
let backend = builder.backend();
let (client, _) =
builder.build_with_native_executor::<frontier_template_runtime::RuntimeApi, _>(None);
let mut client = Arc::new(client);
let client = Arc::new(client);
let storage_override = Arc::new(SchemaV3StorageOverride::new(client.clone()));
let indexer_backend = fc_db::sql::Backend::new(
fc_db::sql::BackendConfig::Sqlite(fc_db::sql::SqliteBackendConfig {
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
10 changes: 5 additions & 5 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod frontier_backend_client {
}
}

pub async fn native_block_id<B: BlockT, C>(
pub async fn native_block_id<B, C>(
client: &C,
backend: &dyn fc_api::Backend<B>,
number: Option<BlockNumberOrHash>,
Expand Down Expand Up @@ -219,7 +219,7 @@ pub mod frontier_backend_client {
})
}

pub async fn load_hash<B: BlockT, C>(
pub async fn load_hash<B, C>(
client: &C,
backend: &dyn fc_api::Backend<B>,
hash: H256,
Expand All @@ -243,7 +243,7 @@ pub mod frontier_backend_client {
Ok(None)
}

pub fn is_canon<B: BlockT, C>(client: &C, target_hash: B::Hash) -> bool
pub fn is_canon<B, C>(client: &C, target_hash: B::Hash) -> bool
where
B: BlockT,
C: HeaderBackend<B> + 'static,
Expand All @@ -256,7 +256,7 @@ pub mod frontier_backend_client {
false
}

pub async fn load_transactions<B: BlockT, C>(
pub async fn load_transactions<B, C>(
client: &C,
backend: &dyn fc_api::Backend<B>,
transaction_hash: H256,
Expand Down Expand Up @@ -389,7 +389,7 @@ mod tests {
None,
);

let mut client = Arc::new(client);
let client = Arc::new(client);

// Create a temporary frontier secondary DB.
let backend = open_frontier_backend::<OpaqueBlock, _>(client.clone(), tmp.into_path())
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
3 changes: 0 additions & 3 deletions frame/evm/precompile/dispatch/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(test)]

use super::*;
use crate::mock::*;

Expand Down
3 changes: 0 additions & 3 deletions frame/evm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(feature = "runtime-benchmarks")]

use super::*;
use frame_benchmarking::benchmarks;

Expand Down
3 changes: 0 additions & 3 deletions frame/evm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(test)]

use super::*;
use crate::mock::*;

Expand Down
3 changes: 0 additions & 3 deletions frame/hotfix-sufficients/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(feature = "runtime-benchmarks")]

use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};

use super::*;
Expand Down
4 changes: 3 additions & 1 deletion precompiles/macro/src/precompile/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ pub mod keyword {
syn::custom_keyword!(pre_check);
}

/// Attributes for methods.
/// Attributes for methods
#[allow(dead_code)]
pub enum MethodAttr {
Public(Span, syn::LitStr),
Fallback(Span),
Expand Down Expand Up @@ -106,6 +107,7 @@ impl syn::parse::Parse for MethodAttr {
}

/// Attributes for the main impl Block.
#[allow(dead_code)]
pub enum ImplAttr {
PrecompileSet(Span),
TestConcreteTypes(Span, Vec<syn::Type>),
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
Loading

0 comments on commit aacf5a4

Please sign in to comment.