Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes to the PartSetHeader and BlockID #510

Merged
merged 3 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 176 additions & 44 deletions abci/types/types.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blockchain/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestBlockchainMessageVectors(t *testing.T) {
BlockRequest: &bcproto.BlockRequest{Height: math.MaxInt64}}},
"0a0a08ffffffffffffffff7f"},
{"BlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_BlockResponse{
BlockResponse: &bcproto.BlockResponse{Block: bpb}}}, "1ac0020abd020a5b0a02080b1803220b088092b8c398feffffff012a00380142204c149a7cfadc92b669b0cbfa4951a1b18c2d9f3177a3b8756d39ebb96e9d63317220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85512130a0b48656c6c6f20576f726c6412001a0022001ac8010a3000000000000000010000000000000001b81cb5596c28d044214b9f935e4af7dbe76e417f6182d86fbee68bfff7b2ff3a0a30ffffffffffffffffffffffffffffffffc4096ba8fccf882c309896e9168fa43fe62fccb752cb12d5160cc1d9c2ebffe7123000000000000000010000000000000001b81cb5596c28d044214b9f935e4af7dbe76e417f6182d86fbee68bfff7b2ff3a1230ffffffffffffffffffffffffffffffffc4096ba8fccf882c309896e9168fa43fe62fccb752cb12d5160cc1d9c2ebffe7"},
BlockResponse: &bcproto.BlockResponse{Block: bpb}}}, "1ac2020abf020a5d0a02080b1803220b088092b8c398feffffff012a021200380142204c149a7cfadc92b669b0cbfa4951a1b18c2d9f3177a3b8756d39ebb96e9d63317220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85512130a0b48656c6c6f20576f726c6412001a0022001ac8010a3000000000000000010000000000000001b81cb5596c28d044214b9f935e4af7dbe76e417f6182d86fbee68bfff7b2ff3a0a30ffffffffffffffffffffffffffffffffc4096ba8fccf882c309896e9168fa43fe62fccb752cb12d5160cc1d9c2ebffe7123000000000000000010000000000000001b81cb5596c28d044214b9f935e4af7dbe76e417f6182d86fbee68bfff7b2ff3a1230ffffffffffffffffffffffffffffffffc4096ba8fccf882c309896e9168fa43fe62fccb752cb12d5160cc1d9c2ebffe7"},
{"NoBlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_NoBlockResponse{
NoBlockResponse: &bcproto.NoBlockResponse{Height: 1}}}, "12020801"},
{"NoBlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_NoBlockResponse{
Expand Down
6 changes: 3 additions & 3 deletions blockchain/v0/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,14 @@ FOR_LOOP:
var (
firstParts = first.MakePartSet(types.BlockPartSizeBytes)
firstPartSetHeader = firstParts.Header()
firstID = types.BlockID{Hash: first.Hash()}
firstID = types.BlockID{Hash: first.Hash(), PartSetHeader: firstPartSetHeader}
)

// Finally, verify the first block using the second's commit
// NOTE: we can probably make this more efficient, but note that calling
// first.Hash() doesn't verify the tx contents, so MakePartSet() is
// currently necessary.
err := state.Validators.VerifyCommitLight(chainID, firstID, firstPartSetHeader, first.Height, second.LastCommit)
err := state.Validators.VerifyCommitLight(chainID, firstID, first.Height, second.LastCommit)
if err != nil {
err = fmt.Errorf("invalid last commit: %w", err)
bcR.Logger.Error(err.Error(),
Expand Down Expand Up @@ -430,7 +430,7 @@ FOR_LOOP:

// TODO: same thing for app - but we would need a way to get the hash
// without persisting the state.
state, _, err = bcR.blockExec.ApplyBlock(state, firstID, firstPartSetHeader, first)
state, _, err = bcR.blockExec.ApplyBlock(state, firstID, first)
if err != nil {
// TODO This is bad, are we zombie?
panic(fmt.Sprintf("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
Expand Down
9 changes: 4 additions & 5 deletions blockchain/v0/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func newBlockchainReactor(

// let's add some blocks in
for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, nil, types.PartSetHeader{})
lastCommit := types.NewCommit(blockHeight-1, 0, types.BlockID{}, nil)
if blockHeight > 1 {
lastBlockMeta := blockStore.LoadBlockMeta(blockHeight - 1)
lastBlock, err := blockStore.LoadBlock(context.TODO(), blockHeight-1)
Expand All @@ -107,7 +107,6 @@ func newBlockchainReactor(
vote, err := types.MakeVote(
lastBlock.Header.Height,
lastBlockMeta.BlockID,
lastBlockMeta.PartSetHeader,
state.Validators,
privVals[0],
lastBlock.Header.ChainID,
Expand All @@ -117,15 +116,15 @@ func newBlockchainReactor(
panic(err)
}
lastCommit = types.NewCommit(vote.Height, vote.Round,
lastBlockMeta.BlockID, []types.CommitSig{vote.CommitSig()}, lastBlockMeta.PartSetHeader)
lastBlockMeta.BlockID, []types.CommitSig{vote.CommitSig()})
}

thisBlock := makeBlock(blockHeight, state, lastCommit)

thisParts := thisBlock.MakePartSet(types.BlockPartSizeBytes)
blockID := types.BlockID{Hash: thisBlock.Hash()}
blockID := types.BlockID{Hash: thisBlock.Hash(), PartSetHeader: thisParts.Header()}

state, _, err = blockExec.ApplyBlock(state, blockID, thisParts.Header(), thisBlock)
state, _, err = blockExec.ApplyBlock(state, blockID, thisBlock)
if err != nil {
panic(fmt.Errorf("error apply block: %w", err))
}
Expand Down
12 changes: 4 additions & 8 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St

// Create a new proposal block from state/txs from the mempool.
block1, blockParts1 := cs.createProposalBlock()
polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash()}
proposal1 := types.NewProposal(
height, round, polRound, propBlockID, &block1.DataAvailabilityHeader, blockParts1.Header(),
)
polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()}
proposal1 := types.NewProposal(height, round, polRound, propBlockID, &block1.DataAvailabilityHeader)
p1, err := proposal1.ToProto()
require.NoError(t, err)
if err := cs.privValidator.SignProposal(cs.state.ChainID, p1); err != nil {
Expand All @@ -402,10 +400,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St

// Create a new proposal block from state/txs from the mempool.
block2, blockParts2 := cs.createProposalBlock()
polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash()}
proposal2 := types.NewProposal(
height, round, polRound, propBlockID, &block2.DataAvailabilityHeader, blockParts2.Header(),
)
polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()}
proposal2 := types.NewProposal(height, round, polRound, propBlockID, &block2.DataAvailabilityHeader)
p2, err := proposal2.ToProto()
require.NoError(t, err)
if err := cs.privValidator.SignProposal(cs.state.ChainID, p2); err != nil {
Expand Down
17 changes: 5 additions & 12 deletions consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ func (vs *validatorStub) signVote(
Round: vs.Round,
Timestamp: tmtime.Now(),
Type: voteType,
BlockID: types.BlockID{Hash: hash},
PartSetHeader: header,
BlockID: types.BlockID{Hash: hash, PartSetHeader: header},
}
v := vote.ToProto()
err = vs.PrivValidator.SignVote(config.ChainID(), v)
Expand Down Expand Up @@ -206,8 +205,8 @@ func decideProposal(
}

// Make proposal
polRound, propBlockID := validRound, types.BlockID{Hash: block.Hash()}
proposal = types.NewProposal(height, round, polRound, propBlockID, &block.DataAvailabilityHeader, blockParts.Header())
polRound, propBlockID := validRound, types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}
proposal = types.NewProposal(height, round, polRound, propBlockID, &block.DataAvailabilityHeader)
p, err := proposal.ToProto()
if err != nil {
panic(err)
Expand Down Expand Up @@ -600,13 +599,7 @@ func ensureNewUnlock(unlockCh <-chan tmpubsub.Message, height int64, round int32
"Timeout expired while waiting for NewUnlock event")
}

func ensureProposal(
proposalCh <-chan tmpubsub.Message,
height int64,
round int32,
propID types.BlockID,
propPartSetHeader types.PartSetHeader,
) {
func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int32, propID types.BlockID) {
select {
case <-time.After(ensureTimeout):
panic("Timeout expired while waiting for NewProposal event")
Expand All @@ -622,7 +615,7 @@ func ensureProposal(
if proposalEvent.Round != round {
panic(fmt.Sprintf("expected round %v, got %v", round, proposalEvent.Round))
}
if !proposalEvent.BlockID.Equals(propID) || !proposalEvent.PartSetHeader.Equals(propPartSetHeader) {
if !proposalEvent.BlockID.Equals(propID) {
panic(fmt.Sprintf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, propID))
}
}
Expand Down
5 changes: 2 additions & 3 deletions consensus/invalid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ func invalidDoPrevoteFunc(t *testing.T, height int64, round int32, cs *State, sw
Timestamp: cs.voteTime(),
Type: tmproto.PrecommitType,
BlockID: types.BlockID{
Hash: blockHash,
},
PartSetHeader: types.PartSetHeader{Total: 1, Hash: tmrand.Bytes(32)},
Hash: blockHash,
PartSetHeader: types.PartSetHeader{Total: 1, Hash: tmrand.Bytes(32)}},
}
p := precommit.ToProto()
err = cs.privValidator.SignVote(cs.state.ChainID, p)
Expand Down
49 changes: 24 additions & 25 deletions consensus/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func TestMsgToProto(t *testing.T) {
}
pbPsh := psh.ToProto()
bi := types.BlockID{
Hash: tmrand.Bytes(32),
Hash: tmrand.Bytes(32),
PartSetHeader: psh,
}
pbBi := bi.ToProto()
bits := bits.NewBitArray(1)
Expand All @@ -50,14 +51,13 @@ func TestMsgToProto(t *testing.T) {
roots, err := types.NmtRootsFromBytes([][]byte{tmrand.Bytes(2*consts.NamespaceSize + tmhash.Size)})
require.NoError(t, err)
proposal := types.Proposal{
Type: tmproto.ProposalType,
Height: 1,
Round: 1,
POLRound: 1,
BlockID: bi,
PartSetHeader: psh,
Timestamp: time.Now(),
Signature: tmrand.Bytes(20),
Type: tmproto.ProposalType,
Height: 1,
Round: 1,
POLRound: 1,
BlockID: bi,
Timestamp: time.Now(),
Signature: tmrand.Bytes(20),
DAHeader: &types.DataAvailabilityHeader{
RowsRoots: roots,
ColumnRoots: roots,
Expand All @@ -72,7 +72,7 @@ func TestMsgToProto(t *testing.T) {
val := types.NewValidator(pk, 100)

vote, err := types.MakeVote(
1, types.BlockID{}, types.PartSetHeader{}, &types.ValidatorSet{Proposer: val, Validators: []*types.Validator{val}},
1, types.BlockID{}, &types.ValidatorSet{Proposer: val, Validators: []*types.Validator{val}},
pv, "chainID", time.Now())
require.NoError(t, err)
pbVote := vote.ToProto()
Expand Down Expand Up @@ -333,7 +333,8 @@ func TestConsMsgsVectors(t *testing.T) {
pbPsh := psh.ToProto()

bi := types.BlockID{
Hash: []byte("add_more_exclamation_marks_code-"),
Hash: []byte("add_more_exclamation_marks_code-"),
PartSetHeader: psh,
}
pbBi := bi.ToProto()
bits := bits.NewBitArray(1)
Expand All @@ -353,15 +354,14 @@ func TestConsMsgsVectors(t *testing.T) {
require.NoError(t, err)

proposal := types.Proposal{
Type: tmproto.ProposalType,
Height: 1,
Round: 1,
POLRound: 1,
BlockID: bi,
Timestamp: date,
Signature: []byte("add_more_exclamation"),
DAHeader: &types.DataAvailabilityHeader{},
PartSetHeader: psh,
Type: tmproto.ProposalType,
Height: 1,
Round: 1,
POLRound: 1,
BlockID: bi,
Timestamp: date,
Signature: []byte("add_more_exclamation"),
DAHeader: &types.DataAvailabilityHeader{},
}
pbProposal, err := proposal.ToProto()
require.NoError(t, err)
Expand All @@ -374,7 +374,6 @@ func TestConsMsgsVectors(t *testing.T) {
Timestamp: date,
Type: tmproto.PrecommitType,
BlockID: bi,
PartSetHeader: psh,
}
vpb := v.ToProto()

Expand Down Expand Up @@ -402,7 +401,7 @@ func TestConsMsgsVectors(t *testing.T) {
Height: 1, Round: 1, BlockPartSetHeader: pbPsh, BlockParts: pbBits, IsCommit: false}}},
"1231080110011a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d22050801120100"},
{"Proposal", &tmcons.Message{Sum: &tmcons.Message_Proposal{Proposal: &tmcons.Proposal{Proposal: *pbProposal}}},
"1a740a7208201001180120012a220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e42004a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"},
"1a740a7208201001180120012a480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e4200"},
{"ProposalPol", &tmcons.Message{Sum: &tmcons.Message_ProposalPol{
ProposalPol: &tmcons.ProposalPOL{Height: 1, ProposalPolRound: 1}}},
"2206080110011a00"},
Expand All @@ -411,7 +410,7 @@ func TestConsMsgsVectors(t *testing.T) {
"2a36080110011a3008011204746573741a26080110011a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"},
{"Vote", &tmcons.Message{Sum: &tmcons.Message_Vote{
Vote: &tmcons.Vote{Vote: vpb}}},
"32700a6e0802100122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a0608c0b89fdc0532146164645f6d6f72655f6578636c616d6174696f6e38014a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"},
"32700a6e0802100122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a0608c0b89fdc0532146164645f6d6f72655f6578636c616d6174696f6e3801"},
{"HasVote", &tmcons.Message{Sum: &tmcons.Message_HasVote{
HasVote: &tmcons.HasVote{Height: 1, Round: 1, Type: tmproto.PrevoteType, Index: 1}}},
"3a080801100118012001"},
Expand All @@ -421,10 +420,10 @@ func TestConsMsgsVectors(t *testing.T) {
"3a1808ffffffffffffffff7f10ffffffff07180120ffffffff07"},
{"VoteSetMaj23", &tmcons.Message{Sum: &tmcons.Message_VoteSetMaj23{
VoteSetMaj23: &tmcons.VoteSetMaj23{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi}}},
"422a08011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"},
"425008011001180122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"},
{"VoteSetBits", &tmcons.Message{Sum: &tmcons.Message_VoteSetBits{
VoteSetBits: &tmcons.VoteSetBits{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi, Votes: *pbBits}}},
"4a3108011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a050801120100"},
"4a5708011001180122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a050801120100"},
}

for _, tc := range testCases {
Expand Down
20 changes: 10 additions & 10 deletions consensus/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ OUTER_LOOP:
"blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height())
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
} else {
ps.InitProposalBlockParts(blockMeta.PartSetHeader)
ps.InitProposalBlockParts(blockMeta.BlockID.PartSetHeader)
}
// continue the loop since prs is a copy and not effected by this initialization
continue OUTER_LOOP
Expand Down Expand Up @@ -597,17 +597,17 @@ func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundSt
"blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height())
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
return
} else if !blockMeta.PartSetHeader.Equals(prs.ProposalBlockPartSetHeader) {
} else if !blockMeta.BlockID.PartSetHeader.Equals(prs.ProposalBlockPartSetHeader) {
logger.Info("Peer ProposalBlockPartSetHeader mismatch, sleeping",
"blockPartSetHeader", blockMeta.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader)
"blockPartSetHeader", blockMeta.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader)
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
return
}
// Load the part
part := conR.conS.blockStore.LoadBlockPart(prs.Height, index)
if part == nil {
logger.Error("Could not load part", "index", index,
"blockPartSetHeader", blockMeta.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader)
"blockPartSetHeader", blockMeta.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader)
time.Sleep(conR.conS.config.PeerGossipSleepDuration)
return
}
Expand Down Expand Up @@ -778,7 +778,7 @@ OUTER_LOOP:
rs := conR.conS.GetRoundState()
prs := ps.GetRoundState()
if rs.Height == prs.Height {
if maj23, _, ok := rs.Votes.Prevotes(prs.Round).TwoThirdsMajority(); ok {
if maj23, ok := rs.Votes.Prevotes(prs.Round).TwoThirdsMajority(); ok {
peer.TrySend(StateChannel, MustEncode(&VoteSetMaj23Message{
Height: prs.Height,
Round: prs.Round,
Expand All @@ -795,7 +795,7 @@ OUTER_LOOP:
rs := conR.conS.GetRoundState()
prs := ps.GetRoundState()
if rs.Height == prs.Height {
if maj23, _, ok := rs.Votes.Precommits(prs.Round).TwoThirdsMajority(); ok {
if maj23, ok := rs.Votes.Precommits(prs.Round).TwoThirdsMajority(); ok {
peer.TrySend(StateChannel, MustEncode(&VoteSetMaj23Message{
Height: prs.Height,
Round: prs.Round,
Expand All @@ -812,7 +812,7 @@ OUTER_LOOP:
rs := conR.conS.GetRoundState()
prs := ps.GetRoundState()
if rs.Height == prs.Height && prs.ProposalPOLRound >= 0 {
if maj23, _, ok := rs.Votes.Prevotes(prs.ProposalPOLRound).TwoThirdsMajority(); ok {
if maj23, ok := rs.Votes.Prevotes(prs.ProposalPOLRound).TwoThirdsMajority(); ok {
peer.TrySend(StateChannel, MustEncode(&VoteSetMaj23Message{
Height: prs.Height,
Round: prs.ProposalPOLRound,
Expand Down Expand Up @@ -1017,8 +1017,8 @@ func (ps *PeerState) SetHasProposal(proposal *types.Proposal) {
return
}

ps.PRS.ProposalBlockPartSetHeader = proposal.PartSetHeader
ps.PRS.ProposalBlockParts = bits.NewBitArray(int(proposal.PartSetHeader.Total))
ps.PRS.ProposalBlockPartSetHeader = proposal.BlockID.PartSetHeader
ps.PRS.ProposalBlockParts = bits.NewBitArray(int(proposal.BlockID.PartSetHeader.Total))
ps.PRS.ProposalPOLRound = proposal.POLRound
ps.PRS.ProposalPOL = nil // Nil until ProposalPOLMessage received.
}
Expand Down Expand Up @@ -1679,7 +1679,7 @@ func (m *VoteSetMaj23Message) ValidateBasic() error {
return errors.New("invalid Type")
}
if err := m.BlockID.ValidateBasic(); err != nil {
return fmt.Errorf("wrong BlockID: %w", err)
return fmt.Errorf("wrong BlockID: %v", err)
}
return nil
}
Expand Down
15 changes: 14 additions & 1 deletion consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,11 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) {

validBlockID := types.BlockID{}
invalidBlockID := types.BlockID{
Hash: bytes.HexBytes("invalid"),
Hash: bytes.HexBytes{},
PartSetHeader: types.PartSetHeader{
Total: 1,
Hash: []byte{0},
},
}

testCases := []struct { // nolint: maligned
Expand Down Expand Up @@ -968,6 +972,15 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) {
{func(msg *VoteSetBitsMessage) {}, ""},
{func(msg *VoteSetBitsMessage) { msg.Height = -1 }, "negative Height"},
{func(msg *VoteSetBitsMessage) { msg.Type = 0x03 }, "invalid Type"},
{func(msg *VoteSetBitsMessage) {
msg.BlockID = types.BlockID{
Hash: bytes.HexBytes{},
PartSetHeader: types.PartSetHeader{
Total: 1,
Hash: []byte{0},
},
}
}, "wrong BlockID: wrong PartSetHeader: wrong Hash:"},
{func(msg *VoteSetBitsMessage) { msg.Votes = bits.NewBitArray(types.MaxVotesCount + 1) },
"votes bit array is too big: 10001, max: 10000"},
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (cs *State) readReplayMessage(msg *TimedWALMessage, newStepSub types.Subscr
case *ProposalMessage:
p := msg.Proposal
cs.Logger.Info("Replay: Proposal", "height", p.Height, "round", p.Round, "header",
p.PartSetHeader, "pol", p.POLRound, "peer", peerID)
p.BlockID.PartSetHeader, "pol", p.POLRound, "peer", peerID)
case *BlockPartMessage:
cs.Logger.Info("Replay: BlockPart", "height", msg.Height, "round", msg.Round, "peer", peerID)
case *VoteMessage:
Expand Down Expand Up @@ -506,7 +506,7 @@ func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.Ap
blockExec := sm.NewBlockExecutor(h.stateStore, h.logger, proxyApp, emptyMempool{}, sm.EmptyEvidencePool{})
blockExec.SetEventBus(h.eventBus)

state, _, err = blockExec.ApplyBlock(state, meta.BlockID, meta.PartSetHeader, block)
state, _, err = blockExec.ApplyBlock(state, meta.BlockID, block)
if err != nil {
return sm.State{}, err
}
Expand Down
Loading