Skip to content

Commit

Permalink
Remove Pallet ethereum-chain-id in favor of frontier evm-chain-id (#2379
Browse files Browse the repository at this point in the history
)

* Add evm-chain-id pallet

* Replace the Ethereum-chain-id pallet with evm-chain-id from frontier

* Remove ethereum-chain-id

* Update unit tests

* Update Readme

* Use a fresh index for the new pallet

* Add a migration to set the evm chain id value

* Fix clippy warnings

* update frontier dependecies git url

use https://github.com/moonbeam-foundation/frontier
instead of https://github.com/purestake/frontier

* update migrations pre/post hooks return types

* remove migration

* cleanup

* update Cargo.lock

* fix formatting

---------

Co-authored-by: Andrea Giacobino <no.andrea@gmail.com>
  • Loading branch information
ahmadkaouk and noandrea authored Sep 20, 2023
1 parent 7bb7a34 commit bb85df1
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 210 deletions.
191 changes: 96 additions & 95 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ moonbeam-runtime-common = { path = "runtime/common", default-features = false }
moonbeam-xcm-benchmarks = { path = "pallets/moonbeam-xcm-benchmarks", default-features = false }
pallet-asset-manager = { path = "pallets/asset-manager", default-features = false }
pallet-erc20-xcm-bridge = { path = "pallets/erc20-xcm-bridge", default-features = false }
pallet-ethereum-chain-id = { path = "pallets/ethereum-chain-id", default-features = false }
pallet-ethereum-xcm = { path = "pallets/ethereum-xcm", default-features = false }

pallet-evm-precompile-author-mapping = { path = "precompiles/author-mapping", default-features = false }
Expand Down Expand Up @@ -233,6 +232,7 @@ pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", bra
pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false, features = [
"forbid-evm-reentrancy",
] }
pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-bn128 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v0.9.43", default-features = false }
Expand Down Expand Up @@ -446,7 +446,7 @@ opt-level = 3
panic = "unwind"

[profile.testnet]
debug = 1 # debug symbols are useful for profilers
debug = 1 # debug symbols are useful for profilers
debug-assertions = true
inherits = "release"
overflow-checks = true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ From substrate:

From frontier:

- _EVM Chain Id_: A place to store the chain id for each Moonbeam network
- _EVM_: Encapsulates execution logic for an Ethereum Virtual Machine
- _Ethereum_: Ethereum-style data encoding and access for the EVM.

Expand All @@ -189,7 +190,6 @@ From cumulus:

The following pallets are stored in `pallets/`. They are designed for Moonbeam's specific requirements:

- _Ethereum Chain Id_: A place to store the chain id for each Moonbeam network
- _Author Inherent_: Allows block authors to include their identity in a block via an inherent
- _Parachain Staking_: Minimal staking pallet that selects collators by total amount at stake

Expand Down
25 changes: 0 additions & 25 deletions pallets/ethereum-chain-id/Cargo.toml

This file was deleted.

60 changes: 0 additions & 60 deletions pallets/ethereum-chain-id/src/lib.rs

This file was deleted.

1 change: 1 addition & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fp-ethereum = { workspace = true }
fp-evm = { workspace = true }
pallet-base-fee = { workspace = true }
pallet-evm = { workspace = true, features = [ "forbid-evm-reentrancy" ] }
pallet-evm-chain-id = { workspace = true }

