Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Local test stack becomes more expensive over time #227

Open
CAPtheorem opened this issue Dec 12, 2021 · 3 comments
Open

Local test stack becomes more expensive over time #227

CAPtheorem opened this issue Dec 12, 2021 · 3 comments
Assignees

Comments

@CAPtheorem
Copy link
Contributor

CAPtheorem commented Dec 12, 2021

When contracts are deployed right after test stack startup, the cost is minor:

  Deployment gasUsed: 1648702
    Deployment cumulativeGasUsed: 1648702
    Helper contract deployed as 0x6823D92A6BFA703978D3E9d81aB7A32f0Af88129 on L2
    Remaining funds: 4999.999999496651897609 ETH

  RegisterMethod TX gasUsed: 66756
    RegisterMethod TX cumulativeGasUsed: 66756
    Remaining funds: 4999.999999495919530853 ETH

  Deployment gasUsed: 1527133
    Deployment cumulativeGasUsed: 1527133
    Test contract deployed as 0x821638926FAF1C7d17F2a23367aD06A807b93a8C
    Remaining funds: 4999.99999947854170372 ETH

but if those same contracts are deployed e.g. 100 times, then at some point, each deployment costs about 10 ETH:

  Deployment gasUsed: 1648702
    Deployment cumulativeGasUsed: 1648702
    Helper contract deployed as 0x13b1900CFF42994842b0e8f60d71721bE180d7F9 on L2
    Remaining funds: 4848.997919261799172203 ETH

  RegisterMethod TX gasUsed: 66756
    RegisterMethod TX cumulativeGasUsed: 66756
    Remaining funds: 4839.560289261476955047 ETH

  Deployment gasUsed: 1527133
    Deployment cumulativeGasUsed: 1527133
    Test contract deployed as 0x9cfce1D02581E8f0eC2a5e9797d5F6870779edba
    Remaining funds: 4830.12265924450927777 ETH

Notably, the gasUsed and the cumulativeGasUsed are constant. Hypothesis - gas-price-oracle setting itself to a new, higher value after a timeout?

@boyuan-chen
Copy link
Contributor

boyuan-chen commented Dec 21, 2021

The gas-price-oracle doesn't work locally due to miss the ADDRESS_MANAGER_ADDRESS. I created a PR to fix the gas-price-oracle. #244

@mmontour1306
Copy link
Contributor

The initial gas price in docker-compose.yml also needs to be set to a reasonable value (currently at 1 wei): [https://github.com/omgnetwork/optimism-v2/blob/0b8a3f1ba81dc0d08171c6d5232877fee4571f80/ops/docker-compose.yml#L162]

@boyuan-chen
Copy link
Contributor

boyuan-chen commented Dec 21, 2021

I updated two things. The first thing is GAS_PRICE_ORACLE_DECIMALS=6, so it reduces l1GasFee.

  function getL1Fee(bytes memory _data) public view returns (uint256) {
    uint256 l1GasUsed = getL1GasUsed(_data);
    uint256 l1Fee = l1GasUsed * l1BaseFee;
    uint256 divisor = 10**decimals; // GAS_PRICE_ORACLE_DECIMALS = decimals
    uint256 unscaled = l1Fee * scalar; 
    uint256 scaled = unscaled / divisor;
    return scaled;
  }

The second thing is that the GAS_PRICE_ORACLE_FLOOR_PRICE and GAS_PRICE_ORACLE_ROOF_PRICE are updated for the gas-price-oracle in #244 .

Also, the gas-price-oracle updates the overhead price. However, it doesn't work in the production. I commented it out in this PR: #242 {"level":30,"time":1640127268154,"overheadGas":151855912199630,"msg":"Updated overhead gas"}

The problem is solved. The root problem is GAS_PRICE_ORACLE_DECIMALS=1, which increases the L1GasFee a lot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants