ethrex_common/types/constants.rs
1// Fee related
2pub const ELASTICITY_MULTIPLIER: u64 = 2;
3pub const BASE_FEE_MAX_CHANGE_DENOMINATOR: u128 = 8;
4pub const GAS_LIMIT_ADJUSTMENT_FACTOR: u64 = 1024;
5pub const GAS_LIMIT_MINIMUM: u64 = 5000;
6pub const DEFAULT_BUILDER_GAS_CEIL: u64 = 60_000_000;
7pub const GWEI_TO_WEI: u64 = 1_000_000_000;
8pub const INITIAL_BASE_FEE: u64 = 1_000_000_000; //Initial base fee as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
9pub const MIN_BASE_FEE_PER_BLOB_GAS: u64 = 1; // Defined in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
10pub const BLOB_BASE_FEE_UPDATE_FRACTION: u64 = 3338477; // Defined in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
11pub const VERSIONED_HASH_VERSION_KZG: u8 = 0x01; // Defined in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
12/// Minimum tip, obtained from geth's default miner config (https://github.com/ethereum/go-ethereum/blob/f750117ad19d623622cc4a46ea361a716ba7407e/miner/miner.go#L56)
13///
14/// Scope: this constant is consumed only by the RPC gas-price estimators
15/// (`eth_gasPrice`, `eth_maxPriorityFeePerGas`). The mempool admission
16/// floor is a separate, lower default (see
17/// `ethrex_blockchain::DEFAULT_MIN_TIP_WEI`).
18pub const MIN_GAS_TIP: u64 = 1000000;
19
20// Blob size related
21// Defined in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
22pub const BYTES_PER_FIELD_ELEMENT: usize = 32;
23pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096;
24pub const BYTES_PER_BLOB: usize = BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
25pub const BYTES_PER_BLOB_F64: f64 = BYTES_PER_BLOB as f64;
26/// The maximum number of bytes that can be "safely" stored in a blob. This is, prepend
27/// a zero byte for every 32 bytes of data to ensure they not exceed the field modulus.
28pub const SAFE_BYTES_PER_BLOB: usize = BYTES_PER_BLOB * 31 / 32;
29// Defined in [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594)
30pub const FIELD_ELEMENTS_PER_EXT_BLOB: usize = 2 * FIELD_ELEMENTS_PER_BLOB;
31pub const FIELD_ELEMENTS_PER_CELL: usize = 64;
32pub const BYTES_PER_CELL: usize = FIELD_ELEMENTS_PER_CELL * BYTES_PER_FIELD_ELEMENT;
33pub const CELLS_PER_EXT_BLOB: usize = FIELD_ELEMENTS_PER_EXT_BLOB / FIELD_ELEMENTS_PER_CELL;
34/// Maximum blobs a single transaction may carry from Osaka onwards.
35pub const MAX_BLOB_COUNT: usize = 6;
36/// Maximum blobs a single transaction may carry before Osaka.
37pub const MAX_BLOB_COUNT_ELECTRA: usize = 9;
38
39// Mempool admission size caps — peer-policy defaults, not consensus.
40// Matches geth `txMaxSize` (legacypool) and `txMaxSize` (blobpool), reth
41// `DEFAULT_MAX_TX_INPUT_BYTES`, nethermind `MaxTxSize` / `MaxBlobTxSize`.
42/// Maximum RLP-encoded wire size for a non-blob transaction (128 KiB).
43pub const MAX_TX_SIZE: usize = 131_072;
44/// Maximum RLP-encoded core size for an EIP-4844 blob transaction (1 MiB),
45/// excluding the blob sidecar. Sidecar size is bounded separately by the
46/// per-blob byte count and the fork's max blob count.
47pub const MAX_BLOB_TX_SIZE: usize = 1_048_576;