Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Dec 12, 2023
1 parent 01de9d3 commit 2e32df3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 7 additions & 7 deletions client/consensus/grandpa/finality_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
// The requested block has not yet been finalized
errBlockNotYetFinalized = errors.New("block not yet finalized")
// The requested block is not covered by authority set changes. Likely this means the block is
// in the authoritySetChangeIDLatest authority set, and the subscription API is more appropriate
// in the latest authority set, and the subscription API is more appropriate
errBlockNotInAuthoritySetChanges = errors.New("block not covered by authority set changes")
)

Expand All @@ -57,8 +57,8 @@ type FinalityProofProvider[
// NewFinalityProofProvider Create new finality proof provider using:
//
// - backend for accessing blockchain data;
// - authority_provider for calling and proving runtime methods.
// - shared_authority_set for accessing authority set data
// - authorityProvider for calling and proving runtime methods.
// - sharedAuthoritySet for accessing authority set data
func NewFinalityProofProvider[
BE Backend[Hash, N, H, B],
Hash constraints.Ordered,
Expand Down Expand Up @@ -98,7 +98,7 @@ func (provider FinalityProofProvider[BE, H, N, S, ID, Header, B]) ProveFinality(
// Prove finality for the given block number by returning a Justification for the last block of
// the authority set.
//
// If `collect_unknown_headers` is true, the finality proof will include all headers from the
// If `collectUnknownHeaders` is true, the finality proof will include all headers from the
// requested block until the block the justification refers to.
func (provider FinalityProofProvider[BE, Hash, N, S, ID, H, B]) proveFinalityProof(
block N,
Expand All @@ -123,15 +123,15 @@ type FinalityProof[Hash constraints.Ordered, N constraints.Unsigned, H Header[Ha
Block Hash
// Justification of the block F
Justification []byte
// The set of headers in the range (B; F] that we believe are authoritySetChangeIDUnknown to the caller. Ordered.
// The set of headers in the range (B; F] that we believe are unknown to the caller. Ordered.
UnknownHeaders []H
}

// Prove finality for the given block number by returning a justification for the last block of
// the authority set of which the given block is part of, or a justification for the authoritySetChangeIDLatest
// the authority set of which the given block is part of, or a justification for the latest
// finalized block if the given block is part of the current authority set.
//
// If `collect_unknown_headers` is true, the finality proof will include all headers from the
// If `collectUnknownHeaders` is true, the finality proof will include all headers from the
// requested block until the block the justification refers to.
func proveFinality[
BE Backend[Hash, N, H, B],
Expand Down
6 changes: 0 additions & 6 deletions client/consensus/grandpa/finality_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ func checkFinalityProof[
H Header[Hash, N],
ID AuthorityID,
](
t *testing.T,
currentSetID uint64,
currentAuthorities AuthorityList[ID],
remoteProof []byte,
) (FinalityProof[Hash, N, H], error) {
t.Helper()
proof := FinalityProof[Hash, N, H]{}
err := scale.Unmarshal(remoteProof, &proof)
if err != nil {
Expand Down Expand Up @@ -166,7 +164,6 @@ func TestFinalityProof_CheckFailsWhenProofDecodeFails(t *testing.T) {
// When we can't decode proof from Vec<u8>
authorityList := AuthorityList[dummyAuthID]{}
_, err := checkFinalityProof[string, uint, string, testHeader[string, uint], dummyAuthID](
t,
1,
authorityList,
[]byte{42},
Expand All @@ -186,7 +183,6 @@ func TestFinalityProof_CheckFailsWhenProofIsEmpty(t *testing.T) {
encJustification, err := scale.Marshal(grandpaJustification)
require.NoError(t, err)
_, err = checkFinalityProof[string, uint, string, testHeader[string, uint], dummyAuthID](
t,
1,
authorityList,
encJustification,
Expand Down Expand Up @@ -219,7 +215,6 @@ func TestFinalityProof_CheckFailsWithIncompleteJustification(t *testing.T) {
}

_, err := checkFinalityProof[string, uint, string, testHeader[string, uint], dummyAuthID](
t,
1,
authorityList,
scale.MustMarshal(finalityProof),
Expand Down Expand Up @@ -250,7 +245,6 @@ func TestFinalityProof_CheckWorksWithCorrectJustification(t *testing.T) {
}

newFinalityProof, err := checkFinalityProof[string, uint, string, testHeader[string, uint], dummyAuthID](
t,
1,
authorityList,
scale.MustMarshal(finalityProof),
Expand Down

0 comments on commit 2e32df3

Please sign in to comment.