Skip to content

Commit

Permalink
Changes: side-tx voting, Precommit name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilpune committed Jan 10, 2024
1 parent b55f621 commit b5b1f31
Show file tree
Hide file tree
Showing 23 changed files with 407 additions and 239 deletions.
2 changes: 1 addition & 1 deletion consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
}

// omit the last signature in the commit
commit.Signatures[len(commit.Signatures)-1] = types.NewCommitSigAbsent()
commit.Precommits[len(commit.Precommits)-1] = types.NewCommitSigAbsent()

if lazyProposer.privValidatorPubKey == nil {
// If this node is a validator & proposer in the current round, it will
Expand Down
2 changes: 1 addition & 1 deletion consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func validateBlock(block *types.Block, activeVals map[string]struct{}) error {
len(activeVals))
}

for _, commitSig := range block.LastCommit.Signatures {
for _, commitSig := range block.LastCommit.Precommits {
if _, ok := activeVals[string(commitSig.ValidatorAddress)]; !ok {
return fmt.Errorf("found vote for inactive validator %X", commitSig.ValidatorAddress)
}
Expand Down
12 changes: 5 additions & 7 deletions consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
)
if commitSize != valSetLen {
panic(fmt.Sprintf("commit size (%d) doesn't match valset length (%d) at height %d\n\n%v\n\n%v",
commitSize, valSetLen, block.Height, block.LastCommit.Signatures, cs.LastValidators.Validators))
commitSize, valSetLen, block.Height, block.LastCommit.Precommits, cs.LastValidators.Validators))
}

if cs.privValidator != nil {
Expand All @@ -1754,7 +1754,7 @@ func (cs *State) recordMetrics(height int64, block *types.Block) {
}

for i, val := range cs.LastValidators.Validators {
commitSig := block.LastCommit.Signatures[i]
commitSig := block.LastCommit.Precommits[i]
if commitSig.Absent() {
missingValidators++
missingValidatorsPower += val.VotingPower
Expand Down Expand Up @@ -2216,10 +2216,8 @@ func (cs *State) signVote(
vote.SideTxResults = sideTxResults
}

v := vote.ToProto()
err := cs.privValidator.SignVote(cs.state.ChainID, v)
vote.Signature = v.Signature
vote.Timestamp = v.Timestamp
err := cs.privValidator.SignVote(cs.state.ChainID, vote.ToProto())
cs.Logger.Info("[dojimamint] vote sign with data", "signBytes", vote.SideTxResults)

return vote, err
}
Expand Down Expand Up @@ -2300,7 +2298,7 @@ func (cs *State) checkDoubleSigningRisk(height int64) error {
for i := int64(1); i < doubleSignCheckHeight; i++ {
lastCommit := cs.blockStore.LoadSeenCommit(height - i)
if lastCommit != nil {
for sigIdx, s := range lastCommit.Signatures {
for sigIdx, s := range lastCommit.Precommits {
if s.BlockIDFlag == types.BlockIDFlagCommit && bytes.Equal(s.ValidatorAddress, valAddr) {
cs.Logger.Info("found signature from the same key", "sig", s, "idx", sigIdx, "height", height-i)
return ErrSignatureFoundInPastBlocks
Expand Down
2 changes: 1 addition & 1 deletion evidence/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func VerifyDuplicateVote(e *types.DuplicateVoteEvidence, chainID string, valSet

va := e.VoteA.ToProto()
vb := e.VoteB.ToProto()
// Signatures must be valid
// Precommits must be valid
if !pubKey.VerifySignature(types.VoteSignBytes(chainID, va), e.VoteA.Signature) {
return fmt.Errorf("verifying VoteA: %w", types.ErrVoteInvalidSignature)
}
Expand Down
74 changes: 37 additions & 37 deletions proto/tendermint/types/canonical.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/tendermint/types/canonical.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ message CanonicalVote {
CanonicalBlockID block_id = 4 [(gogoproto.customname) = "BlockID"];
google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
string chain_id = 6 [(gogoproto.customname) = "ChainID"];
repeated tendermint.types.SideTxResult side_tx_results = 7;
repeated tendermint.types.SideTxResult side_tx_results = 7 [(gogoproto.nullable) = false];
}
Loading

0 comments on commit b5b1f31

Please sign in to comment.