From 66a31fa4b9f13ce2f50367ff7d3927114ed0e8a8 Mon Sep 17 00:00:00 2001 From: jimboj Date: Tue, 15 Aug 2023 14:32:42 -0600 Subject: [PATCH] respond to feedback --- client/consensus/grandpa/authorities.go | 36 +++++----- client/consensus/grandpa/authorities_test.go | 66 +++++++++---------- .../grandpa/{auxSchema.go => aux_schema.go} | 29 ++++---- .../{auxSchema_test.go => aux_schema_test.go} | 26 ++++---- client/consensus/grandpa/environment_test.go | 16 ++--- client/consensus/grandpa/interfaces.go | 2 +- 6 files changed, 90 insertions(+), 85 deletions(-) rename client/consensus/grandpa/{auxSchema.go => aux_schema.go} (92%) rename client/consensus/grandpa/{auxSchema_test.go => aux_schema_test.go} (95%) diff --git a/client/consensus/grandpa/authorities.go b/client/consensus/grandpa/authorities.go index a2678d11ab7..6bdb2256e50 100644 --- a/client/consensus/grandpa/authorities.go +++ b/client/consensus/grandpa/authorities.go @@ -60,7 +60,7 @@ type IsDescendentOf[H comparable] func(base, target H) (bool, error) // setIDNumber represents the set id and block number of an authority set hashNumber type setIDNumber[N constraints.Unsigned] struct { - SetId uint64 + SetID uint64 BlockNumber N } @@ -199,7 +199,7 @@ type AuthoritySet[H comparable, N constraints.Unsigned] struct { // The current active authorities. CurrentAuthorities AuthorityList // The current set id. - SetId uint64 + SetID uint64 // Tree of pending standard changes across forks. Standard changes are // enacted on finality and must be enacted (i.e. finalized) in-order across // a given branch @@ -247,7 +247,7 @@ func NewGenesisAuthoritySet[H comparable, N constraints.Unsigned](initial Author // NewAuthoritySet creates a new AuthoritySet func NewAuthoritySet[H comparable, N constraints.Unsigned](authorities AuthorityList, - setId uint64, + setID uint64, pendingStandardChanges ForkTree[H, N], pendingForcedChanges []PendingChange[H, N], authoritySetChanges AuthoritySetChanges[N], @@ -258,7 +258,7 @@ func NewAuthoritySet[H comparable, N constraints.Unsigned](authorities Authority return &AuthoritySet[H, N]{ CurrentAuthorities: authorities, - SetId: setId, + SetID: setID, PendingStandardChanges: pendingStandardChanges, PendingForcedChanges: pendingForcedChanges, AuthoritySetChanges: authoritySetChanges, @@ -267,7 +267,7 @@ func NewAuthoritySet[H comparable, N constraints.Unsigned](authorities Authority // current Get the current set id and a reference to the current authority set. func (authSet *AuthoritySet[H, N]) current() (uint64, *AuthorityList) { - return authSet.SetId, &authSet.CurrentAuthorities + return authSet.SetID, &authSet.CurrentAuthorities } func (authSet *AuthoritySet[H, N]) revert() { @@ -526,12 +526,12 @@ func (authSet *AuthoritySet[H, N]) applyForcedChanges(bestHash H, // TODO telemetry authSetChanges := authSet.AuthoritySetChanges - authSetChanges.append(authSet.SetId, medianLastFinalized) + authSetChanges.append(authSet.SetID, medianLastFinalized) newSet = &appliedChanges[H, N]{ medianLastFinalized, AuthoritySet[H, N]{ CurrentAuthorities: change.NextAuthorities, - SetId: authSet.SetId + 1, + SetID: authSet.SetID + 1, PendingStandardChanges: NewChangeTree[H, N](), // new set, new changes PendingForcedChanges: []PendingChange[H, N]{}, AuthoritySetChanges: authSetChanges, @@ -602,9 +602,9 @@ func (authSet *AuthoritySet[H, N]) applyStandardChanges( // TODO add telemetry // Store the set_id together with the last block_number for the set - authSet.AuthoritySetChanges.append(authSet.SetId, finalizedNumber) + authSet.AuthoritySetChanges.append(authSet.SetID, finalizedNumber) authSet.CurrentAuthorities = finalizationResult.Value.NextAuthorities - authSet.SetId++ + authSet.SetID++ status.NewSetBlock = &hashNumber[H, N]{ hash: finalizedHash, @@ -665,9 +665,9 @@ func (pc *PendingChange[H, N]) EffectiveNumber() N { type AuthoritySetChanges[N constraints.Unsigned] []setIDNumber[N] // append an setIDNumber to AuthoritySetChanges -func (asc *AuthoritySetChanges[N]) append(setId uint64, blockNumber N) { +func (asc *AuthoritySetChanges[N]) append(setID uint64, blockNumber N) { *asc = append(*asc, setIDNumber[N]{ - SetId: setId, + SetID: setID, BlockNumber: blockNumber, }) } @@ -707,7 +707,7 @@ func (asc *AuthoritySetChanges[N]) getSetID(blockNumber N) (latest bool, set *se authChange := authSet[idx] // if this is the first index but not the first set id then we are missing data. - if idx == 0 && authChange.SetId != 0 { + if idx == 0 && authChange.SetID != 0 { return false, nil, nil // Unknown case } @@ -742,19 +742,19 @@ func (asc *AuthoritySetChanges[N]) insert(blockNumber N) { set := *asc - var setId uint64 + var setID uint64 if idx == 0 { - setId = 0 + setID = 0 } else { - setId = set[idx-1].SetId + 1 + setID = set[idx-1].SetID + 1 } - if idx != len(set) && set[idx].SetId == setId { + if idx != len(set) && set[idx].SetID == setID { panic("inserting authority set hashNumber") } change := setIDNumber[N]{ - SetId: setId, + SetID: setID, BlockNumber: blockNumber, } @@ -801,7 +801,7 @@ func (asc *AuthoritySetChanges[N]) IterFrom(blockNumber N) *AuthoritySetChanges[ authChange := authSet[idx] // if this is the first index but not the first set id then we are missing data. - if idx == 0 && authChange.SetId != 0 { + if idx == 0 && authChange.SetID != 0 { return nil } } diff --git a/client/consensus/grandpa/authorities_test.go b/client/consensus/grandpa/authorities_test.go index 73b945f2d74..33d28fb61e0 100644 --- a/client/consensus/grandpa/authorities_test.go +++ b/client/consensus/grandpa/authorities_test.go @@ -61,7 +61,7 @@ func TestCurrentLimitFiltersMin(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: currentAuthorities, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -96,7 +96,7 @@ func TestChangesIteratedInPreOrder(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: currentAuthorities, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -175,7 +175,7 @@ func TestChangesIteratedInPreOrder(t *testing.T) { func TestApplyChange(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -277,12 +277,12 @@ func TestApplyChange(t *testing.T) { require.True(t, status.Changed) require.Equal(t, status.NewSetBlock, expectedBlockInfo) require.Equal(t, authorities.CurrentAuthorities, setA) - require.Equal(t, authorities.SetId, uint64(1)) + require.Equal(t, authorities.SetID, uint64(1)) pendingChanges = authorities.pendingChanges() require.Equal(t, 0, len(pendingChanges)) expChange := setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 15, } require.Equal(t, authorities.AuthoritySetChanges, AuthoritySetChanges[uint]{expChange}) @@ -291,7 +291,7 @@ func TestApplyChange(t *testing.T) { func TestDisallowMultipleChangesBeingFinalizedAtOnce(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -376,12 +376,12 @@ func TestDisallowMultipleChangesBeingFinalizedAtOnce(t *testing.T) { number: 15, } expAuthSetChange := AuthoritySetChanges[uint]{setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 15, }} require.Equal(t, expectedBlockInfo, status.NewSetBlock) require.Equal(t, setA, authorities.CurrentAuthorities) - require.Equal(t, uint64(1), authorities.SetId) + require.Equal(t, uint64(1), authorities.SetID) require.Equal(t, expAuthSetChange, authorities.AuthoritySetChanges) status, err = authorities.applyStandardChanges( @@ -398,25 +398,25 @@ func TestDisallowMultipleChangesBeingFinalizedAtOnce(t *testing.T) { } expAuthSetChange = AuthoritySetChanges[uint]{ setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 15, }, setIDNumber[uint]{ - SetId: 1, + SetID: 1, BlockNumber: 40, }, } require.Equal(t, expectedBlockInfo, status.NewSetBlock) require.Equal(t, setC, authorities.CurrentAuthorities) - require.Equal(t, uint64(2), authorities.SetId) + require.Equal(t, uint64(2), authorities.SetID) require.Equal(t, expAuthSetChange, authorities.AuthoritySetChanges) } func TestEnactsStandardChangeWorks(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -494,7 +494,7 @@ func TestEnactsStandardChangeWorks(t *testing.T) { func TestForceChanges(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -583,12 +583,12 @@ func TestForceChanges(t *testing.T) { median: 42, set: AuthoritySet[Hash, uint]{ CurrentAuthorities: setA, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{ setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 42, }, }, @@ -604,7 +604,7 @@ func TestForceChangesWithNoDelay(t *testing.T) { // NOTE: this is a regression test authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -643,7 +643,7 @@ func TestForceChangesWithNoDelay(t *testing.T) { func TestForceChangesBlockedByStandardChanges(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -721,7 +721,7 @@ func TestForceChangesBlockedByStandardChanges(t *testing.T) { // we apply the first pending standard hashNumber at #15 expChanges := AuthoritySetChanges[uint]{ setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 15, }, } @@ -735,7 +735,7 @@ func TestForceChangesBlockedByStandardChanges(t *testing.T) { // we apply the pending standard hashNumber at #20 expChanges = append(expChanges, setIDNumber[uint]{ - SetId: 1, + SetID: 1, BlockNumber: 20, }) _, err = authorities.applyStandardChanges(bytesToHash([]byte("hash_b")), 20, staticIsDescendentOf[Hash](true), nil) @@ -745,14 +745,14 @@ func TestForceChangesBlockedByStandardChanges(t *testing.T) { // that finality stalled at #31, and the next pending standard hashNumber is effective // at #35. subsequent forced changes on the same branch must be kept expChanges = append(expChanges, setIDNumber[uint]{ - SetId: 2, + SetID: 2, BlockNumber: 31, }) exp := appliedChanges[Hash, uint]{ median: 31, set: AuthoritySet[Hash, uint]{ CurrentAuthorities: setA, - SetId: 3, + SetID: 3, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: expChanges, @@ -775,7 +775,7 @@ func TestNextChangeWorks(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: currentAuthorities, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -967,7 +967,7 @@ func TestCleanUpStaleForcedChangesWhenApplyingStandardChange(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: currentAuthorities, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -1074,7 +1074,7 @@ func TestCleanUpStaleForcedChangesWhenApplyingStandardChangeAlternateCase(t *tes authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: currentAuthorities, - SetId: 0, + SetID: 0, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -1180,7 +1180,7 @@ func TestAuthoritySetChangesInsert(t *testing.T) { authoritySetChanges.insert(101) expChange := setIDNumber[uint]{ - SetId: 2, + SetID: 2, BlockNumber: 101, } _, set, err := authoritySetChanges.getSetID(100) @@ -1199,12 +1199,12 @@ func TestAuthoritySetChangesForCompleteData(t *testing.T) { authoritySetChanges.append(2, 121) expChange0 := setIDNumber[uint]{ - SetId: 0, + SetID: 0, BlockNumber: 41, } expChange1 := setIDNumber[uint]{ - SetId: 1, + SetID: 1, BlockNumber: 81, } @@ -1236,7 +1236,7 @@ func TestAuthoritySetChangesForIncompleteData(t *testing.T) { authoritySetChanges.append(4, 121) expChange := setIDNumber[uint]{ - SetId: 3, + SetID: 3, BlockNumber: 81, } @@ -1279,15 +1279,15 @@ func TestIterFromWorks(t *testing.T) { expectedChanges := &AuthoritySetChanges[uint]{ setIDNumber[uint]{ - SetId: 1, + SetID: 1, BlockNumber: 41, }, setIDNumber[uint]{ - SetId: 2, + SetID: 2, BlockNumber: 81, }, setIDNumber[uint]{ - SetId: 3, + SetID: 3, BlockNumber: 121, }, } @@ -1297,11 +1297,11 @@ func TestIterFromWorks(t *testing.T) { expectedChanges = &AuthoritySetChanges[uint]{ setIDNumber[uint]{ - SetId: 2, + SetID: 2, BlockNumber: 81, }, setIDNumber[uint]{ - SetId: 3, + SetID: 3, BlockNumber: 121, }, } diff --git a/client/consensus/grandpa/auxSchema.go b/client/consensus/grandpa/aux_schema.go similarity index 92% rename from client/consensus/grandpa/auxSchema.go rename to client/consensus/grandpa/aux_schema.go index 861d5d0fcc0..7a776a7f13e 100644 --- a/client/consensus/grandpa/auxSchema.go +++ b/client/consensus/grandpa/aux_schema.go @@ -17,7 +17,12 @@ var ( BEST_JUSTIFICATION = []byte("grandpa_best_justification") ) -type databaseKeyValue [2][]byte +//type databaseKeyValue [2][]byte + +type KeyValue struct { + key []byte + value []byte +} // SharedVoterSetState . type SharedVoterSetState[H comparable, N constraints.Unsigned] struct { @@ -25,16 +30,15 @@ type SharedVoterSetState[H comparable, N constraints.Unsigned] struct { inner VoterSetState[H, N] } -type PersistentData[H comparable, N constraints.Unsigned] struct { +type persistentData[H comparable, N constraints.Unsigned] struct { authoritySet SharedAuthoritySet[H, N] // TODO this needs to be shared auth set setState SharedVoterSetState[H, N] } -func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesisHash H, genesisNumber N, genesisAuthorities AuthorityList) (*PersistentData[H, N], error) { +func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesisHash H, genesisNumber N, genesisAuthorities AuthorityList) (*persistentData[H, N], error) { genesis := finalityGrandpa.HashNumber[H, N]{Hash: genesisHash, Number: genesisNumber} makeGenesisRound := finalityGrandpa.NewRoundState[H, N] - // No longer use version to tell if data is persisted, just use actual data set := AuthoritySet[H, N]{ PendingStandardChanges: NewChangeTree[H, N](), PendingForcedChanges: make([]PendingChange[H, N], 0), @@ -46,6 +50,7 @@ func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesi return nil, err } + // If there is no authoritySet data stored, then we are starting from genesis if encodedAuthSet != nil { err = scale.Unmarshal(*encodedAuthSet, &set) if err != nil { @@ -69,7 +74,7 @@ func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesi base := state.PrevoteGHOST if base != nil { voterSetState := NewVoterSetState[H, N]() - state, err := voterSetState.Live(set.SetId, set, *base) + state, err := voterSetState.Live(set.SetID, set, *base) if err != nil { return nil, err } @@ -79,7 +84,7 @@ func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesi panic("state is for completed round; completed rounds must have a prevote ghost; qed") } } - return &PersistentData[H, N]{ + return &persistentData[H, N]{ authoritySet: SharedAuthoritySet[H, N]{inner: set}, setState: SharedVoterSetState[H, N]{inner: setState}, }, nil @@ -99,7 +104,7 @@ func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesi return nil, err } - insert := []databaseKeyValue{ + insert := []KeyValue{ {AUTHORITY_SET_KEY, scale.MustMarshal(*genesisSet)}, {SET_STATE_KEY, scale.MustMarshal(genesisState)}, } @@ -109,7 +114,7 @@ func loadPersistent[H comparable, N constraints.Unsigned](store AuxStore, genesi return nil, err } - return &PersistentData[H, N]{ + return &persistentData[H, N]{ authoritySet: SharedAuthoritySet[H, N]{inner: *genesisSet}, setState: SharedVoterSetState[H, N]{inner: genesisState}, }, nil @@ -147,7 +152,7 @@ func UpdateAuthoritySet[H comparable, N constraints.Unsigned](store AuxStore, se return err } - insert := []databaseKeyValue{ + insert := []KeyValue{ {AUTHORITY_SET_KEY, encodedAuthSet}, {SET_STATE_KEY, encodedVoterSet}, } @@ -157,7 +162,7 @@ func UpdateAuthoritySet[H comparable, N constraints.Unsigned](store AuxStore, se } } else { - insert := []databaseKeyValue{ + insert := []KeyValue{ {AUTHORITY_SET_KEY, encodedAuthSet}, } @@ -191,7 +196,7 @@ func WriteVoterSetState[H comparable, N constraints.Unsigned](store AuxStore, se if err != nil { return err } - insert := []databaseKeyValue{ + insert := []KeyValue{ {SET_STATE_KEY, encodedVoterSet}, } err = store.Insert(insert, nil) @@ -216,7 +221,7 @@ func WriteConcludedRound[H comparable, N constraints.Unsigned](store AuxStore, r return err } - insert := []databaseKeyValue{ + insert := []KeyValue{ {key, encRoundData}, } err = store.Insert(insert, nil) diff --git a/client/consensus/grandpa/auxSchema_test.go b/client/consensus/grandpa/aux_schema_test.go similarity index 95% rename from client/consensus/grandpa/auxSchema_test.go rename to client/consensus/grandpa/aux_schema_test.go index 453755fd04f..c82d4e8811d 100644 --- a/client/consensus/grandpa/auxSchema_test.go +++ b/client/consensus/grandpa/aux_schema_test.go @@ -12,9 +12,9 @@ import ( "testing" ) -type dummyStore []databaseKeyValue +type dummyStore []KeyValue -func (client *dummyStore) Insert(insert []databaseKeyValue, deleted [][]byte) error { +func (client *dummyStore) Insert(insert []KeyValue, deleted [][]byte) error { for _, val := range insert { *client = append(*client, val) } @@ -23,7 +23,7 @@ func (client *dummyStore) Insert(insert []databaseKeyValue, deleted [][]byte) er // append if not in deleted found := false for _, del := range deleted { - if slices.Equal(value[0], del) { + if slices.Equal(value.key, del) { found = true } } @@ -39,8 +39,8 @@ func (client *dummyStore) Insert(insert []databaseKeyValue, deleted [][]byte) er func (client *dummyStore) Get(key []byte) (*[]byte, error) { for _, value := range *client { - if slices.Equal(value[0], key) { - return &value[1], nil + if slices.Equal(value.key, key) { + return &value.value, nil } } return nil, nil @@ -53,7 +53,7 @@ func newDummyStore(t *testing.T) *dummyStore { func TestDummyStore(t *testing.T) { store := newDummyStore(t) - insert := []databaseKeyValue{ + insert := []KeyValue{ {AUTHORITY_SET_KEY, scale.MustMarshal([]byte{1})}, {SET_STATE_KEY, scale.MustMarshal([]byte{2})}, } @@ -140,7 +140,7 @@ func TestLoadPersistentNotGenesis(t *testing.T) { genesisState, err := voterSetState.Live(0, *genesisSet, *base) require.NoError(t, err) - insert := []databaseKeyValue{ + insert := []KeyValue{ {AUTHORITY_SET_KEY, scale.MustMarshal(*genesisSet)}, {SET_STATE_KEY, scale.MustMarshal(genesisState)}, } @@ -160,7 +160,7 @@ func TestLoadPersistentNotGenesis(t *testing.T) { // Auth set written but not set state store = newDummyStore(t) - insert = []databaseKeyValue{ + insert = []KeyValue{ {AUTHORITY_SET_KEY, scale.MustMarshal(*genesisSet)}, } @@ -170,7 +170,7 @@ func TestLoadPersistentNotGenesis(t *testing.T) { require.NoError(t, err) newVoterSetState := NewVoterSetState[Hash, uint]() - newState, err := newVoterSetState.Live(genesisSet.SetId, *genesisSet, *base) + newState, err := newVoterSetState.Live(genesisSet.SetID, *genesisSet, *base) require.NoError(t, err) require.Equal(t, *genesisSet, persistentData.authoritySet.inner) @@ -185,7 +185,7 @@ func TestUpdateAuthoritySet(t *testing.T) { // Test no new set case store := newDummyStore(t) authorities := AuthoritySet[Hash, uint]{ - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), } @@ -206,7 +206,7 @@ func TestUpdateAuthoritySet(t *testing.T) { // New set case store = newDummyStore(t) authorities = AuthoritySet[Hash, uint]{ - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), } @@ -250,7 +250,7 @@ func TestWriteVoterSetState(t *testing.T) { store := newDummyStore(t) authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -301,7 +301,7 @@ func TestWriteConcludedRound(t *testing.T) { store := newDummyStore(t) authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, diff --git a/client/consensus/grandpa/environment_test.go b/client/consensus/grandpa/environment_test.go index f58e87654c0..d09b0749c30 100644 --- a/client/consensus/grandpa/environment_test.go +++ b/client/consensus/grandpa/environment_test.go @@ -37,7 +37,7 @@ func TestCompleteRoundEncoding(t *testing.T) { func TestCompletedRoundsEncoding(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -72,7 +72,7 @@ func TestCompletedRoundsEncoding(t *testing.T) { func TestCompletedRounds_Last(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -104,7 +104,7 @@ func TestCompletedRounds_Last(t *testing.T) { func TestCompletedRounds_Push(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -188,7 +188,7 @@ func TestCurrentRoundsEncoding(t *testing.T) { func TestVoterSetStateEncoding(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -240,7 +240,7 @@ func TestVoterSetStateEncoding(t *testing.T) { func TestVoterSetState_Live(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -268,7 +268,7 @@ func TestVoterSetState_Live(t *testing.T) { func TestVoterSetState_CompletedRounds(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -304,7 +304,7 @@ func TestVoterSetState_CompletedRounds(t *testing.T) { func TestVoterSetState_LastCompletedRound(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, @@ -348,7 +348,7 @@ func TestVoterSetState_LastCompletedRound(t *testing.T) { func TestVoterSetState_WithCurrentRound(t *testing.T) { authorities := AuthoritySet[Hash, uint]{ CurrentAuthorities: AuthorityList{}, - SetId: 1, + SetID: 1, PendingStandardChanges: NewChangeTree[Hash, uint](), PendingForcedChanges: []PendingChange[Hash, uint]{}, AuthoritySetChanges: AuthoritySetChanges[uint]{}, diff --git a/client/consensus/grandpa/interfaces.go b/client/consensus/grandpa/interfaces.go index 2efb58c3ae2..10e66b2b82f 100644 --- a/client/consensus/grandpa/interfaces.go +++ b/client/consensus/grandpa/interfaces.go @@ -38,7 +38,7 @@ type AuxStore interface { // Insert auxiliary data into key-Value store. // // Deletions occur after insertions. - Insert(insert []databaseKeyValue, deleted [][]byte) error + Insert(insert []KeyValue, deleted [][]byte) error // Get Query auxiliary data from key-Value store. Get(key []byte) (*[]byte, error) }