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

Fix Constantinople tests #931

Merged
merged 9 commits into from
Oct 29, 2020
Merged

Fix Constantinople tests #931

merged 9 commits into from
Oct 29, 2020

Conversation

evertonfraga
Copy link
Contributor

Thanks for the contribution, @jochem-brouwer!

Closes #928 and fixes nightly builds.

@evertonfraga evertonfraga requested a review from cgewecke October 28, 2020 23:01
@codecov
Copy link

codecov bot commented Oct 28, 2020

Codecov Report

Merging #931 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

Flag Coverage Δ
#block 76.06% <ø> (ø)
#blockchain 80.33% <ø> (ø)
#common 92.03% <ø> (ø)
#ethash 82.08% <ø> (ø)
#tx 88.18% <ø> (ø)
#vm 87.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@jochem-brouwer
Copy link
Member

Can we run the Constantinople tests in this PR just to (double) make sure that my claim it is fixed is actually true? 😄

@evertonfraga
Copy link
Contributor Author

@jochem-brouwer sure! doing it now

@jochem-brouwer
Copy link
Member

Heh. Looks like other tests are now failing 😅 I could take a look at this tomorrow.

} else if (value.length !== 0 && !found.length) {
runState.eei.useGas(new BN(runState._common.param('gasPrices', 'sstoreSet')))
}
}
await runState.eei.storageStore(keyBuf, value)
Copy link
Contributor

@cgewecke cgewecke Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes this make sense, sorry and thanks! 🙂

Perhaps the misplaced stuff could also go in a function in opcodes/utils as updateSstoreGas?

      updateSstoreGas(runState, found, setLengthLeftStorage(value))
      updateSstoreGasEIP1283(runState, found, setLengthLeftStorage(value))
      updateSstoreGasEIP2200(runState, found, setLengthLeftStorage(value), keyBuf)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep great suggestion! I will also move the HF logic inside the SSTORE, because otherwise it seems that it updates SSTORE gas 3 times (which is not the case)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, yes that's a lot clearer now 💯

vm: move HF-selection logic for SSTORE gas into functions
vm: move HF-selection logic for SSTORE gas into functions

vm: remove HF selection logic
@ryanio
Copy link
Contributor

ryanio commented Oct 29, 2020

Great PR :) It looks like all the uses of adjustSstoreGasEIP2929 are being wrapped in a new BN, should we just alter the function to return a BN and simplify some of the syntax?

@jochem-brouwer
Copy link
Member

jochem-brouwer commented Oct 29, 2020

Can you point to these lines @ryanio ?

These new BN things are very misleading, I never understood why this was done in the first place as especially the new keyword implies that you are actually creating a new (i.e. independent) object.

However...

> a = new BN(1)
<BN: 1>
> b = new BN(a)
<BN: 1>
> b.iaddn(1)
<BN: 2>
> a
<BN: 2>
> b
<BN: 2>

@ryanio
Copy link
Contributor

ryanio commented Oct 29, 2020

These new BN things are very misleading, I never understood why this was done in the first place as especially the new keyword implies that you are actually creating a new (i.e. independent) object.

Yeah I find that confusing as well, that clone() is actually needed to create a new independent object. I would also expect it to be part of the new BN initialization.

re: adjustSstoreGasEIP2929, just look at all its uses here in the PR, it's returning a number but always needing to be wrapped as a BN, so my suggestion is to make the return value a BN so we can reduce some of these crazy amount of new BNs.

Most of it is common.param though, which we can possibly take in another PR, as you suggest in #914, would be pretty great to have that return a BN I think that would possibly reduce 100s of extra new BNs. I guess just being nit picky here, no stopper 😆

@jochem-brouwer
Copy link
Member

Ah I see! Just a note here these new BNs are not introduced here, might look like it due to the diff but it is merely copying the original logic around.

I think it would be great to do this in a seperate PR, possibly together with #914

@ryanio
Copy link
Contributor

ryanio commented Oct 29, 2020

ah right ok, yeah sounds like something good for future work then. This LGTM then!

@jochem-brouwer jochem-brouwer merged commit dbcd46c into master Oct 29, 2020
@jochem-brouwer jochem-brouwer deleted the fix-constantinople-tests branch October 29, 2020 21:21
@holgerd77
Copy link
Member

@jochem-brouwer Great stuff here! 😄

Could you please update this post-merge with a proper title and a short description on what was broken respectively has been fixed for the release notes? Thanks!

@holgerd77
Copy link
Member

(also can please everyone try hard to internalize our new process of upgrading the release notes along PRs 😜 and then hopefully directly add to the release notes on PRs and also mention missing release notes on PR reviews? Seems this is still forgotten 80%+ of the times 😋 🎃 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing nightly build
5 participants