Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hevm: UnitTest.hs: fix nonce initialisation bug (fixes #222) #224

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

livnev
Copy link
Member

@livnev livnev commented Jun 14, 2019

this was an old, unnoticed bug in the unit-test runner, which was
brought to light when correct EIP684 collision semantics were recently
introduced. The nonce was being incorrectly reset to that of the
ethrun account, to adjust for it being potentially incremented during
the execution of the test contract's constructor, if that constructor
itself contains contract creations. However, since the creation
happens on behalf of the test contract, and not the ethrun address,
the nonce should be left as is, since replaceCode will propagate the
correct nonce.

Presumably this mistake was made because prior to commit
070cc9e, the nonce didn't get
propagated after a creation at all, so this line was introduced in a
flawed attempt to propagate it.

Any dapp tests which had creations inside the constructor (including
implicit creations that initialise storage variables) would have had
their nonces set incorrectly, and were also assigned the wrong
addresses. This had gone unnoticed since previously hevm would
overwrite on contract collisions, instead of throwing (which is the
correct behaviour). Creations in setUp() were not affected.

Fixes #222

cc @gbalabasquer @rainbreak

livnev and others added 2 commits June 14, 2019 11:29
this was an old, unnoticed bug in the unit-test runner, which was
brought to light when correct EIP684 collision semantics were recently
introduced. The nonce was being incorrectly reset to that of the
ethrun account, to adjust for it being potentially incremented during
the execution of the test contract's constructor, if that constructor
itself contains contract creations. However, since the creation
happens on behalf of the test contract, and not the ethrun address,
the nonce should be left as is, since replaceCode will propagate the
correct nonce.

Presumably this mistake was made because prior to commit
070cc9e, the nonce didn't get
propagated after a creation at all, so this line was introduced in a
flawed attempt to propagate it.

Any dapp tests which had creations inside the constructor (including
implicit creations that initialise storage variables) would have had
their nonces set incorrectly, and were also assigned the wrong
addresses. This had gone unnoticed since previously hevm would
overwrite on contract collisions, instead of throwing (which is the
correct behaviour). Creations in setUp() were not affected.
@rainbreak rainbreak merged commit 5fd1c52 into master Jun 14, 2019
@rainbreak rainbreak deleted the fix-nonce branch June 14, 2019 17:14
asymmetric added a commit to makerdao/makerpkgs that referenced this pull request Jun 18, 2019
The nonce issue in hevm has been fixed in [224](dapphub/dapptools#224).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hevm: weird failure on test case
2 participants