Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
800 changes: 535 additions & 265 deletions Cargo.lock

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions Cargo.toml

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<Block: BlockT, I: Clone + BlockImport<Block>, C> Clone for FrontierBlockImp
impl<B, I, C> FrontierBlockImport<B, I, C>
where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>>,
I: BlockImport<B>,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B>,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
Expand All @@ -98,13 +98,12 @@ where
impl<B, I, C> BlockImport<B> for FrontierBlockImport<B, I, C>
where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
I: BlockImport<B> + Send + Sync,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B> + Send + Sync,
C::Api: BlockBuilderApi<B> + EthereumRuntimeRPCApi<B>,
{
type Error = ConsensusError;
type Transaction = sp_api::TransactionFor<C, B>;

async fn check_block(
&mut self,
Expand All @@ -115,7 +114,7 @@ where

async fn import_block(
&mut self,
block: BlockImportParams<B, Self::Transaction>,
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
Expand Down
16 changes: 7 additions & 9 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ use scale_codec::{Decode, Encode};
// Substrate
use sc_client_api::backend::{Backend, StorageProvider};
use sc_transaction_pool::ChainApi;
use sp_api::{
ApiExt, CallApiAt, CallApiAtParams, CallContext, Extensions, ProvideRuntimeApi,
StorageTransactionCache,
};
use sp_api::{ApiExt, CallApiAt, CallApiAtParams, Extensions, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::HeaderBackend;
use sp_core::traits::CallContext;
use sp_inherents::CreateInherentDataProviders;
use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{traits::Block as BlockT, DispatchError, SaturatedConversion};
use sp_runtime::{
traits::{Block as BlockT, HashingFor},
DispatchError, SaturatedConversion,
};
use sp_state_machine::OverlayedChanges;
// Frontier
use fc_rpc_core::types::*;
Expand Down Expand Up @@ -241,14 +242,11 @@ where
api_version,
state_overrides,
)?;
let storage_transaction_cache =
RefCell::<StorageTransactionCache<B, C::StateBackend>>::default();
let params = CallApiAtParams {
at: substrate_hash,
function: "EthereumRuntimeRPCApi_call",
arguments: encoded_params,
overlayed_changes: &RefCell::new(overlayed_changes),
storage_transaction_cache: &storage_transaction_cache,
call_context: CallContext::Offchain,
recorder: &None,
extensions: &RefCell::new(Extensions::new()),
Expand Down Expand Up @@ -888,7 +886,7 @@ where
block_hash: B::Hash,
api_version: u32,
state_overrides: Option<BTreeMap<H160, CallStateOverride>>,
) -> RpcResult<OverlayedChanges> {
) -> RpcResult<OverlayedChanges<HashingFor<B>>> {
let mut overlayed_changes = OverlayedChanges::default();
if let Some(state_overrides) = state_overrides {
for (address, state_override) in state_overrides {
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub mod frontier_backend_client {
use sp_io::hashing::{blake2_128, twox_128};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, UniqueSaturatedInto, Zero},
traits::{Block as BlockT, HashingFor, UniqueSaturatedInto, Zero},
};
use sp_state_machine::OverlayedChanges;
// Frontier
Expand All @@ -95,7 +95,7 @@ pub mod frontier_backend_client {

fn set_overlayed_changes(
client: &C,
overlayed_changes: &mut OverlayedChanges,
overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
block: B::Hash,
_version: u32,
address: H160,
Expand Down Expand Up @@ -148,7 +148,7 @@ pub mod frontier_backend_client {

fn set_overlayed_changes(
client: &C,
overlayed_changes: &mut OverlayedChanges,
overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
block: B::Hash,
_version: u32,
address: H160,
Expand Down
2 changes: 2 additions & 0 deletions frame/dynamic-fee/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub mod pallet {
pub _marker: PhantomData<T>,
}

// TODO: Just for following macro
use sp_runtime as _;
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Expand Down
4 changes: 2 additions & 2 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ use fp_evm::{
};
use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA};
use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchErrorWithPostInfo, DispatchInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo,
},
scale_info::TypeInfo,
traits::{EnsureOrigin, Get, PalletInfoAccess, Time},
weights::Weight,
};
use frame_system::{pallet_prelude::OriginFor, CheckWeight, WeightInfo};
use pallet_evm::{BlockHashMapping, FeeCalculator, GasWeightMapping, Runner};
use scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{
generic::DigestItem,
traits::{DispatchInfoOf, Dispatchable, One, Saturating, UniqueSaturatedInto, Zero},
Expand Down
3 changes: 1 addition & 2 deletions frame/ethereum/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use ethereum::{TransactionAction, TransactionSignature};
use frame_support::{
dispatch::Dispatchable,
parameter_types,
traits::{ConstU32, FindAuthor},
weights::Weight,
Expand All @@ -29,7 +28,7 @@ use pallet_evm::{AddressMapping, EnsureAddressTruncated, FeeCalculator};
use rlp::RlpStream;
use sp_core::{hashing::keccak_256, H160, H256, U256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
traits::{BlakeTwo256, Dispatchable, IdentityLookup},
AccountId32, BuildStorage,
};

Expand Down
2 changes: 2 additions & 0 deletions frame/evm-chain-id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub mod pallet {
pub _marker: PhantomData<T>,
}

// TODO: Just for following macro
use sp_runtime as _;
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Expand Down
3 changes: 2 additions & 1 deletion frame/evm/precompile/dispatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ edition = { workspace = true }
repository = { workspace = true }

[dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
# Substrate
frame-support = { workspace = true }
sp-runtime = { workspace = true }
# Frontier
fp-evm = { workspace = true }
pallet-evm = { workspace = true }

[dev-dependencies]
scale-codec = { package = "parity-scale-codec", workspace = true }
scale-info = { workspace = true }
# Substrate
frame-system = { workspace = true, features = ["default"] }
Expand Down
5 changes: 3 additions & 2 deletions frame/evm/precompile/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ use fp_evm::{
PrecompileResult,
};
use frame_support::{
codec::{Decode, DecodeLimit as _},
dispatch::{DispatchClass, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo},
dispatch::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo},
traits::{ConstU32, Get},
};
use pallet_evm::{AddressMapping, GasWeightMapping};
use scale_codec::{Decode, DecodeLimit as _};
use sp_runtime::traits::Dispatchable;

// `DecodeLimit` specifies the max depth a call can use when decoding, as unbounded depth
// can be used to overflow the stack.
Expand Down
2 changes: 1 addition & 1 deletion frame/evm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ benchmarks! {

let x in 1..10000000;

use frame_benchmarking::vec;
use sp_std::vec;
use rlp::RlpStream;
use sp_core::{H160, U256};

Expand Down
3 changes: 2 additions & 1 deletion frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ pub use evm::{
Config as EvmConfig, Context, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed,
};
use impl_trait_for_tuples::impl_for_tuples;
use scale_codec::MaxEncodedLen;
use scale_info::TypeInfo;
// Substrate
use frame_support::{
dispatch::{DispatchResultWithPostInfo, MaxEncodedLen, Pays, PostDispatchInfo},
dispatch::{DispatchResultWithPostInfo, Pays, PostDispatchInfo},
traits::{
tokens::{
currency::Currency,
Expand Down
3 changes: 2 additions & 1 deletion precompiles/src/substrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ use crate::{evm::handle::using_precompile_handle, solidity::revert::revert};
use core::marker::PhantomData;
use fp_evm::{ExitError, PrecompileFailure, PrecompileHandle};
use frame_support::{
dispatch::{Dispatchable, GetDispatchInfo, PostDispatchInfo},
dispatch::{GetDispatchInfo, PostDispatchInfo},
pallet_prelude::*,
traits::Get,
};
use pallet_evm::GasWeightMapping;
use sp_runtime::traits::Dispatchable;

#[derive(Debug)]
pub enum TryDispatchError {
Expand Down
9 changes: 6 additions & 3 deletions primitives/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ use scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
// Substrate
use sp_core::{H160, H256, U256};
use sp_runtime::{traits::Block as BlockT, Permill, RuntimeDebug};
use sp_runtime::{
traits::{Block as BlockT, HashingFor},
Permill, RuntimeDebug,
};
use sp_state_machine::OverlayedChanges;
use sp_std::vec::Vec;

Expand All @@ -51,7 +54,7 @@ pub trait RuntimeStorageOverride<B: BlockT, C>: Send + Sync {

fn set_overlayed_changes(
client: &C,
overlayed_changes: &mut OverlayedChanges,
overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
block: B::Hash,
version: u32,
address: H160,
Expand All @@ -69,7 +72,7 @@ impl<B: BlockT, C> RuntimeStorageOverride<B, C> for () {

fn set_overlayed_changes(
_client: &C,
_overlayed_changes: &mut OverlayedChanges,
_overlayed_changes: &mut OverlayedChanges<HashingFor<B>>,
_block: B::Hash,
_version: u32,
_address: H160,
Expand Down
2 changes: 0 additions & 2 deletions template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ sc-consensus-grandpa = { workspace = true }
sc-consensus-manual-seal = { workspace = true }
sc-executor = { workspace = true }
sc-network = { workspace = true }
sc-network-common = { workspace = true }
sc-network-sync = { workspace = true }
sc-offchain = { workspace = true }
sc-rpc = { workspace = true }
Expand All @@ -56,7 +55,6 @@ sp-session = { workspace = true, features = ["default"] }
sp-state-machine = { workspace = true, features = ["default"] }
sp-timestamp = { workspace = true, features = ["default"] }
sp-transaction-pool = { workspace = true, features = ["default"] }
sp-trie = { workspace = true, features = ["default"] }
# These dependencies are used for RPC
frame-system-rpc-runtime-api = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
Expand Down
17 changes: 4 additions & 13 deletions template/node/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Substrate
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_runtime::traits::BlakeTwo256;
// Local
use frontier_template_runtime::{opaque::Block, AccountId, Balance, Nonce};

Expand Down Expand Up @@ -43,20 +42,16 @@ pub trait BaseRuntimeApiCollection:
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}

impl<Api> BaseRuntimeApiCollection for Api
where
impl<Api> BaseRuntimeApiCollection for Api where
Api: sp_api::ApiExt<Block>
+ sp_api::Metadata<Block>
+ sp_block_builder::BlockBuilder<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_session::SessionKeys<Block>
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
+ sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
{
}

Expand All @@ -68,19 +63,15 @@ pub trait RuntimeApiCollection:
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}

impl<Api> RuntimeApiCollection for Api
where
impl<Api> RuntimeApiCollection for Api where
Api: BaseRuntimeApiCollection
+ EthCompatRuntimeApiCollection
+ sp_consensus_aura::AuraApi<Block, AuraId>
+ sp_consensus_grandpa::GrandpaApi<Block>
+ frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
+ pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance>
{
}
14 changes: 4 additions & 10 deletions template/node/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use std::{

use futures::{future, prelude::*};
// Substrate
use sc_client_api::{BlockchainEvents, StateBackendFor};
use sc_client_api::BlockchainEvents;
use sc_executor::NativeExecutionDispatch;
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sp_api::ConstructRuntimeApi;
use sp_runtime::traits::BlakeTwo256;
// Frontier
pub use fc_consensus::FrontierBlockImport;
use fc_rpc::{EthTask, OverrideHandle};
Expand Down Expand Up @@ -113,17 +112,13 @@ pub trait EthCompatRuntimeApiCollection:
sp_api::ApiExt<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
where
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
}

impl<Api> EthCompatRuntimeApiCollection for Api
where
impl<Api> EthCompatRuntimeApiCollection for Api where
Api: sp_api::ApiExt<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>,
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
+ fp_rpc::EthereumRuntimeRPCApi<Block>
{
}

Expand All @@ -145,8 +140,7 @@ pub async fn spawn_frontier_tasks<RuntimeApi, Executor>(
) where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>>,
RuntimeApi: Send + Sync + 'static,
RuntimeApi::RuntimeApi:
EthCompatRuntimeApiCollection<StateBackend = StateBackendFor<FullBackend, Block>>,
RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection,
Executor: NativeExecutionDispatch + 'static,
{
// Spawn main mapping sync worker background task.
Expand Down
Loading