Precompiles (#201)

* Moved PR to monorepo

* Update evm-template/runtime/src/lib.rs

Co-authored-by: Amar Singh <asinghchrony@protonmail.com>

* minimal precompile config

* try fix remaining merge conflicts by accepting all incoming

* into merge again

* clippy fix

* use workspace dep as per suggestion

* try fix

* insert revert bytecode in evm account storage at genesis for precompile addresses

* toml sort

---------

Co-authored-by: Nikita Khateev <nikita.khateev@openzeppelin.com>
This commit is contained in:
Amar Singh
2024-05-31 16:04:14 -04:00
committed by GitHub
parent dc4f0129f1
commit 7b1388b15c
8 changed files with 176 additions and 56 deletions
+1
View File
@@ -82,6 +82,7 @@ fc-rpc = { workspace = true }
fc-rpc-core = { workspace = true }
fc-storage = { workspace = true }
fp-dynamic-fee = { workspace = true, features = [ "std" ] }
fp-evm = { workspace = true }
fp-rpc = { workspace = true }
[build-dependencies]
+24 -2
View File
@@ -1,12 +1,16 @@
use std::collections::BTreeMap;
use cumulus_primitives_core::ParaId;
use fp_evm::GenesisAccount;
use hex_literal::hex;
use parachain_template_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId, Signature,
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AuraId,
OpenZeppelinPrecompiles as Precompiles, Runtime, Signature,
};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use sp_core::{ecdsa, Pair, Public};
use sp_core::{ecdsa, Pair, Public, H160};
use sp_runtime::traits::{IdentifyAccount, Verify};
/// Specialized `ChainSpec` for the normal parachain runtime.
@@ -200,6 +204,24 @@ fn testnet_genesis(
"evmChainId": {
"chainId": 9999
},
"evm": {
"accounts": Precompiles::<Runtime>::used_addresses()
.map(|addr| {
(
addr,
GenesisAccount {
nonce: Default::default(),
balance: Default::default(),
storage: Default::default(),
// bytecode to revert without returning data
// (PUSH1 0x00 PUSH1 0x00 REVERT)
code: vec![0x60, 0x00, 0x60, 0x00, 0xFD],
},
)
})
.into_iter()
.collect::<BTreeMap<H160, GenesisAccount>>(),
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
},