-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Prefer ledger by branch #2300
Closed
Closed
Prefer ledger by branch #2300
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
36de9a2
[FOLD] Prepare preferred ledger by branch test:
bachase 5e35cf9
[FOLD] Add LedgerTrie and tests
bachase 72e7ac9
[FOLD] Switch to Adaptor design in Validations:
bachase 0685beb
[FOLD] Add full/partial to validation type
bachase 62a9c73
[FOLD] Simplify Validations test harness:
bachase 892caad
[FOLD] Hoist and rename AddOutcome to ValStatus
bachase 085e400
[FOLD] Make lock use explicit
bachase 2abf766
[FOLD] Require full validations for trusted calculations
bachase f4c8644
[FOLD] Simplify Validations::add:
bachase 9187516
[FOLD] Require increasing full validation sequence numbers:
bachase 6d3c2e0
[FOLD] Use Ledgers in Validations_test:
bachase fa1a96e
[FOLD] Add RCLValidatedLedger:
bachase bd2b860
[FOLD] Don't save partial validations to database
bachase f0e6efd
[FOLD] Use LedgerTrie in generic validations:
bachase c614718
[FOLD] Use trie in generic Consensus:
bachase 8315578
Use LedgerTrie for preferred ledger (RIPD-1551):
bachase b5f528a
[FOLD] Update docs
bachase fa576e5
[FOLD] Remove old validation code
bachase 9501278
[FOLD] Fix misspellings
seelabs 329ca88
[FOLD] Fix clang PeerGroup warnings
bachase ad35ee2
[FOLD] Address PR suggestions
bachase cff3191
[FOLD] Make a few memer functions const
HowardHinnant f9de5be
[FOLD] Change full validation sequence number invariant:
bachase fd58f28
[FOLD] Address PR comments
bachase 2b2ba69
[FOLD] Explicitly initialize zero IDs
bachase 0b58ac4
[FOLD] Address PR comments:
bachase 7cdd0e7
[FOLD] Move support classes to namespace
bachase 961747f
[FOLD] Fix assert
bachase 37c583d
[FOLD] Enforce increasing sequence invariant on all validations:
bachase b6e19b7
[FOLD] Use uncommitted support in preferred branch:
bachase 0ccf0a8
[FOLD] Reduce log warnings:
bachase 277134b
[FOLD] Address PR comments
bachase 83d5d55
[FOLD] Fix typos
bachase 944527d
[FOLD] Only acquire ledgers we are not yet acquiring
bachase ea18089
[FOLD] Add SpanTip:
bachase 2a97f83
[FOLD] Address PR comments
bachase 5fd14de
[FOLD] Track seq and ID in acquiring ledgers
bachase f0bdfe1
[FOLD] Fallback to acquiring ledgers:
bachase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,46 @@ | |
|
||
namespace ripple { | ||
|
||
/** The tip of a span of ledger ancestry | ||
*/ | ||
template <class Ledger> | ||
class SpanTip | ||
{ | ||
public: | ||
using Seq = typename Ledger::Seq; | ||
using ID = typename Ledger::ID; | ||
|
||
SpanTip(Seq s, ID i, Ledger const lgr) | ||
: seq{s}, id{i}, ledger{std::move(lgr)} | ||
{ | ||
} | ||
|
||
// The sequence number the tip ledger | ||
Seq seq; | ||
// The ID of the tip ledger | ||
ID id; | ||
|
||
/** Lookup the ID of an ancestor of the tip ledger | ||
|
||
@param s The sequence number of the ancestor | ||
@return The ID of the ancestor with that sequence number | ||
|
||
@note s must be less than or equal to the sequence number of the | ||
preferred ledger | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should that say |
||
*/ | ||
ID | ||
ancestor(Seq const& s) const | ||
{ | ||
assert(s <= seq); | ||
return ledger[s]; | ||
} | ||
|
||
private: | ||
Ledger const ledger; | ||
}; | ||
|
||
namespace ledger_trie_detail { | ||
|
||
// Represents a span of ancestry of a ledger | ||
template <class Ledger> | ||
class Span | ||
|
@@ -101,12 +140,12 @@ class Span | |
return clamp(mismatch(ledger_, o)); | ||
} | ||
|
||
// The Seq and ID of the end of the span | ||
std::pair<Seq, ID> | ||
// The tip of this span | ||
SpanTip<Ledger> | ||
tip() const | ||
{ | ||
Seq tipSeq{end_ - Seq{1}}; | ||
return {tipSeq, ledger_[tipSeq]}; | ||
return SpanTip<Ledger>{tipSeq, ledger_[tipSeq], ledger_}; | ||
} | ||
|
||
private: | ||
|
@@ -137,7 +176,7 @@ class Span | |
friend std::ostream& | ||
operator<<(std::ostream& o, Span const& s) | ||
{ | ||
return o << s.tip().second << "[" << s.start_ << "," << s.end_ << ")"; | ||
return o << s.tip().id << "[" << s.start_ << "," << s.end_ << ")"; | ||
} | ||
|
||
friend Span | ||
|
@@ -203,8 +242,8 @@ struct Node | |
getJson() const | ||
{ | ||
Json::Value res; | ||
res["id"] = to_string(span.tip().second); | ||
res["seq"] = static_cast<std::uint32_t>(span.tip().first); | ||
res["id"] = to_string(span.tip().id); | ||
res["seq"] = static_cast<std::uint32_t>(span.tip().seq); | ||
res["tipSupport"] = tipSupport; | ||
res["branchSupport"] = branchSupport; | ||
if (!children.empty()) | ||
|
@@ -407,7 +446,6 @@ class LedgerTrie | |
boost::optional<Span> oldSuffix = loc->span.from(diffSeq); | ||
boost::optional<Span> newSuffix = Span{ledger}.from(diffSeq); | ||
|
||
|
||
if (oldSuffix) | ||
{ | ||
// Have | ||
|
@@ -623,7 +661,7 @@ class LedgerTrie | |
issued by this node. | ||
@return Pair with the sequence number and ID of the preferred ledger | ||
*/ | ||
std::pair<Seq,ID> | ||
SpanTip<Ledger> | ||
getPreferred(Seq const largestIssued) const | ||
{ | ||
Node* curr = root.get(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
->
of the