# Nimbus
pallet-author-inherent = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pallet-asset-manager = { workspace = true }
pallet-author-mapping = { workspace = true }
pallet-crowdloan-rewards = { workspace = true }
pallet-erc20-xcm-bridge = { workspace = true }
pallet-ethereum-chain-id = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-ethereum-xcm = { workspace = true }
pallet-maintenance-mode = { workspace = true, features = [ "xcm-support" ] }
pallet-migrations = { workspace = true }
Expand Down Expand Up @@ -219,7 +219,7 @@ std = [
"pallet-crowdloan-rewards/std",
"pallet-democracy/std",
"pallet-erc20-xcm-bridge/std",
"pallet-ethereum-chain-id/std",
"pallet-evm-chain-id/std",
"pallet-ethereum-xcm/std",
"pallet-ethereum/std",
"pallet-evm-precompile-author-mapping/std",
Expand Down
8 changes: 3 additions & 5 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl pallet_sudo::Config for Runtime {
type WeightInfo = moonbeam_weights::pallet_sudo::WeightInfo<Runtime>;
}

impl pallet_ethereum_chain_id::Config for Runtime {}
impl pallet_evm_chain_id::Config for Runtime {}

/// Current approximation of the gas/s consumption considering
/// EVM execution over compiled WASM (on 4.4Ghz CPU).
Expand Down Expand Up @@ -1330,7 +1330,7 @@ construct_runtime! {
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>} = 6,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Config, Event<T>} = 7,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 8,
EthereumChainId: pallet_ethereum_chain_id::{Pallet, Storage, Config} = 9,
EthereumChainId: pallet_evm_chain_id::{Pallet, Storage, Config} = 9,
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 10,
Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Origin, Config} = 11,
ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event<T>, Config<T>} = 12,
Expand Down Expand Up @@ -1579,9 +1579,7 @@ mod tests {
// need to be Boxed.
fn call_max_size() {
const CALL_ALIGN: u32 = 1024;
assert!(
std::mem::size_of::<pallet_ethereum_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize
);
assert!(std::mem::size_of::<pallet_evm_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_evm::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_ethereum::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbase/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ impl ExtBuilder {
.assimilate_storage(&mut t)
.unwrap();

<pallet_ethereum_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_ethereum_chain_id::GenesisConfig {
<pallet_evm_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_evm_chain_id::GenesisConfig {
chain_id: self.chain_id,
},
&mut t,
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbeam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pallet-asset-manager = { workspace = true }
pallet-author-mapping = { workspace = true }
pallet-crowdloan-rewards = { workspace = true }
pallet-erc20-xcm-bridge = { workspace = true }
pallet-ethereum-chain-id = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-ethereum-xcm = { workspace = true }
pallet-maintenance-mode = { workspace = true, features = [ "xcm-support" ] }
pallet-migrations = { workspace = true }
Expand Down Expand Up @@ -218,7 +218,7 @@ std = [
"pallet-crowdloan-rewards/std",
"pallet-democracy/std",
"pallet-erc20-xcm-bridge/std",
"pallet-ethereum-chain-id/std",
"pallet-evm-chain-id/std",
"pallet-ethereum-xcm/std",
"pallet-ethereum/std",
"pallet-evm-precompile-author-mapping/std",
Expand Down
8 changes: 3 additions & 5 deletions runtime/moonbeam/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

impl pallet_ethereum_chain_id::Config for Runtime {}
impl pallet_evm_chain_id::Config for Runtime {}

/// Current approximation of the gas/s consumption considering
/// EVM execution over compiled WASM (on 4.4Ghz CPU).
Expand Down Expand Up @@ -1359,7 +1359,7 @@ construct_runtime! {
// Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>} = 40,

// Ethereum compatibility.
EthereumChainId: pallet_ethereum_chain_id::{Pallet, Storage, Config} = 50,
EthereumChainId: pallet_evm_chain_id::{Pallet, Storage, Config} = 50,
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 51,
Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Origin, Config} = 52,

Expand Down Expand Up @@ -1619,9 +1619,7 @@ mod tests {
// need to be Boxed.
fn call_max_size() {
const CALL_ALIGN: u32 = 1024;
assert!(
std::mem::size_of::<pallet_ethereum_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize
);
assert!(std::mem::size_of::<pallet_evm_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_evm::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_ethereum::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonbeam/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ impl ExtBuilder {
.assimilate_storage(&mut t)
.unwrap();

<pallet_ethereum_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_ethereum_chain_id::GenesisConfig {
<pallet_evm_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_evm_chain_id::GenesisConfig {
chain_id: self.chain_id,
},
&mut t,
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pallet-asset-manager = { workspace = true }
pallet-author-mapping = { workspace = true }
pallet-crowdloan-rewards = { workspace = true }
pallet-erc20-xcm-bridge = { workspace = true }
pallet-ethereum-chain-id = { workspace = true }
pallet-evm-chain-id = { workspace = true }
pallet-ethereum-xcm = { workspace = true }
pallet-maintenance-mode = { workspace = true, features = [ "xcm-support" ] }
pallet-migrations = { workspace = true }
Expand Down Expand Up @@ -218,7 +218,7 @@ std = [
"pallet-crowdloan-rewards/std",
"pallet-democracy/std",
"pallet-erc20-xcm-bridge/std",
"pallet-ethereum-chain-id/std",
"pallet-evm-chain-id/std",
"pallet-ethereum-xcm/std",
"pallet-ethereum/std",
"pallet-evm-precompile-author-mapping/std",
Expand Down
8 changes: 3 additions & 5 deletions runtime/moonriver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
}

impl pallet_ethereum_chain_id::Config for Runtime {}
impl pallet_evm_chain_id::Config for Runtime {}

/// Current approximation of the gas/s consumption considering
/// EVM execution over compiled WASM (on 4.4Ghz CPU).
Expand Down Expand Up @@ -1367,7 +1367,7 @@ construct_runtime! {
// Sudo was previously index 40

// Ethereum compatibility
EthereumChainId: pallet_ethereum_chain_id::{Pallet, Storage, Config} = 50,
EthereumChainId: pallet_evm_chain_id::{Pallet, Storage, Config} = 50,
EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 51,
Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Origin, Config} = 52,

Expand Down Expand Up @@ -1626,9 +1626,7 @@ mod tests {
// need to be Boxed.
fn call_max_size() {
const CALL_ALIGN: u32 = 1024;
assert!(
std::mem::size_of::<pallet_ethereum_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize
);
assert!(std::mem::size_of::<pallet_evm_chain_id::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_evm::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(std::mem::size_of::<pallet_ethereum::Call<Runtime>>() <= CALL_ALIGN as usize);
assert!(
Expand Down
4 changes: 2 additions & 2 deletions runtime/moonriver/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ impl ExtBuilder {
.assimilate_storage(&mut t)
.unwrap();

<pallet_ethereum_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_ethereum_chain_id::GenesisConfig {
<pallet_evm_chain_id::GenesisConfig as GenesisBuild<Runtime>>::assimilate_storage(
&pallet_evm_chain_id::GenesisConfig {
chain_id: self.chain_id,
},
&mut t,
Expand Down

0 comments on commit bb85df1

Please sign in to comment.