Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit ee62088

Browse files
asiniscalchidastan
andauthored
revert solidity bytecode is set in the precompiled evm contracts (#131)
* revert solidity bytecode is set in the precompiled evm contracts * Update node/src/chain_spec.rs Co-authored-by: dastan <[email protected]> * fix compoilation * back to the previous implemnetation --------- Co-authored-by: dastan <[email protected]>
1 parent 53af635 commit ee62088

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

node/src/chain_spec.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use cumulus_primitives_core::ParaId;
2-
use laos_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
2+
use fp_evm::GenesisAccount;
3+
use laos_runtime::{AccountId, AuraId, Precompiles, Signature, EXISTENTIAL_DEPOSIT};
34
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
45
use sc_service::ChainType;
56
use serde::{Deserialize, Serialize};
@@ -190,6 +191,12 @@ fn testnet_genesis(
190191
// let alice = get_from_seed::<sr25519::Public>("Alice");
191192
// let bob = get_from_seed::<sr25519::Public>("Bob");
192193

194+
// This is the simplest bytecode to revert without returning any data.
195+
// We will pre-deploy it under all of our precompiles to ensure they can be called from
196+
// within contracts.
197+
// (PUSH1 0x00 PUSH1 0x00 REVERT)
198+
let revert_bytecode = vec![0x60, 0x00, 0x60, 0x00, 0xFD];
199+
193200
laos_runtime::RuntimeGenesisConfig {
194201
system: laos_runtime::SystemConfig {
195202
code: laos_runtime::WASM_BINARY
@@ -259,7 +266,21 @@ fn testnet_genesis(
259266
evm_chain_id: laos_runtime::EVMChainIdConfig { chain_id: 1000, ..Default::default() },
260267
evm: laos_runtime::EVMConfig {
261268
accounts: {
262-
let mut map = BTreeMap::new();
269+
let mut map: BTreeMap<_, _> = Precompiles::used_addresses()
270+
.iter()
271+
.map(|&address| {
272+
(
273+
address.into(),
274+
GenesisAccount {
275+
nonce: Default::default(),
276+
balance: Default::default(),
277+
storage: Default::default(),
278+
code: revert_bytecode.clone(),
279+
},
280+
)
281+
})
282+
.collect();
283+
263284
map.insert(
264285
// H160 address of Alice dev account
265286
// Derived from SS58 (42 prefix) address

runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ pub type Executive = frame_executive::Executive<
154154
AllPalletsWithSystem,
155155
>;
156156

157+
pub type Precompiles = FrontierPrecompiles<Runtime>;
158+
157159
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
158160
/// node's balance type.
159161
///

0 commit comments

Comments
 (0)