Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add frontier evm #1133

Merged
merged 1 commit into from
Jul 28, 2023
Merged

feat: add frontier evm #1133

merged 1 commit into from
Jul 28, 2023

Conversation

gregdhill
Copy link
Member

@gregdhill gregdhill commented Jul 19, 2023

Closes #1098

TODO

  • Verify all parameters make sense (most are taken from Centrifuge or Moonbeam)
  • Review signing logic (for wallet compatibility) and account conversion
  • Confirm required precompiles (included standard Ethereum ones)
  • Cleanup service (de-duplicate code, add SQL DB support, resolve TransactionConverter)
  • Configurable contract creation
  • Add EVM contract fixtures

Adds the following pallets to the interlay and kintsugi runtimes in addition to those required for RPC compatibility.

BaseFee (pallet_base_fee)

Controls the price per gas unit, updates based on the weight of the previous block - decreases if below or increases if above the target.

Ethereum (pallet_ethereum)

Emulation for block processing, validates and stores (EVM) transactions then constructs the Ethereum compatible block on_finalize.

EVM (pallet_evm)

Contains the SputnikVM to execute EVM bytecode compatible with the Ethereum mainnet.

Configuration

All non-root calls are disabled.

EVMChainId (pallet_evm_chain_id)

Stores the chain ID which is used by the EVM runner.

@gregdhill gregdhill force-pushed the frontier-evm branch 2 times, most recently from 03d2a84 to 96890df Compare July 24, 2023 13:47
@gregdhill gregdhill marked this pull request as ready for review July 27, 2023 16:03
Signed-off-by: Gregory Hill <[email protected]>
Copy link
Member

@sander2 sander2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, but honestly it's very difficult to review, because there's so much code involved..

One question I do have is, how can the evm interact with our runtime? E.g. if it wants to check a bitcoin inclusion?

pub mod precompiles;

/// Current approximation of the gas/s consumption (Moonbeam)
pub const GAS_PER_SECOND: u64 = 40_000_000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to benchmark this somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK that is used in production and Centrifuge also copied that for their runtime.

pub type AccountConverter = HashedAddressMapping<BlakeTwo256>;

parameter_types! {
pub DefaultBaseFeePerGas: U256 = U256::from(CENTS);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "flipper" contract fixture costs 133751 gas to create which would total (133751 * (10**10 / 100)) / 10**10 = 1337.51 INTR ($19.7).

pub type AccountConverter = HashedAddressMapping<BlakeTwo256>;

parameter_types! {
pub DefaultBaseFeePerGas: U256 = U256::from(CENTS * 10);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "flipper" contract fixture costs 133751 gas to create which would total (133751 * (10**12 / 30_000 * 10)) / 10**12 = 44.58 KINT ($16.94).

@gregdhill
Copy link
Member Author

how can the evm interact with our runtime?

We need to add precompiles, see for example Acala's MultiCurrencyPrecompile.

@gregdhill gregdhill merged commit d866068 into master Jul 28, 2023
2 of 3 checks passed
@gregdhill gregdhill deleted the frontier-evm branch July 28, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EVM support
2 participants