Skip to main content

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`). It is NOT a mempool
16/// admission gate — zero-tip transactions are currently admitted.
17///
18/// TODO: This should be configurable along with the tip filter on https://github.com/lambdaclass/ethrex/issues/680
19pub const MIN_GAS_TIP: u64 = 1000000;
20
21// Blob size related
22// Defined in [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
23pub const BYTES_PER_FIELD_ELEMENT: usize = 32;
24pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096;
25pub const BYTES_PER_BLOB: usize = BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB;
26pub const BYTES_PER_BLOB_F64: f64 = BYTES_PER_BLOB as f64;
27/// The maximum number of bytes that can be "safely" stored in a blob. This is, prepend
28/// a zero byte for every 32 bytes of data to ensure they not exceed the field modulus.
29pub const SAFE_BYTES_PER_BLOB: usize = BYTES_PER_BLOB * 31 / 32;
30// Defined in [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594)
31pub const FIELD_ELEMENTS_PER_EXT_BLOB: usize = 2 * FIELD_ELEMENTS_PER_BLOB;
32pub const FIELD_ELEMENTS_PER_CELL: usize = 64;
33pub const BYTES_PER_CELL: usize = FIELD_ELEMENTS_PER_CELL * BYTES_PER_FIELD_ELEMENT;
34pub const CELLS_PER_EXT_BLOB: usize = FIELD_ELEMENTS_PER_EXT_BLOB / FIELD_ELEMENTS_PER_CELL;
35
36// Mempool admission size caps — peer-policy defaults, not consensus.
37// Matches geth `txMaxSize` (legacypool) and `txMaxSize` (blobpool), reth
38// `DEFAULT_MAX_TX_INPUT_BYTES`, nethermind `MaxTxSize` / `MaxBlobTxSize`.
39/// Maximum RLP-encoded wire size for a non-blob transaction (128 KiB).
40pub const MAX_TX_SIZE: usize = 131_072;
41/// Maximum RLP-encoded core size for an EIP-4844 blob transaction (1 MiB),
42/// excluding the blob sidecar. Sidecar size is bounded separately by the
43/// per-blob byte count and the fork's max blob count.
44pub const MAX_BLOB_TX_SIZE: usize = 1_048_576;