Skip to main content

tempo_revm/
gas_params.rs

1use auto_impl::auto_impl;
2use revm::context_interface::cfg::{GasId, GasParams};
3use tempo_chainspec::hardfork::TempoHardfork;
4
5/// Extending [`GasParams`] for Tempo use case.
6#[auto_impl(&, Arc, Box, &mut)]
7pub trait TempoGasParams {
8    fn gas_params(&self) -> &GasParams;
9
10    fn tx_tip1000_auth_account_creation_cost(&self) -> u64 {
11        self.gas_params().get(GasId::new(255))
12    }
13}
14
15impl TempoGasParams for GasParams {
16    fn gas_params(&self) -> &GasParams {
17        self
18    }
19}
20
21/// Tempo gas params override.
22#[inline]
23pub fn tempo_gas_params(spec: TempoHardfork) -> GasParams {
24    let mut gas_params = GasParams::new_spec(spec.into());
25    let mut overrides = vec![];
26    if spec.is_t1() {
27        overrides.extend([
28            // storage set with SSTORE opcode.
29            (GasId::sstore_set_without_load_cost(), 250_000),
30            // Base cost of Create kind transaction.
31            (GasId::tx_create_cost(), 500_000),
32            // create cost for CREATE/CREATE2 opcodes.
33            (GasId::create(), 500_000),
34            // new account cost for new accounts.
35            (GasId::new_account_cost(), 250_000),
36            // Selfdestruct will not be possible to create new account as this can only be
37            // done when account value is not zero.
38            (GasId::new_account_cost_for_selfdestruct(), 250_000),
39            // code deposit cost is 1000 per byte.
40            (GasId::code_deposit_cost(), 1_000),
41            // The base cost per authorization is reduced to 12,500 gas
42            (GasId::tx_eip7702_per_empty_account_cost(), 12500),
43            // Auth account creation cost.
44            (GasId::new(255), 250_000),
45        ]);
46    }
47
48    gas_params.override_gas(overrides);
49    gas_params
50}