From eaf821b35f5a5e7eae219ad0897ca1d3c95ac6e7 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 28 Jun 2022 09:53:48 -0400 Subject: [PATCH] wip --- internal/consensus/state.go | 4 ++++ internal/consensus/state_test.go | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index 64a201ef6..e521146c0 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -816,6 +816,7 @@ func (cs *State) receiveRoutine(maxSteps int) { cs.handleTxsAvailable() case mi = <-cs.peerMsgQueue: + fmt.Println("got message") if err := cs.wal.Write(mi); err != nil { cs.Logger.Error("failed writing to WAL", "err", err) } @@ -915,9 +916,12 @@ func (cs *State) handleMsg(mi msgInfo) { case *VoteMessage: // attempt to add the vote and dupeout the validator if its a duplicate signature // if the vote gives us a 2/3-any or 2/3-one, we transition + fmt.Println("adding vote") added, err = cs.tryAddVote(msg.Vote, peerID) if added { + fmt.Println("adding stats") cs.statsMsgQueue <- mi + fmt.Println("added stats") } // if err == ErrAddingVote { diff --git a/internal/consensus/state_test.go b/internal/consensus/state_test.go index 515460e4f..7d5f4b5bc 100644 --- a/internal/consensus/state_test.go +++ b/internal/consensus/state_test.go @@ -384,10 +384,12 @@ func TestStateFullRoundNil(t *testing.T) { // where the first validator has to wait for votes from the second func TestStateTooManyVotes(t *testing.T) { config := configSetup(t) + config.Consensus.TimeoutCommit = 25 * time.Second - cs1, vss, err := randState(config, 2) + cs1, vss, err := randState(config, 10000) require.NoError(t, err) - vs2 := vss[1] + // vs1, vs2, vs3 := vss[0], vss[1], vss[2] + vs1 := vss[0] height, round := cs1.Height, cs1.Round voteCh := subscribe(cs1.eventBus, types.EventQueryVote) @@ -403,7 +405,7 @@ func TestStateTooManyVotes(t *testing.T) { propBlockHash, propPartSetHeader := rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header() // prevote arrives from vs2: - signAddVotes(config, cs1, tmproto.PrevoteType, propBlockHash, propPartSetHeader, vs2) + signAddVotes(config, cs1, tmproto.PrevoteType, propBlockHash, propPartSetHeader, vss[1:]...) ensurePrevote(voteCh, height, round) // prevote ensurePrecommit(voteCh, height, round) // precommit @@ -413,7 +415,9 @@ func TestStateTooManyVotes(t *testing.T) { // we should be stuck in limbo waiting for more precommits // precommit arrives from vs2: - signAddVotes(config, cs1, tmproto.PrecommitType, propBlockHash, propPartSetHeader, vs2) + for i := 0; i < 10000; i++ { + signAddVotes(config, cs1, tmproto.PrecommitType, propBlockHash, propPartSetHeader, vs1) + } ensurePrecommit(voteCh, height, round) // wait to finish commit, propose in next height