Skip to content

Commit

Permalink
update client/consensus/grandpa comments
Browse files Browse the repository at this point in the history
  • Loading branch information
timwu20 committed Oct 11, 2024
1 parent e02551a commit 76f21a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions internal/client/consensus/grandpa/authorities.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (sas *SharedAuthoritySet[H, N]) applyForcedChanges(bestHash H, //nolint //s
// method ensures that if there are multiple changes in the same branch,
// finalising this block won't finalise past multiple transitions (i.e.
// transitions must be finalised in-order). The given function
// `is_descendent_of` should return `true` if the second hash (target) is a
// `isDescendentOf` should return `true` if the second hash (target) is a
// descendent of the first hash (base).
//
// When the set has changed, the return value will be a status type where newSetBlockInfo
Expand All @@ -172,7 +172,7 @@ func (sas *SharedAuthoritySet[H, N]) applyStandardChanges(finalisedHash H, //nol
// change that can be immediately applied, *false if the block being
// finalised enacts a change but it cannot be applied yet since there are
// other dependent changes, and nil if no change is enacted. The given
// function `is_descendent_of` should return `true` if the second hash
// function `isDescendentOf` should return `true` if the second hash
// (target) is a descendent of the first hash (base).
func (sas *SharedAuthoritySet[H, N]) EnactsStandardChange(finalisedHash H,
finalisedNumber N,
Expand Down Expand Up @@ -277,7 +277,7 @@ func (authSet *AuthoritySet[H, N]) revert() { //nolint //skipcq: SCC-U1000 //ski
}

// Returns the block hash and height at which the next pending HashNumber in
// the given chain (i.e. it includes `best_hash`) was signalled, nil if
// the given chain (i.e. it includes `bestHash`) was signalled, nil if
// there are no pending changes for the given chain.
func (authSet *AuthoritySet[H, N]) nextChange(bestHash H, //skipcq: RVV-B0001
isDescendentOf IsDescendentOf[H]) (*HashNumber[H, N], error) {
Expand Down Expand Up @@ -432,7 +432,7 @@ func (authSet *AuthoritySet[H, N]) addForcedChange(
// on the same branch can be added as long as they don't overlap. Forced
// changes are restricted to one per fork. This method assumes that changes
// on the same branch will be added in-order. The given function
// `is_descendent_of` should return `true` if the second hash (target) is a
// `isDescendentOf` should return `true` if the second hash (target) is a
// descendent of the first hash (base).
func (authSet *AuthoritySet[H, N]) addPendingChange(
pending PendingChange[H, N],
Expand Down Expand Up @@ -570,7 +570,7 @@ func (authSet *AuthoritySet[H, N]) applyForcedChanges(bestHash H, //skipcq: RVV
// method ensures that if there are multiple changes in the same branch,
// finalising this block won't finalise past multiple transitions (i.e.
// transitions must be finalised in-order). The given function
// `is_descendent_of` should return `true` if the second hash (target) is a
// `isDescendantOf` should return `true` if the second hash (target) is a
// descendent of the first hash (base).
//
// When the set has changed, the return value will be a status type where newSetBlock
Expand Down Expand Up @@ -651,7 +651,7 @@ func (authSet *AuthoritySet[H, N]) applyStandardChanges( //skipcq: RVV-B0001
// HashNumber that can be immediately applied, *false if the block being
// finalised enacts a HashNumber but it cannot be applied yet since there are
// other dependent changes, and nil if no HashNumber is enacted. The given
// function `is_descendent_of` should return `true` if the second hash
// function `isDescendentOf` should return `true` if the second hash
// (target) is a descendent of the first hash (base).
func (authSet *AuthoritySet[H, N]) EnactsStandardChange( //skipcq: RVV-B0001
finalisedHash H, finalisedNumber N, isDescendentOf IsDescendentOf[H]) (*bool, error) {
Expand Down
8 changes: 4 additions & 4 deletions internal/client/consensus/grandpa/change_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ func (ct *ChangeTree[H, N]) Roots() []*PendingChangeNode[H, N] { //skipcq: RVV-B

// Import a new node into the roots.
//
// The given function `is_descendent_of` should return `true` if the second
// The given function `isDescendentOf` should return `true` if the second
// hash (target) is a descendent of the first hash (base).
//
// This method assumes that children in the same branch are imported in order.
//
// Returns `true` if the imported node is a root.
// WARNING: some users of this method (i.e. consensus epoch changes roots) currently silently
// rely on a **post-order DFS** traversal. If we are using instead a top-down traversal method
// then the `is_descendent_of` closure, when used after a warp-sync, may end up querying the
// then the `isDescendentOf` closure, when used after a warp-sync, may end up querying the
// backend for a block (the one corresponding to the root) that is not present and thus will
// return a wrong result.
func (ct *ChangeTree[H, N]) Import(hash H,
Expand Down Expand Up @@ -127,7 +127,7 @@ func (ct *ChangeTree[H, N]) getPreOrderChangeNodes() []*PendingChangeNode[H, N]
// a root, *false if the node being finalized is not a root, and
// nil if no node in the tree is finalized. The given `Predicate` is
// checked on the prospective finalized root and must pass for finalisation
// to occur. The given function `is_descendent_of` should return `true` if
// to occur. The given function `isDescendentOf` should return `true` if
// the second hash (target) is a descendent of the first hash (base). func(T) bool
func (ct *ChangeTree[H, N]) FinalizesAnyWithDescendentIf(
hash *H,
Expand Down Expand Up @@ -249,7 +249,7 @@ type unchanged struct{}
// being finalized isn't a descendent of (or equal to) any of the root's
// children. The given `Predicate` is checked on the prospective finalized
// root and must pass for finalisation to occur. The given function
// `is_descendent_of` should return `true` if the second hash (target) is a
// `isDescendentOf` should return `true` if the second hash (target) is a
// descendent of the first hash (base).
func (ct *ChangeTree[H, N]) FinalizeWithDescendentIf(
hash *H,
Expand Down

0 comments on commit 76f21a5

Please sign in to comment.