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

Compare buffers directly #851

Merged
merged 2 commits into from
Sep 9, 2020
Merged

Compare buffers directly #851

merged 2 commits into from
Sep 9, 2020

Conversation

ryanio
Copy link
Contributor

@ryanio ryanio commented Aug 27, 2020

This PR focuses on this point from #775:

There's a huge number of unnecessary calls to toString(). Sometimes it is used instead of Buffer#equals. Sometimes it's called to initialize a BN from a Buffer, instead of just passing the Buffer.

These cases are handled in this PR:

  • Block#validateTransactionsTrie
  • Block#validateUnclesHash
  • Account#isContract
  • Account#setCode
  • Account#isEmpty
  • EEI#getExternalBalance
  • PUSH's handler
  • VM#runBlock
  • VM#runCall
  • VM#runTx
  • DefaultStateManager#accountIsEmpty

These cases were not handled:

  • Block#validateUncles: a Set is used to identify duplicates
  • FakeTransaction#hash, Transaction#toCreationAddress: addressed in refactoring in Refactor tx lib #812

This PR also:

  • Cleans up some found vars to let and const where appropriate
  • Fixes outdated example decode-opcodes
  • Updates ethash rawExample to new async syntax

@codecov
Copy link

codecov bot commented Aug 27, 2020

Codecov Report

Merging #851 into master will increase coverage by 0.79%.
The diff coverage is 75.00%.

Impacted file tree graph

Flag Coverage Δ
#account 92.85% <100.00%> (ø)
#block ?
#blockchain 81.33% <ø> (ø)
#common 94.50% <ø> (+0.17%) ⬆️
#ethash 83.33% <ø> (?)
#tx 94.02% <ø> (ø)
#vm 82.27% <71.42%> (-0.01%) ⬇️

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

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Thanks Ryan, nice, love this kind of PRs! 🥳

Will merge.

@holgerd77 holgerd77 merged commit f9efee5 into master Sep 9, 2020
@holgerd77 holgerd77 deleted the fix-buffer-comparisons branch September 9, 2020 10:27
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.

2 participants