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 inconsistencies related to best chain order in RFC and state impl #1267

Merged
merged 1 commit into from
Nov 9, 2020

Conversation

yaahc
Copy link
Contributor

@yaahc yaahc commented Nov 6, 2020

Motivation

Prior to this PR we realized that the RFC had been drafted with the assumption that chains would be ordered from best to worst in NonFinalizedState. This assumption was incorrect, since BTreeSet only ever orders values in ascending order. This discrepancy was noticed and fixed in the code, but there were still some inconsistencies that needed to be cleaned up.

Solution

This PR updates all the incorrect or confusing comments about chain ordering in the RFC and code.

The code in this pull request has:

  • Documentation Comments
  • Unit Tests and Property Tests

Review

@teor2345

Related Issues

Follow Up Work

@yaahc yaahc marked this pull request as draft November 6, 2020 23:02
@yaahc yaahc changed the base branch from main to memory-state-split November 6, 2020 23:03
@yaahc yaahc self-assigned this Nov 6, 2020
@yaahc yaahc added the S-blocked Status: Blocked on other tasks label Nov 6, 2020
@yaahc
Copy link
Contributor Author

yaahc commented Nov 6, 2020

blocked until #1258 merges

@@ -93,6 +93,7 @@ impl NonFinalizedState {
pub fn any_chain_contains(&self, hash: &block::Hash) -> bool {
self.chain_set
.iter()
.rev()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isn't strictly necessary but I thought it would be best for us to iterate in best chain order when searching for hashes.

Base automatically changed from memory-state-split to main November 9, 2020 18:05
@yaahc yaahc removed the S-blocked Status: Blocked on other tasks label Nov 9, 2020
@yaahc yaahc marked this pull request as ready for review November 9, 2020 20:54
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

@yaahc can you rebase the chain order PR so it only contains relevant changes?
Then I can do a review.

I think the "Reorganize memory_state to avoid giant test module" commit has been merged to main.

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for updating the RFC.

@yaahc yaahc merged commit 34f50d7 into main Nov 9, 2020
@yaahc yaahc deleted the jane/ord-doc branch November 9, 2020 23:53
mergify bot pushed a commit that referenced this pull request May 23, 2023
* ZIPs were updated to remove ambiguity, this was tracked in #1267.

* #2105 was fixed by #3039 and #2379 was closed by #3069

* #2230 was a duplicate of #2231 which was closed by #2511

* #3235 was obsoleted by #2156 which was fixed by #3505

* #1850 was fixed by #2944, #1851 was fixed by #2961 and #2902 was fixed by #2969

* We migrated to Rust 2021 edition in Jan 2022 with #3332

* #1631 was closed as not needed

* #338 was fixed by #3040 and #1162 was fixed by #3067

* #2079 was fixed by #2445

* #4794 was fixed by #6122

* #1678 stopped being an issue

* #3151 was fixed by #3934

* #3204 was closed as not needed

* #1213 was fixed by #4586

* #1774 was closed as not needed

* #4633 was closed as not needed

* Clarify behaviour of difficulty spacing

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour

Co-authored-by: teor <teor@riseup.net>

* Update comment to reflect implemented behaviour when retrying block downloads

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify when we might want to fix

Co-authored-by: teor <teor@riseup.net>

* Update `TODO` to remove closed issue and clarify what we might want to change in future

Co-authored-by: teor <teor@riseup.net>

* Clarify benefits of how we do block verification

Co-authored-by: teor <teor@riseup.net>

* Fix rustfmt errors

---------

Co-authored-by: teor <teor@riseup.net>
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.

2 participants