Skip to content

Commit

Permalink
Revert "Fix gas cost calculation related to address access cost"
Browse files Browse the repository at this point in the history
This reverts commit 5406dab.
  • Loading branch information
sorpaas committed Nov 19, 2023
1 parent 5406dab commit 9e55b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/standard/gasometer/costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub fn verylowcopy_cost(len: U256) -> Result<u64, ExitException> {
pub fn extcodecopy_cost(len: U256, is_cold: bool, config: &Config) -> Result<u64, ExitException> {
let wordd = len / U256::from(32);
let wordr = len % U256::from(32);
let gas = (U256::from(address_access_cost(is_cold, config)) + config.gas_ext_code)
let gas = U256::from(address_access_cost(is_cold, config.gas_ext_code, config))
.checked_add(
U256::from(G_COPY)
.checked_mul(if wordr == U256::zero() {
Expand Down Expand Up @@ -272,21 +272,20 @@ pub fn call_cost(
config: &Config,
) -> u64 {
let transfers_value = value != U256::default();
address_access_cost(is_cold, config)
+ config.gas_call
address_access_cost(is_cold, config.gas_call, config)
+ xfer_cost(is_call_or_callcode, transfers_value)
+ new_cost(is_call_or_staticcall, new_account, transfers_value, config)
}

pub fn address_access_cost(is_cold: bool, config: &Config) -> u64 {
pub fn address_access_cost(is_cold: bool, regular_value: u64, config: &Config) -> u64 {
if config.increase_state_access_gas {
if is_cold {
config.gas_account_access_cold
} else {
config.gas_storage_read_warm
}
} else {
0
regular_value
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/standard/gasometer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,18 +670,18 @@ impl GasCost {
GasCost::Invalid(opcode) => return Err(ExitException::InvalidOpcode(opcode).into()),

GasCost::ExtCodeSize { target_is_cold } => {
costs::address_access_cost(target_is_cold, config) + config.gas_ext_code
costs::address_access_cost(target_is_cold, config.gas_ext_code, config)
}
GasCost::ExtCodeCopy {
target_is_cold,
len,
} => costs::extcodecopy_cost(len, target_is_cold, config)?,
GasCost::Balance { target_is_cold } => {
costs::address_access_cost(target_is_cold, config) + config.gas_balance
costs::address_access_cost(target_is_cold, config.gas_balance, config)
}
GasCost::BlockHash => consts::G_BLOCKHASH,
GasCost::ExtCodeHash { target_is_cold } => {
costs::address_access_cost(target_is_cold, config) + config.gas_ext_code_hash
costs::address_access_cost(target_is_cold, config.gas_ext_code_hash, config)
}
})
}
Expand Down

0 comments on commit 9e55b21

Please sign in to comment.