pallet_evm/runner/
mod.rs

1// This file is part of Frontier.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18pub mod meter;
19pub mod stack;
20
21use crate::{Config, Weight};
22use alloc::vec::Vec;
23use ethereum::AuthorizationList;
24use fp_evm::{CallInfo, CreateInfo, StateOverride};
25use sp_core::{H160, H256, U256};
26
27#[derive(Debug)]
28pub struct RunnerError<E: Into<sp_runtime::DispatchError>> {
29	pub error: E,
30	pub weight: Weight,
31}
32
33pub trait Runner<T: Config> {
34	type Error: Into<sp_runtime::DispatchError>;
35
36	fn validate(
37		source: H160,
38		target: Option<H160>,
39		input: Vec<u8>,
40		value: U256,
41		gas_limit: u64,
42		max_fee_per_gas: Option<U256>,
43		max_priority_fee_per_gas: Option<U256>,
44		nonce: Option<U256>,
45		access_list: Vec<(H160, Vec<H256>)>,
46		authorization_list: Vec<(U256, H160, U256, Option<H160>)>,
47		is_transactional: bool,
48		weight_limit: Option<Weight>,
49		proof_size_base_cost: Option<u64>,
50		evm_config: &evm::Config,
51	) -> Result<(), RunnerError<Self::Error>>;
52
53	fn call(
54		source: H160,
55		target: H160,
56		input: Vec<u8>,
57		value: U256,
58		gas_limit: u64,
59		max_fee_per_gas: Option<U256>,
60		max_priority_fee_per_gas: Option<U256>,
61		nonce: Option<U256>,
62		access_list: Vec<(H160, Vec<H256>)>,
63		authorization_list: AuthorizationList,
64		is_transactional: bool,
65		validate: bool,
66		weight_limit: Option<Weight>,
67		proof_size_base_cost: Option<u64>,
68		// Per-account full storage replacement (Geth-style `state` override).
69		// See [`StateOverride`] for the encoding and semantics.
70		state_override: StateOverride,
71		config: &evm::Config,
72	) -> Result<CallInfo, RunnerError<Self::Error>>;
73
74	fn create(
75		source: H160,
76		init: Vec<u8>,
77		value: U256,
78		gas_limit: u64,
79		max_fee_per_gas: Option<U256>,
80		max_priority_fee_per_gas: Option<U256>,
81		nonce: Option<U256>,
82		access_list: Vec<(H160, Vec<H256>)>,
83		authorization_list: AuthorizationList,
84		is_transactional: bool,
85		validate: bool,
86		weight_limit: Option<Weight>,
87		proof_size_base_cost: Option<u64>,
88		config: &evm::Config,
89	) -> Result<CreateInfo, RunnerError<Self::Error>>;
90
91	fn create2(
92		source: H160,
93		init: Vec<u8>,
94		salt: H256,
95		value: U256,
96		gas_limit: u64,
97		max_fee_per_gas: Option<U256>,
98		max_priority_fee_per_gas: Option<U256>,
99		nonce: Option<U256>,
100		access_list: Vec<(H160, Vec<H256>)>,
101		authorization_list: AuthorizationList,
102		is_transactional: bool,
103		validate: bool,
104		weight_limit: Option<Weight>,
105		proof_size_base_cost: Option<u64>,
106		config: &evm::Config,
107	) -> Result<CreateInfo, RunnerError<Self::Error>>;
108
109	fn create_force_address(
110		source: H160,
111		init: Vec<u8>,
112		value: U256,
113		gas_limit: u64,
114		max_fee_per_gas: Option<U256>,
115		max_priority_fee_per_gas: Option<U256>,
116		nonce: Option<U256>,
117		access_list: Vec<(H160, Vec<H256>)>,
118		authorization_list: AuthorizationList,
119		is_transactional: bool,
120		validate: bool,
121		weight_limit: Option<Weight>,
122		proof_size_base_cost: Option<u64>,
123		config: &evm::Config,
124		contract_address: H160,
125	) -> Result<CreateInfo, RunnerError<Self::Error>>;
126}