Precomiles functions having more cost than contracts
surangap opened this issue · comments
surangap commented
After #639, and the extra fee refunds were corrected, now a few precompile functions cost more than their contract counterparts. listed below
- ERC20::transferFrom
- ERC721::transferOwnership
- ERC721::renounceOwnership
surangap commented
Investigation so far
contract actual gas used drastically reduces from it’s estimate. this causes the difference.
ERC20
before
## Generated tx costs(Gas) for ERC20 Precompiles
| Function Call | Contract gas | Precompile gas | (Extrinsic fee/Gas price) |
|:--------------|:------------:|:--------------:|:-------------------------:|
| totalSupply | 23717 | 22388 | 0 |
| balanceOf | 25860 | 23974 | 0 |
| allowance | 26064 | 23273 | 0 |
| approval | 47152 | 26359 | 19503 |
| transfer | 50730 | 23241 | 19505 |
| transferFrom | 35619 | 32411 | 22840 |
| name | 25926 | 22388 | 0 |
| decimals | 22354 | 22388 | 0 |
| symbol | 25945 | 22388 | 0 |
## Generated tx costs(fees) for ERC20 Precompiles
| Function Call | Contract cost (Drops) | Precompile cost (Drops) | Extrinsic cost (Drops) |
|:--------------|:---------------------:|:-----------------------:|:----------------------:|
| approval | 1414631 | 790810 | 292552 |
| transfer | 1521977 | 697365 | 292588 |
| transferFrom | 1068624 | 972279 | 342607 |
contract actual gas transferFrom: BigNumber { value: "27792" }
precompile actual gas transferFrom: BigNumber { value: "31345" }
after
## Generated tx costs(Gas) for ERC20 Precompiles
| Function Call | Contract gas | Precompile gas | (Extrinsic fee/Gas price) |
|:--------------|:------------:|:--------------:|:-------------------------:|
| totalSupply | 23717 | 22388 | 0 |
| balanceOf | 25860 | 23974 | 0 |
| allowance | 26064 | 23273 | 0 |
| approval | 47152 | 26359 | 19503 |
| transfer | 50730 | 23241 | 19505 |
| transferFrom | 35619 | 32411 | 22840 |
| name | 25926 | 22388 | 0 |
| decimals | 22354 | 22388 | 0 |
| symbol | 25945 | 22388 | 0 |
## Generated tx costs(fees) for ERC20 Precompiles
| Function Call | Contract cost (Drops) | Precompile cost (Drops) | Extrinsic cost (Drops) |
|:--------------|:---------------------:|:-----------------------:|:----------------------:|
| approval | 702835 | 390894 | 292552 |
| transfer | 739318 | 344249 | 292588 |
| transferFrom | 416921 | 470122 | 342607 |
contract actual gas transferFrom: BigNumber { value: "27792" }
precompile actual gas transferFrom: BigNumber { value: "31345" }