Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Guantong committed Mar 28, 2023
1 parent cca2fbf commit a00cd34
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 123 deletions.
98 changes: 59 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

57 changes: 28 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,30 @@ pallet-bridge-parachains = { default-features = false, git = "https://github.com
pallet-fee-market = { default-features = false, git = "https://github.com/darwinia-network/darwinia-messages-substrate", branch = "polkadot-v0.9.38" }

# frontier
fc-cli = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-consensus = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-db = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-mapping-sync = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-rpc = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-rpc-core = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fp-ethereum = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fp-evm = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fp-rpc = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fp-self-contained = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fp-storage = { git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-ethereum = { default-features = false, features = ["forbid-evm-reentrancy"], git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm = { default-features = false, features = ["forbid-evm-reentrancy"], git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-blake2 = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-bn128 = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-dispatch = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-modexp = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-simple = { default-features = false, git = "https://github.com/darwinia-network/frontier", branch = "polkadot-v0.9.38" }
fc-cli = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fp-ethereum = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fp-evm = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fp-rpc = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fp-self-contained = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-ethereum = { default-features = false, features = ["forbid-evm-reentrancy"], git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm = { default-features = false, features = ["forbid-evm-reentrancy"], git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-blake2 = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-bn128 = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-dispatch = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-modexp = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }
pallet-evm-precompile-simple = { default-features = false, git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.38" }

# moonbeam
account = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38" }
moonbeam-relay-encoder = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38" }
pallet-ethereum-xcm = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38" }
precompile-utils = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38" }
xcm-primitives = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "polkadot-v0.9.38" }
account = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38" }
pallet-ethereum-xcm = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38" }
precompile-utils = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38" }
xcm-primitives = { default-features = false, git = "https://github.com/darwinia-network/moonbeam", branch = "update-0.9.38" }

# polkadot
pallet-xcm = { default-features = false, git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38" }
Expand Down Expand Up @@ -193,11 +192,11 @@ substrate-prometheus-endpoint = { git = "https://github.com/parityt
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38" }

[patch."https://github.com/darwinia-network/moonbeam"]
account = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
pallet-ethereum-xcm = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
precompile-utils = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
xcm-primitives = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
# [patch."https://github.com/darwinia-network/moonbeam"]
# account = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
# pallet-ethereum-xcm = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
# precompile-utils = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }
# xcm-primitives = { git = "https://github.com/jiguantong/moonbeam", branch = "evm-xcm-debug" }

# [patch."https://github.com/paritytech/polkadot"]
# pallet-xcm = { git = "https://github.com/jiguantong/polkadot", branch = "evm-xcm-debug" }
Expand All @@ -216,7 +215,7 @@ xcm-primitives = { git = "https://github.com/jiguantong/moonbeam", branc
# fp-evm = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# fp-rpc = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# fp-self-contained = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# fp-storage = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# fc-storage = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# pallet-ethereum = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# pallet-evm = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
# pallet-evm-precompile-blake2 = { git = "https://github.com/jiguantong/frontier", branch = "evm-xcm-debug" }
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fc-rpc = { features = ["rpc-binary-search-estimate"], workspace = true
fc-rpc-core = { workspace = true }
fp-evm = { workspace = true }
fp-rpc = { workspace = true }
fp-storage = { workspace = true }
fc-storage = { workspace = true }

# polkadot
polkadot-cli = { workspace = true }
Expand Down
54 changes: 4 additions & 50 deletions node/src/frontier_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,20 @@
//! Service and service factory implementation. Specialized wrapper over substrate service.
// std
use std::{collections::BTreeMap, path::PathBuf, sync::Arc, time::Duration};
use std::{path::PathBuf, sync::Arc, time::Duration};
// crates.io
use futures::{future, StreamExt};
// darwinia
use crate::cli::Cli;
use dc_primitives::{Block, BlockNumber, Hash, Hashing};
use dc_primitives::{BlockNumber, Hash, Hashing};
// frontier
use fc_db::Backend as FrontierBackend;
use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};
use fc_rpc::{
EthTask, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, SchemaV2Override,
SchemaV3Override, StorageOverride,
};
use fc_rpc::{EthTask, OverrideHandle};
use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
use fp_storage::EthereumStorageSchema;
// substrate
use sc_cli::SubstrateCli;
use sc_client_api::backend::{AuxStore, Backend, StateBackend, StorageProvider};
use sc_service::{BasePath, Configuration, TaskManager};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};

#[allow(clippy::too_many_arguments)]
pub fn spawn_frontier_tasks<B, BE, C>(
Expand Down Expand Up @@ -73,6 +66,7 @@ pub fn spawn_frontier_tasks<B, BE, C>(
Duration::new(6, 0),
client.clone(),
backend,
overrides.clone(),
frontier_backend,
3,
0,
Expand Down Expand Up @@ -110,43 +104,3 @@ pub(crate) fn db_config_dir(config: &Configuration) -> PathBuf {
.config_dir(config.chain_spec.id())
})
}

pub(crate) fn overrides_handle<C, BE>(client: Arc<C>) -> Arc<OverrideHandle<Block>>
where
C: 'static
+ Send
+ Sync
+ ProvideRuntimeApi<Block>
+ StorageProvider<Block, BE>
+ AuxStore
+ HeaderBackend<Block>
+ HeaderMetadata<Block, Error = BlockChainError>,
C::Api: sp_api::ApiExt<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>,
BE: 'static + Backend<Block>,
BE::State: StateBackend<Hashing>,
{
let mut overrides_map = BTreeMap::new();

overrides_map.insert(
EthereumStorageSchema::V1,
Box::new(SchemaV1Override::new(client.clone()))
as Box<dyn StorageOverride<_> + Send + Sync>,
);
overrides_map.insert(
EthereumStorageSchema::V2,
Box::new(SchemaV2Override::new(client.clone()))
as Box<dyn StorageOverride<_> + Send + Sync>,
);
overrides_map.insert(
EthereumStorageSchema::V3,
Box::new(SchemaV3Override::new(client.clone()))
as Box<dyn StorageOverride<_> + Send + Sync>,
);

Arc::new(OverrideHandle {
schemas: overrides_map,
fallback: Box::new(RuntimeApiStorageOverride::new(client)),
})
}
4 changes: 2 additions & 2 deletions node/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ where
);
}

let overrides = frontier_service::overrides_handle(client.clone());
let overrides = fc_storage::overrides_handle(client.clone());
let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
task_manager.spawn_handle(),
overrides.clone(),
Expand Down Expand Up @@ -813,7 +813,7 @@ where
}

let prometheus_registry = config.prometheus_registry().cloned();
let overrides = frontier_service::overrides_handle(client.clone());
let overrides = fc_storage::overrides_handle(client.clone());
let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new(
task_manager.spawn_handle(),
overrides.clone(),
Expand Down
5 changes: 3 additions & 2 deletions pallet/message-transact/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ use fp_ethereum::{TransactionData, ValidatedTransaction};
use fp_evm::{CheckEvmTransaction, CheckEvmTransactionConfig, InvalidEvmTransactionError};
use pallet_evm::{FeeCalculator, GasWeightMapping};
// substrate
use frame_support::{traits::EnsureOrigin, PalletError, RuntimeDebug};
use frame_support::{
sp_runtime::traits::BadOrigin, traits::EnsureOrigin, PalletError, RuntimeDebug,
};
use sp_core::{H160, U256};
use frame_support::sp_runtime::traits::BadOrigin;
use sp_std::boxed::Box;

pub use pallet::*;
Expand Down
5 changes: 5 additions & 0 deletions runtime/crab/src/pallets/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
// darwinia
use crate::*;

frame_support::parameter_types! {
pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes;
}

impl pallet_ethereum::Config for Runtime {
type PostLogContent = PostBlockAndTxnHashes;
type RuntimeEvent = RuntimeEvent;
type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
}
5 changes: 5 additions & 0 deletions runtime/darwinia/src/pallets/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
// darwinia
use crate::*;

frame_support::parameter_types! {
pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes;
}

impl pallet_ethereum::Config for Runtime {
type PostLogContent = PostBlockAndTxnHashes;
type RuntimeEvent = RuntimeEvent;
type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
}
5 changes: 5 additions & 0 deletions runtime/pangolin/src/pallets/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
// darwinia
use crate::*;

frame_support::parameter_types! {
pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes;
}

impl pallet_ethereum::Config for Runtime {
type PostLogContent = PostBlockAndTxnHashes;
type RuntimeEvent = RuntimeEvent;
type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
}
5 changes: 5 additions & 0 deletions runtime/pangoro/src/pallets/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
// darwinia
use crate::*;

frame_support::parameter_types! {
pub const PostBlockAndTxnHashes: pallet_ethereum::PostLogContent = pallet_ethereum::PostLogContent::BlockAndTxnHashes;
}

impl pallet_ethereum::Config for Runtime {
type PostLogContent = PostBlockAndTxnHashes;
type RuntimeEvent = RuntimeEvent;
type StateRoot = pallet_ethereum::IntermediateStateRoot<Self>;
}

0 comments on commit a00cd34

Please sign in to comment.