ethernaut icon indicating copy to clipboard operation
ethernaut copied to clipboard

Solidity 0.5 Version: Levels marked as `Completed` when not attempted

Open abcoathup opened this issue 5 years ago • 4 comments

Reported by a community member via email:

Levels 10 and 11 show as 'Completed' with blue ticks in front of them when they had not been attempted in the Solidity 0.5 Version. Refreshing and hard-refreshing, as well as disabling and re-enabling MetaMask plugin did not resolve.


I have seen something similar previously but haven't been able to reproduce.

abcoathup avatar Dec 03 '19 23:12 abcoathup

Same happened to me, Token and Delegation appeared as completed after I solved Telephone :thinking:

tinchoabbate avatar Dec 04 '19 19:12 tinchoabbate

I now have a number of levels showing as completed:

  1. Re-entrancy ✔
  2. Elevator ✔
  3. Privacy ✔
  4. Gatekeeper One
  5. Gatekeeper Two ✔
  6. Naught Coin ✔
  7. Preservation ✔
  8. Recovery ✔
  9. MagicNumber ✔
  10. Alien Codex
  11. Denial ✔
  12. Shop

abcoathup avatar Dec 06 '19 05:12 abcoathup

I'm trying to track this down.

Completed levels are tracked in LocalStorage (see https://github.com/OpenZeppelin/ethernaut/blob/solidity-05/src/reducers/playerReducer.js#L36-L62). Removing the level from LocalStorage manually puts things back to normal.

The SUBMIT_LEVEL_INSTANCE action is triggered here by a listener: https://github.com/OpenZeppelin/ethernaut/blob/solidity-05/src/middlewares/syncPlayerProgress.js#L16-L41. So my first guess is that there's something going on with the event being watched, that may be triggering the action which sets the level as completed. Here we can see which changes suffered after the PR updating to Solidity 0.5: https://github.com/OpenZeppelin/ethernaut/pull/151/files#diff-a0fd93803dc376f8b086ec3611f9ad88

By I still haven't figured the why.

tinchoabbate avatar Dec 06 '19 14:12 tinchoabbate

I seem to have found the culprit. In https://github.com/OpenZeppelin/ethernaut/blob/solidity-05/src/middlewares/syncPlayerProgress.js#L16-L18 we don't seem to be filtering appropriately. According to https://web3js.readthedocs.io/en/v1.2.2/web3-eth-contract.html#contract-events, we should be doing:

const log = state.contracts.ethernaut.LevelCompletedLog(
    { filter: { player: state.player.address } }
);

tinchoabbate avatar Dec 06 '19 15:12 tinchoabbate

Closing since it's fixed

xaler5 avatar Nov 17 '22 09:11 xaler5