-
Notifications
You must be signed in to change notification settings - Fork 773
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
Blockchain: Add reorg test + do not skip any reorg test in VM #926
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
aacf3b3
to
b82f7a0
Compare
@ryanio had to rebase this one, could you re-approve? 😄 |
st.end() | ||
} | ||
) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really a beautiful beautiful test 🤩 , would even call this educational. Great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and all the comments along are fantastic)
Closes #879
This PR cherry-picks from #895 and does:
In this test, we create two chains: one chain which has a low difficulty and another one which has a higher difficulty, but this chain is actually 1 block behind the other chain. This is possible due to the difficulty formula: if time since last block > 18 seconds, decrease the difficulty, if it is < 9 seconds, increase the difficulty. Block number is thus not a good identifier to find the "best chain" (which has the highest sum of difficulties, i.e. the Total Difficulty). In practice, this test first writes 65 blocks to the chain. Then it puts all the blocks in (64 blocks) which have a higher total difficulty: this thus re-orgs 65 blocks. Without any necessary change this test passes. Thus, we can also: