Skip to content

Commit

Permalink
remove copy of types containing mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjbrettj committed Dec 7, 2023
1 parent c01915d commit d91434f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
16 changes: 6 additions & 10 deletions client/consensus/grandpa/aux_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ func loadPersistent[H comparable, N constraints.Unsigned, ID AuthorityID, Sig Au
}
}

newSharedVoterSetState := sharedVoterSetState[H, N, ID, Sig]{
Inner: setState,
}

return &persistentData[H, N, ID, Sig]{
authoritySet: SharedAuthoritySet[H, N, ID]{inner: *authSet},
setState: SharedVoterSetState[H, N, ID, Sig]{Inner: newSharedVoterSetState}, //nolint
setState: SharedVoterSetState[H, N, ID, Sig]{Inner: sharedVoterSetState[H, N, ID, Sig]{
Inner: setState,
}},
}, nil
}

Expand Down Expand Up @@ -125,13 +123,11 @@ func loadPersistent[H comparable, N constraints.Unsigned, ID AuthorityID, Sig Au
return nil, err
}

newSharedVoterSetState := sharedVoterSetState[H, N, ID, Sig]{
Inner: genesisState,
}

return &persistentData[H, N, ID, Sig]{
authoritySet: SharedAuthoritySet[H, N, ID]{inner: *genesisSet},
setState: SharedVoterSetState[H, N, ID, Sig]{Inner: newSharedVoterSetState}, //nolint
setState: SharedVoterSetState[H, N, ID, Sig]{Inner: sharedVoterSetState[H, N, ID, Sig]{
Inner: genesisState,
}},
}, nil
}

Expand Down
7 changes: 3 additions & 4 deletions client/consensus/grandpa/finality_proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,12 @@ func (provider FinalityProofProvider[BE, Hash, N, AuthID, S, ID, H, B]) proveFin
return nil, nil
}

// TODO address lock copy
authoritySetChanges := *provider.sharedAuthoritySet //nolint
return proveFinality[BE, Hash, N, S, ID, H, B](
provider.backend,
authoritySetChanges.inner.AuthoritySetChanges,
provider.sharedAuthoritySet.inner.AuthoritySetChanges,
block,
collectUnknownHeaders)
collectUnknownHeaders,
)
}

// FinalityProof Finality for block B is proved by providing:
Expand Down
12 changes: 6 additions & 6 deletions client/consensus/grandpa/finality_proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
// Returns the vector of headers that MUST be validated + imported
// AND if at least one of those headers is invalid, all other MUST be considered invalid.
func checkFinalityProof[
Hash constraints.Ordered,
N constraints.Unsigned,
S comparable,
H Header[Hash, N],
ID AuthorityID,
Hash constraints.Ordered,
N constraints.Unsigned,
S comparable,
H Header[Hash, N],
ID AuthorityID,
](
t *testing.T,
currentSetID uint64,
Expand Down Expand Up @@ -415,7 +415,7 @@ func TestFinalityProof_InLastSetFailsWithoutLatest(t *testing.T) {
// the best stored justification, for which there is none in this case.
authoritySetChanges := AuthoritySetChanges[uint]{}
authoritySetChanges.append(0, 5)

proof, err := proveFinality[
*BackendMock[string, uint, testHeader[string, uint],
*BlockchainBackendMock[string, uint, testHeader[string, uint]]],
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/grandpa/justification.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
errBlockNotDescendentOfBase = errors.New("block not descendent of base")
)

// Justification is a GRANDPA justification for block finality, it includes a commit message and
// GrandpaJustification is a GRANDPA justification for block finality, it includes a commit message and
// an ancestry proof including all headers routing all precommit target blocks
// to the commit target block. Due to the current voting strategy the precommit
// targets should be the same as the commit target, since honest voters don't
Expand Down

0 comments on commit d91434f

Please sign in to comment.