revm_interpreter/gas/
constants.rs

1/// Gas cost for operations that consume zero gas.
2pub const ZERO: u64 = 0;
3/// Base gas cost for basic operations.
4pub const BASE: u64 = 2;
5
6/// Gas cost for very low-cost operations.
7pub const VERYLOW: u64 = 3;
8/// Gas cost for DATALOADN instruction.
9pub const DATA_LOADN_GAS: u64 = 3;
10
11/// Gas cost for conditional jump instructions.
12pub const CONDITION_JUMP_GAS: u64 = 4;
13/// Gas cost for RETF instruction.
14pub const RETF_GAS: u64 = 3;
15/// Gas cost for DATALOAD instruction.
16pub const DATA_LOAD_GAS: u64 = 4;
17
18/// Gas cost for low-cost operations.
19pub const LOW: u64 = 5;
20/// Gas cost for medium-cost operations.
21pub const MID: u64 = 8;
22/// Gas cost for high-cost operations.
23pub const HIGH: u64 = 10;
24/// Gas cost for JUMPDEST instruction.
25pub const JUMPDEST: u64 = 1;
26/// Gas cost for SELFDESTRUCT instruction.
27pub const SELFDESTRUCT: i64 = 24000;
28/// Gas cost for CREATE instruction.
29pub const CREATE: u64 = 32000;
30/// Additional gas cost when a call transfers value.
31pub const CALLVALUE: u64 = 9000;
32/// Gas cost for creating a new account.
33pub const NEWACCOUNT: u64 = 25000;
34/// Base gas cost for EXP instruction.
35pub const EXP: u64 = 10;
36/// Gas cost per word for memory operations.
37pub const MEMORY: u64 = 3;
38/// Base gas cost for LOG instructions.
39pub const LOG: u64 = 375;
40/// Gas cost per byte of data in LOG instructions.
41pub const LOGDATA: u64 = 8;
42/// Gas cost per topic in LOG instructions.
43pub const LOGTOPIC: u64 = 375;
44/// Base gas cost for KECCAK256 instruction.
45pub const KECCAK256: u64 = 30;
46/// Gas cost per word for KECCAK256 instruction.
47pub const KECCAK256WORD: u64 = 6;
48/// Gas cost per word for copy operations.
49pub const COPY: u64 = 3;
50/// Gas cost for BLOCKHASH instruction.
51pub const BLOCKHASH: u64 = 20;
52/// Gas cost per byte for code deposit during contract creation.
53pub const CODEDEPOSIT: u64 = 200;
54
55/// EIP-1884: Repricing for trie-size-dependent opcodes
56pub const ISTANBUL_SLOAD_GAS: u64 = 800;
57/// Gas cost for SSTORE when setting a storage slot from zero to non-zero.
58pub const SSTORE_SET: u64 = 20000;
59/// Gas cost for SSTORE when modifying an existing non-zero storage slot.
60pub const SSTORE_RESET: u64 = 5000;
61/// Gas refund for SSTORE when clearing a storage slot (setting to zero).
62pub const REFUND_SSTORE_CLEARS: i64 = 15000;
63
64/// The standard cost of calldata token.
65pub const STANDARD_TOKEN_COST: u64 = 4;
66/// The cost of a non-zero byte in calldata.
67pub const NON_ZERO_BYTE_DATA_COST: u64 = 68;
68/// The multiplier for a non zero byte in calldata.
69pub const NON_ZERO_BYTE_MULTIPLIER: u64 = NON_ZERO_BYTE_DATA_COST / STANDARD_TOKEN_COST;
70/// The cost of a non-zero byte in calldata adjusted by [EIP-2028](https://eips.ethereum.org/EIPS/eip-2028).
71pub const NON_ZERO_BYTE_DATA_COST_ISTANBUL: u64 = 16;
72/// The multiplier for a non zero byte in calldata adjusted by [EIP-2028](https://eips.ethereum.org/EIPS/eip-2028).
73pub const NON_ZERO_BYTE_MULTIPLIER_ISTANBUL: u64 =
74    NON_ZERO_BYTE_DATA_COST_ISTANBUL / STANDARD_TOKEN_COST;
75// The cost floor per token as defined by [EIP-2028](https://eips.ethereum.org/EIPS/eip-2028).
76/// The cost floor per token as defined by EIP-2028.
77pub const TOTAL_COST_FLOOR_PER_TOKEN: u64 = 10;
78
79/// Gas cost for EOF CREATE instruction.
80pub const EOF_CREATE_GAS: u64 = 32000;
81
82// Berlin eip2929 constants
83/// Gas cost for accessing an address in the access list (EIP-2929).
84pub const ACCESS_LIST_ADDRESS: u64 = 2400;
85/// Gas cost for accessing a storage key in the access list (EIP-2929).
86pub const ACCESS_LIST_STORAGE_KEY: u64 = 1900;
87/// Gas cost for SLOAD when accessing a cold storage slot (EIP-2929).
88pub const COLD_SLOAD_COST: u64 = 2100;
89/// Gas cost for accessing a cold account (EIP-2929).
90pub const COLD_ACCOUNT_ACCESS_COST: u64 = 2600;
91/// Gas cost for reading from a warm storage slot (EIP-2929).
92pub const WARM_STORAGE_READ_COST: u64 = 100;
93/// Gas cost for SSTORE reset operation on a warm storage slot.
94pub const WARM_SSTORE_RESET: u64 = SSTORE_RESET - COLD_SLOAD_COST;
95
96/// EIP-3860 : Limit and meter initcode
97pub const INITCODE_WORD_COST: u64 = 2;
98
99/// Gas stipend provided to the recipient of a CALL with value transfer.
100pub const CALL_STIPEND: u64 = 2300;
101/// Minimum gas that must be provided to a callee.
102pub const MIN_CALLEE_GAS: u64 = CALL_STIPEND;