Skip to content

Commit

Permalink
deps: update substrate to polkadot-v1.4.0 (polkadot-evm#1271)
Browse files Browse the repository at this point in the history
* deps: update substrate to polkadot-sdk#8b061a5c5d29a4ef8efa0f2919fdc5c3cfc36361

* some trivials

* adjust the log level of pending runtime api

* deps: update substrate to polkadot-v1.3.0

* fix mock

* use release-polkadot-v1.3.0 branch and remove version field

* update some deps

* deps: update substrate to polkadot-v1.4.0

* fix toml fmt

---------

Co-authored-by: Wei Tang <wei@pacna.org>
  • Loading branch information
koushiro and sorpaas authored Jan 14, 2024
1 parent e262e80 commit c33caba
Show file tree
Hide file tree
Showing 13 changed files with 1,049 additions and 712 deletions.
892 changes: 592 additions & 300 deletions Cargo.lock

Large diffs are not rendered by default.

144 changes: 71 additions & 73 deletions Cargo.toml

Large diffs are not rendered by default.

28 changes: 21 additions & 7 deletions client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use scale_codec::Encode;
use serde::Serialize;
use tempfile::tempdir;
// Substrate
use sc_block_builder::BlockBuilderProvider;
use sc_block_builder::BlockBuilderBuilder;
use sc_cli::DatabasePruningMode;
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
Expand Down Expand Up @@ -546,7 +546,12 @@ fn commitment_create() {

// Build a block and fill the pallet-ethereum status.
let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS);
let mut builder = client.new_block(Default::default()).unwrap();
let chain = client.chain_info();
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain.best_hash)
.with_parent_block_number(chain.best_number)
.build()
.unwrap();
builder
.push_storage_change(key, Some(statuses.encode()))
.unwrap();
Expand Down Expand Up @@ -628,8 +633,10 @@ fn commitment_update() {
// First we create block and insert data in the offchain db.

// Build a block A1 and fill the pallet-ethereum status.
let mut builder = client
.new_block_at(client.genesis_hash(), Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(client.genesis_hash())
.with_parent_block_number(0)
.build()
.unwrap();
builder
.push_storage_change(key.clone(), Some(statuses_a1.encode()))
Expand Down Expand Up @@ -678,8 +685,10 @@ fn commitment_update() {
// Build a block A2 and fill the pallet-ethereum status.
let tmp = tempdir().expect("create a temporary directory");

let mut builder = client
.new_block_at(client.genesis_hash(), Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(client.genesis_hash())
.with_parent_block_number(0)
.build()
.unwrap();
builder
.push_storage_change(key, Some(statuses_a2.encode()))
Expand Down Expand Up @@ -748,7 +757,12 @@ fn mapping_read_works() {

// Build a block and fill the pallet-ethereum status.
let key = storage_prefix_build(PALLET_ETHEREUM, ETHEREUM_CURRENT_TRANSACTION_STATUS);
let mut builder = client.new_block(Default::default()).unwrap();
let chain = client.chain_info();
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain.best_hash)
.with_parent_block_number(chain.best_number)
.build()
.unwrap();
builder
.push_storage_change(key, Some(statuses.encode()))
.unwrap();
Expand Down
26 changes: 19 additions & 7 deletions client/db/src/kv/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ mod tests {
use scale_codec::Encode;
use tempfile::tempdir;
// Substrate
use sc_block_builder::BlockBuilderProvider;
use sc_block_builder::BlockBuilderBuilder;
use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
use sp_core::H256;
use sp_runtime::{
generic::{Block, Header},
traits::{BlakeTwo256, Block as BlockT},
traits::{BlakeTwo256, Block as BlockT, Header as HeaderT},
};
use substrate_test_runtime_client::{
prelude::*, DefaultTestClientBuilderExt, TestClientBuilder,
Expand Down Expand Up @@ -386,10 +386,16 @@ mod tests {
let mut client = Arc::new(client);

// Genesis block
let mut builder = client.new_block(Default::default()).unwrap();
let chain_info = client.chain_info();
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain_info.best_hash)
.with_parent_block_number(chain_info.best_number)
.build()
.unwrap();
builder.push_storage_change(vec![1], None).unwrap();
let block = builder.build().unwrap().block;
let mut previous_canon_block_hash = block.header.hash();
let mut previous_canon_block_number = *block.header.number();
executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();

let path = setting.source.path().unwrap();
Expand All @@ -410,16 +416,21 @@ mod tests {
// Create two branches, and map the orphan one.
// Keep track of the canon hash to later verify the migration replaced it.
// A1
let mut builder = client
.new_block_at(previous_canon_block_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(previous_canon_block_hash)
.with_parent_block_number(previous_canon_block_number)
.build()
.unwrap();
builder.push_storage_change(vec![1], None).unwrap();
let block = builder.build().unwrap().block;
let next_canon_block_hash = block.header.hash();
let next_canon_block_number = *block.header.number();
executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();
// A2
let mut builder = client
.new_block_at(previous_canon_block_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(previous_canon_block_hash)
.with_parent_block_number(previous_canon_block_number)
.build()
.unwrap();
builder.push_storage_change(vec![2], None).unwrap();
let block = builder.build().unwrap().block;
Expand Down Expand Up @@ -454,6 +465,7 @@ mod tests {
);
transaction_hashes.push(eth_tx_hash);
previous_canon_block_hash = next_canon_block_hash;
previous_canon_block_number = next_canon_block_number;
}
let _ = backend.mapping().db.commit(transaction);
}
Expand Down
26 changes: 22 additions & 4 deletions client/mapping-sync/src/kv/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ mod tests {
use crate::{EthereumBlockNotification, EthereumBlockNotificationSinks};
use fc_storage::{OverrideHandle, SchemaV3Override, StorageOverride};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use sc_block_builder::BlockBuilderProvider;
use sc_block_builder::BlockBuilderBuilder;
use sc_client_api::BlockchainEvents;
use sp_api::Encode;
use sp_consensus::BlockOrigin;
Expand Down Expand Up @@ -313,7 +313,13 @@ mod tests {
}

// Let's produce a block, which we expect to trigger a channel message
let builder = client.new_block(ethereum_digest()).unwrap();
let chain_info = client.chain_info();
let builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain_info.best_hash)
.with_parent_block_number(chain_info.best_number)
.with_inherent_digests(ethereum_digest())
.build()
.unwrap();
let block = builder.build().unwrap().block;
let block_hash = block.header.hash();
let _res = client.import(BlockOrigin::Own, block).await;
Expand Down Expand Up @@ -350,7 +356,13 @@ mod tests {

// Let's produce another block, this not only triggers a message in the new channel
// but also removes the closed channels from the pool.
let builder = client.new_block(ethereum_digest()).unwrap();
let chain_info = client.chain_info();
let builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain_info.best_hash)
.with_parent_block_number(chain_info.best_number)
.with_inherent_digests(ethereum_digest())
.build()
.unwrap();
let block = builder.build().unwrap().block;
let block_hash = block.header.hash();
let _res = client.import(BlockOrigin::Own, block).await;
Expand Down Expand Up @@ -451,7 +463,13 @@ mod tests {
}

// Let's produce a block, which we expect to trigger a channel message
let builder = client.new_block(ethereum_digest()).unwrap();
let chain_info = client.chain_info();
let builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain_info.best_hash)
.with_parent_block_number(chain_info.best_number)
.with_inherent_digests(ethereum_digest())
.build()
.unwrap();
let block = builder.build().unwrap().block;
let _res = client.import(BlockOrigin::Own, block).await;

Expand Down
93 changes: 68 additions & 25 deletions client/mapping-sync/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ mod test {
use sqlx::Row;
use tempfile::tempdir;
// Substrate
use sc_block_builder::BlockBuilderProvider;
use sc_block_builder::BlockBuilderBuilder;
use sc_client_api::{BlockchainEvents, HeaderBackend};
use sp_consensus::BlockOrigin;
use sp_core::{H160, H256, U256};
Expand Down Expand Up @@ -593,7 +593,12 @@ mod test {
let mut logs: Vec<(i32, fc_db::sql::Log)> = vec![];
for block_number in 1..11 {
// New block including pallet ethereum block digest
let mut builder = client.new_block(Default::default()).unwrap();
let chain = client.chain_info();
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain.best_hash)
.with_parent_block_number(chain.best_number)
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
.expect("deposit log");
Expand Down Expand Up @@ -829,7 +834,12 @@ mod test {
let mut logs: Vec<(i32, fc_db::sql::Log)> = vec![];
for block_number in 1..11 {
// New block including pallet ethereum block digest
let mut builder = client.new_block(Default::default()).unwrap();
let chain = client.chain_info();
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(chain.best_hash)
.with_parent_block_number(chain.best_number)
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
.expect("deposit log");
Expand Down Expand Up @@ -1040,8 +1050,11 @@ mod test {
let mut hashes_to_be_orphaned: Vec<H256> = vec![];
for block_number in 1..11 {
// New block including pallet ethereum block digest
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1077,8 +1090,11 @@ mod test {
parent_hash = common_ancestor;
for _ in 1..11 {
// New block including pallet ethereum block digest
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1178,8 +1194,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=5 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1355,8 +1374,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1461,8 +1483,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand All @@ -1476,8 +1501,11 @@ mod test {
}

// create non-best block
let mut builder = client
.new_block_at(best_block_hashes[0], Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(best_block_hashes[0])
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1578,8 +1606,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1684,8 +1715,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand All @@ -1699,8 +1733,11 @@ mod test {
}

// create non-best block
let mut builder = client
.new_block_at(best_block_hashes[0], Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(best_block_hashes[0])
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1801,8 +1838,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down Expand Up @@ -1907,8 +1947,11 @@ mod test {
.expect("genesis hash");
let mut best_block_hashes: Vec<H256> = vec![];
for _block_number in 1..=3 {
let mut builder = client
.new_block_at(parent_hash, Default::default(), false)
let mut builder = BlockBuilderBuilder::new(&*client)
.on_parent_block(parent_hash)
.fetch_parent_block_number(&*client)
.unwrap()
.build()
.unwrap();
builder
.push_deposit_log_digest_item(ethereum_digest())
Expand Down
Loading

0 comments on commit c33caba

Please sign in to comment.