I need help understanding why the first push to a dynamic array is more gas consuming.
For example, executing the push endpoint in the following code:
pragma solidity >0.7.0 <0.8.0;
contract PushTest{
uint[] array;
function push ( uint amount) external {
array.push(amount);
}
}
The first push consumes 41129 gas, while the second one only consumes 26129. I tried to debug the execution with Remix but apparently the same EVM instructions are being executed for the first and following pushes.