I have this contract
contract Contract {
function a() external {
assembly {
return(0, 1000000)
}
}
}
I am calculating the gas cost for a call to a
.
Following https://github.com/wolflo/evm-opcodes/blob/main/gas.md#a0-1-memory-expansion,
I have roughly:
gas = (1e6/32)^2/512 + (1e6/32)*3 ~ 2M
Running the transaction via hardhat returns a gas of ~4M. Why is it double? I also changed the size in the return, and confirmed the quadratic behavior, but there is this factor 2 I can't understand.