Browse Source

Merge branch 'master' into wb/epoch-fixes-forward-port-master

pull/8139/head
William Banfield 3 years ago
committed by GitHub
parent
commit
66f32ba9fc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 29 deletions
  1. +1
    -1
      internal/consensus/types/height_vote_set.go
  2. +0
    -6
      types/keys.go
  3. +0
    -10
      types/signable.go
  4. +6
    -12
      types/vote_set.go

+ 1
- 1
internal/consensus/types/height_vote_set.go View File

@ -199,7 +199,7 @@ func (hvs *HeightVoteSet) SetPeerMaj23(
if voteSet == nil { if voteSet == nil {
return nil // something we don't know about yet return nil // something we don't know about yet
} }
return voteSet.SetPeerMaj23(types.P2PID(peerID), blockID)
return voteSet.SetPeerMaj23(string(peerID), blockID)
} }
//--------------------------------------------------------- //---------------------------------------------------------


+ 0
- 6
types/keys.go View File

@ -1,6 +0,0 @@
package types
// UNSTABLE
var (
PeerStateKey = "ConsensusReactor.peerState"
)

+ 0
- 10
types/signable.go View File

@ -11,13 +11,3 @@ var (
// XXX: secp256k1 does not have Size nor MaxSize defined. // XXX: secp256k1 does not have Size nor MaxSize defined.
MaxSignatureSize = tmmath.MaxInt(ed25519.SignatureSize, 64) MaxSignatureSize = tmmath.MaxInt(ed25519.SignatureSize, 64)
) )
// Signable is an interface for all signable things.
// It typically removes signatures before serializing.
// SignBytes returns the bytes to be signed
// NOTE: chainIDs are part of the SignBytes but not
// necessarily the object themselves.
// NOTE: Expected to panic if there is an error marshaling.
type Signable interface {
SignBytes(chainID string) []byte
}

+ 6
- 12
types/vote_set.go View File

@ -18,12 +18,6 @@ const (
MaxVotesCount = 10000 MaxVotesCount = 10000
) )
// UNSTABLE
// XXX: duplicate of p2p.ID to avoid dependence between packages.
// Perhaps we can have a minimal types package containing this (and other things?)
// that both `types` and `p2p` import ?
type P2PID string
/* /*
VoteSet helps collect signatures from validators at each height+round for a VoteSet helps collect signatures from validators at each height+round for a
predefined vote type. predefined vote type.
@ -71,7 +65,7 @@ type VoteSet struct {
sum int64 // Sum of voting power for seen votes, discounting conflicts sum int64 // Sum of voting power for seen votes, discounting conflicts
maj23 *BlockID // First 2/3 majority seen maj23 *BlockID // First 2/3 majority seen
votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes
peerMaj23s map[P2PID]BlockID // Maj23 for each peer
peerMaj23s map[string]BlockID // Maj23 for each peer
} }
// Constructs a new VoteSet struct used to accumulate votes for given height/round. // Constructs a new VoteSet struct used to accumulate votes for given height/round.
@ -91,7 +85,7 @@ func NewVoteSet(chainID string, height int64, round int32,
sum: 0, sum: 0,
maj23: nil, maj23: nil,
votesByBlock: make(map[string]*blockVotes, valSet.Size()), votesByBlock: make(map[string]*blockVotes, valSet.Size()),
peerMaj23s: make(map[P2PID]BlockID),
peerMaj23s: make(map[string]BlockID),
} }
} }
@ -313,7 +307,7 @@ func (voteSet *VoteSet) addVerifiedVote(
// this can cause memory issues. // this can cause memory issues.
// TODO: implement ability to remove peers too // TODO: implement ability to remove peers too
// NOTE: VoteSet must not be nil // NOTE: VoteSet must not be nil
func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error {
func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID BlockID) error {
if voteSet == nil { if voteSet == nil {
panic("SetPeerMaj23() on nil VoteSet") panic("SetPeerMaj23() on nil VoteSet")
} }
@ -530,9 +524,9 @@ func (voteSet *VoteSet) MarshalJSON() ([]byte, error) {
// NOTE: insufficient for unmarshaling from (compressed votes) // NOTE: insufficient for unmarshaling from (compressed votes)
// TODO: make the peerMaj23s nicer to read (eg just the block hash) // TODO: make the peerMaj23s nicer to read (eg just the block hash)
type VoteSetJSON struct { type VoteSetJSON struct {
Votes []string `json:"votes"`
VotesBitArray string `json:"votes_bit_array"`
PeerMaj23s map[P2PID]BlockID `json:"peer_maj_23s"`
Votes []string `json:"votes"`
VotesBitArray string `json:"votes_bit_array"`
PeerMaj23s map[string]BlockID `json:"peer_maj_23s"`
} }
// Return the bit-array of votes including // Return the bit-array of votes including


Loading…
Cancel
Save