Where can I find the source code file where the EVM extracts the gas cost of all OPCODES? What I need is the file where the EVM calculates the gas cost of SLOAD, ADD, etc. For example, hardhat-gas-reporter plugin is able to calculate the gas cost of a smart contract's functions. From where do they get this information?
1 Answer
You can find gas prices that Hardhat uses from ethereumjs-monorepo.
For instance, DELEGATECALL
opcode was introduced with HomeStead hardfork, and the base fee is found here.
I'm assuming that these gas fees are referenced from the yellowpaper and additional EIPs are drawn from the Ethereum Github repository. e.g. EIP-7(homestead hardfork).