Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Bug when using --hardfork istanbul #511

Closed
@varasev

Description

Expected 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:

image

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions