Bug when using `--hardfork istanbul`
See original GitHub issueExpected Behavior
The code
array.push(variable);
array.push(variable);
should work for Istanbul
.
Current Behavior
We have smart contracts with complex unit tests and use ganache-cli
along with truffle
. Everything works fine if we don’t use --hardfork istanbul
even for 6.8.0-istanbul.0
, but when we activate the istanbul
, there is a pretty weird bug.
Steps to Reproduce
$ git clone -b ganache-istanbul-bug https://github.com/poanetwork/posdao-contracts
$ cd posdao-contracts
$ npm i
$ npm run test
After that, the unit tests are run. On the step staking epoch trufflesuite/ganache-cli#3 finished
you will see revert
failure:
This is the line in test/BlockRewardAuRa.js
which calls BlockRewardAuRa.reward
function which in turn calls ValidatorSetAuRa.newValidatorSet
function.
The ValidatorSetAuRa.newValidatorSet
function calls the internal _setPendingValidators
function. And that _setPendingValidators
reverts here:
// This reverts for some reason:
// _stakingAddresses.length == 4 here and gas is enough
for (uint256 i = 0; i < _stakingAddresses.length; i++) {
_pendingValidators.push(_stakingAddresses[0]);
}
If we remove the --hardfork istanbul
flag from our cli parameters, the test works fine as it should.
Please, take a look at these lines (and the comments there): https://github.com/poanetwork/posdao-contracts/blob/b0abf0cfd50bb78894b744f2f5fd6734054a476c/contracts/ValidatorSetAuRa.sol#L787-L808
It seems that the issue somehow relates to these lines which modificate the _pendingValidators
array. The bug is only reproduced after those lines are executed in the same block.
Context
This issue doesn’t let us test our contracts for Istanbul
.
Your Environment
- Version used: 6.8.0-istanbul.0
- Version of Truffle used: 5.0.34
- NodeJS Version: v8.16.0
- Operating System and version: macOS High Sierra 10.13.6
- Link to your project or repro gist: https://github.com/poanetwork/posdao-contracts/tree/ganache-istanbul-bug
- Commit hash to use with above link for reproduction: b0abf0cfd50bb78894b744f2f5fd6734054a476c
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Unless there’s a bug. I thought EIP-2200 because that seems to be the only istanbul-relevant code that this contract snippet touches.
I recently started to make the VM pass the istanbul state tests in https://github.com/ethereumjs/ethereumjs-vm/pull/607. If there’s a bug in the VM it’ll most likely surface there.
Closing for issue maintenance. Let us know if you’re still running into this, and we’ll be happy to re-open. Thanks!