revm_primitives/constants.rs
1use alloy_primitives::{address, Address};
2
3/// EIP-170: Contract code size limit
4///
5/// By default the limit is `0x6000` (~25kb)
6pub const MAX_CODE_SIZE: usize = 0x6000;
7
8/// Number of block hashes that EVM can access in the past (pre-Prague).
9pub const BLOCK_HASH_HISTORY: u64 = 256;
10
11/// EIP-2935: Serve historical block hashes from state
12///
13/// Number of block hashes the EVM can access in the past (Prague).
14///
15/// # Note
16///
17/// This is named `HISTORY_SERVE_WINDOW` in the EIP.
18pub const BLOCKHASH_SERVE_WINDOW: usize = 8192;
19
20/// EIP-2935: Serve historical block hashes from state
21///
22/// The address where historical blockhashes are available.
23///
24/// # Note
25///
26/// This is named `HISTORY_STORAGE_ADDRESS` in the EIP.
27pub const BLOCKHASH_STORAGE_ADDRESS: Address = address!("25a219378dad9b3503c8268c9ca836a52427a4fb");
28
29/// EIP-3860: Limit and meter initcode
30///
31/// Limit of maximum initcode size is `2 * MAX_CODE_SIZE`.
32pub const MAX_INITCODE_SIZE: usize = 2 * MAX_CODE_SIZE;
33
34/// The address of precompile 3, which is handled specially in a few places.
35pub const PRECOMPILE3: Address =
36 Address::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]);
37
38// === EIP-4844 constants ===
39
40/// Gas consumption of a single data blob (== blob byte size).
41pub const GAS_PER_BLOB: u64 = 1 << 17;
42
43/// Target number of the blob per block.
44pub const TARGET_BLOB_NUMBER_PER_BLOCK: u64 = 3;
45
46/// Max number of blobs per block
47pub const MAX_BLOB_NUMBER_PER_BLOCK: u64 = 2 * TARGET_BLOB_NUMBER_PER_BLOCK;
48
49/// Maximum consumable blob gas for data blobs per block.
50pub const MAX_BLOB_GAS_PER_BLOCK: u64 = MAX_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB;
51
52/// Target consumable blob gas for data blobs per block (for 1559-like pricing).
53pub const TARGET_BLOB_GAS_PER_BLOCK: u64 = TARGET_BLOB_NUMBER_PER_BLOCK * GAS_PER_BLOB;
54
55/// Minimum gas price for data blobs.
56pub const MIN_BLOB_GASPRICE: u64 = 1;
57
58/// Controls the maximum rate of change for blob gas price.
59pub const BLOB_GASPRICE_UPDATE_FRACTION: u64 = 3338477;
60
61/// First version of the blob.
62pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01;