Skip to content

unexpected high gas used with bootstrap predeploy #2819

@shunjizhan

Description

@shunjizhan

when calling bootstrap multiple times, gasUsed will be extremely high after the first time.

Reproduce

prepare

  • checkout this branch
  • put KEY=<yout private key> into .env, make sure you have enough jitosol (>1) and ACA (>20) on acala fork testnet for testing
  • yarn build

route bootstrap without gasdrop

GAS_DROP=0 yarn hardhat run scripts/test.ts --network acalaFork

this will perform deployDropAndBootstrapStakeRouter for 2 times, and we can observe that in the second run, gasUsed is extremely high, which is abnormal.

-------------------- RUN 0 --------------------
{
  usedGas: '49,773',
  usedStorage: '-64'
}
{
  usedGas: '3,008,857',    // looks normal
  usedStorage: '22,974'    // expected since we need to deploy router for the first time
}

-------------------- RUN 1 --------------------
{
  usedGas: '49,773',
  usedStorage: '-64'
}
{
  usedGas: '24,592,742',  // ❓❓❓
  usedStorage: '0'        // expected since we do not need to deploy router now
}

route bootstrap with gasdrop 3 ACA

GAS_DROP=3 yarn hardhat run scripts/test.ts --network acalaFork

with gas drop, first run is fine, but second run will fail. My guess is that gasUsed will exceed block gas limit

-------------------- RUN 0 --------------------
{
  usedGas: '49,773',
  usedStorage: '-64'
}
{
  usedGas: '3,043,770',
  usedStorage: '22,974'    // expected since we need to deploy router for the first time
}

-------------------- RUN 1 --------------------
Error: cannot estimate gas; transaction may fail or may require manual gas limit
...
execution reverted: TRANSFER_FROM_FAILED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions