Skip to content

Duplicated calculation in eth_estimateGas. #1584

@chaoticlonghair

Description

@chaoticlonghair

Description

When call eth_estimateGas to estimate gas used, the gas calculation for create-tx, call-tx and tx.data are incorrect and duplicated.

let base_gas = if to.is_some() {
GAS_CALL_TRANSACTION + data_gas_cost(&data)
} else {
GAS_CREATE_TRANSACTION + GAS_CALL_TRANSACTION + data_gas_cost(&data)
};

let used_gas = executor.used_gas() + base_gas;


For Example

  • Do simplest transfer transaction.

    Data Size1 Estimated in Axon Actual in Axon Estimated in Geth Actual in Geth
    0 42000 21000 21000 21000
    1 42084 21016 21016 21016
    2 42168 21032 21032 21032

Appendix: More Unit Tests are Required

  • Call eth_estimateGas for a transaction whose gas is set to a value that greater than u64::MAX, will cause Axon panic.

    .map(|gas| gas.as_u64())

    There is already an in-process PR.

    I just record it here, and request a unit test for it, after that PR merged.

Footnotes

  1. Set the transaction.data to be N non-zero bytes.

Metadata

Metadata

Labels

t:bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions