Skip to content

Commit

Permalink
update substrate to polkadot-v0.9.39 (polkadot-evm#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Mar 7, 2023
1 parent 98aacf6 commit 58c5689
Show file tree
Hide file tree
Showing 22 changed files with 512 additions and 494 deletions.
646 changes: 342 additions & 304 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions client/cli/src/frontier_db_cmd/mapping_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use serde::Deserialize;
// Substrate
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
use sp_runtime::traits::Block as BlockT;
// Frontier
use fp_rpc::EthereumRuntimeRPCApi;

Expand Down Expand Up @@ -79,11 +79,10 @@ where
.block_hash(ethereum_block_hash)?
.is_none()
{
let id = BlockId::Hash(*substrate_block_hash);
let existing_transaction_hashes: Vec<H256> = if let Some(statuses) = self
.client
.runtime_api()
.current_transaction_statuses(&id)
.current_transaction_statuses(*substrate_block_hash)
.map_err(|e| format!("{:?}", e))?
{
statuses
Expand Down Expand Up @@ -138,11 +137,10 @@ where
.block_hash(ethereum_block_hash)?
.is_some()
{
let id = BlockId::Hash(*substrate_block_hash);
let existing_transaction_hashes: Vec<H256> = if let Some(statuses) = self
.client
.runtime_api()
.current_transaction_statuses(&id)
.current_transaction_statuses(*substrate_block_hash)
.map_err(|e| format!("{:?}", e))?
{
statuses
Expand Down
14 changes: 3 additions & 11 deletions client/cli/src/frontier_db_cmd/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sp_blockchain::HeaderBackend;
use sp_consensus::BlockOrigin;
use sp_io::hashing::twox_128;
use sp_runtime::{
generic::{Block, BlockId, Header},
generic::{Block, Header},
traits::{BlakeTwo256, Block as BlockT},
};
use substrate_test_runtime_client::{
Expand Down Expand Up @@ -626,11 +626,7 @@ fn commitment_update() {

// Build a block A1 and fill the pallet-ethereum status.
let mut builder = client
.new_block_at(
&BlockId::Hash(client.genesis_hash()),
Default::default(),
false,
)
.new_block_at(client.genesis_hash(), Default::default(), false)
.unwrap();
builder
.push_storage_change(key.clone(), Some(statuses_a1.encode()))
Expand Down Expand Up @@ -680,11 +676,7 @@ fn commitment_update() {
let tmp = tempdir().expect("create a temporary directory");

let mut builder = client
.new_block_at(
&BlockId::Hash(client.genesis_hash()),
Default::default(),
false,
)
.new_block_at(client.genesis_hash(), Default::default(), false)
.unwrap();
builder
.push_storage_change(key, Some(statuses_a2.encode()))
Expand Down
14 changes: 3 additions & 11 deletions client/db/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ mod tests {
use sp_blockchain::HeaderBackend;
use sp_core::H256;
use sp_runtime::{
generic::{Block, BlockId, Header},
generic::{Block, Header},
traits::{BlakeTwo256, Block as BlockT},
};
use tempfile::tempdir;
Expand Down Expand Up @@ -406,23 +406,15 @@ mod tests {
// Keep track of the canon hash to later verify the migration replaced it.
// A1
let mut builder = client
.new_block_at(
&BlockId::Hash(previous_canon_block_hash),
Default::default(),
false,
)
.new_block_at(previous_canon_block_hash, Default::default(), false)
.unwrap();
builder.push_storage_change(vec![1], None).unwrap();
let block = builder.build().unwrap().block;
let next_canon_block_hash = block.header.hash();
executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();
// A2
let mut builder = client
.new_block_at(
&BlockId::Hash(previous_canon_block_hash),
Default::default(),
false,
)
.new_block_at(previous_canon_block_hash, Default::default(), false)
.unwrap();
builder.push_storage_change(vec![2], None).unwrap();
let block = builder.build().unwrap().block;
Expand Down
19 changes: 8 additions & 11 deletions client/mapping-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ use std::sync::Arc;
use sc_client_api::backend::{Backend, StorageProvider};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::{Backend as _, HeaderBackend};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, Zero},
};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero};
// Frontier
use fc_storage::OverrideHandle;
use fp_consensus::{FindLogError, Hashes, Log, PostLog, PreLog};
Expand All @@ -44,7 +41,7 @@ pub fn sync_block<Block: BlockT, C, BE>(
header: &Block::Header,
) -> Result<(), String>
where
C: StorageProvider<Block, BE> + HeaderBackend<Block>,
C: HeaderBackend<Block> + StorageProvider<Block, BE>,
BE: Backend<Block>,
{
let substrate_block_hash = header.hash();
Expand Down Expand Up @@ -118,23 +115,23 @@ where
C: ProvideRuntimeApi<Block>,
C::Api: EthereumRuntimeRPCApi<Block>,
{
let id = BlockId::Hash(header.hash());
let substrate_block_hash = header.hash();

if let Some(api_version) = client
.runtime_api()
.api_version::<dyn EthereumRuntimeRPCApi<Block>>(&id)
.api_version::<dyn EthereumRuntimeRPCApi<Block>>(substrate_block_hash)
.map_err(|e| format!("{:?}", e))?
{
let block = if api_version > 1 {
client
.runtime_api()
.current_block(&id)
.current_block(substrate_block_hash)
.map_err(|e| format!("{:?}", e))?
} else {
#[allow(deprecated)]
let legacy_block = client
.runtime_api()
.current_block_before_version_2(&id)
.current_block_before_version_2(substrate_block_hash)
.map_err(|e| format!("{:?}", e))?;
legacy_block.map(|block| block.into())
};
Expand All @@ -143,13 +140,13 @@ where
.header
.hash();
let mapping_commitment = fc_db::MappingCommitment::<Block> {
block_hash: header.hash(),
block_hash: substrate_block_hash,
ethereum_block_hash: block_hash,
ethereum_transaction_hashes: Vec::new(),
};
backend.mapping().write_hashes(mapping_commitment)?;
} else {
backend.mapping().write_none(header.hash())?;
backend.mapping().write_none(substrate_block_hash)?;
};

Ok(())
Expand Down
11 changes: 7 additions & 4 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use sc_transaction_pool::ChainApi;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::hashing::keccak_256;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
use sp_runtime::traits::Block as BlockT;
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::EthereumRuntimeRPCApi;
Expand Down Expand Up @@ -70,13 +70,13 @@ where

let base_fee = client
.runtime_api()
.gas_price(&BlockId::Hash(substrate_hash))
.gas_price(substrate_hash)
.unwrap_or_default();

match (block, statuses) {
(Some(block), Some(statuses)) => Ok(Some(rich_block_build(
block,
statuses.into_iter().map(Option::Some).collect(),
statuses.into_iter().map(Some).collect(),
Some(hash),
full,
Some(base_fee),
Expand Down Expand Up @@ -113,7 +113,10 @@ where
.current_transaction_statuses(schema, substrate_hash)
.await;

let base_fee = client.runtime_api().gas_price(&id).unwrap_or_default();
let base_fee = client
.runtime_api()
.gas_price(substrate_hash)
.unwrap_or_default();

match (block, statuses) {
(Some(block), Some(statuses)) => {
Expand Down
7 changes: 2 additions & 5 deletions client/rpc/src/eth/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ use sc_client_api::{
use sc_service::SpawnTaskHandle;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, UniqueSaturatedInto},
};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, UniqueSaturatedInto};
// Frontier
use fc_rpc_core::types::*;
use fc_storage::{OverrideHandle, StorageOverride};
Expand Down Expand Up @@ -339,7 +336,7 @@ where

let block = handler.current_block(hash);
let mut block_number: Option<u64> = None;
let base_fee = client.runtime_api().gas_price(&BlockId::Hash(hash)).unwrap_or_default();
let base_fee = client.runtime_api().gas_price(hash).unwrap_or_default();
let receipts = handler.current_receipts(hash);
let mut result = FeeHistoryCacheItem {
base_fee: if base_fee > U256::from(u64::MAX) { u64::MAX } else { base_fee.low_u64() },
Expand Down
7 changes: 2 additions & 5 deletions client/rpc/src/eth/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ use sc_transaction_pool::ChainApi;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, UniqueSaturatedInto},
};
use sp_runtime::traits::{Block as BlockT, UniqueSaturatedInto};
// Frontier
use fc_rpc_core::types::*;
use fp_rpc::EthereumRuntimeRPCApi;
Expand Down Expand Up @@ -101,7 +98,7 @@ where
Ok(Some(
self.client
.runtime_api()
.chain_id(&BlockId::Hash(hash))
.chain_id(hash)
.map_err(|err| internal_err(format!("fetch runtime chain id failed: {:?}", err)))?
.into(),
))
Expand Down

0 comments on commit 58c5689

Please sign in to comment.