From 29f160da0f0ef19386ca1701e6898e17cbfe6756 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Wed, 24 Mar 2021 11:59:05 +0200 Subject: [PATCH] some intermediate progress that will be overwritten anyway --- consensus/byzantine_test.go | 47 +-- consensus/common_test.go | 33 +- consensus/invalid_test.go | 2 +- consensus/msgs.go | 42 +- consensus/msgs_test.go | 123 +++--- consensus/reactor.go | 205 ++++----- consensus/reactor_test.go | 66 ++- consensus/replay.go | 9 +- consensus/replay_file.go | 4 +- consensus/replay_test.go | 53 +-- consensus/state.go | 290 ++++++------- consensus/state_test.go | 298 ++++++------- consensus/types/height_vote_set.go | 2 +- consensus/types/peer_round_state.go | 12 +- consensus/types/round_state.go | 33 +- consensus/wal_test.go | 23 +- go.sum | 2 - light/rpc/client.go | 2 +- p2p/conn/connection.go | 4 +- p2p/node_info.go | 6 +- proto/tendermint/blockchain/types.pb.go | 2 +- proto/tendermint/consensus/types.pb.go | 540 ++++++++++++++++++------ proto/tendermint/consensus/types.proto | 13 +- proto/tendermint/p2p/types.pb.go | 2 +- proto/tendermint/types/block.pb.go | 6 +- proto/tendermint/types/params.pb.go | 2 +- proto/tendermint/types/types.pb.go | 330 +++++++++------ proto/tendermint/types/types.proto | 9 +- proto/tendermint/version/types.pb.go | 2 +- rpc/client/rpc_test.go | 2 +- state/state.go | 6 +- state/validation.go | 20 +- store/store.go | 8 +- test/maverick/consensus/reactor.go | 2 +- test/maverick/consensus/replay.go | 2 +- types/block.go | 37 +- types/events.go | 2 +- types/evidence.go | 4 - types/params.go | 2 +- types/proposal.go | 8 +- types/protobuf.go | 2 +- types/vote.go | 8 + types/vote_set.go | 14 +- types/vote_set_test.go | 4 +- 44 files changed, 1244 insertions(+), 1039 deletions(-) diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 0268b31de8..aab38e1b83 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -132,9 +132,9 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { // allow first height to happen normally so that byzantine validator is no longer proposer if height == prevoteHeight { bcs.Logger.Info("Sending two votes") - prevote1, err := bcs.signVote(tmproto.PrevoteType, bcs.ProposalBlock.Hash(), bcs.ProposalBlockParts.Header()) + prevote1, err := bcs.signVote(tmproto.PrevoteType, bcs.ProposalBlock.Hash(), bcs.ProposalBlockDAHeader) require.NoError(t, err) - prevote2, err := bcs.signVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) + prevote2, err := bcs.signVote(tmproto.PrevoteType, nil, nil) require.NoError(t, err) peerList := reactors[byzantineNode].Switch.Peers().List() bcs.Logger.Info("Getting peer list", "peers", peerList) @@ -374,9 +374,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St // Avoid sending on internalMsgQueue and running consensus state. // Create a new proposal block from state/txs from the mempool. - block1, blockParts1 := cs.createProposalBlock() - polRound, propBlockID := cs.ValidRound, types.BlockID{Hash: block1.Hash(), PartSetHeader: blockParts1.Header()} - proposal1 := types.NewProposal(height, round, polRound, propBlockID) + block1 := cs.createProposalBlock() + proposal1 := types.NewProposal(height, round, cs.ValidRound, &block1.DataAvailabilityHeader) p1 := proposal1.ToProto() if err := cs.privValidator.SignProposal(cs.state.ChainID, p1); err != nil { t.Error(err) @@ -388,9 +387,8 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St deliverTxsRange(cs, 0, 1) // Create a new proposal block from state/txs from the mempool. - block2, blockParts2 := cs.createProposalBlock() - polRound, propBlockID = cs.ValidRound, types.BlockID{Hash: block2.Hash(), PartSetHeader: blockParts2.Header()} - proposal2 := types.NewProposal(height, round, polRound, propBlockID) + block2 := cs.createProposalBlock() + proposal2 := types.NewProposal(height, round, cs.ValidRound, &block1.DataAvailabilityHeader) p2 := proposal2.ToProto() if err := cs.privValidator.SignProposal(cs.state.ChainID, p2); err != nil { t.Error(err) @@ -406,41 +404,38 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *St t.Logf("Byzantine: broadcasting conflicting proposals to %d peers", len(peers)) for i, peer := range peers { if i < len(peers)/2 { - go sendProposalAndParts(height, round, cs, peer, proposal1, block1Hash, blockParts1) + go sendProposalAndBlock(height, round, cs, peer, proposal1, block1Hash, block1) } else { - go sendProposalAndParts(height, round, cs, peer, proposal2, block2Hash, blockParts2) + go sendProposalAndBlock(height, round, cs, peer, proposal2, block2Hash, block2) } } } -func sendProposalAndParts( +func sendProposalAndBlock( height int64, round int32, cs *State, peer p2p.Peer, proposal *types.Proposal, blockHash []byte, - parts *types.PartSet, + block *types.Block, ) { // proposal - msg := &ProposalMessage{Proposal: proposal} - peer.Send(DataChannel, MustEncode(msg)) - - // parts - for i := 0; i < int(parts.Total()); i++ { - part := parts.GetPart(i) - msg := &BlockPartMessage{ - Height: height, // This tells peer that this part applies to us. - Round: round, // This tells peer that this part applies to us. - Part: part, - } - peer.Send(DataChannel, MustEncode(msg)) + pmsg := &ProposalMessage{Proposal: proposal} + peer.Send(DataChannel, MustEncode(pmsg)) + + // block + bmsg := &BlockMessage{ + Height: height, // This tells peer that this part applies to us. + Round: round, // This tells peer that this part applies to us. + Block: block, } + peer.Send(DataChannel, MustEncode(bmsg)) // votes cs.mtx.Lock() - prevote, _ := cs.signVote(tmproto.PrevoteType, blockHash, parts.Header()) - precommit, _ := cs.signVote(tmproto.PrecommitType, blockHash, parts.Header()) + prevote, _ := cs.signVote(tmproto.PrevoteType, blockHash, &block.DataAvailabilityHeader) + precommit, _ := cs.signVote(tmproto.PrecommitType, blockHash, &block.DataAvailabilityHeader) cs.mtx.Unlock() peer.Send(VoteChannel, MustEncode(&VoteMessage{prevote})) diff --git a/consensus/common_test.go b/consensus/common_test.go index 198622cef9..17b8471f66 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -86,11 +86,7 @@ func newValidatorStub(privValidator types.PrivValidator, valIndex int32) *valida } } -func (vs *validatorStub) signVote( - voteType tmproto.SignedMsgType, - hash []byte, - header types.PartSetHeader) (*types.Vote, error) { - +func (vs *validatorStub) signVote(voteType tmproto.SignedMsgType, hash []byte, dah *types.DataAvailabilityHeader) (*types.Vote, error) { pubKey, err := vs.PrivValidator.GetPubKey() if err != nil { return nil, fmt.Errorf("can't get pubkey: %w", err) @@ -103,8 +99,10 @@ func (vs *validatorStub) signVote( Round: vs.Round, Timestamp: tmtime.Now(), Type: voteType, - BlockID: types.BlockID{Hash: hash, PartSetHeader: header}, + BlockID: types.BlockID{Hash: hash}, + DAHeader: dah, } + v := vote.ToProto() err = vs.PrivValidator.SignVote(config.ChainID(), v) vote.Signature = v.Signature @@ -113,8 +111,8 @@ func (vs *validatorStub) signVote( } // Sign vote for type/hash/header -func signVote(vs *validatorStub, voteType tmproto.SignedMsgType, hash []byte, header types.PartSetHeader) *types.Vote { - v, err := vs.signVote(voteType, hash, header) +func signVote(vs *validatorStub, voteType tmproto.SignedMsgType, hash []byte, dah *types.DataAvailabilityHeader) *types.Vote { + v, err := vs.signVote(voteType, hash, dah) if err != nil { panic(fmt.Errorf("failed to sign vote: %v", err)) } @@ -124,11 +122,11 @@ func signVote(vs *validatorStub, voteType tmproto.SignedMsgType, hash []byte, he func signVotes( voteType tmproto.SignedMsgType, hash []byte, - header types.PartSetHeader, + dah *types.DataAvailabilityHeader, vss ...*validatorStub) []*types.Vote { votes := make([]*types.Vote, len(vss)) for i, vs := range vss { - votes[i] = signVote(vs, voteType, hash, header) + votes[i] = signVote(vs, voteType, hash, dah) } return votes } @@ -191,7 +189,7 @@ func decideProposal( round int32, ) (proposal *types.Proposal, block *types.Block) { cs1.mtx.Lock() - block, blockParts := cs1.createProposalBlock() + block = cs1.createProposalBlock() validRound := cs1.ValidRound chainID := cs1.state.ChainID cs1.mtx.Unlock() @@ -200,8 +198,7 @@ func decideProposal( } // Make proposal - polRound, propBlockID := validRound, types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()} - proposal = types.NewProposal(height, round, polRound, propBlockID) + proposal = types.NewProposal(height, round, validRound, &block.DataAvailabilityHeader) p := proposal.ToProto() if err := vs.SignProposal(chainID, p); err != nil { panic(err) @@ -222,10 +219,10 @@ func signAddVotes( to *State, voteType tmproto.SignedMsgType, hash []byte, - header types.PartSetHeader, + dah *types.DataAvailabilityHeader, vss ...*validatorStub, ) { - votes := signVotes(voteType, hash, header, vss...) + votes := signVotes(voteType, hash, dah, vss...) addVotes(to, votes...) } @@ -589,7 +586,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) { +func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int32, dah *types.DataAvailabilityHeader) { select { case <-time.After(ensureTimeout): panic("Timeout expired while waiting for NewProposal event") @@ -605,8 +602,8 @@ func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int3 if proposalEvent.Round != round { panic(fmt.Sprintf("expected round %v, got %v", round, proposalEvent.Round)) } - if !proposalEvent.BlockID.Equals(propID) { - panic(fmt.Sprintf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, propID)) + if !proposalEvent.DAHeader.Equal(dah) { + panic(fmt.Sprintf("Proposed block does not match expected block (%v != %v)", proposalEvent.DAHeader, dah)) } } } diff --git a/consensus/invalid_test.go b/consensus/invalid_test.go index 1ddee58727..4ac30b175d 100644 --- a/consensus/invalid_test.go +++ b/consensus/invalid_test.go @@ -80,7 +80,7 @@ func invalidDoPrevoteFunc(t *testing.T, height int64, round int32, cs *State, sw Type: tmproto.PrecommitType, BlockID: types.BlockID{ Hash: blockHash, - PartSetHeader: types.PartSetHeader{Total: 1, Hash: tmrand.Bytes(32)}}, + }, } p := precommit.ToProto() err = cs.privValidator.SignVote(cs.state.ChainID, p) diff --git a/consensus/msgs.go b/consensus/msgs.go index 686284a4c7..9a457f110d 100644 --- a/consensus/msgs.go +++ b/consensus/msgs.go @@ -36,15 +36,12 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { }, } case *NewValidBlockMessage: - pbPartSetHeader := msg.BlockPartSetHeader.ToProto() - pbBits := msg.BlockParts.ToProto() pb = tmcons.Message{ Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ Height: msg.Height, Round: msg.Round, - BlockPartSetHeader: pbPartSetHeader, - BlockParts: pbBits, + DAHeader: msg.BlockDAHeader.ToProto(), IsCommit: msg.IsCommit, }, }, @@ -69,17 +66,17 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { }, }, } - case *BlockPartMessage: - parts, err := msg.Part.ToProto() + case *BlockMessage: + block, err := msg.Block.ToProto() if err != nil { return nil, fmt.Errorf("msg to proto error: %w", err) } pb = tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_Block{ + Block: &tmcons.Block{ Height: msg.Height, Round: msg.Round, - Part: *parts, + Block: block, }, }, } @@ -165,22 +162,15 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { LastCommitRound: msg.NewRoundStep.LastCommitRound, } case *tmcons.Message_NewValidBlock: - pbPartSetHeader, err := types.PartSetHeaderFromProto(&msg.NewValidBlock.BlockPartSetHeader) + dah, err := types.DataAvailabilityHeaderFromProto(msg.NewValidBlock.DAHeader) if err != nil { - return nil, fmt.Errorf("parts header to proto error: %w", err) - } - - pbBits := new(bits.BitArray) - err = pbBits.FromProto(msg.NewValidBlock.BlockParts) - if err != nil { - return nil, fmt.Errorf("parts to proto error: %w", err) + return nil, fmt.Errorf("DAHeader to proto error: %w", err) } pb = &NewValidBlockMessage{ Height: msg.NewValidBlock.Height, Round: msg.NewValidBlock.Round, - BlockPartSetHeader: *pbPartSetHeader, - BlockParts: pbBits, + BlockDAHeader: dah, IsCommit: msg.NewValidBlock.IsCommit, } case *tmcons.Message_Proposal: @@ -203,15 +193,15 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { ProposalPOLRound: msg.ProposalPol.ProposalPolRound, ProposalPOL: pbBits, } - case *tmcons.Message_BlockPart: - parts, err := types.PartFromProto(&msg.BlockPart.Part) + case *tmcons.Message_Block: + block, err := types.BlockFromProto(msg.Block.Block) if err != nil { - return nil, fmt.Errorf("blockpart msg to proto error: %w", err) + return nil, fmt.Errorf("block msg to proto error: %w", err) } - pb = &BlockPartMessage{ - Height: msg.BlockPart.Height, - Round: msg.BlockPart.Round, - Part: parts, + pb = &BlockMessage{ + Height: msg.Block.Height, + Round: msg.Block.Round, + Block: block, } case *tmcons.Message_Vote: vote, err := types.VoteFromProto(msg.Vote.Vote) diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index 2984878622..88107518e6 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/lazyledger/lazyledger-core/crypto/merkle" + "github.com/lazyledger/lazyledger-core/crypto" "github.com/lazyledger/lazyledger-core/libs/bits" tmrand "github.com/lazyledger/lazyledger-core/libs/rand" "github.com/lazyledger/lazyledger-core/p2p" @@ -20,38 +20,34 @@ import ( ) func TestMsgToProto(t *testing.T) { - psh := types.PartSetHeader{ - Total: 1, - Hash: tmrand.Bytes(32), - } - pbPsh := psh.ToProto() bi := types.BlockID{ Hash: tmrand.Bytes(32), - PartSetHeader: psh, } pbBi := bi.ToProto() bits := bits.NewBitArray(1) pbBits := bits.ToProto() - parts := types.Part{ - Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: tmrand.Bytes(32), - Aunts: [][]byte{}, - }, - } - pbParts, err := parts.ToProto() + block := types.MakeBlock( + int64(3), + []types.Tx{types.Tx("Hello World")}, + nil, + nil, + types.Messages{}, + &types.Commit{Signatures: []types.CommitSig{}}, + ) + block.ProposerAddress = tmrand.Bytes(crypto.AddressSize) + pbBlock, err := block.ToProto() require.NoError(t, err) + dah := &block.DataAvailabilityHeader + pbDah := dah.ToProto() + proposal := types.Proposal{ Type: tmproto.ProposalType, Height: 1, Round: 1, POLRound: 1, - BlockID: bi, + DAHeader: dah, Timestamp: time.Now(), Signature: tmrand.Bytes(20), } @@ -95,30 +91,28 @@ func TestMsgToProto(t *testing.T) { {"successful NewValidBlockMessage", &NewValidBlockMessage{ Height: 1, Round: 1, - BlockPartSetHeader: psh, - BlockParts: bits, + BlockDAHeader: dah, IsCommit: false, }, &tmcons.Message{ Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ Height: 1, Round: 1, - BlockPartSetHeader: pbPsh, - BlockParts: pbBits, + DAHeader: pbDah, IsCommit: false, }, }, }, false}, - {"successful BlockPartMessage", &BlockPartMessage{ + {"successful BlockPartMessage", &BlockMessage{ Height: 100, Round: 1, - Part: &parts, + Block: block, }, &tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_Block{ + Block: &tmcons.Block{ Height: 100, Round: 1, - Part: *pbParts, + Block: pbBlock, }, }, }, false}, @@ -210,18 +204,17 @@ func TestMsgToProto(t *testing.T) { } func TestWALMsgProto(t *testing.T) { + block := types.MakeBlock( + int64(3), + []types.Tx{types.Tx("Hello World")}, + nil, + nil, + types.Messages{}, + &types.Commit{Signatures: []types.CommitSig{}}, + ) + block.ProposerAddress = tmrand.Bytes(crypto.AddressSize) - parts := types.Part{ - Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: tmrand.Bytes(32), - Aunts: [][]byte{}, - }, - } - pbParts, err := parts.ToProto() + pbBlock, err := block.ToProto() require.NoError(t, err) testsCases := []struct { @@ -244,21 +237,21 @@ func TestWALMsgProto(t *testing.T) { }, }, false}, {"successful msgInfo", msgInfo{ - Msg: &BlockPartMessage{ + Msg: &BlockMessage{ Height: 100, Round: 1, - Part: &parts, + Block: block, }, PeerID: p2p.ID("string"), }, &tmcons.WALMessage{ Sum: &tmcons.WALMessage_MsgInfo{ MsgInfo: &tmcons.MsgInfo{ Msg: tmcons.Message{ - Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{ + Sum: &tmcons.Message_Block{ + Block: &tmcons.Block{ Height: 100, Round: 1, - Part: *pbParts, + Block: pbBlock, }, }, }, @@ -306,7 +299,7 @@ func TestWALMsgProto(t *testing.T) { if !tt.wantErr { require.NoError(t, err) - assert.Equal(t, tt.msg, msg, tt.testName) // need the concrete type as WAL Message is a empty interface + assert.EqualValues(t, tt.msg, msg, tt.testName) // need the concrete type as WAL Message is a empty interface } else { require.Error(t, err, tt.testName) } @@ -321,7 +314,6 @@ func TestConsMsgsVectors(t *testing.T) { Total: 1, Hash: []byte("add_more_exclamation_marks_code-"), } - pbPsh := psh.ToProto() bi := types.BlockID{ Hash: []byte("add_more_exclamation_marks_code-"), @@ -331,25 +323,26 @@ func TestConsMsgsVectors(t *testing.T) { bits := bits.NewBitArray(1) pbBits := bits.ToProto() - parts := types.Part{ - Index: 1, - Bytes: []byte("test"), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: []byte("add_more_exclamation_marks_code-"), - Aunts: [][]byte{}, - }, - } - pbParts, err := parts.ToProto() + block := types.MakeBlock( + int64(3), + []types.Tx{types.Tx("Hello World")}, + nil, + nil, + types.Messages{}, + nil, + ) + pbBlock, err := block.ToProto() require.NoError(t, err) + dah := &block.DataAvailabilityHeader + pbDah := dah.ToProto() + proposal := types.Proposal{ Type: tmproto.ProposalType, Height: 1, Round: 1, POLRound: 1, - BlockID: bi, + DAHeader: dah, Timestamp: date, Signature: []byte("add_more_exclamation"), } @@ -387,19 +380,19 @@ func TestConsMsgsVectors(t *testing.T) { }}}, "0a2608ffffffffffffffff7f10ffffffff0718ffffffff0f20ffffffffffffffff7f28ffffffff07"}, {"NewValidBlock", &tmcons.Message{Sum: &tmcons.Message_NewValidBlock{ NewValidBlock: &tmcons.NewValidBlock{ - Height: 1, Round: 1, BlockPartSetHeader: pbPsh, BlockParts: pbBits, IsCommit: false}}}, - "1231080110011a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d22050801120100"}, + Height: 1, Round: 1, DAHeader: pbDah, IsCommit: false}}}, + "12cf01080110011ac8010a300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d0a30ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e812300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d1230ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e8"}, {"Proposal", &tmcons.Message{Sum: &tmcons.Message_Proposal{Proposal: &tmcons.Proposal{Proposal: *pbProposal}}}, - "1a720a7008201001180120012a480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e"}, + "1af4010af10108201001180120012ac8010a300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d0a30ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e812300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d1230ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e8320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e"}, {"ProposalPol", &tmcons.Message{Sum: &tmcons.Message_ProposalPol{ ProposalPol: &tmcons.ProposalPOL{Height: 1, ProposalPolRound: 1}}}, "2206080110011a00"}, - {"BlockPart", &tmcons.Message{Sum: &tmcons.Message_BlockPart{ - BlockPart: &tmcons.BlockPart{Height: 1, Round: 1, Part: *pbParts}}}, - "2a36080110011a3008011204746573741a26080110011a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"}, + {"Blocks", &tmcons.Message{Sum: &tmcons.Message_Block{ + Block: &tmcons.Block{Height: 1, Round: 1, Block: pbBlock}}}, + "52c402080110011abd020a5b0a02080b1803220b088092b8c398feffffff012a0212003a20ba28ef83fed712be8a128587469a4effda9f4f4895bd5638dab1f10775c9bed66a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b85512130a0b48656c6c6f20576f726c6412001a0022001ac8010a300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d0a30ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e812300000000000000001000000000000000119251d276ad8a1831db7b86ead3f42c4e03093d50ecf026da7ecc3b0da8ec87d1230ffffffffffffffffffffffffffffffff12d55aea72367d0d6a7899103a437c913ee5a6f9e86f42e0fe8743b0d8d3a1e8"}, {"Vote", &tmcons.Message{Sum: &tmcons.Message_Vote{ Vote: &tmcons.Vote{Vote: vpb}}}, - "32700a6e0802100122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a0608c0b89fdc0532146164645f6d6f72655f6578636c616d6174696f6e3801"}, + "32720a700802100122480a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d1224080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a00320608c0b89fdc053a146164645f6d6f72655f6578636c616d6174696f6e4001"}, {"HasVote", &tmcons.Message{Sum: &tmcons.Message_HasVote{ HasVote: &tmcons.HasVote{Height: 1, Round: 1, Type: tmproto.PrevoteType, Index: 1}}}, "3a080801100118012001"}, diff --git a/consensus/reactor.go b/consensus/reactor.go index 09871e7652..dcb78fc74d 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -313,10 +313,12 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} case *ProposalPOLMessage: ps.ApplyProposalPOLMessage(msg) - case *BlockPartMessage: - ps.SetHasProposalBlockPart(msg.Height, msg.Round, int(msg.Part.Index)) - conR.Metrics.BlockParts.With("peer_id", string(src.ID())).Add(1) + case *BlockMessage: + ps.SetHasProposalBlock(msg.Height, msg.Round) conR.conS.peerMsgQueue <- msgInfo{msg, src.ID()} + + // TODO(Wondertan): Have to be Metrics.Blocks or removed at all + conR.Metrics.BlockParts.With("peer_id", string(src.ID())).Add(1) default: conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg))) } @@ -419,7 +421,6 @@ func (conR *Reactor) subscribeToBroadcastEvents() { }); err != nil { conR.Logger.Error("Error adding listener for events", "err", err) } - } func (conR *Reactor) unsubscribeFromBroadcastEvents() { @@ -436,8 +437,7 @@ func (conR *Reactor) broadcastNewValidBlockMessage(rs *cstypes.RoundState) { csMsg := &NewValidBlockMessage{ Height: rs.Height, Round: rs.Round, - BlockPartSetHeader: rs.ProposalBlockParts.Header(), - BlockParts: rs.ProposalBlockParts.BitArray(), + BlockDAHeader: rs.ProposalBlockDAHeader, IsCommit: rs.Step == cstypes.RoundStepCommit, } conR.Switch.Broadcast(StateChannel, MustEncode(csMsg)) @@ -502,40 +502,36 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() - // Send proposal Block parts? - if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartSetHeader) { - if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok { - part := rs.ProposalBlockParts.GetPart(index) - msg := &BlockPartMessage{ - Height: rs.Height, // This tells peer that this part applies to us. - Round: rs.Round, // This tells peer that this part applies to us. - Part: part, - } - logger.Debug("Sending block part", "height", prs.Height, "round", prs.Round) - if peer.Send(DataChannel, MustEncode(msg)) { - ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) - } - continue OUTER_LOOP + if rs.ProposalBlock != nil && rs.ProposalBlockDAHeader.Equal(prs.ProposalBlockDAHeader) && !prs.ProposalBlock { + msg := &BlockMessage{ + Height: rs.Height, // This tells peer that this part applies to us. + Round: rs.Round, // This tells peer that this part applies to us. + Block: rs.ProposalBlock, + } + logger.Debug("Sending block", "height", prs.Height, "round", prs.Round) + if peer.Send(DataChannel, MustEncode(msg)) { + ps.SetHasProposalBlock(prs.Height, prs.Round) } + continue OUTER_LOOP } // If the peer is on a previous height that we have, help catch up. if (0 < prs.Height) && (prs.Height < rs.Height) && (prs.Height >= conR.conS.blockStore.Base()) { heightLogger := logger.With("height", prs.Height) - // if we never received the commit message from the peer, the block parts wont be initialized - if prs.ProposalBlockParts == nil { - blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) - if blockMeta == nil { - heightLogger.Error("Failed to load block meta", - "blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height()) - time.Sleep(conR.conS.config.PeerGossipSleepDuration) - } else { - ps.InitProposalBlockParts(blockMeta.BlockID.PartSetHeader) - } - // continue the loop since prs is a copy and not effected by this initialization - continue OUTER_LOOP - } + // // if we never received the commit message from the peer, the block parts wont be initialized + // if prs.ProposalBlockParts == nil { + // blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) + // if blockMeta == nil { + // heightLogger.Error("Failed to load block meta", + // "blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height()) + // time.Sleep(conR.conS.config.PeerGossipSleepDuration) + // } else { + // ps.InitProposalBlockParts(blockMeta.BlockID.PartSetHeader) + // } + // // continue the loop since prs is a copy and not effected by this initialization + // continue OUTER_LOOP + // } conR.gossipDataForCatchup(heightLogger, rs, prs, ps, peer) continue OUTER_LOOP } @@ -589,39 +585,34 @@ OUTER_LOOP: func (conR *Reactor) gossipDataForCatchup(logger log.Logger, rs *cstypes.RoundState, prs *cstypes.PeerRoundState, ps *PeerState, peer p2p.Peer) { - if index, ok := prs.ProposalBlockParts.Not().PickRandom(); ok { - // Ensure that the peer's PartSetHeader is correct - blockMeta := conR.conS.blockStore.LoadBlockMeta(prs.Height) - if blockMeta == nil { - logger.Error("Failed to load block meta", "ourHeight", rs.Height, - "blockstoreBase", conR.conS.blockStore.Base(), "blockstoreHeight", conR.conS.blockStore.Height()) - time.Sleep(conR.conS.config.PeerGossipSleepDuration) - return - } else if !blockMeta.BlockID.PartSetHeader.Equals(prs.ProposalBlockPartSetHeader) { - logger.Info("Peer ProposalBlockPartSetHeader mismatch, sleeping", - "blockPartSetHeader", blockMeta.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader) + if prs.ProposalBlockDAHeader != nil { + // Load the part + block := conR.conS.blockStore.LoadBlock(prs.Height) + if block == nil { + logger.Error("Could not load block", "height", prs.Height, + "blockDAHeader", prs.ProposalBlockDAHeader) 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.BlockID.PartSetHeader, "peerBlockPartSetHeader", prs.ProposalBlockPartSetHeader) + + // Ensure that the peer's DAHeader is correct + if !block.DataAvailabilityHeader.Equal(prs.ProposalBlockDAHeader) { + logger.Info("Peer ProposalBlockDAHeader mismatch, sleeping", + "blockDAHeader", block.DataAvailabilityHeader, "peerBlockDAHeader", prs.ProposalBlockDAHeader) time.Sleep(conR.conS.config.PeerGossipSleepDuration) - return } + // Send the part - msg := &BlockPartMessage{ + msg := &BlockMessage{ Height: prs.Height, // Not our height, so it doesn't matter. Round: prs.Round, // Not our height, so it doesn't matter. - Part: part, + Block: block, } - logger.Debug("Sending block part for catchup", "round", prs.Round, "index", index) + logger.Debug("Sending block for catchup", "round", prs.Round) if peer.Send(DataChannel, MustEncode(msg)) { - ps.SetHasProposalBlockPart(prs.Height, prs.Round, index) + ps.SetHasProposalBlock(prs.Height, prs.Round) } else { - logger.Debug("Sending block part for catchup failed") + logger.Debug("Sending block for catchup failed") } return } @@ -696,6 +687,7 @@ OUTER_LOOP: sleeping = 1 } + // Why not to catch Events from EventBus and send them accordingly without unnecessary looping?? time.Sleep(conR.conS.config.PeerGossipSleepDuration) continue OUTER_LOOP } @@ -778,7 +770,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, @@ -795,7 +787,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, @@ -812,7 +804,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, @@ -876,8 +868,8 @@ func (conR *Reactor) peerStatsRoutine() { if numVotes := ps.RecordVote(); numVotes%votesToContributeToBecomeGoodPeer == 0 { conR.Switch.MarkPeerAsGood(peer) } - case *BlockPartMessage: - if numParts := ps.RecordBlockPart(); numParts%blocksToContributeToBecomeGoodPeer == 0 { + case *BlockMessage: + if numParts := ps.RecordBlock(); numParts%blocksToContributeToBecomeGoodPeer == 0 { conR.Switch.MarkPeerAsGood(peer) } } @@ -940,13 +932,13 @@ type PeerState struct { // peerStateStats holds internal statistics for a peer. type peerStateStats struct { - Votes int `json:"votes"` - BlockParts int `json:"block_parts"` + Votes int `json:"votes"` + Blocks int `json:"block_parts"` } func (pss peerStateStats) String() string { return fmt.Sprintf("peerStateStats{votes: %d, blockParts: %d}", - pss.Votes, pss.BlockParts) + pss.Votes, pss.Blocks) } // NewPeerState returns a new PeerState for the given Peer @@ -1011,33 +1003,15 @@ func (ps *PeerState) SetHasProposal(proposal *types.Proposal) { } ps.PRS.Proposal = true - - // ps.PRS.ProposalBlockParts is set due to NewValidBlockMessage - if ps.PRS.ProposalBlockParts != nil { - return - } - - ps.PRS.ProposalBlockPartSetHeader = proposal.BlockID.PartSetHeader - ps.PRS.ProposalBlockParts = bits.NewBitArray(int(proposal.BlockID.PartSetHeader.Total)) ps.PRS.ProposalPOLRound = proposal.POLRound + ps.PRS.ProposalBlockDAHeader = proposal.DAHeader + ps.PRS.ProposalBlock = false ps.PRS.ProposalPOL = nil // Nil until ProposalPOLMessage received. } -// InitProposalBlockParts initializes the peer's proposal block parts header and bit array. -func (ps *PeerState) InitProposalBlockParts(partSetHeader types.PartSetHeader) { - ps.mtx.Lock() - defer ps.mtx.Unlock() - - if ps.PRS.ProposalBlockParts != nil { - return - } - - ps.PRS.ProposalBlockPartSetHeader = partSetHeader - ps.PRS.ProposalBlockParts = bits.NewBitArray(int(partSetHeader.Total)) -} - -// SetHasProposalBlockPart sets the given block part index as known for the peer. -func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index int) { +// SetHasProposalBlock sets the given block as known for the peer. +// FIXME: Should it take DAH or BlockID(HeaderHash) ? +func (ps *PeerState) SetHasProposalBlock(height int64, round int32) { ps.mtx.Lock() defer ps.mtx.Unlock() @@ -1045,7 +1019,7 @@ func (ps *PeerState) SetHasProposalBlockPart(height int64, round int32, index in return } - ps.PRS.ProposalBlockParts.SetIndex(index, true) + ps.PRS.ProposalBlock = true } // PickSendVote picks a vote and sends it to the peer. @@ -1219,22 +1193,22 @@ func (ps *PeerState) VotesSent() int { return ps.Stats.Votes } -// RecordBlockPart increments internal block part related statistics for this peer. +// RecordBlock increments internal block part related statistics for this peer. // It returns the total number of added block parts. -func (ps *PeerState) RecordBlockPart() int { +func (ps *PeerState) RecordBlock() int { ps.mtx.Lock() defer ps.mtx.Unlock() - ps.Stats.BlockParts++ - return ps.Stats.BlockParts + ps.Stats.Blocks++ + return ps.Stats.Blocks } -// BlockPartsSent returns the number of useful block parts the peer has sent us. -func (ps *PeerState) BlockPartsSent() int { +// BlocksSent returns the number of useful block parts the peer has sent us. +func (ps *PeerState) BlocksSent() int { ps.mtx.Lock() defer ps.mtx.Unlock() - return ps.Stats.BlockParts + return ps.Stats.Blocks } // SetHasVote sets the given vote as known by the peer @@ -1283,8 +1257,8 @@ func (ps *PeerState) ApplyNewRoundStepMessage(msg *NewRoundStepMessage) { ps.PRS.StartTime = startTime if psHeight != msg.Height || psRound != msg.Round { ps.PRS.Proposal = false - ps.PRS.ProposalBlockPartSetHeader = types.PartSetHeader{} - ps.PRS.ProposalBlockParts = nil + ps.PRS.ProposalBlock = false + ps.PRS.ProposalBlockDAHeader = nil ps.PRS.ProposalPOLRound = -1 ps.PRS.ProposalPOL = nil // We'll update the BitArray capacity later. @@ -1326,8 +1300,7 @@ func (ps *PeerState) ApplyNewValidBlockMessage(msg *NewValidBlockMessage) { return } - ps.PRS.ProposalBlockPartSetHeader = msg.BlockPartSetHeader - ps.PRS.ProposalBlockParts = msg.BlockParts + ps.PRS.ProposalBlockDAHeader = msg.BlockDAHeader } // ApplyProposalPOLMessage updates the peer state for the new proposal POL. @@ -1413,7 +1386,7 @@ func init() { tmjson.RegisterType(&NewValidBlockMessage{}, "tendermint/NewValidBlockMessage") tmjson.RegisterType(&ProposalMessage{}, "tendermint/Proposal") tmjson.RegisterType(&ProposalPOLMessage{}, "tendermint/ProposalPOL") - tmjson.RegisterType(&BlockPartMessage{}, "tendermint/BlockPart") + tmjson.RegisterType(&BlockMessage{}, "tendermint/Blocks") tmjson.RegisterType(&VoteMessage{}, "tendermint/Vote") tmjson.RegisterType(&HasVoteMessage{}, "tendermint/HasVote") tmjson.RegisterType(&VoteSetMaj23Message{}, "tendermint/VoteSetMaj23") @@ -1496,8 +1469,7 @@ func (m *NewRoundStepMessage) String() string { type NewValidBlockMessage struct { Height int64 Round int32 - BlockPartSetHeader types.PartSetHeader - BlockParts *bits.BitArray + BlockDAHeader *types.DataAvailabilityHeader IsCommit bool } @@ -1509,27 +1481,16 @@ func (m *NewValidBlockMessage) ValidateBasic() error { if m.Round < 0 { return errors.New("negative Round") } - if err := m.BlockPartSetHeader.ValidateBasic(); err != nil { - return fmt.Errorf("wrong BlockPartSetHeader: %v", err) - } - if m.BlockParts.Size() == 0 { - return errors.New("empty blockParts") - } - if m.BlockParts.Size() != int(m.BlockPartSetHeader.Total) { - return fmt.Errorf("blockParts bit array size %d not equal to BlockPartSetHeader.Total %d", - m.BlockParts.Size(), - m.BlockPartSetHeader.Total) - } - if m.BlockParts.Size() > int(types.MaxBlockPartsCount) { - return fmt.Errorf("blockParts bit array is too big: %d, max: %d", m.BlockParts.Size(), types.MaxBlockPartsCount) + if m.BlockDAHeader == nil { + return errors.New("empty BlockDAHeader") } return nil } // String returns a string representation. func (m *NewValidBlockMessage) String() string { - return fmt.Sprintf("[ValidBlockMessage H:%v R:%v BP:%v BA:%v IsCommit:%v]", - m.Height, m.Round, m.BlockPartSetHeader, m.BlockParts, m.IsCommit) + return fmt.Sprintf("[ValidBlockMessage H:%v R:%v BDAH:%v IsCommit:%v]", + m.Height, m.Round,m.BlockDAHeader, m.IsCommit) } //------------------------------------- @@ -1583,29 +1544,29 @@ func (m *ProposalPOLMessage) String() string { //------------------------------------- // BlockPartMessage is sent when gossipping a piece of the proposed block. -type BlockPartMessage struct { +type BlockMessage struct { Height int64 Round int32 - Part *types.Part + Block *types.Block } // ValidateBasic performs basic validation. -func (m *BlockPartMessage) ValidateBasic() error { +func (m *BlockMessage) ValidateBasic() error { if m.Height < 0 { return errors.New("negative Height") } if m.Round < 0 { return errors.New("negative Round") } - if err := m.Part.ValidateBasic(); err != nil { + if err := m.Block.ValidateBasic(); err != nil { return fmt.Errorf("wrong Part: %v", err) } return nil } // String returns a string representation. -func (m *BlockPartMessage) String() string { - return fmt.Sprintf("[BlockPart H:%v R:%v P:%v]", m.Height, m.Round, m.Part) +func (m *BlockMessage) String() string { + return fmt.Sprintf("[BlockPart H:%v R:%v P:%v]", m.Height, m.Round, m.Block) } //------------------------------------- diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index b3c601aaf7..78e8364048 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -22,11 +22,12 @@ import ( abci "github.com/lazyledger/lazyledger-core/abci/types" cfg "github.com/lazyledger/lazyledger-core/config" cstypes "github.com/lazyledger/lazyledger-core/consensus/types" + "github.com/lazyledger/lazyledger-core/crypto" cryptoenc "github.com/lazyledger/lazyledger-core/crypto/encoding" - "github.com/lazyledger/lazyledger-core/crypto/tmhash" "github.com/lazyledger/lazyledger-core/libs/bits" "github.com/lazyledger/lazyledger-core/libs/bytes" "github.com/lazyledger/lazyledger-core/libs/log" + tmrand "github.com/lazyledger/lazyledger-core/libs/rand" tmsync "github.com/lazyledger/lazyledger-core/libs/sync" mempl "github.com/lazyledger/lazyledger-core/mempool" "github.com/lazyledger/lazyledger-core/p2p" @@ -277,7 +278,7 @@ func TestReactorReceivePanicsIfInitPeerHasntBeenCalledYet(t *testing.T) { } // Test we record stats about votes and block parts from other peers. -func TestReactorRecordsVotesAndBlockParts(t *testing.T) { +func TestReactorRecordsVotesAndBlocks(t *testing.T) { N := 4 css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) defer cleanup() @@ -295,7 +296,7 @@ func TestReactorRecordsVotesAndBlockParts(t *testing.T) { ps := peer.Get(types.PeerStateKey).(*PeerState) assert.Equal(t, true, ps.VotesSent() > 0, "number of votes sent should have increased") - assert.Equal(t, true, ps.BlockPartsSent() > 0, "number of votes sent should have increased") + assert.Equal(t, true, ps.BlocksSent() > 0, "number of blocks sent should have increased") } //------------------------------------------------------------- @@ -637,7 +638,7 @@ func timeoutWaitGroup(t *testing.T, n int, f func(int), css []*State) { close(done) }() - // we're running many nodes in-process, possibly in in a virtual machine, + // we're running many nodes in-process, possibly in a virtual machine, // and spewing debug messages - making a block could take a while, timeout := time.Second * 120 @@ -748,20 +749,11 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) { {func(msg *NewValidBlockMessage) {}, ""}, {func(msg *NewValidBlockMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *NewValidBlockMessage) { msg.Round = -1 }, "negative Round"}, - { - func(msg *NewValidBlockMessage) { msg.BlockPartSetHeader.Total = 2 }, - "blockParts bit array size 1 not equal to BlockPartSetHeader.Total 2", - }, { func(msg *NewValidBlockMessage) { - msg.BlockPartSetHeader.Total = 0 - msg.BlockParts = bits.NewBitArray(0) + msg.BlockDAHeader = nil }, - "empty blockParts", - }, - { - func(msg *NewValidBlockMessage) { msg.BlockParts = bits.NewBitArray(int(types.MaxBlockPartsCount) + 1) }, - "blockParts bit array size 1602 not equal to BlockPartSetHeader.Total 1", + "empty BlockDAHeader", }, } @@ -771,10 +763,7 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) { msg := &NewValidBlockMessage{ Height: 1, Round: 0, - BlockPartSetHeader: types.PartSetHeader{ - Total: 1, - }, - BlockParts: bits.NewBitArray(1), + BlockDAHeader: new(types.DataAvailabilityHeader), } tc.malleateFn(msg) @@ -817,38 +806,45 @@ func TestProposalPOLMessageValidateBasic(t *testing.T) { } } -func TestBlockPartMessageValidateBasic(t *testing.T) { - testPart := new(types.Part) - testPart.Proof.LeafHash = tmhash.Sum([]byte("leaf")) +func TestBlockMessageValidateBasic(t *testing.T) { + testBlock := types.MakeBlock( + int64(3), + []types.Tx{types.Tx("Hello World")}, + nil, + nil, + types.Messages{}, + &types.Commit{Signatures: []types.CommitSig{}}, + ) + testBlock.ProposerAddress = tmrand.Bytes(crypto.AddressSize) + testCases := []struct { testName string messageHeight int64 messageRound int32 - messagePart *types.Part + messageBlock *types.Block expectErr bool }{ - {"Valid Message", 0, 0, testPart, false}, - {"Invalid Message", -1, 0, testPart, true}, - {"Invalid Message", 0, -1, testPart, true}, + {"Valid Message", 0, 0, testBlock, false}, + {"Invalid Message", -1, 0, testBlock, true}, + {"Invalid Message", 0, -1, testBlock, true}, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { - message := BlockPartMessage{ + message := BlockMessage{ Height: tc.messageHeight, Round: tc.messageRound, - Part: tc.messagePart, + Block: tc.messageBlock, } assert.Equal(t, tc.expectErr, message.ValidateBasic() != nil, "Validate Basic had an unexpected result") }) } - message := BlockPartMessage{Height: 0, Round: 0, Part: new(types.Part)} - message.Part.Index = 1 + message := BlockMessage{Height: 0, Round: 0, Block: new(types.Block)} - assert.Equal(t, true, message.ValidateBasic() != nil, "Validate Basic had an unexpected result") + assert.Error(t, message.ValidateBasic(), "Validate Basic had an unexpected result") } func TestHasVoteMessageValidateBasic(t *testing.T) { @@ -896,10 +892,6 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) { validBlockID := types.BlockID{} invalidBlockID := types.BlockID{ Hash: bytes.HexBytes{}, - PartSetHeader: types.PartSetHeader{ - Total: 1, - Hash: []byte{0}, - }, } testCases := []struct { // nolint: maligned @@ -943,10 +935,6 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) { {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) }, diff --git a/consensus/replay.go b/consensus/replay.go index beb0d70039..efbb7122ad 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -69,10 +69,9 @@ func (cs *State) readReplayMessage(msg *TimedWALMessage, newStepSub types.Subscr switch msg := m.Msg.(type) { case *ProposalMessage: p := msg.Proposal - cs.Logger.Info("Replay: Proposal", "height", p.Height, "round", p.Round, "header", - p.BlockID.PartSetHeader, "pol", p.POLRound, "peer", peerID) - case *BlockPartMessage: - cs.Logger.Info("Replay: BlockPart", "height", msg.Height, "round", msg.Round, "peer", peerID) + cs.Logger.Info("Replay: Proposal", "height", p.Height, "round", p.Round, "pol", p.POLRound, "peer", peerID) + case *BlockMessage: + cs.Logger.Info("Replay: Blocks", "height", msg.Height, "round", msg.Round, "peer", peerID) case *VoteMessage: v := msg.Vote cs.Logger.Info("Replay: Vote", "height", v.Height, "round", v.Round, "type", v.Type, @@ -515,7 +514,7 @@ func assertAppHashEqualsOneFromBlock(appHash []byte, block *types.Block) { if !bytes.Equal(appHash, block.AppHash) { panic(fmt.Sprintf(`block.AppHash does not match AppHash after replay. Got %X, expected %X. -Block: %v +Blocks: %v `, appHash, block.AppHash, block)) } diff --git a/consensus/replay_file.go b/consensus/replay_file.go index df1cd16a57..2998aef748 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -262,11 +262,11 @@ func (pb *playback) replayConsoleLoop() int { case "proposal": fmt.Println(rs.Proposal) case "proposal_block": - fmt.Printf("%v %v\n", rs.ProposalBlockParts.StringShort(), rs.ProposalBlock.StringShort()) + fmt.Printf("%v\n", rs.ProposalBlock.StringShort()) case "locked_round": fmt.Println(rs.LockedRound) case "locked_block": - fmt.Printf("%v %v\n", rs.LockedBlockParts.StringShort(), rs.LockedBlock.StringShort()) + fmt.Printf("%v\n", rs.LockedBlock.StringShort()) case "votes": fmt.Println(rs.Votes.StringIndented(" ")) diff --git a/consensus/replay_test.go b/consensus/replay_test.go index 28931b99d0..4a83fab3b3 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -333,8 +333,6 @@ func TestSimulateValidatorsChange(t *testing.T) { sim.GenesisState, _ = sm.MakeGenesisState(genDoc) sim.CleanupFunc = cleanup - partSize := types.BlockPartSizeBytes - newRoundCh := subscribe(css[0].eventBus, types.EventQueryNewRound) proposalCh := subscribe(css[0].eventBus, types.EventQueryCompleteProposal) @@ -350,7 +348,7 @@ func TestSimulateValidatorsChange(t *testing.T) { ensureNewRound(newRoundCh, height, 0) ensureNewProposal(proposalCh, height, round) rs := css[0].GetRoundState() - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) // HEIGHT 2 @@ -363,11 +361,9 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx1 := kvstore.MakeValSetChangeTx(valPubKey1ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts := propBlock.MakePartSet(partSize) - blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} + propBlock := css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - proposal := types.NewProposal(vss[1].Height, round, -1, blockID) + proposal := types.NewProposal(vss[1].Height, round, -1, nil) p := proposal.ToProto() if err := vss[1].SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -375,12 +371,12 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) rs = css[0].GetRoundState() - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) // HEIGHT 3 @@ -393,11 +389,9 @@ func TestSimulateValidatorsChange(t *testing.T) { updateValidatorTx1 := kvstore.MakeValSetChangeTx(updatePubKey1ABCI, 25) err = assertMempool(css[0].txNotifier).CheckTx(updateValidatorTx1, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) - blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} + propBlock = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - proposal = types.NewProposal(vss[2].Height, round, -1, blockID) + proposal = types.NewProposal(vss[2].Height, round, -1, nil) p = proposal.ToProto() if err := vss[2].SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -405,12 +399,12 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) rs = css[0].GetRoundState() - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:nVals]...) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, vss[1:nVals]...) ensureNewRound(newRoundCh, height+1, 0) // HEIGHT 4 @@ -430,9 +424,8 @@ func TestSimulateValidatorsChange(t *testing.T) { newValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, testMinPower) err = assertMempool(css[0].txNotifier).CheckTx(newValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) - blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} + propBlock = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) + newVss := make([]*validatorStub, nVals+1) copy(newVss, vss[:nVals+1]) sort.Sort(ValidatorStubsByPower(newVss)) @@ -454,7 +447,7 @@ func TestSimulateValidatorsChange(t *testing.T) { selfIndex := valIndexFn(0) - proposal = types.NewProposal(vss[3].Height, round, -1, blockID) + proposal = types.NewProposal(vss[3].Height, round, -1, nil) p = proposal.ToProto() if err := vss[3].SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -462,7 +455,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -476,7 +469,7 @@ func TestSimulateValidatorsChange(t *testing.T) { if i == selfIndex { continue } - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), newVss[i]) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, newVss[i]) } ensureNewRound(newRoundCh, height+1, 0) @@ -495,7 +488,7 @@ func TestSimulateValidatorsChange(t *testing.T) { if i == selfIndex { continue } - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), newVss[i]) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, newVss[i]) } ensureNewRound(newRoundCh, height+1, 0) @@ -505,15 +498,13 @@ func TestSimulateValidatorsChange(t *testing.T) { removeValidatorTx3 := kvstore.MakeValSetChangeTx(newVal3ABCI, 0) err = assertMempool(css[0].txNotifier).CheckTx(removeValidatorTx3, nil, mempl.TxInfo{}) assert.Nil(t, err) - propBlock, _ = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) - propBlockParts = propBlock.MakePartSet(partSize) - blockID = types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} + propBlock = css[0].createProposalBlock() // changeProposer(t, cs1, vs2) newVss = make([]*validatorStub, nVals+3) copy(newVss, vss[:nVals+3]) sort.Sort(ValidatorStubsByPower(newVss)) selfIndex = valIndexFn(0) - proposal = types.NewProposal(vss[1].Height, round, -1, blockID) + proposal = types.NewProposal(vss[1].Height, round, -1, nil) p = proposal.ToProto() if err := vss[1].SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -521,7 +512,7 @@ func TestSimulateValidatorsChange(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := css[0].SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := css[0].SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -530,7 +521,7 @@ func TestSimulateValidatorsChange(t *testing.T) { if i == selfIndex { continue } - signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), newVss[i]) + signAddVotes(css[0], tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, newVss[i]) } ensureNewRound(newRoundCh, height+1, 0) @@ -1138,9 +1129,9 @@ func readPieceFromWAL(msg *TimedWALMessage) interface{} { case msgInfo: switch msg := m.Msg.(type) { case *ProposalMessage: - return &msg.Proposal.BlockID.PartSetHeader - case *BlockPartMessage: - return msg.Part + return &msg.Proposal.DAHeader + case *BlockMessage: + return msg.Block case *VoteMessage: return msg.Vote } diff --git a/consensus/state.go b/consensus/state.go index 2a2f75ba75..1f7a5aa64b 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -4,14 +4,11 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" "os" "reflect" "runtime/debug" "time" - "github.com/gogo/protobuf/proto" - cfg "github.com/lazyledger/lazyledger-core/config" cstypes "github.com/lazyledger/lazyledger-core/consensus/types" "github.com/lazyledger/lazyledger-core/crypto" @@ -473,36 +470,24 @@ func (cs *State) SetProposal(proposal *types.Proposal, peerID p2p.ID) error { return nil } -// AddProposalBlockPart inputs a part of the proposal block. -func (cs *State) AddProposalBlockPart(height int64, round int32, part *types.Part, peerID p2p.ID) error { - +func (cs *State) AddProposalBlock(height int64, round int32, block *types.Block, peerID p2p.ID) error { if peerID == "" { - cs.internalMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, ""} + cs.internalMsgQueue <- msgInfo{&BlockMessage{height, round, block}, ""} } else { - cs.peerMsgQueue <- msgInfo{&BlockPartMessage{height, round, part}, peerID} + cs.peerMsgQueue <- msgInfo{&BlockMessage{height, round, block}, peerID} } // TODO: wait for event?! return nil } -// SetProposalAndBlock inputs the proposal and all block parts. -func (cs *State) SetProposalAndBlock( - proposal *types.Proposal, - block *types.Block, - parts *types.PartSet, - peerID p2p.ID, -) error { - if err := cs.SetProposal(proposal, peerID); err != nil { +func (cs *State) SetProposalAndBlock(proposal *types.Proposal, block *types.Block, peerID p2p.ID) error { + err := cs.SetProposal(proposal, peerID) + if err != nil { return err } - for i := 0; i < int(parts.Total()); i++ { - part := parts.GetPart(i) - if err := cs.AddProposalBlockPart(proposal.Height, proposal.Round, part, peerID); err != nil { - return err - } - } - return nil + + return cs.AddProposalBlock(proposal.Height, proposal.POLRound, block, peerID) } //------------------------------------------------------------ @@ -642,13 +627,13 @@ func (cs *State) updateToState(state sm.State) { cs.Validators = validators cs.Proposal = nil cs.ProposalBlock = nil - cs.ProposalBlockParts = nil + cs.ProposalBlockDAHeader = nil cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil + cs.ProposalBlockDAHeader = nil cs.ValidRound = -1 cs.ValidBlock = nil - cs.ValidBlockParts = nil + cs.ProposalBlockDAHeader = nil cs.Votes = cstypes.NewHeightVoteSet(state.ChainID, height, validators) cs.CommitRound = -1 cs.LastValidators = state.LastValidators @@ -777,11 +762,11 @@ func (cs *State) handleMsg(mi msgInfo) { switch msg := msg.(type) { case *ProposalMessage: // will not cause transition. - // once proposal is set, we can receive block parts + // once proposal is set, we can receive block err = cs.setProposal(msg.Proposal) - case *BlockPartMessage: + case *BlockMessage: // if the proposal is complete, we'll enterPrevote or tryFinalizeCommit - added, err = cs.addProposalBlockPart(msg, peerID) + added, err = cs.addProposalBlock(msg, peerID) if added { cs.statsMsgQueue <- mi } @@ -946,7 +931,7 @@ func (cs *State) enterNewRound(height int64, round int32) { logger.Info("Resetting Proposal info") cs.Proposal = nil cs.ProposalBlock = nil - cs.ProposalBlockParts = nil + cs.ProposalBlockDAHeader = nil } cs.Votes.SetRound(tmmath.SafeAddInt32(round, 1)) // also track next round (round+1) to allow round-skipping cs.TriggeredTimeoutPrecommit = false @@ -1061,20 +1046,7 @@ func (cs *State) isProposer(address []byte) bool { } func (cs *State) defaultDecideProposal(height int64, round int32) { - var block *types.Block - var blockParts *types.PartSet - - // Decide on block - if cs.ValidBlock != nil { - // If there is valid block, choose that. - block, blockParts = cs.ValidBlock, cs.ValidBlockParts - } else { - // Create a new proposal block from state/txs from the mempool. - block, blockParts = cs.createProposalBlock() - if block == nil { - return - } - } + block := cs.getProposalBlock() // Flush the WAL. Otherwise, we may not recompute the same proposal to sign, // and the privValidator will refuse to sign anything. @@ -1082,19 +1054,15 @@ func (cs *State) defaultDecideProposal(height int64, round int32) { cs.Logger.Error("Error flushing to disk") } - // Make proposal - propBlockID := types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()} - proposal := types.NewProposal(height, round, cs.ValidRound, propBlockID) + proposal := types.NewProposal(height, round, cs.ValidRound, &block.DataAvailabilityHeader) p := proposal.ToProto() if err := cs.privValidator.SignProposal(cs.state.ChainID, p); err == nil { proposal.Signature = p.Signature - // send proposal and block parts on internal msg queue + // send proposal and block on internal msg queue cs.sendInternalMessage(msgInfo{&ProposalMessage{proposal}, ""}) - for i := 0; i < int(blockParts.Total()); i++ { - part := blockParts.GetPart(i) - cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) - } + cs.sendInternalMessage(msgInfo{&BlockMessage{Height: cs.Height, Round: cs.Round, Block: block}, ""}) + cs.Logger.Info("Signed proposal", "height", height, "round", round, "proposal", proposal) cs.Logger.Debug(fmt.Sprintf("Signed proposal block: %v", block)) } else if !cs.replayMode { @@ -1115,9 +1083,16 @@ func (cs *State) isProposalComplete() bool { } // if this is false the proposer is lying or we haven't received the POL yet return cs.Votes.Prevotes(cs.Proposal.POLRound).HasTwoThirdsMajority() - } +// gets local block for proposalgetProposalBlock +func (cs *State) getProposalBlock() *types.Block { + if cs.ValidBlock != nil { // if there is already valid one + return cs.ValidBlock // return it + } + + return cs.createProposalBlock() // otherwise, create one +} // Create the next block to propose and return it. Returns nil block upon error. // // We really only need to return the parts, but the block is returned for @@ -1125,7 +1100,7 @@ func (cs *State) isProposalComplete() bool { // // NOTE: keep it side-effect free for clarity. // CONTRACT: cs.privValidator is not nil. -func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.PartSet) { +func (cs *State) createProposalBlock() (block *types.Block) { if cs.privValidator == nil { panic("entered createProposalBlock with privValidator being nil") } @@ -1152,7 +1127,8 @@ func (cs *State) createProposalBlock() (block *types.Block, blockParts *types.Pa } proposerAddr := cs.privValidatorPubKey.Address() - return cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr) + block, _ = cs.blockExec.CreateProposalBlock(cs.Height, cs.state, commit, proposerAddr) + return } // Enter: `timeoutPropose` after entering Propose. @@ -1192,14 +1168,14 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { // If a block is locked, prevote that. if cs.LockedBlock != nil { logger.Info("enterPrevote: Already locked on a block, prevoting locked block") - cs.signAddVote(tmproto.PrevoteType, cs.LockedBlock.Hash(), cs.LockedBlockParts.Header()) + cs.signAddVote(tmproto.PrevoteType, cs.LockedBlock.Hash(), cs.LockedBlockDAHeader) return } // If ProposalBlock is nil, prevote nil. if cs.ProposalBlock == nil { logger.Info("enterPrevote: ProposalBlock is nil") - cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) + cs.signAddVote(tmproto.PrevoteType, nil, nil) return } @@ -1208,7 +1184,7 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { if err != nil { // ProposalBlock is invalid, prevote nil. logger.Error("enterPrevote: ProposalBlock is invalid", "err", err) - cs.signAddVote(tmproto.PrevoteType, nil, types.PartSetHeader{}) + cs.signAddVote(tmproto.PrevoteType, nil, nil) return } @@ -1216,7 +1192,7 @@ func (cs *State) defaultDoPrevote(height int64, round int32) { // NOTE: the proposal signature is validated when it is received, // and the proposal block parts are validated as they are received (against the merkle hash in the proposal) logger.Info("enterPrevote: ProposalBlock is valid") - cs.signAddVote(tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockParts.Header()) + cs.signAddVote(tmproto.PrevoteType, cs.ProposalBlock.Hash(), cs.ProposalBlockDAHeader) } // Enter: any +2/3 prevotes at next round. @@ -1277,7 +1253,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { }() // check for a polka - blockID, ok := cs.Votes.Prevotes(round).TwoThirdsMajority() + blockID, dah, ok := cs.Votes.Prevotes(round).TwoThirdsMajority() // If we don't have a polka, we must precommit nil. if !ok { @@ -1286,7 +1262,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { } else { logger.Info("enterPrecommit: No +2/3 prevotes during enterPrecommit. Precommitting nil.") } - cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{}) + cs.signAddVote(tmproto.PrecommitType, nil, nil) return } @@ -1309,12 +1285,12 @@ func (cs *State) enterPrecommit(height int64, round int32) { logger.Info("enterPrecommit: +2/3 prevoted for nil. Unlocking") cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil + cs.LockedBlockDAHeader = nil if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) } } - cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{}) + cs.signAddVote(tmproto.PrecommitType, nil, nil) return } @@ -1327,7 +1303,7 @@ func (cs *State) enterPrecommit(height int64, round int32) { if err := cs.eventBus.PublishEventRelock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event relock", "err", err) } - cs.signAddVote(tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader) + cs.signAddVote(tmproto.PrecommitType, blockID.Hash, dah) return } @@ -1340,11 +1316,11 @@ func (cs *State) enterPrecommit(height int64, round int32) { } cs.LockedRound = round cs.LockedBlock = cs.ProposalBlock - cs.LockedBlockParts = cs.ProposalBlockParts + cs.LockedBlockDAHeader = cs.ProposalBlockDAHeader if err := cs.eventBus.PublishEventLock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event lock", "err", err) } - cs.signAddVote(tmproto.PrecommitType, blockID.Hash, blockID.PartSetHeader) + cs.signAddVote(tmproto.PrecommitType, blockID.Hash, dah) return } @@ -1354,15 +1330,17 @@ func (cs *State) enterPrecommit(height int64, round int32) { logger.Info("enterPrecommit: +2/3 prevotes for a block we don't have. Voting nil", "blockID", blockID) cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil - if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { - cs.ProposalBlock = nil - cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) + cs.LockedBlockDAHeader = nil + + // In case we have a polka and known proposed DAHeader does not match to majority + if !cs.ProposalBlockDAHeader.Equal(dah) { + cs.ProposalBlock = nil // remove unaccepted block we might have + cs.ProposalBlockDAHeader = dah // and set DAHeader of the accepted one } if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing event unlock", "err", err) } - cs.signAddVote(tmproto.PrecommitType, nil, types.PartSetHeader{}) + cs.signAddVote(tmproto.PrecommitType, nil, nil) } // Enter: any +2/3 precommits for next round. @@ -1420,7 +1398,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) { cs.tryFinalizeCommit(height) }() - blockID, ok := cs.Votes.Precommits(commitRound).TwoThirdsMajority() + blockID, dah, ok := cs.Votes.Precommits(commitRound).TwoThirdsMajority() if !ok { panic("RunActionCommit() expects +2/3 precommits") } @@ -1431,12 +1409,12 @@ func (cs *State) enterCommit(height int64, commitRound int32) { if cs.LockedBlock.HashesTo(blockID.Hash) { logger.Info("Commit is for locked block. Set ProposalBlock=LockedBlock", "blockHash", blockID.Hash) cs.ProposalBlock = cs.LockedBlock - cs.ProposalBlockParts = cs.LockedBlockParts + cs.ProposalBlockDAHeader = cs.LockedBlockDAHeader } // If we don't have the block being committed, set up to get it. if !cs.ProposalBlock.HashesTo(blockID.Hash) { - if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { + if !cs.ProposalBlockDAHeader.Equal(dah) { logger.Info( "Commit is for a block we don't know about. Set ProposalBlock=nil", "proposal", @@ -1446,7 +1424,7 @@ func (cs *State) enterCommit(height int64, commitRound int32) { // We're getting the wrong block. // Set up ProposalBlockParts and keep waiting. cs.ProposalBlock = nil - cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) + cs.ProposalBlockDAHeader = dah if err := cs.eventBus.PublishEventValidBlock(cs.RoundStateEvent()); err != nil { cs.Logger.Error("Error publishing valid block", "err", err) } @@ -1466,7 +1444,7 @@ func (cs *State) tryFinalizeCommit(height int64) { panic(fmt.Sprintf("tryFinalizeCommit() cs.Height: %v vs height: %v", cs.Height, height)) } - blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() + blockID, _, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() if !ok || len(blockID.Hash) == 0 { logger.Error("Attempt to finalize failed. There was no +2/3 majority, or +2/3 was for .") return @@ -1499,15 +1477,12 @@ func (cs *State) finalizeCommit(height int64) { return } - blockID, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() - block, blockParts := cs.ProposalBlock, cs.ProposalBlockParts + blockID, _, ok := cs.Votes.Precommits(cs.CommitRound).TwoThirdsMajority() + block := cs.ProposalBlock if !ok { panic("Cannot finalizeCommit, commit does not have two thirds majority") } - if !blockParts.HasHeader(blockID.PartSetHeader) { - panic("Expected ProposalBlockParts header to be commit header") - } if !block.HashesTo(blockID.Hash) { panic("Cannot finalizeCommit, ProposalBlock does not hash to commit hash") } @@ -1530,7 +1505,9 @@ func (cs *State) finalizeCommit(height int64) { // but may differ from the LastCommit included in the next block precommits := cs.Votes.Precommits(cs.CommitRound) seenCommit := precommits.MakeCommit() - cs.blockStore.SaveBlock(block, blockParts, seenCommit) + + // TODO: Save only header + cs.blockStore.SaveBlock(block, block.MakePartSet(types.BlockPartSizeBytes), seenCommit) } else { // Happens during replay if we already saved the block but didn't commit cs.Logger.Info("Calling finalizeCommit on already stored block", "height", block.Height) @@ -1568,7 +1545,7 @@ func (cs *State) finalizeCommit(height int64) { var retainHeight int64 stateCopy, retainHeight, err = cs.blockExec.ApplyBlock( stateCopy, - types.BlockID{Hash: block.Hash(), PartSetHeader: blockParts.Header()}, + types.BlockID{Hash: block.Hash()}, block) if err != nil { cs.Logger.Error("Error on ApplyBlock", "err", err) @@ -1744,101 +1721,88 @@ func (cs *State) defaultSetProposal(proposal *types.Proposal) error { proposal.Signature = p.Signature cs.Proposal = proposal - // We don't update cs.ProposalBlockParts if it is already set. + // We don't update cs.ProposalBlockDAHeader if it is already set. // This happens if we're already in cstypes.RoundStepCommit or if there is a valid block in the current round. // TODO: We can check if Proposal is for a different block as this is a sign of misbehavior! - if cs.ProposalBlockParts == nil { - cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartSetHeader) + if cs.ProposalBlockDAHeader == nil { + cs.ProposalBlockDAHeader = proposal.DAHeader } cs.Logger.Info("Received proposal", "proposal", proposal) return nil } -// NOTE: block is not necessarily valid. -// Asynchronously triggers either enterPrevote (before we timeout of propose) or tryFinalizeCommit, -// once we have the full block. -func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (added bool, err error) { - height, round, part := msg.Height, msg.Round, msg.Part +func (cs *State) addProposalBlock(msg *BlockMessage, peerID p2p.ID) (bool, error) { + height, round, block := msg.Height, msg.Round, msg.Block // Blocks might be reused, so round mismatch is OK if cs.Height != height { - cs.Logger.Debug("Received block part from wrong height", "height", height, "round", round) + cs.Logger.Debug("Receivedblocks block from wrong height", + "height", height, "round", round, "peer", peerID) return false, nil } - // We're not expecting a block part. - if cs.ProposalBlockParts == nil { + // We're not expecting a block. + if cs.ProposalBlockDAHeader == nil { // NOTE: this can happen when we've gone to a higher round and // then receive parts from the previous round - not necessarily a bad peer. - cs.Logger.Info("Received a block part when we're not expecting any", - "height", height, "round", round, "index", part.Index, "peer", peerID) + cs.Logger.Info("Received a block when we're not expecting any", + "height", height, "round", round, "block", block.StringShort(), "peer", peerID) return false, nil } - added, err = cs.ProposalBlockParts.AddPart(part) - if err != nil { - return added, err - } - if cs.ProposalBlockParts.ByteSize() > cs.state.ConsensusParams.Block.MaxBytes { - return added, fmt.Errorf("total size of proposal block parts exceeds maximum block bytes (%d > %d)", - cs.ProposalBlockParts.ByteSize(), cs.state.ConsensusParams.Block.MaxBytes, - ) + // We already have one + if cs.ProposalBlock != nil { + return false, nil } - if added && cs.ProposalBlockParts.IsComplete() { - bz, err := ioutil.ReadAll(cs.ProposalBlockParts.GetReader()) - if err != nil { - return added, err - } - var pbb = new(tmproto.Block) - err = proto.Unmarshal(bz, pbb) - if err != nil { - return added, err - } + if !cs.ProposalBlockDAHeader.Equal(&msg.Block.DataAvailabilityHeader) { + return false, fmt.Errorf("proposal block does not match known DAHeader") + } - block, err := types.BlockFromProto(pbb) - if err != nil { - return added, err - } + size := int64(block.Size()) + if size > cs.state.ConsensusParams.Block.MaxBytes { + return false, fmt.Errorf("total size of proposal block parts exceeds maximum block bytes (%d > %d)", + size, cs.state.ConsensusParams.Block.MaxBytes, + ) + } - cs.ProposalBlock = block - // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal - cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) - if err := cs.eventBus.PublishEventCompleteProposal(cs.CompleteProposalEvent()); err != nil { - cs.Logger.Error("Error publishing event complete proposal", "err", err) - } + cs.ProposalBlock = block + // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal + cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) + if err := cs.eventBus.PublishEventCompleteProposal(cs.CompleteProposalEvent()); err != nil { + cs.Logger.Error("Error publishing event complete proposal", "err", err) + } - // Update Valid* if we can. - prevotes := cs.Votes.Prevotes(cs.Round) - blockID, hasTwoThirds := prevotes.TwoThirdsMajority() - if hasTwoThirds && !blockID.IsZero() && (cs.ValidRound < cs.Round) { - if cs.ProposalBlock.HashesTo(blockID.Hash) { - cs.Logger.Info("Updating valid block to new proposal block", - "valid-round", cs.Round, "valid-block-hash", cs.ProposalBlock.Hash()) - cs.ValidRound = cs.Round - cs.ValidBlock = cs.ProposalBlock - cs.ValidBlockParts = cs.ProposalBlockParts - } - // TODO: In case there is +2/3 majority in Prevotes set for some - // block and cs.ProposalBlock contains different block, either - // proposer is faulty or voting power of faulty processes is more - // than 1/3. We should trigger in the future accountability - // procedure at this point. + // Update Valid* if we can. + prevotes := cs.Votes.Prevotes(cs.Round) + blockID, _, hasTwoThirds := prevotes.TwoThirdsMajority() + if hasTwoThirds && !blockID.IsZero() && (cs.ValidRound < cs.Round) { + if cs.ProposalBlock.HashesTo(blockID.Hash) { + cs.Logger.Info("Updating valid block to new proposal block", + "valid-round", cs.Round, "valid-block-hash", cs.ProposalBlock.Hash()) + cs.ValidRound = cs.Round + cs.ValidBlock = cs.ProposalBlock + cs.ValidBlockDAHeader = cs.ProposalBlockDAHeader } - - if cs.Step <= cstypes.RoundStepPropose && cs.isProposalComplete() { - // Move onto the next step - cs.enterPrevote(height, cs.Round) - if hasTwoThirds { // this is optimisation as this will be triggered when prevote is added - cs.enterPrecommit(height, cs.Round) - } - } else if cs.Step == cstypes.RoundStepCommit { - // If we're waiting on the proposal block... - cs.tryFinalizeCommit(height) + // TODO: In case there is +2/3 majority in Prevotes set for some + // block and cs.ProposalBlock contains different block, either + // proposer is faulty or voting power of faulty processes is more + // than 1/3. We should trigger in the future accountability + // procedure at this point. + } + + if cs.Step <= cstypes.RoundStepPropose && cs.isProposalComplete() { + // Move onto the next step + cs.enterPrevote(height, cs.Round) + if hasTwoThirds { // this is optimisation as this will be triggered when prevote is added + cs.enterPrecommit(height, cs.Round) } - return added, nil + } else if cs.Step == cstypes.RoundStepCommit { + // If we're waiting on the proposal block... + cs.tryFinalizeCommit(height) } - return added, nil + + return true, nil } // Attempt to add the vote. if its a duplicate signature, dupeout the validator @@ -1967,7 +1931,7 @@ func (cs *State) addVote( cs.Logger.Info("Added to prevote", "vote", vote, "prevotes", prevotes.StringShort()) // If +2/3 prevotes for a block or nil for *any* round: - if blockID, ok := prevotes.TwoThirdsMajority(); ok { + if blockID, dah, ok := prevotes.TwoThirdsMajority(); ok { // There was a polka! // If we're locked but this is a recent polka, unlock. @@ -1983,7 +1947,6 @@ func (cs *State) addVote( cs.Logger.Info("Unlocking because of POL.", "lockedRound", cs.LockedRound, "POLRound", vote.Round) cs.LockedRound = -1 cs.LockedBlock = nil - cs.LockedBlockParts = nil if err := cs.eventBus.PublishEventUnlock(cs.RoundStateEvent()); err != nil { return added, err } @@ -1998,7 +1961,6 @@ func (cs *State) addVote( "Updating ValidBlock because of POL.", "validRound", cs.ValidRound, "POLRound", vote.Round) cs.ValidRound = vote.Round cs.ValidBlock = cs.ProposalBlock - cs.ValidBlockParts = cs.ProposalBlockParts } else { cs.Logger.Info( "Valid block we don't know about. Set ProposalBlock=nil", @@ -2006,8 +1968,8 @@ func (cs *State) addVote( // We're getting the wrong block. cs.ProposalBlock = nil } - if !cs.ProposalBlockParts.HasHeader(blockID.PartSetHeader) { - cs.ProposalBlockParts = types.NewPartSetFromHeader(blockID.PartSetHeader) + if !cs.ProposalBlockDAHeader.Equal(dah) { + cs.ProposalBlockDAHeader = dah } cs.evsw.FireEvent(types.EventValidBlock, &cs.RoundState) if err := cs.eventBus.PublishEventValidBlock(cs.RoundStateEvent()); err != nil { @@ -2022,7 +1984,7 @@ func (cs *State) addVote( // Round-skip if there is any 2/3+ of votes ahead of us cs.enterNewRound(height, vote.Round) case cs.Round == vote.Round && cstypes.RoundStepPrevote <= cs.Step: // current round - blockID, ok := prevotes.TwoThirdsMajority() + blockID, _, ok := prevotes.TwoThirdsMajority() if ok && (cs.isProposalComplete() || len(blockID.Hash) == 0) { cs.enterPrecommit(height, vote.Round) } else if prevotes.HasTwoThirdsAny() { @@ -2039,7 +2001,7 @@ func (cs *State) addVote( precommits := cs.Votes.Precommits(vote.Round) cs.Logger.Info("Added to precommit", "vote", vote, "precommits", precommits.StringShort()) - blockID, ok := precommits.TwoThirdsMajority() + blockID, _, ok := precommits.TwoThirdsMajority() if ok { // Executed as TwoThirdsMajority could be from a higher round cs.enterNewRound(height, vote.Round) @@ -2068,7 +2030,7 @@ func (cs *State) addVote( func (cs *State) signVote( msgType tmproto.SignedMsgType, hash []byte, - header types.PartSetHeader, + dah *types.DataAvailabilityHeader, ) (*types.Vote, error) { // Flush the WAL. Otherwise, we may not recompute the same vote to sign, // and the privValidator will refuse to sign anything. @@ -2089,8 +2051,10 @@ func (cs *State) signVote( Round: cs.Round, Timestamp: cs.voteTime(), Type: msgType, - BlockID: types.BlockID{Hash: hash, PartSetHeader: header}, + BlockID: types.BlockID{Hash: hash}, + DAHeader: dah, } + v := vote.ToProto() err := cs.privValidator.SignVote(cs.state.ChainID, v) vote.Signature = v.Signature @@ -2118,7 +2082,7 @@ func (cs *State) voteTime() time.Time { } // sign the vote and publish on internalMsgQueue -func (cs *State) signAddVote(msgType tmproto.SignedMsgType, hash []byte, header types.PartSetHeader) *types.Vote { +func (cs *State) signAddVote(msgType tmproto.SignedMsgType, hash []byte, dah *types.DataAvailabilityHeader) *types.Vote { if cs.privValidator == nil { // the node does not have a key return nil } @@ -2135,7 +2099,7 @@ func (cs *State) signAddVote(msgType tmproto.SignedMsgType, hash []byte, header } // TODO: pass pubKey to signVote - vote, err := cs.signVote(msgType, hash, header) + vote, err := cs.signVote(msgType, hash, dah) if err == nil { cs.sendInternalMessage(msgInfo{&VoteMessage{vote}, ""}) cs.Logger.Info("Signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote) diff --git a/consensus/state_test.go b/consensus/state_test.go index 7d2f26c2f3..0237ad4c38 100644 --- a/consensus/state_test.go +++ b/consensus/state_test.go @@ -80,7 +80,7 @@ func TestStateProposerSelection0(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() - signAddVotes(cs1, tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header(), vss[1:]...) + signAddVotes(cs1, tmproto.PrecommitType, rs.ProposalBlock.Hash(), rs.ProposalBlockDAHeader, vss[1:]...) // Wait for new round so next validator is set. ensureNewRound(newRoundCh, height+1, 0) @@ -123,8 +123,8 @@ func TestStateProposerSelection2(t *testing.T) { prop.Address)) } - rs := cs1.GetRoundState() - signAddVotes(cs1, tmproto.PrecommitType, nil, rs.ProposalBlockParts.Header(), vss[1:]...) + // rs := cs1.GetRoundState() + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vss[1:]...) ensureNewRound(newRoundCh, height, i+round+1) // wait for the new round event each round incrementRound(vss[1:]...) } @@ -173,9 +173,6 @@ func TestStateEnterProposeYesPrivValidator(t *testing.T) { if rs.ProposalBlock == nil { t.Error("rs.ProposalBlock should be set") } - if rs.ProposalBlockParts.Total() == 0 { - t.Error("rs.ProposalBlockParts should be set") - } // if we're a validator, enterPropose should not timeout ensureNoNewTimeout(timeoutCh, cs.config.TimeoutPropose.Nanoseconds()) @@ -186,12 +183,11 @@ func TestStateBadProposal(t *testing.T) { height, round := cs1.Height, cs1.Round vs2 := vss[1] - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) + propBlock := cs1.createProposalBlock() // changeProposer(t, cs1, vs2) + propDAH := &propBlock.DataAvailabilityHeader // make the second validator the proposer by incrementing round round++ @@ -204,9 +200,7 @@ func TestStateBadProposal(t *testing.T) { } stateHash[0] = (stateHash[0] + 1) % 255 propBlock.AppHash = stateHash - propBlockParts := propBlock.MakePartSet(partSize) - blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} - proposal := types.NewProposal(vs2.Height, round, -1, blockID) + proposal := types.NewProposal(vs2.Height, round, -1, propDAH) p := proposal.ToProto() if err := vs2.SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -215,7 +209,7 @@ func TestStateBadProposal(t *testing.T) { proposal.Signature = p.Signature // set the proposal block - if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -223,20 +217,20 @@ func TestStateBadProposal(t *testing.T) { startTestRound(cs1, height, round) // wait for proposal - ensureProposal(proposalCh, height, round, blockID) + ensureProposal(proposalCh, height, round, propDAH) // wait for prevote ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], nil) // add bad prevote from vs2 and wait for it - signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), &propBlock.DataAvailabilityHeader, vs2) ensurePrevote(voteCh, height, round) // wait for precommit ensurePrecommit(voteCh, height, round) validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), &propBlock.DataAvailabilityHeader, vs2) } func TestStateOversizedBlock(t *testing.T) { @@ -250,7 +244,7 @@ func TestStateOversizedBlock(t *testing.T) { timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) voteCh := subscribe(cs1.eventBus, types.EventQueryVote) - propBlock, _ := cs1.createProposalBlock() + propBlock := cs1.createProposalBlock() propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)} propBlock.Header.DataHash = propBlock.DataAvailabilityHeader.Hash() @@ -259,8 +253,7 @@ func TestStateOversizedBlock(t *testing.T) { incrementRound(vss[1:]...) propBlockParts := propBlock.MakePartSet(partSize) - blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()} - proposal := types.NewProposal(height, round, -1, blockID) + proposal := types.NewProposal(height, round, -1, &propBlock.DataAvailabilityHeader) p := proposal.ToProto() if err := vs2.SignProposal(config.ChainID(), p); err != nil { t.Fatal("failed to sign bad proposal", err) @@ -273,14 +266,14 @@ func TestStateOversizedBlock(t *testing.T) { totalBytes += len(part.Bytes) } - if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(proposal, propBlock, "some peer"); err != nil { t.Fatal(err) } // start the machine startTestRound(cs1, height, round) - t.Log("Block Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes) + t.Log("Blocks Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes) // c1 should log an error with the block part message as it exceeds the consensus params. The // block is not added to cs.ProposalBlock so the node timeouts. @@ -290,11 +283,11 @@ func TestStateOversizedBlock(t *testing.T) { // precommit on it ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], nil) - signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), &propBlock.DataAvailabilityHeader, vs2) ensurePrevote(voteCh, height, round) ensurePrecommit(voteCh, height, round) validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), &propBlock.DataAvailabilityHeader, vs2) } //---------------------------------------------------------------------------------------------------- @@ -374,10 +367,11 @@ func TestStateFullRound2(t *testing.T) { // we should be stuck in limbo waiting for more prevotes rs := cs1.GetRoundState() - propBlockHash, propPartSetHeader := rs.ProposalBlock.Hash(), rs.ProposalBlockParts.Header() + propBlockHash := rs.ProposalBlock.Hash() + propBlockDAHeader := rs.ProposalBlockDAHeader // prevote arrives from vs2: - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propPartSetHeader, vs2) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockDAHeader, vs2) ensurePrevote(voteCh, height, round) // prevote ensurePrecommit(voteCh, height, round) // precommit @@ -387,7 +381,7 @@ func TestStateFullRound2(t *testing.T) { // we should be stuck in limbo waiting for more precommits // precommit arrives from vs2: - signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propPartSetHeader, vs2) + signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propBlockDAHeader, vs2) ensurePrecommit(voteCh, height, round) // wait to finish commit, propose in next height @@ -404,8 +398,6 @@ func TestStateLockNoPOL(t *testing.T) { vs2 := vss[1] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) voteCh := subscribeUnBuffered(cs1.eventBus, types.EventQueryVote) @@ -423,15 +415,15 @@ func TestStateLockNoPOL(t *testing.T) { ensureNewRound(newRoundCh, height, round) ensureNewProposal(proposalCh, height, round) - roundState := cs1.GetRoundState() - theBlockHash := roundState.ProposalBlock.Hash() - thePartSetHeader := roundState.ProposalBlockParts.Header() + rs := cs1.GetRoundState() + theBlockHash := rs.ProposalBlock.Hash() + dah := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) // prevote // we should now be stuck in limbo forever, waiting for more prevotes // prevote arrives from vs2: - signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, thePartSetHeader, vs2) + signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, dah, vs2) ensurePrevote(voteCh, height, round) // prevote ensurePrecommit(voteCh, height, round) // precommit @@ -443,7 +435,7 @@ func TestStateLockNoPOL(t *testing.T) { hash := make([]byte, len(theBlockHash)) copy(hash, theBlockHash) hash[0] = (hash[0] + 1) % 255 - signAddVotes(cs1, tmproto.PrecommitType, hash, thePartSetHeader, vs2) + signAddVotes(cs1, tmproto.PrecommitType, hash, dah, vs2) ensurePrecommit(voteCh, height, round) // precommit // (note we're entering precommit for a second time this round) @@ -464,7 +456,7 @@ func TestStateLockNoPOL(t *testing.T) { // now we're on a new round and not the proposer, so wait for timeout ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds()) - rs := cs1.GetRoundState() + rs = cs1.GetRoundState() if rs.ProposalBlock != nil { panic("Expected proposal block to be nil") @@ -476,7 +468,7 @@ func TestStateLockNoPOL(t *testing.T) { validatePrevote(t, cs1, round, vss[0], rs.LockedBlock.Hash()) // add a conflicting prevote from the other validator - signAddVotes(cs1, tmproto.PrevoteType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, hash, &rs.LockedBlock.DataAvailabilityHeader, vs2) ensurePrevote(voteCh, height, round) // now we're going to enter prevote again, but with invalid args @@ -489,7 +481,7 @@ func TestStateLockNoPOL(t *testing.T) { validatePrecommit(t, cs1, round, 0, vss[0], nil, theBlockHash) // add conflicting precommit from vs2 - signAddVotes(cs1, tmproto.PrecommitType, hash, rs.LockedBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrecommitType, hash, &rs.LockedBlock.DataAvailabilityHeader, vs2) ensurePrecommit(voteCh, height, round) // (note we're entering precommit for a second time this round, but with invalid args @@ -519,7 +511,7 @@ func TestStateLockNoPOL(t *testing.T) { ensurePrevote(voteCh, height, round) // prevote validatePrevote(t, cs1, round, vss[0], rs.LockedBlock.Hash()) - signAddVotes(cs1, tmproto.PrevoteType, hash, rs.ProposalBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, hash, &rs.ProposalBlock.DataAvailabilityHeader, vs2) ensurePrevote(voteCh, height, round) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) @@ -531,7 +523,7 @@ func TestStateLockNoPOL(t *testing.T) { cs1, tmproto.PrecommitType, hash, - rs.ProposalBlock.MakePartSet(partSize).Header(), + &rs.ProposalBlock.DataAvailabilityHeader, vs2) // NOTE: conflicting precommits at same height ensurePrecommit(voteCh, height, round) @@ -555,7 +547,7 @@ func TestStateLockNoPOL(t *testing.T) { // now we're on a new round and not the proposer // so set the proposal block - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlock.MakePartSet(partSize), ""); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, ""); err != nil { t.Fatal(err) } @@ -565,7 +557,7 @@ func TestStateLockNoPOL(t *testing.T) { validatePrevote(t, cs1, 3, vss[0], cs1.LockedBlock.Hash()) // prevote for proposed block - signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), &propBlock.DataAvailabilityHeader, vs2) ensurePrevote(voteCh, height, round) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) @@ -576,7 +568,7 @@ func TestStateLockNoPOL(t *testing.T) { cs1, tmproto.PrecommitType, propBlock.Hash(), - propBlock.MakePartSet(partSize).Header(), + &propBlock.DataAvailabilityHeader, vs2) // NOTE: conflicting precommits at same height ensurePrecommit(voteCh, height, round) } @@ -590,8 +582,6 @@ func TestStateLockPOLRelock(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) pv1, err := cs1.privValidator.GetPubKey() @@ -616,18 +606,18 @@ func TestStateLockPOLRelock(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() theBlockHash := rs.ProposalBlock.Hash() - theBlockParts := rs.ProposalBlockParts.Header() + dah := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) // prevote - signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, dah, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // our precommit // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], theBlockHash, theBlockHash) // add precommits from the rest - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, dah, vs2, vs3, vs4) // before we timeout to the new round set the new proposal cs2 := newState(cs1.state, vs2, counter.NewApplication(true)) @@ -635,8 +625,9 @@ func TestStateLockPOLRelock(t *testing.T) { if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } - propBlockParts := propBlock.MakePartSet(partSize) + propBlockHash := propBlock.Hash() + propDAH := &propBlock.DataAvailabilityHeader require.NotEqual(t, propBlockHash, theBlockHash) incrementRound(vs2, vs3, vs4) @@ -646,7 +637,7 @@ func TestStateLockPOLRelock(t *testing.T) { round++ // moving to the next round //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -668,14 +659,14 @@ func TestStateLockPOLRelock(t *testing.T) { validatePrevote(t, cs1, round, vss[0], theBlockHash) // now lets add prevotes from everyone else for the new block - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // we should have unlocked and locked on the new block, sending a precommit for this new block validatePrecommit(t, cs1, round, round, vss[0], propBlockHash, propBlockHash) // more prevote creating a majority on the new block and this is then committed - signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3) + signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propDAH, vs2, vs3) ensureNewBlockHeader(newBlockCh, height, propBlockHash) ensureNewRound(newRoundCh, height+1, 0) @@ -687,8 +678,6 @@ func TestStateLockPOLUnlock(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -712,25 +701,23 @@ func TestStateLockPOLUnlock(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() theBlockHash := rs.ProposalBlock.Hash() - theBlockParts := rs.ProposalBlockParts.Header() + dah := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], theBlockHash) - signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, dah, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], theBlockHash, theBlockHash) // add precommits from the rest - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs4) - signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) + signAddVotes(cs1, tmproto.PrecommitType, nil, dah, vs2, vs4) + signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, dah, vs3) // before we time out into new round, set next proposal block prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) - propBlockParts := propBlock.MakePartSet(partSize) - // timeout to new round ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) rs = cs1.GetRoundState() @@ -746,7 +733,7 @@ func TestStateLockPOLUnlock(t *testing.T) { cs1 unlocks! */ //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -756,7 +743,7 @@ func TestStateLockPOLUnlock(t *testing.T) { ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], lockedBlockHash) // now lets add prevotes from everyone else for nil (a polka!) - signAddVotes(cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, nil, nil, vs2, vs3, vs4) // the polka makes us unlock and precommit nil ensureNewUnlock(unlockCh, height, round) @@ -766,7 +753,7 @@ func TestStateLockPOLUnlock(t *testing.T) { // NOTE: since we don't relock on nil, the lock round is -1 validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3) ensureNewRound(newRoundCh, height, round+1) } @@ -779,8 +766,6 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) pv1, err := cs1.privValidator.GetPubKey() @@ -801,18 +786,18 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() firstBlockHash := rs.ProposalBlock.Hash() - firstBlockParts := rs.ProposalBlockParts.Header() + firstDAH := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) // prevote - signAddVotes(cs1, tmproto.PrevoteType, firstBlockHash, firstBlockParts, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, firstBlockHash, firstDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // our precommit // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], firstBlockHash, firstBlockHash) // add precommits from the rest - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) // before we timeout to the new round set the new proposal cs2 := newState(cs1.state, vs2, counter.NewApplication(true)) @@ -820,7 +805,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } - secondBlockParts := propBlock.MakePartSet(partSize) + secondDAH := &propBlock.DataAvailabilityHeader secondBlockHash := propBlock.Hash() require.NotEqual(t, secondBlockHash, firstBlockHash) @@ -845,18 +830,18 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { validatePrevote(t, cs1, round, vss[0], firstBlockHash) // now lets add prevotes from everyone else for the new block - signAddVotes(cs1, tmproto.PrevoteType, secondBlockHash, secondBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, secondBlockHash, secondDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // we should have unlocked and locked on the new block, sending a precommit for this new block validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - if err := cs1.SetProposalAndBlock(prop, propBlock, secondBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } // more prevote creating a majority on the new block and this is then committed - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) // before we timeout to the new round set the new proposal cs3 := newState(cs1.state, vs3, counter.NewApplication(true)) @@ -864,7 +849,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { if prop == nil || propBlock == nil { t.Fatal("Failed to create proposal block with vs2") } - thirdPropBlockParts := propBlock.MakePartSet(partSize) + thirdDAH := &propBlock.DataAvailabilityHeader thirdPropBlockHash := propBlock.Hash() require.NotEqual(t, secondBlockHash, thirdPropBlockHash) @@ -881,7 +866,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { Round2 (vs3, C) // C C C C // C nil nil nil) */ - if err := cs1.SetProposalAndBlock(prop, propBlock, thirdPropBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -889,7 +874,7 @@ func TestStateLockPOLUnlockOnUnknownBlock(t *testing.T) { // we are no longer locked to the first block so we should be able to prevote validatePrevote(t, cs1, round, vss[0], thirdPropBlockHash) - signAddVotes(cs1, tmproto.PrevoteType, thirdPropBlockHash, thirdPropBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, thirdPropBlockHash, thirdDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // we have a majority, now vs1 can change lock to the third block @@ -905,8 +890,6 @@ func TestStateLockPOLSafety1(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) @@ -923,17 +906,18 @@ func TestStateLockPOLSafety1(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() propBlock := rs.ProposalBlock + propDAH := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlock.Hash()) // the others sign a polka but we don't see it - prevotes := signVotes(tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2, vs3, vs4) + prevotes := signVotes(tmproto.PrevoteType, propBlock.Hash(), propDAH, vs2, vs3, vs4) t.Logf("old prop hash %v", fmt.Sprintf("%X", propBlock.Hash())) // we do see them precommit nil - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) // cs1 precommit nil ensurePrecommit(voteCh, height, round) @@ -943,7 +927,6 @@ func TestStateLockPOLSafety1(t *testing.T) { prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash := propBlock.Hash() - propBlockParts := propBlock.MakePartSet(partSize) incrementRound(vs2, vs3, vs4) @@ -951,7 +934,7 @@ func TestStateLockPOLSafety1(t *testing.T) { ensureNewRound(newRoundCh, height, round) //XXX: this isnt guaranteed to get there before the timeoutPropose ... - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } /*Round2 @@ -973,13 +956,13 @@ func TestStateLockPOLSafety1(t *testing.T) { validatePrevote(t, cs1, round, vss[0], propBlockHash) // now we see the others prevote for it, so we should lock on it - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // we should have precommitted validatePrecommit(t, cs1, round, round, vss[0], propBlockHash, propBlockHash) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) @@ -1024,8 +1007,6 @@ func TestStateLockPOLSafety2(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -1039,16 +1020,15 @@ func TestStateLockPOLSafety2(t *testing.T) { // (even though we signed it, shhh) _, propBlock0 := decideProposal(cs1, vss[0], height, round) propBlockHash0 := propBlock0.Hash() - propBlockParts0 := propBlock0.MakePartSet(partSize) - propBlockID0 := types.BlockID{Hash: propBlockHash0, PartSetHeader: propBlockParts0.Header()} + propDAH0 := &propBlock0.DataAvailabilityHeader // the others sign a polka but we don't see it - prevotes := signVotes(tmproto.PrevoteType, propBlockHash0, propBlockParts0.Header(), vs2, vs3, vs4) + prevotes := signVotes(tmproto.PrevoteType, propBlockHash0, propDAH0, vs2, vs3, vs4) // the block for round 1 prop1, propBlock1 := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash1 := propBlock1.Hash() - propBlockParts1 := propBlock1.MakePartSet(partSize) + propDAH1 := &propBlock1.DataAvailabilityHeader incrementRound(vs2, vs3, vs4) @@ -1058,7 +1038,7 @@ func TestStateLockPOLSafety2(t *testing.T) { startTestRound(cs1, height, round) ensureNewRound(newRoundCh, height, round) - if err := cs1.SetProposalAndBlock(prop1, propBlock1, propBlockParts1, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop1, propBlock1, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height, round) @@ -1066,15 +1046,15 @@ func TestStateLockPOLSafety2(t *testing.T) { ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlockHash1) - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash1, propBlockParts1.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash1, propDAH1, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], propBlockHash1, propBlockHash1) // add precommits from the rest - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs4) - signAddVotes(cs1, tmproto.PrecommitType, propBlockHash1, propBlockParts1.Header(), vs3) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs4) + signAddVotes(cs1, tmproto.PrecommitType, propBlockHash1, propDAH1, vs3) incrementRound(vs2, vs3, vs4) @@ -1083,7 +1063,7 @@ func TestStateLockPOLSafety2(t *testing.T) { round++ // moving to the next round // in round 2 we see the polkad block from round 0 - newProp := types.NewProposal(height, round, 0, propBlockID0) + newProp := types.NewProposal(height, round, 0, &propBlock0.DataAvailabilityHeader) p := newProp.ToProto() if err := vs3.SignProposal(config.ChainID(), p); err != nil { t.Fatal(err) @@ -1091,7 +1071,7 @@ func TestStateLockPOLSafety2(t *testing.T) { newProp.Signature = p.Signature - if err := cs1.SetProposalAndBlock(newProp, propBlock0, propBlockParts0, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(newProp, propBlock0, "some peer"); err != nil { t.Fatal(err) } @@ -1121,8 +1101,6 @@ func TestProposeValidBlock(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) @@ -1141,18 +1119,19 @@ func TestProposeValidBlock(t *testing.T) { rs := cs1.GetRoundState() propBlock := rs.ProposalBlock propBlockHash := propBlock.Hash() + propDAH := &propBlock.DataAvailabilityHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlockHash) // the others sign a polka - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlock.MakePartSet(partSize).Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // we should have precommitted validatePrecommit(t, cs1, round, round, vss[0], propBlockHash, propBlockHash) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) @@ -1169,7 +1148,7 @@ func TestProposeValidBlock(t *testing.T) { ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlockHash) - signAddVotes(cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, nil, nil, vs2, vs3, vs4) ensureNewUnlock(unlockCh, height, round) @@ -1180,7 +1159,7 @@ func TestProposeValidBlock(t *testing.T) { incrementRound(vs2, vs3, vs4) incrementRound(vs2, vs3, vs4) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) round += 2 // moving to the next round @@ -1201,7 +1180,7 @@ func TestProposeValidBlock(t *testing.T) { assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), propBlockHash)) assert.True(t, bytes.Equal(rs.ProposalBlock.Hash(), rs.ValidBlock.Hash())) assert.True(t, rs.Proposal.POLRound == rs.ValidRound) - assert.True(t, bytes.Equal(rs.Proposal.BlockID.Hash, rs.ValidBlock.Hash())) + // assert.True(t, bytes.Equal(rs.Proposal.BlockID.Hash, rs.ValidBlock.Hash())) } // What we want: @@ -1211,8 +1190,6 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -1230,16 +1207,16 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { rs := cs1.GetRoundState() propBlock := rs.ProposalBlock propBlockHash := propBlock.Hash() - propBlockParts := propBlock.MakePartSet(partSize) + propDAH := &propBlock.DataAvailabilityHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], propBlockHash) // vs2 send prevote for propBlock - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs2) // vs3 send prevote nil - signAddVotes(cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs3) + signAddVotes(cs1, tmproto.PrevoteType, nil, propDAH, vs3) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) @@ -1250,31 +1227,28 @@ func TestSetValidBlockOnDelayedPrevote(t *testing.T) { rs = cs1.GetRoundState() assert.True(t, rs.ValidBlock == nil) - assert.True(t, rs.ValidBlockParts == nil) + assert.True(t, rs.ValidBlockDAHeader.IsZero()) assert.True(t, rs.ValidRound == -1) // vs2 send (delayed) prevote for propBlock - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs4) ensureNewValidBlock(validBlockCh, height, round) rs = cs1.GetRoundState() assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), propBlockHash)) - assert.True(t, rs.ValidBlockParts.Header().Equals(propBlockParts.Header())) assert.True(t, rs.ValidRound == round) } // What we want: -// P0 miss to lock B as Proposal Block is missing, but set valid block to B after -// receiving delayed Block Proposal. +// P0 miss to lock B as Proposal Blocks is missing, but set valid block to B after +// receiving delayed Blocks Proposal. func TestSetValidBlockOnDelayedProposal(t *testing.T) { cs1, vss := randState(4) vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -1298,10 +1272,10 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round+1) propBlockHash := propBlock.Hash() - propBlockParts := propBlock.MakePartSet(partSize) + propDAH := &propBlock.DataAvailabilityHeader // vs2, vs3 and vs4 send prevote for propBlock - signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlockHash, propDAH, vs2, vs3, vs4) ensureNewValidBlock(validBlockCh, height, round) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Prevote(round).Nanoseconds()) @@ -1309,7 +1283,7 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { ensurePrecommit(voteCh, height, round) validatePrecommit(t, cs1, round, -1, vss[0], nil, nil) - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -1317,7 +1291,6 @@ func TestSetValidBlockOnDelayedProposal(t *testing.T) { rs := cs1.GetRoundState() assert.True(t, bytes.Equal(rs.ValidBlock.Hash(), propBlockHash)) - assert.True(t, rs.ValidBlockParts.Header().Equals(propBlockParts.Header())) assert.True(t, rs.ValidRound == round) } @@ -1336,7 +1309,7 @@ func TestWaitingTimeoutOnNilPolka(t *testing.T) { startTestRound(cs1, height, round) ensureNewRound(newRoundCh, height, round) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) ensureNewTimeout(timeoutWaitCh, height, round, cs1.config.Precommit(round).Nanoseconds()) ensureNewRound(newRoundCh, height, round+1) @@ -1364,7 +1337,7 @@ func TestWaitingTimeoutProposeOnNewRound(t *testing.T) { ensurePrevote(voteCh, height, round) incrementRound(vss[1:]...) - signAddVotes(cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, nil, nil, vs2, vs3, vs4) round++ // moving to the next round ensureNewRound(newRoundCh, height, round) @@ -1400,7 +1373,7 @@ func TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) { ensurePrevote(voteCh, height, round) incrementRound(vss[1:]...) - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2, vs3, vs4) round++ // moving to the next round ensureNewRound(newRoundCh, height, round) @@ -1434,7 +1407,7 @@ func TestWaitTimeoutProposeOnNilPolkaForTheCurrentRound(t *testing.T) { ensureNewRound(newRoundCh, height, round) incrementRound(vss[1:]...) - signAddVotes(cs1, tmproto.PrevoteType, nil, types.PartSetHeader{}, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, nil, nil, vs2, vs3, vs4) ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds()) @@ -1451,28 +1424,25 @@ func TestEmitNewValidBlockEventOnCommitWithoutBlock(t *testing.T) { incrementRound(vs2, vs3, vs4) - partSize := types.BlockPartSizeBytes - newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock) _, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round) propBlockHash := propBlock.Hash() - propBlockParts := propBlock.MakePartSet(partSize) + propDAH := &propBlock.DataAvailabilityHeader // start round in which PO is not proposer startTestRound(cs1, height, round) ensureNewRound(newRoundCh, height, round) // vs2, vs3 and vs4 send precommit for propBlock - signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propDAH, vs2, vs3, vs4) ensureNewValidBlock(validBlockCh, height, round) rs := cs1.GetRoundState() assert.True(t, rs.Step == cstypes.RoundStepCommit) assert.True(t, rs.ProposalBlock == nil) - assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header())) - + assert.True(t, rs.ProposalBlockDAHeader.Equal(propDAH)) } // What we want: @@ -1483,22 +1453,20 @@ func TestCommitFromPreviousRound(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, int32(1) - partSize := types.BlockPartSizeBytes - newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) validBlockCh := subscribe(cs1.eventBus, types.EventQueryValidBlock) proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) prop, propBlock := decideProposal(cs1, vs2, vs2.Height, vs2.Round) propBlockHash := propBlock.Hash() - propBlockParts := propBlock.MakePartSet(partSize) + propDAH := &propBlock.DataAvailabilityHeader // start round in which PO is not proposer startTestRound(cs1, height, round) ensureNewRound(newRoundCh, height, round) // vs2, vs3 and vs4 send precommit for propBlock for the previous round - signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrecommitType, propBlockHash, &propBlock.DataAvailabilityHeader, vs2, vs3, vs4) ensureNewValidBlock(validBlockCh, height, round) @@ -1506,9 +1474,9 @@ func TestCommitFromPreviousRound(t *testing.T) { assert.True(t, rs.Step == cstypes.RoundStepCommit) assert.True(t, rs.CommitRound == vs2.Round) assert.True(t, rs.ProposalBlock == nil) - assert.True(t, rs.ProposalBlockParts.Header().Equals(propBlockParts.Header())) + assert.True(t, rs.ProposalBlockDAHeader.Equal(propDAH)) - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } @@ -1557,20 +1525,20 @@ func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() theBlockHash := rs.ProposalBlock.Hash() - theBlockParts := rs.ProposalBlockParts.Header() + dah := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], theBlockHash) - signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, dah, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], theBlockHash, theBlockHash) // add precommits - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2) - signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) + signAddVotes(cs1, tmproto.PrecommitType, nil, dah, vs2) + signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, dah, vs3) // wait till timeout occurs ensurePrecommitTimeout(precommitTimeoutCh) @@ -1578,7 +1546,7 @@ func TestStartNextHeightCorrectlyAfterTimeout(t *testing.T) { ensureNewRound(newRoundCh, height, round+1) // majority is now reached - signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs4) + signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, dah, vs4) ensureNewBlockHeader(newBlockHeader, height, theBlockHash) @@ -1599,8 +1567,6 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes - proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) newRoundCh := subscribe(cs1.eventBus, types.EventQueryNewRound) @@ -1617,27 +1583,26 @@ func TestResetTimeoutPrecommitUponNewHeight(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() theBlockHash := rs.ProposalBlock.Hash() - theBlockParts := rs.ProposalBlockParts.Header() + dah := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) validatePrevote(t, cs1, round, vss[0], theBlockHash) - signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, theBlockParts, vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, theBlockHash, dah, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) validatePrecommit(t, cs1, round, round, vss[0], theBlockHash, theBlockHash) // add precommits - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2) - signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs3) - signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, theBlockParts, vs4) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2) + signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, dah, vs3) + signAddVotes(cs1, tmproto.PrecommitType, theBlockHash, dah, vs4) ensureNewBlockHeader(newBlockHeader, height, theBlockHash) prop, propBlock := decideProposal(cs1, vs2, height+1, 0) - propBlockParts := propBlock.MakePartSet(partSize) - if err := cs1.SetProposalAndBlock(prop, propBlock, propBlockParts, "some peer"); err != nil { + if err := cs1.SetProposalAndBlock(prop, propBlock, "some peer"); err != nil { t.Fatal(err) } ensureNewProposal(proposalCh, height+1, 0) @@ -1738,7 +1703,6 @@ func TestStateHalt1(t *testing.T) { cs1, vss := randState(4) vs2, vs3, vs4 := vss[1], vss[2], vss[3] height, round := cs1.Height, cs1.Round - partSize := types.BlockPartSizeBytes proposalCh := subscribe(cs1.eventBus, types.EventQueryCompleteProposal) timeoutWaitCh := subscribe(cs1.eventBus, types.EventQueryTimeoutWait) @@ -1756,21 +1720,21 @@ func TestStateHalt1(t *testing.T) { ensureNewProposal(proposalCh, height, round) rs := cs1.GetRoundState() propBlock := rs.ProposalBlock - propBlockParts := propBlock.MakePartSet(partSize) + propDAH := rs.ProposalBlockDAHeader ensurePrevote(voteCh, height, round) - signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propBlockParts.Header(), vs2, vs3, vs4) + signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propDAH, vs2, vs3, vs4) ensurePrecommit(voteCh, height, round) // the proposed block should now be locked and our precommit added validatePrecommit(t, cs1, round, round, vss[0], propBlock.Hash(), propBlock.Hash()) // add precommits from the rest - signAddVotes(cs1, tmproto.PrecommitType, nil, types.PartSetHeader{}, vs2) // didnt receive proposal - signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propBlockParts.Header(), vs3) + signAddVotes(cs1, tmproto.PrecommitType, nil, nil, vs2) // didnt receive proposal + signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propDAH, vs3) // we receive this later, but vs3 might receive it earlier and with ours will go to commit! - precommit4 := signVote(vs4, tmproto.PrecommitType, propBlock.Hash(), propBlockParts.Header()) + precommit4 := signVote(vs4, tmproto.PrecommitType, propBlock.Hash(), propDAH) incrementRound(vs2, vs3, vs4) @@ -1801,20 +1765,31 @@ func TestStateHalt1(t *testing.T) { ensureNewRound(newRoundCh, height+1, 0) } -func TestStateOutputsBlockPartsStats(t *testing.T) { +func TestStateOutputsBlocksStats(t *testing.T) { // create dummy peer cs, _ := randState(1) peer := p2pmock.NewPeer(nil) - // 1) new block part - parts := types.NewPartSetFromData(tmrand.Bytes(100), 10) - msg := &BlockPartMessage{ + block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil, types.Messages{}, nil) + prop := types.NewProposal(1, 0, -1, &block.DataAvailabilityHeader) + p := prop.ToProto() + cs.privValidator.SignProposal(cs.state.ChainID, p); + prop.Signature = p.Signature + + msg := &BlockMessage{ Height: 1, Round: 0, - Part: parts.GetPart(0), + Block: block, + } + + propMsg := &ProposalMessage{ + Proposal: prop, } - cs.ProposalBlockParts = types.NewPartSetFromHeader(parts.Header()) + // 1) Send Proposal first to allow further block + cs.handleMsg(msgInfo{propMsg, peer.ID()}) + + // 2) Send Block Message cs.handleMsg(msgInfo{msg, peer.ID()}) statsMessage := <-cs.statsMsgQueue @@ -1838,10 +1813,9 @@ func TestStateOutputsBlockPartsStats(t *testing.T) { select { case <-cs.statsMsgQueue: - t.Errorf("should not output stats message after receiving the known block part!") + t.Errorf("should not output stats message after receiving the known block") case <-time.After(50 * time.Millisecond): } - } func TestStateOutputVoteStats(t *testing.T) { @@ -1851,7 +1825,7 @@ func TestStateOutputVoteStats(t *testing.T) { randBytes := tmrand.Bytes(tmhash.Size) - vote := signVote(vss[1], tmproto.PrecommitType, randBytes, types.PartSetHeader{}) + vote := signVote(vss[1], tmproto.PrecommitType, randBytes, nil) voteMessage := &VoteMessage{vote} cs.handleMsg(msgInfo{voteMessage, peer.ID()}) @@ -1865,7 +1839,7 @@ func TestStateOutputVoteStats(t *testing.T) { // sending the vote for the bigger height incrementHeight(vss[1]) - vote = signVote(vss[1], tmproto.PrecommitType, randBytes, types.PartSetHeader{}) + vote = signVote(vss[1], tmproto.PrecommitType, randBytes, nil) cs.handleMsg(msgInfo{&VoteMessage{vote}, peer.ID()}) diff --git a/consensus/types/height_vote_set.go b/consensus/types/height_vote_set.go index f20cd78324..3bbe278a00 100644 --- a/consensus/types/height_vote_set.go +++ b/consensus/types/height_vote_set.go @@ -155,7 +155,7 @@ func (hvs *HeightVoteSet) POLInfo() (polRound int32, polBlockID types.BlockID) { defer hvs.mtx.Unlock() for r := hvs.round; r >= 0; r-- { rvs := hvs.getVoteSet(r, tmproto.PrevoteType) - polBlockID, ok := rvs.TwoThirdsMajority() + polBlockID, _, ok := rvs.TwoThirdsMajority() if ok { return r, polBlockID } diff --git a/consensus/types/peer_round_state.go b/consensus/types/peer_round_state.go index 6a1447eec0..02b323baf9 100644 --- a/consensus/types/peer_round_state.go +++ b/consensus/types/peer_round_state.go @@ -20,10 +20,10 @@ type PeerRoundState struct { // Estimated start of round 0 at this height StartTime time.Time `json:"start_time"` - // True if peer has proposal for this round - Proposal bool `json:"proposal"` - ProposalBlockPartSetHeader types.PartSetHeader `json:"proposal_block_part_set_header"` - ProposalBlockParts *bits.BitArray `json:"proposal_block_parts"` + Proposal bool `json:"proposal"` // True if peer has proposal for this round + ProposalBlock bool `json:"proposal_block"` // True if peer has block for this round + ProposalBlockDAHeader *types.DataAvailabilityHeader `json:"proposal_block_da_header"` + // Proposal's POL round. -1 if none. ProposalPOLRound int32 `json:"proposal_pol_round"` @@ -50,7 +50,7 @@ func (prs PeerRoundState) String() string { func (prs PeerRoundState) StringIndented(indent string) string { return fmt.Sprintf(`PeerRoundState{ %s %v/%v/%v @%v -%s Proposal %v -> %v +%s ProposalDAHeader %v %s POL %v (round %v) %s Prevotes %v %s Precommits %v @@ -58,7 +58,7 @@ func (prs PeerRoundState) StringIndented(indent string) string { %s Catchup %v (round %v) %s}`, indent, prs.Height, prs.Round, prs.Step, prs.StartTime, - indent, prs.ProposalBlockPartSetHeader, prs.ProposalBlockParts, + indent, prs.ProposalBlockDAHeader, indent, prs.ProposalPOL, prs.ProposalPOLRound, indent, prs.Prevotes, indent, prs.Precommits, diff --git a/consensus/types/round_state.go b/consensus/types/round_state.go index 8c76019a44..217c1c49ac 100644 --- a/consensus/types/round_state.go +++ b/consensus/types/round_state.go @@ -70,22 +70,22 @@ type RoundState struct { Step RoundStepType `json:"step"` StartTime time.Time `json:"start_time"` - // Subjective time when +2/3 precommits for Block at Round were found + // Subjective time when +2/3 precommits for Blocks at Round were found CommitTime time.Time `json:"commit_time"` Validators *types.ValidatorSet `json:"validators"` + Proposal *types.Proposal `json:"proposal"` ProposalBlock *types.Block `json:"proposal_block"` - ProposalBlockParts *types.PartSet `json:"proposal_block_parts"` + ProposalBlockDAHeader *types.DataAvailabilityHeader `json:"proposal_block_da_header"` + LockedRound int32 `json:"locked_round"` LockedBlock *types.Block `json:"locked_block"` - LockedBlockParts *types.PartSet `json:"locked_block_parts"` + LockedBlockDAHeader *types.DataAvailabilityHeader `json:"locked_block_da_header"` - // Last known round with POL for non-nil valid block. - ValidRound int32 `json:"valid_round"` + ValidRound int32 `json:"valid_round"` // Last known round with POL for non-nil valid block. ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above. + ValidBlockDAHeader *types.DataAvailabilityHeader `json:"valid_block_da_header"` // Last known block ID of POL mentioned above. - // Last known block parts of POL mentioned above. - ValidBlockParts *types.PartSet `json:"valid_block_parts"` Votes *HeightVoteSet `json:"votes"` CommitRound int32 `json:"commit_round"` // LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1 @@ -146,18 +146,11 @@ func (rs *RoundState) NewRoundEvent() types.EventDataNewRound { // CompleteProposalEvent returns information about a proposed block as an event. func (rs *RoundState) CompleteProposalEvent() types.EventDataCompleteProposal { - // We must construct BlockID from ProposalBlock and ProposalBlockParts - // cs.Proposal is not guaranteed to be set when this function is called - blockID := types.BlockID{ - Hash: rs.ProposalBlock.Hash(), - PartSetHeader: rs.ProposalBlockParts.Header(), - } - return types.EventDataCompleteProposal{ Height: rs.Height, Round: rs.Round, Step: rs.Step.String(), - BlockID: blockID, + DAHeader: rs.ProposalBlockDAHeader, } } @@ -186,8 +179,8 @@ func (rs *RoundState) StringIndented(indent string) string { %s ProposalBlock: %v %v %s LockedRound: %v %s LockedBlock: %v %v -%s ValidRound: %v -%s ValidBlock: %v %v +%s ValidRound: %v +%s ValidBlock: %v %v %s Votes: %v %s LastCommit: %v %s LastValidators:%v @@ -197,11 +190,11 @@ func (rs *RoundState) StringIndented(indent string) string { indent, rs.CommitTime, indent, rs.Validators.StringIndented(indent+" "), indent, rs.Proposal, - indent, rs.ProposalBlockParts.StringShort(), rs.ProposalBlock.StringShort(), + indent, rs.ProposalBlockDAHeader.String(), rs.ProposalBlock.StringShort(), indent, rs.LockedRound, - indent, rs.LockedBlockParts.StringShort(), rs.LockedBlock.StringShort(), + indent, rs.LockedBlockDAHeader.String(), rs.LockedBlock.StringShort(), indent, rs.ValidRound, - indent, rs.ValidBlockParts.StringShort(), rs.ValidBlock.StringShort(), + indent, rs.ValidBlockDAHeader.String(), rs.ValidBlock.StringShort(), indent, rs.Votes.StringIndented(indent+" "), indent, rs.LastCommit.StringShort(), indent, rs.LastValidators.StringIndented(indent+" "), diff --git a/consensus/wal_test.go b/consensus/wal_test.go index e2af9a748f..8a241168af 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "path/filepath" - // "sync" "testing" "time" @@ -13,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "github.com/lazyledger/lazyledger-core/consensus/types" - "github.com/lazyledger/lazyledger-core/crypto/merkle" "github.com/lazyledger/lazyledger-core/libs/autofile" "github.com/lazyledger/lazyledger-core/libs/log" tmtypes "github.com/lazyledger/lazyledger-core/types" @@ -120,19 +118,20 @@ func TestWALWrite(t *testing.T) { wal.Wait() }) + block := tmtypes.MakeBlock( + int64(3), + []tmtypes.Tx{make([]byte, maxMsgSizeBytes-30)}, + nil, + nil, + tmtypes.Messages{}, + nil, + ) + // 1) Write returns an error if msg is too big - msg := &BlockPartMessage{ + msg := &BlockMessage{ Height: 1, Round: 1, - Part: &tmtypes.Part{ - Index: 1, - Bytes: make([]byte, 1), - Proof: merkle.Proof{ - Total: 1, - Index: 1, - LeafHash: make([]byte, maxMsgSizeBytes-30), - }, - }, + Block: block, } err = wal.Write(msgInfo{ diff --git a/go.sum b/go.sum index cc7cc8ba8d..f6d4191163 100644 --- a/go.sum +++ b/go.sum @@ -607,8 +607,6 @@ github.com/lazyledger/go-leopard v0.0.0-20200604113236-298f93361181/go.mod h1:v1 github.com/lazyledger/merkletree v0.0.0-20201214195110-6901c4c3c75f h1:jbyPAH6o6hGte4RtZBaqWs2n4Fl6hS7qJGXX3qnjiy4= github.com/lazyledger/merkletree v0.0.0-20201214195110-6901c4c3c75f/go.mod h1:10PA0NlnYtB8HrtwIDQAyTKWp8TEZ0zBZCGlYC/7+QE= github.com/lazyledger/nmt v0.2.0/go.mod h1:tY7ypPX26Sbkt6F8EbPl3AT33B5N0BJe4OVPbq849YI= -github.com/lazyledger/nmt v0.2.1-0.20210311211820-a5c8085cd40d h1:/4e9eoYm9qQLoTczb2QCMDQvGrER14HnPdwPzi2ngv4= -github.com/lazyledger/nmt v0.2.1-0.20210311211820-a5c8085cd40d/go.mod h1:tY7ypPX26Sbkt6F8EbPl3AT33B5N0BJe4OVPbq849YI= github.com/lazyledger/nmt v0.2.1 h1:/gSzFilF/fzykHiDDkwvnoyRdtntosgXP5feJbcTs1o= github.com/lazyledger/nmt v0.2.1/go.mod h1:tY7ypPX26Sbkt6F8EbPl3AT33B5N0BJe4OVPbq849YI= github.com/lazyledger/rsmt2d v0.0.0-20201215203123-e5ec7910ddd4 h1:r2mI8AnDTOSwL9GWGjgHC4rwzaR56jRCo1GLpG2lwIw= diff --git a/light/rpc/client.go b/light/rpc/client.go index 2060cb7777..e68ce87358 100644 --- a/light/rpc/client.go +++ b/light/rpc/client.go @@ -277,7 +277,7 @@ func (c *Client) Genesis(ctx context.Context) (*ctypes.ResultGenesis, error) { return c.next.Genesis(ctx) } -// Block calls rpcclient#Block and then verifies the result. +// Block calls rpcclient#Blocks and then verifies the result. func (c *Client) Block(ctx context.Context, height *int64) (*ctypes.ResultBlock, error) { res, err := c.next.Block(ctx, height) if err != nil { diff --git a/p2p/conn/connection.go b/p2p/conn/connection.go index 1b3c1f9802..41957f5926 100644 --- a/p2p/conn/connection.go +++ b/p2p/conn/connection.go @@ -501,7 +501,7 @@ FOR_LOOP: // Returns true if messages from channels were exhausted. // Blocks in accordance to .sendMonitor throttling. func (c *MConnection) sendSomePacketMsgs() bool { - // Block until .sendMonitor says we can write. + // Blocks until .sendMonitor says we can write. // Once we're ready we send more than we asked for, // but amortized it should even out. c.sendMonitor.Limit(c._maxPacketMsgSize, atomic.LoadInt64(&c.config.SendRate), true) @@ -563,7 +563,7 @@ func (c *MConnection) recvRoutine() { FOR_LOOP: for { - // Block until .recvMonitor says we can read. + // Blocks until .recvMonitor says we can read. c.recvMonitor.Limit(c._maxPacketMsgSize, atomic.LoadInt64(&c.config.RecvRate), true) // Peek into bufConnReader for debugging diff --git a/p2p/node_info.go b/p2p/node_info.go index 0203ba2f55..d75a1a6a43 100644 --- a/p2p/node_info.go +++ b/p2p/node_info.go @@ -51,7 +51,7 @@ type ProtocolVersion struct { App uint64 `json:"app"` } -// defaultProtocolVersion populates the Block and P2P versions using +// defaultProtocolVersion populates the Blocks and P2P versions using // the global values, but not the App. var defaultProtocolVersion = NewProtocolVersion( version.P2PProtocol, @@ -173,7 +173,7 @@ func (info DefaultNodeInfo) Validate() error { } // CompatibleWith checks if two DefaultNodeInfo are compatible with eachother. -// CONTRACT: two nodes are compatible if the Block version and network match +// CONTRACT: two nodes are compatible if the Blocks version and network match // and they have at least one channel in common. func (info DefaultNodeInfo) CompatibleWith(otherInfo NodeInfo) error { other, ok := otherInfo.(DefaultNodeInfo) @@ -182,7 +182,7 @@ func (info DefaultNodeInfo) CompatibleWith(otherInfo NodeInfo) error { } if info.ProtocolVersion.Block != other.ProtocolVersion.Block { - return fmt.Errorf("peer is on a different Block version. Got %v, expected %v", + return fmt.Errorf("peer is on a different Blocks version. Got %v, expected %v", other.ProtocolVersion.Block, info.ProtocolVersion.Block) } diff --git a/proto/tendermint/blockchain/types.pb.go b/proto/tendermint/blockchain/types.pb.go index 2ec783ed7f..de927382a9 100644 --- a/proto/tendermint/blockchain/types.pb.go +++ b/proto/tendermint/blockchain/types.pb.go @@ -1015,7 +1015,7 @@ func (m *BlockResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) } var msglen int for shift := uint(0); ; shift += 7 { diff --git a/proto/tendermint/consensus/types.pb.go b/proto/tendermint/consensus/types.pb.go index 43ff41a7fe..aedf7e63dc 100644 --- a/proto/tendermint/consensus/types.pb.go +++ b/proto/tendermint/consensus/types.pb.go @@ -107,11 +107,10 @@ func (m *NewRoundStep) GetLastCommitRound() int32 { //i.e., there is a Proposal for block B and 2/3+ prevotes for the block B in the round r. // In case the block is also committed, then IsCommit flag is set to true. type NewValidBlock struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` - BlockPartSetHeader types.PartSetHeader `protobuf:"bytes,3,opt,name=block_part_set_header,json=blockPartSetHeader,proto3" json:"block_part_set_header"` - BlockParts *bits.BitArray `protobuf:"bytes,4,opt,name=block_parts,json=blockParts,proto3" json:"block_parts,omitempty"` - IsCommit bool `protobuf:"varint,5,opt,name=is_commit,json=isCommit,proto3" json:"is_commit,omitempty"` + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` + DAHeader *types.DataAvailabilityHeader `protobuf:"bytes,3,opt,name=da_header,json=daHeader,proto3" json:"da_header,omitempty"` + IsCommit bool `protobuf:"varint,4,opt,name=is_commit,json=isCommit,proto3" json:"is_commit,omitempty"` } func (m *NewValidBlock) Reset() { *m = NewValidBlock{} } @@ -161,16 +160,9 @@ func (m *NewValidBlock) GetRound() int32 { return 0 } -func (m *NewValidBlock) GetBlockPartSetHeader() types.PartSetHeader { +func (m *NewValidBlock) GetDAHeader() *types.DataAvailabilityHeader { if m != nil { - return m.BlockPartSetHeader - } - return types.PartSetHeader{} -} - -func (m *NewValidBlock) GetBlockParts() *bits.BitArray { - if m != nil { - return m.BlockParts + return m.DAHeader } return nil } @@ -349,6 +341,66 @@ func (m *BlockPart) GetPart() types.Part { return types.Part{} } +type Block struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` + Block *types.Block `protobuf:"bytes,3,opt,name=block,proto3" json:"block,omitempty"` +} + +func (m *Block) Reset() { *m = Block{} } +func (m *Block) String() string { return proto.CompactTextString(m) } +func (*Block) ProtoMessage() {} +func (*Block) Descriptor() ([]byte, []int) { + return fileDescriptor_81a22d2efc008981, []int{5} +} +func (m *Block) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Block) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Block.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Block) XXX_Merge(src proto.Message) { + xxx_messageInfo_Block.Merge(m, src) +} +func (m *Block) XXX_Size() int { + return m.Size() +} +func (m *Block) XXX_DiscardUnknown() { + xxx_messageInfo_Block.DiscardUnknown(m) +} + +var xxx_messageInfo_Block proto.InternalMessageInfo + +func (m *Block) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *Block) GetRound() int32 { + if m != nil { + return m.Round + } + return 0 +} + +func (m *Block) GetBlock() *types.Block { + if m != nil { + return m.Block + } + return nil +} + // Vote is sent when voting for a proposal (or lack thereof). type Vote struct { Vote *types.Vote `protobuf:"bytes,1,opt,name=vote,proto3" json:"vote,omitempty"` @@ -358,7 +410,7 @@ func (m *Vote) Reset() { *m = Vote{} } func (m *Vote) String() string { return proto.CompactTextString(m) } func (*Vote) ProtoMessage() {} func (*Vote) Descriptor() ([]byte, []int) { - return fileDescriptor_81a22d2efc008981, []int{5} + return fileDescriptor_81a22d2efc008981, []int{6} } func (m *Vote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,7 +458,7 @@ func (m *HasVote) Reset() { *m = HasVote{} } func (m *HasVote) String() string { return proto.CompactTextString(m) } func (*HasVote) ProtoMessage() {} func (*HasVote) Descriptor() ([]byte, []int) { - return fileDescriptor_81a22d2efc008981, []int{6} + return fileDescriptor_81a22d2efc008981, []int{7} } func (m *HasVote) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -475,7 +527,7 @@ func (m *VoteSetMaj23) Reset() { *m = VoteSetMaj23{} } func (m *VoteSetMaj23) String() string { return proto.CompactTextString(m) } func (*VoteSetMaj23) ProtoMessage() {} func (*VoteSetMaj23) Descriptor() ([]byte, []int) { - return fileDescriptor_81a22d2efc008981, []int{7} + return fileDescriptor_81a22d2efc008981, []int{8} } func (m *VoteSetMaj23) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -545,7 +597,7 @@ func (m *VoteSetBits) Reset() { *m = VoteSetBits{} } func (m *VoteSetBits) String() string { return proto.CompactTextString(m) } func (*VoteSetBits) ProtoMessage() {} func (*VoteSetBits) Descriptor() ([]byte, []int) { - return fileDescriptor_81a22d2efc008981, []int{8} + return fileDescriptor_81a22d2efc008981, []int{9} } func (m *VoteSetBits) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -620,6 +672,7 @@ type Message struct { // *Message_HasVote // *Message_VoteSetMaj23 // *Message_VoteSetBits + // *Message_Block Sum isMessage_Sum `protobuf_oneof:"sum"` } @@ -627,7 +680,7 @@ func (m *Message) Reset() { *m = Message{} } func (m *Message) String() string { return proto.CompactTextString(m) } func (*Message) ProtoMessage() {} func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_81a22d2efc008981, []int{9} + return fileDescriptor_81a22d2efc008981, []int{10} } func (m *Message) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -689,6 +742,9 @@ type Message_VoteSetMaj23 struct { type Message_VoteSetBits struct { VoteSetBits *VoteSetBits `protobuf:"bytes,9,opt,name=vote_set_bits,json=voteSetBits,proto3,oneof" json:"vote_set_bits,omitempty"` } +type Message_Block struct { + Block *Block `protobuf:"bytes,10,opt,name=block,proto3,oneof" json:"block,omitempty"` +} func (*Message_NewRoundStep) isMessage_Sum() {} func (*Message_NewValidBlock) isMessage_Sum() {} @@ -699,6 +755,7 @@ func (*Message_Vote) isMessage_Sum() {} func (*Message_HasVote) isMessage_Sum() {} func (*Message_VoteSetMaj23) isMessage_Sum() {} func (*Message_VoteSetBits) isMessage_Sum() {} +func (*Message_Block) isMessage_Sum() {} func (m *Message) GetSum() isMessage_Sum { if m != nil { @@ -770,6 +827,13 @@ func (m *Message) GetVoteSetBits() *VoteSetBits { return nil } +func (m *Message) GetBlock() *Block { + if x, ok := m.GetSum().(*Message_Block); ok { + return x.Block + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*Message) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -782,6 +846,7 @@ func (*Message) XXX_OneofWrappers() []interface{} { (*Message_HasVote)(nil), (*Message_VoteSetMaj23)(nil), (*Message_VoteSetBits)(nil), + (*Message_Block)(nil), } } @@ -791,6 +856,7 @@ func init() { proto.RegisterType((*Proposal)(nil), "tendermint.consensus.Proposal") proto.RegisterType((*ProposalPOL)(nil), "tendermint.consensus.ProposalPOL") proto.RegisterType((*BlockPart)(nil), "tendermint.consensus.BlockPart") + proto.RegisterType((*Block)(nil), "tendermint.consensus.Blocks") proto.RegisterType((*Vote)(nil), "tendermint.consensus.Vote") proto.RegisterType((*HasVote)(nil), "tendermint.consensus.HasVote") proto.RegisterType((*VoteSetMaj23)(nil), "tendermint.consensus.VoteSetMaj23") @@ -801,61 +867,64 @@ func init() { func init() { proto.RegisterFile("tendermint/consensus/types.proto", fileDescriptor_81a22d2efc008981) } var fileDescriptor_81a22d2efc008981 = []byte{ - // 863 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0xb7, 0x59, 0x67, 0x93, 0x7d, 0xde, 0x3f, 0x30, 0xda, 0x56, 0x61, 0x81, 0x6c, 0x30, 0x97, - 0x15, 0x02, 0x07, 0x65, 0x0f, 0x48, 0x15, 0x12, 0xc5, 0xfc, 0xa9, 0x5b, 0x35, 0x6d, 0xe4, 0x54, - 0x15, 0xea, 0xc5, 0x72, 0xe2, 0x91, 0x33, 0xd4, 0xf6, 0x58, 0x9e, 0x49, 0x96, 0x70, 0xe4, 0x13, - 0xf0, 0x01, 0xf8, 0x1a, 0x48, 0x7c, 0x84, 0x1e, 0x7b, 0xe4, 0x54, 0xa1, 0xec, 0x47, 0x40, 0x70, - 0x46, 0x33, 0x9e, 0x24, 0x13, 0xea, 0x2e, 0xec, 0x05, 0xa9, 0xb7, 0x99, 0xbc, 0xf7, 0x7e, 0xf3, - 0xde, 0xef, 0xbd, 0xf7, 0x8b, 0x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, 0x70, - 0xa9, 0x1d, 0x3f, 0x9e, 0xd0, 0x12, 0xf7, 0xaa, 0x4f, 0x8f, 0xba, 0x8f, 0x97, 0xf1, 0xae, 0xb4, - 0x9d, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x08, 0xab, 0x10, 0x2c, 0xdb, 0x08, 0x00, 0x00, + // 904 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcf, 0x6e, 0x1b, 0x45, + 0x18, 0xdf, 0x6d, 0xbc, 0xf1, 0xfa, 0xb3, 0x93, 0xc0, 0x2a, 0x14, 0x93, 0x82, 0x1d, 0x96, 0x4b, + 0x84, 0xa8, 0x5d, 0x39, 0x07, 0xa4, 0x8a, 0x43, 0x63, 0x02, 0xdd, 0x56, 0x4d, 0x6b, 0x8d, 0xab, + 0x1e, 0x7a, 0x59, 0x8d, 0xbd, 0x23, 0x7b, 0xe8, 0x7a, 0x67, 0xb5, 0x33, 0x71, 0x30, 0x47, 0x9e, + 0x80, 0x07, 0xe0, 0x0d, 0x38, 0x70, 0x42, 0xe2, 0x11, 0x7a, 0xcc, 0x91, 0x53, 0x84, 0x9c, 0x47, + 0xe0, 0x05, 0xd0, 0xfc, 0xb1, 0x33, 0x21, 0x4e, 0x44, 0x38, 0x20, 0xf5, 0x36, 0xe3, 0xef, 0xfb, + 0x7e, 0xdf, 0x6f, 0xbe, 0x3f, 0x3f, 0x2f, 0xec, 0x0a, 0x92, 0x25, 0xa4, 0x98, 0xd0, 0x4c, 0xb4, + 0x87, 0x2c, 0xe3, 0x24, 0xe3, 0xc7, 0xbc, 0x2d, 0x66, 0x39, 0xe1, 0xad, 0xbc, 0x60, 0x82, 0x05, + 0xdb, 0x17, 0x1e, 0xad, 0xa5, 0xc7, 0xce, 0xf6, 0x88, 0x8d, 0x98, 0x72, 0x68, 0xcb, 0x93, 0xf6, + 0xdd, 0xf9, 0xd8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88, 0x14, 0xd6, 0xf1, 0xfe, 0x90, 0x15, 0xa4, 0xad, + 0xbf, 0x76, 0x56, 0x7d, 0x2f, 0x0d, 0xd6, 0x95, 0x6d, 0xff, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x38, 0xbd, 0x06, 0x64, 0x4e, 0x09, 0x00, 0x00, } func (m *NewRoundStep) Marshal() (dAtA []byte, err error) { @@ -934,11 +1003,11 @@ func (m *NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x28 + dAtA[i] = 0x20 } - if m.BlockParts != nil { + if m.DAHeader != nil { { - size, err := m.BlockParts.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.DAHeader.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -946,18 +1015,8 @@ func (m *NewValidBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - } - { - size, err := m.BlockPartSetHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + dAtA[i] = 0x1a } - i-- - dAtA[i] = 0x1a if m.Round != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.Round)) i-- @@ -1090,6 +1149,51 @@ func (m *BlockPart) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Block) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Block) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Block != nil { + { + size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Round != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Round)) + i-- + dAtA[i] = 0x10 + } + if m.Height != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *Vote) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1495,6 +1599,27 @@ func (m *Message_VoteSetBits) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } +func (m *Message_Block) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Message_Block) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Block != nil { + { + size, err := m.Block.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + return len(dAtA) - i, nil +} func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -1542,10 +1667,8 @@ func (m *NewValidBlock) Size() (n int) { if m.Round != 0 { n += 1 + sovTypes(uint64(m.Round)) } - l = m.BlockPartSetHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - if m.BlockParts != nil { - l = m.BlockParts.Size() + if m.DAHeader != nil { + l = m.DAHeader.Size() n += 1 + l + sovTypes(uint64(l)) } if m.IsCommit { @@ -1599,6 +1722,25 @@ func (m *BlockPart) Size() (n int) { return n } +func (m *Block) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovTypes(uint64(m.Height)) + } + if m.Round != 0 { + n += 1 + sovTypes(uint64(m.Round)) + } + if m.Block != nil { + l = m.Block.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func (m *Vote) Size() (n int) { if m == nil { return 0 @@ -1795,6 +1937,18 @@ func (m *Message_VoteSetBits) Size() (n int) { } return n } +func (m *Message_Block) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Block != nil { + l = m.Block.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 @@ -2016,7 +2170,7 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { } case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockPartSetHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DAHeader", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2043,47 +2197,14 @@ func (m *NewValidBlock) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BlockPartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockParts", wireType) + if m.DAHeader == nil { + m.DAHeader = &types.DataAvailabilityHeader{} } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.BlockParts == nil { - m.BlockParts = &bits.BitArray{} - } - if err := m.BlockParts.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.DAHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IsCommit", wireType) } @@ -2449,6 +2570,130 @@ func (m *BlockPart) Unmarshal(dAtA []byte) error { } return nil } +func (m *Block) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Blocks: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Blocks: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) + } + m.Round = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Round |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Block == nil { + m.Block = &types.Block{} + } + if err := m.Block.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Vote) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3318,6 +3563,41 @@ func (m *Message) Unmarshal(dAtA []byte) error { } m.Sum = &Message_VoteSetBits{v} iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &Block{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Sum = &Message_Block{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) diff --git a/proto/tendermint/consensus/types.proto b/proto/tendermint/consensus/types.proto index 36bf40b27a..071b4f5380 100644 --- a/proto/tendermint/consensus/types.proto +++ b/proto/tendermint/consensus/types.proto @@ -5,6 +5,7 @@ option go_package = "github.com/lazyledger/lazyledger-core/proto/tendermint/cons import "gogoproto/gogo.proto"; import "tendermint/types/types.proto"; +import "tendermint/types/block.proto"; import "tendermint/libs/bits/types.proto"; // NewRoundStep is sent for every step taken in the ConsensusState. @@ -23,9 +24,8 @@ message NewRoundStep { message NewValidBlock { int64 height = 1; int32 round = 2; - tendermint.types.PartSetHeader block_part_set_header = 3 [(gogoproto.nullable) = false]; - tendermint.libs.bits.BitArray block_parts = 4; - bool is_commit = 5; + tendermint.types.DataAvailabilityHeader da_header = 3 [(gogoproto.customname) = "DAHeader"]; + bool is_commit = 4; } // Proposal is sent when a new block is proposed. @@ -47,6 +47,12 @@ message BlockPart { tendermint.types.Part part = 3 [(gogoproto.nullable) = false]; } +message Block { + int64 height = 1; + int32 round = 2; + tendermint.types.Block block = 3; +} + // Vote is sent when voting for a proposal (or lack thereof). message Vote { tendermint.types.Vote vote = 1; @@ -88,5 +94,6 @@ message Message { HasVote has_vote = 7; VoteSetMaj23 vote_set_maj23 = 8; VoteSetBits vote_set_bits = 9; + Block block = 10; } } diff --git a/proto/tendermint/p2p/types.pb.go b/proto/tendermint/p2p/types.pb.go index ddc7e0d49e..0650faa77e 100644 --- a/proto/tendermint/p2p/types.pb.go +++ b/proto/tendermint/p2p/types.pb.go @@ -833,7 +833,7 @@ func (m *ProtocolVersion) Unmarshal(dAtA []byte) error { } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) } m.Block = 0 for shift := uint(0); ; shift += 7 { diff --git a/proto/tendermint/types/block.pb.go b/proto/tendermint/types/block.pb.go index 832cf23fe7..34f33545d4 100644 --- a/proto/tendermint/types/block.pb.go +++ b/proto/tendermint/types/block.pb.go @@ -92,7 +92,7 @@ func (m *Block) GetLastCommit() *Commit { } func init() { - proto.RegisterType((*Block)(nil), "tendermint.types.Block") + proto.RegisterType((*Block)(nil), "tendermint.types.Blocks") } func init() { proto.RegisterFile("tendermint/types/block.proto", fileDescriptor_70840e82f4357ab1) } @@ -247,10 +247,10 @@ func (m *Block) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Block: wiretype end group for non-group") + return fmt.Errorf("proto: Blocks: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Block: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Blocks: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/proto/tendermint/types/params.pb.go b/proto/tendermint/types/params.pb.go index 482765df1d..c2b6ab2872 100644 --- a/proto/tendermint/types/params.pb.go +++ b/proto/tendermint/types/params.pb.go @@ -1077,7 +1077,7 @@ func (m *ConsensusParams) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) } var msglen int for shift := uint(0); ; shift += 7 { diff --git a/proto/tendermint/types/types.pb.go b/proto/tendermint/types/types.pb.go index 96d633ae10..04be15da9c 100644 --- a/proto/tendermint/types/types.pb.go +++ b/proto/tendermint/types/types.pb.go @@ -977,14 +977,15 @@ func (m *DataAvailabilityHeader) GetColumnRoots() [][]byte { // Vote represents a prevote, precommit, or commit vote from validators for // consensus. type Vote struct { - Type SignedMsgType `protobuf:"varint,1,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` - Round int32 `protobuf:"varint,3,opt,name=round,proto3" json:"round,omitempty"` - BlockID BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` - Timestamp time.Time `protobuf:"bytes,5,opt,name=timestamp,proto3,stdtime" json:"timestamp"` - ValidatorAddress []byte `protobuf:"bytes,6,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` - ValidatorIndex int32 `protobuf:"varint,7,opt,name=validator_index,json=validatorIndex,proto3" json:"validator_index,omitempty"` - Signature []byte `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"` + Type SignedMsgType `protobuf:"varint,1,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,3,opt,name=round,proto3" json:"round,omitempty"` + BlockID BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` + DAHeader DataAvailabilityHeader `protobuf:"bytes,5,opt,name=da_header,json=daHeader,proto3" json:"da_header"` + Timestamp time.Time `protobuf:"bytes,6,opt,name=timestamp,proto3,stdtime" json:"timestamp"` + ValidatorAddress []byte `protobuf:"bytes,7,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + ValidatorIndex int32 `protobuf:"varint,8,opt,name=validator_index,json=validatorIndex,proto3" json:"validator_index,omitempty"` + Signature []byte `protobuf:"bytes,9,opt,name=signature,proto3" json:"signature,omitempty"` } func (m *Vote) Reset() { *m = Vote{} } @@ -1048,6 +1049,13 @@ func (m *Vote) GetBlockID() BlockID { return BlockID{} } +func (m *Vote) GetDAHeader() DataAvailabilityHeader { + if m != nil { + return m.DAHeader + } + return DataAvailabilityHeader{} +} + func (m *Vote) GetTimestamp() time.Time { if m != nil { return m.Timestamp @@ -1568,120 +1576,121 @@ func init() { func init() { proto.RegisterFile("tendermint/types/types.proto", fileDescriptor_d3a6e55e2345de56) } var fileDescriptor_d3a6e55e2345de56 = []byte{ - // 1807 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcb, 0x6f, 0x23, 0x49, - 0x19, 0x4f, 0xdb, 0x4e, 0x6c, 0x7f, 0xb6, 0x13, 0xa7, 0xc8, 0x64, 0x1c, 0xcf, 0x8c, 0x63, 0x9a, - 0xc7, 0x66, 0x5f, 0xce, 0x30, 0x8b, 0x10, 0x48, 0xcb, 0x6a, 0xed, 0x24, 0x3b, 0x63, 0x36, 0x0f, - 0xab, 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 0x6d, - 0xa8, 0xdb, 0xd2, 0x88, 0x6e, 0x4b, 0xe3, 0x34, 0xba, 0x2d, 0xad, 0x9c, 0x50, 0xfc, 0xfc, 0x1f, - 0xdb, 0x86, 0x25, 0x25, 0xd0, 0x1e, 0x94, 0x3c, 0xcc, 0xb8, 0xdd, 0x13, 0x61, 0x13, 0xea, 0x97, - 0xe5, 0x16, 0x5b, 0xb3, 0x01, 0xd1, 0x81, 0xd5, 0xa6, 0x17, 0x84, 0x94, 0x22, 0x39, 0x68, 0x07, - 0xca, 0x72, 0x93, 0x3e, 0x1d, 0x8d, 0x5c, 0x6e, 0xcb, 0xb8, 0xaf, 0xc8, 0xb8, 0xaf, 0x0a, 0xfa, - 0x9e, 0x24, 0x3f, 0x12, 0x27, 0x70, 0x07, 0xf2, 0x0e, 0xe6, 0x58, 0x41, 0xb2, 0x12, 0x92, 0x13, - 0x04, 0xc9, 0x7c, 0x07, 0xd6, 0xe2, 0x5b, 0xc7, 0x14, 0x24, 0xa7, 0x76, 0x99, 0x90, 0x25, 0xf0, - 0x3e, 0x6c, 0xf8, 0xe4, 0x82, 0xdb, 0x37, 0xd1, 0x79, 0x89, 0x46, 0x82, 0x77, 0x36, 0x2d, 0xf1, - 0x3d, 0x58, 0xed, 0x47, 0xc1, 0x57, 0x58, 0x90, 0xd8, 0x52, 0x4c, 0x95, 0xb0, 0x2d, 0xc8, 0xe1, - 0x20, 0x50, 0x80, 0x82, 0x04, 0x64, 0x71, 0x10, 0x48, 0xd6, 0x7b, 0xb0, 0x2e, 0x7d, 0x0c, 0x09, - 0x1b, 0x7b, 0x5c, 0x6f, 0x52, 0x94, 0x98, 0x35, 0xc1, 0xb0, 0x14, 0x5d, 0x62, 0xbf, 0x03, 0x25, - 0x72, 0xee, 0x3a, 0xc4, 0xef, 0x13, 0x85, 0x2b, 0x49, 0x5c, 0x31, 0x22, 0x4a, 0xd0, 0xbb, 0x50, - 0x0e, 0x42, 0x1a, 0x50, 0x46, 0x42, 0x1b, 0x3b, 0x4e, 0x48, 0x18, 0xab, 0xac, 0xaa, 0xfd, 0x22, - 0x7a, 0x53, 0x91, 0xcd, 0x5f, 0xa7, 0x20, 0xb3, 0x8f, 0x39, 0x46, 0x65, 0x48, 0xf3, 0x0b, 0x56, - 0x31, 0xea, 0xe9, 0x9d, 0xa2, 0x25, 0x3e, 0xd1, 0x10, 0x2a, 0xae, 0xcf, 0x49, 0x38, 0x22, 0x8e, - 0x8b, 0x39, 0xb1, 0x19, 0x17, 0xbf, 0x21, 0xa5, 0x9c, 0xe9, 0xbb, 0xbd, 0x33, 0x7b, 0x94, 0xed, - 0x84, 0x44, 0x57, 0x08, 0x58, 0x02, 0xaf, 0x4f, 0x76, 0xd3, 0x9d, 0xcb, 0x45, 0x9f, 0x42, 0x2e, - 0xb2, 0x5f, 0x27, 0x65, 0x6d, 0x76, 0xe7, 0x03, 0x8d, 0x38, 0x74, 0x19, 0xd7, 0xfb, 0xc5, 0x52, - 0xe8, 0x63, 0xc8, 0x8d, 0x08, 0x63, 0x78, 0x40, 0x58, 0x7c, 0x53, 0x67, 0x76, 0x38, 0xd2, 0x88, - 0x48, 0x3a, 0x92, 0x30, 0xff, 0x65, 0x40, 0x2e, 0xda, 0x1e, 0x61, 0xb8, 0xed, 0x8c, 0x03, 0xcf, - 0xed, 0x0b, 0x6f, 0xcf, 0x29, 0x27, 0x76, 0x6c, 0x9b, 0xca, 0xbf, 0x77, 0x66, 0x77, 0xde, 0x8f, - 0x04, 0xce, 0x28, 0x27, 0xd1, 0x4e, 0x8f, 0x96, 0xac, 0x5b, 0xce, 0x3c, 0x06, 0xf2, 0xe1, 0xae, - 0x27, 0x92, 0xcb, 0xee, 0x7b, 0x2e, 0xf1, 0xb9, 0x8d, 0x39, 0xc7, 0xfd, 0x27, 0x13, 0x3d, 0x2a, - 0xba, 0xef, 0xcf, 0xea, 0x39, 0x14, 0x52, 0x7b, 0x52, 0xa8, 0x29, 0x65, 0x12, 0xba, 0xb6, 0xbc, - 0x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, 0xd6, - 0xaf, 0xae, 0xeb, 0xa5, 0x4e, 0x48, 0x54, 0xfe, 0x48, 0x89, 0x06, 0x54, 0x66, 0x25, 0x4e, 0x3a, - 0x27, 0xdd, 0xe6, 0x61, 0xb9, 0x5e, 0x2d, 0x5f, 0x5d, 0xd7, 0x8b, 0x51, 0x79, 0x14, 0xf8, 0x89, - 0x67, 0xad, 0xb3, 0xaf, 0x5e, 0xd4, 0x8c, 0xaf, 0x5f, 0xd4, 0x8c, 0x7f, 0xbe, 0xa8, 0x19, 0xcf, - 0x5f, 0xd6, 0x96, 0xbe, 0x7e, 0x59, 0x5b, 0xfa, 0xdb, 0xcb, 0xda, 0xd2, 0x2f, 0x3f, 0x1e, 0xb8, - 0x7c, 0x38, 0xee, 0x35, 0xfa, 0x74, 0xb4, 0xeb, 0xe1, 0x67, 0x97, 0x1e, 0x71, 0x06, 0x24, 0x4c, - 0x7c, 0x7e, 0xd8, 0xa7, 0xa1, 0xfe, 0x0f, 0x69, 0xf7, 0xe6, 0x1f, 0x3e, 0xbd, 0x15, 0x49, 0xff, - 0xe8, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd1, 0xa8, 0x35, 0xdb, 0xb1, 0x12, 0x00, 0x00, + // 1809 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcd, 0x6f, 0x23, 0x49, + 0x15, 0x4f, 0xdb, 0x4e, 0x6c, 0x3f, 0xdb, 0x89, 0x53, 0x64, 0x32, 0x8e, 0x67, 0xc6, 0x31, 0xcd, + 0xc7, 0x66, 0xbf, 0x9c, 0x61, 0x16, 0x21, 0x90, 0x96, 0xd5, 0xda, 0x49, 0x76, 0xc6, 0x6c, 0x3e, + 0xac, 0x76, 0x36, 0x0b, 0x5c, 0x5a, 0x65, 0x77, 0x8d, 0xdd, 0x4c, 0xbb, 0xab, 0xd5, 0x55, 0xce, + 0x24, 0x73, 0xe4, 0x84, 0x72, 0x9a, 0x13, 0xb7, 0x9c, 0xe0, 0xc0, 0x9f, 0x01, 0x48, 0x48, 0x7b, + 0x41, 0xda, 0x1b, 0x5c, 0x58, 0xd0, 0x0c, 0xe2, 0xef, 0x40, 0xf5, 0xd1, 0xed, 0x76, 0x6c, 0x0f, + 0xab, 0x08, 0x21, 0x2e, 0x56, 0xd7, 0x7b, 0xbf, 0x57, 0xef, 0xab, 0xde, 0x7b, 0x55, 0x86, 0xfb, + 0x9c, 0xf8, 0x0e, 0x09, 0x47, 0xae, 0xcf, 0x77, 0xf9, 0x65, 0x40, 0x98, 0xfa, 0x6d, 0x04, 0x21, + 0xe5, 0x14, 0x95, 0x27, 0xdc, 0x86, 0xa4, 0x57, 0x37, 0x06, 0x74, 0x40, 0x25, 0x73, 0x57, 0x7c, + 0x29, 0x5c, 0x75, 0x7b, 0x40, 0xe9, 0xc0, 0x23, 0xbb, 0x72, 0xd5, 0x1b, 0x3f, 0xdd, 0xe5, 0xee, + 0x88, 0x30, 0x8e, 0x47, 0x81, 0x06, 0x3c, 0x48, 0xa8, 0xe9, 0x87, 0x97, 0x01, 0xa7, 0x02, 0x4b, + 0x9f, 0x6a, 0x76, 0x2d, 0xc1, 0x3e, 0x27, 0x21, 0x73, 0xa9, 0x9f, 0xb4, 0xa3, 0x5a, 0x9f, 0xb1, + 0xf2, 0x1c, 0x7b, 0xae, 0x83, 0x39, 0x0d, 0x15, 0xc2, 0xfc, 0x11, 0x94, 0x3a, 0x38, 0xe4, 0x5d, + 0xc2, 0x9f, 0x10, 0xec, 0x90, 0x10, 0x6d, 0xc0, 0x32, 0xa7, 0x1c, 0x7b, 0x15, 0xa3, 0x6e, 0xec, + 0x94, 0x2c, 0xb5, 0x40, 0x08, 0x32, 0x43, 0xcc, 0x86, 0x95, 0x54, 0xdd, 0xd8, 0x29, 0x5a, 0xf2, + 0xdb, 0x1c, 0x42, 0x46, 0x88, 0x0a, 0x09, 0xd7, 0x77, 0xc8,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xdb, 0xb0, 0xa4, 0x04, 0xda, 0x83, 0x92, 0x87, 0x19, 0xb7, 0x7b, 0x22, 0x6c, 0x42, 0xfd, 0xb2, + 0xdc, 0x62, 0x6b, 0x36, 0x20, 0x3a, 0xb0, 0xda, 0xf4, 0x82, 0x90, 0x52, 0x24, 0x07, 0xed, 0x40, + 0x59, 0x6e, 0xd2, 0xa7, 0xa3, 0x91, 0xcb, 0x6d, 0x19, 0xf7, 0x15, 0x19, 0xf7, 0x55, 0x41, 0xdf, + 0x93, 0xe4, 0x27, 0x22, 0x03, 0xf7, 0x20, 0xef, 0x60, 0x8e, 0x15, 0x24, 0x2b, 0x21, 0x39, 0x41, + 0x90, 0xcc, 0xb7, 0x60, 0x2d, 0x3e, 0x75, 0x4c, 0x41, 0x72, 0x6a, 0x97, 0x09, 0x59, 0x02, 0x1f, + 0xc2, 0x86, 0x4f, 0x2e, 0xb8, 0x7d, 0x13, 0x9d, 0x97, 0x68, 0x24, 0x78, 0x67, 0xd3, 0x12, 0xdf, + 0x81, 0xd5, 0x7e, 0x14, 0x7c, 0x85, 0x05, 0x89, 0x2d, 0xc5, 0x54, 0x09, 0xdb, 0x82, 0x1c, 0x0e, + 0x02, 0x05, 0x28, 0x48, 0x40, 0x16, 0x07, 0x81, 0x64, 0xbd, 0x03, 0xeb, 0xd2, 0xc7, 0x90, 0xb0, + 0xb1, 0xc7, 0xf5, 0x26, 0x45, 0x89, 0x59, 0x13, 0x0c, 0x4b, 0xd1, 0x25, 0xf6, 0x5b, 0x50, 0x22, + 0xe7, 0xae, 0x43, 0xfc, 0x3e, 0x51, 0xb8, 0x92, 0xc4, 0x15, 0x23, 0xa2, 0x04, 0xbd, 0x0d, 0xe5, + 0x20, 0xa4, 0x01, 0x65, 0x24, 0xb4, 0xb1, 0xe3, 0x84, 0x84, 0xb1, 0xca, 0xaa, 0xda, 0x2f, 0xa2, + 0x37, 0x15, 0xd9, 0xfc, 0x65, 0x0a, 0x32, 0xfb, 0x98, 0x63, 0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, 0x4a, + 0x9c, 0x74, 0x4e, 0xba, 0xcd, 0xc3, 0x72, 0xbd, 0x5a, 0xbe, 0xba, 0xae, 0x17, 0xa3, 0xf6, 0x28, + 0xf0, 0x13, 0xcf, 0x5a, 0x67, 0x5f, 0xbc, 0xaa, 0x19, 0x5f, 0xbe, 0xaa, 0x19, 0xff, 0x78, 0x55, + 0x33, 0x5e, 0xbe, 0xae, 0x2d, 0x7d, 0xf9, 0xba, 0xb6, 0xf4, 0xd7, 0xd7, 0xb5, 0xa5, 0x9f, 0x7f, + 0x38, 0x70, 0xf9, 0x70, 0xdc, 0x6b, 0xf4, 0xe9, 0x68, 0xd7, 0xc3, 0x2f, 0x2e, 0x3d, 0xe2, 0x0c, + 0x48, 0x98, 0xf8, 0x7c, 0xbf, 0x4f, 0x43, 0xfd, 0xe7, 0xd4, 0xee, 0xcd, 0x7f, 0x92, 0x7a, 0x2b, + 0x92, 0xfe, 0xc1, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x45, 0xd6, 0x6e, 0x25, 0x0a, 0x13, 0x00, + 0x00, } func (m *PartSetHeader) Marshal() (dAtA []byte, err error) { @@ -2407,19 +2416,19 @@ func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Signature) i = encodeVarintTypes(dAtA, i, uint64(len(m.Signature))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } if m.ValidatorIndex != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.ValidatorIndex)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if len(m.ValidatorAddress) > 0 { i -= len(m.ValidatorAddress) copy(dAtA[i:], m.ValidatorAddress) i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } n16, err16 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) if err16 != nil { @@ -2428,6 +2437,16 @@ func (m *Vote) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n16 i = encodeVarintTypes(dAtA, i, uint64(n16)) i-- + dAtA[i] = 0x32 + { + size, err := m.DAHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x2a { size, err := m.BlockID.MarshalToSizedBuffer(dAtA[:i]) @@ -2541,12 +2560,12 @@ func (m *CommitSig) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - n19, err19 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err19 != nil { - return 0, err19 + n20, err20 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) + if err20 != nil { + return 0, err20 } - i -= n19 - i = encodeVarintTypes(dAtA, i, uint64(n19)) + i -= n20 + i = encodeVarintTypes(dAtA, i, uint64(n20)) i-- dAtA[i] = 0x1a if len(m.ValidatorAddress) > 0 { @@ -2591,12 +2610,12 @@ func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x3a } - n20, err20 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) - if err20 != nil { - return 0, err20 + n21, err21 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):]) + if err21 != nil { + return 0, err21 } - i -= n20 - i = encodeVarintTypes(dAtA, i, uint64(n20)) + i -= n21 + i = encodeVarintTypes(dAtA, i, uint64(n21)) i-- dAtA[i] = 0x32 { @@ -3155,6 +3174,8 @@ func (m *Vote) Size() (n int) { } l = m.BlockID.Size() n += 1 + l + sovTypes(uint64(l)) + l = m.DAHeader.Size() + n += 1 + l + sovTypes(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp) n += 1 + l + sovTypes(uint64(l)) l = len(m.ValidatorAddress) @@ -5474,6 +5495,39 @@ func (m *Vote) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DAHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DAHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) } @@ -5506,7 +5560,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) } @@ -5540,7 +5594,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { m.ValidatorAddress = []byte{} } iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ValidatorIndex", wireType) } @@ -5559,7 +5613,7 @@ func (m *Vote) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) } diff --git a/proto/tendermint/types/types.proto b/proto/tendermint/types/types.proto index 4f699adfc7..f384288a9c 100644 --- a/proto/tendermint/types/types.proto +++ b/proto/tendermint/types/types.proto @@ -159,11 +159,12 @@ message Vote { int32 round = 3; BlockID block_id = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. - google.protobuf.Timestamp timestamp = 5 + DataAvailabilityHeader da_header = 5 [(gogoproto.nullable) = false, (gogoproto.customname) = "DAHeader"]; + google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes validator_address = 6; - int32 validator_index = 7; - bytes signature = 8; + bytes validator_address = 7; + int32 validator_index = 8; + bytes signature = 9; } // Commit contains the evidence that a block was committed by a set of validators. diff --git a/proto/tendermint/version/types.pb.go b/proto/tendermint/version/types.pb.go index 53ca4300ec..ad2fb8608a 100644 --- a/proto/tendermint/version/types.pb.go +++ b/proto/tendermint/version/types.pb.go @@ -224,7 +224,7 @@ func (m *Consensus) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) } m.Block = 0 for shift := uint(0); ; shift += 7 { diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index f0022a7e70..593bb2cb17 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -286,7 +286,7 @@ func TestAppCalls(t *testing.T) { assert.Equal(appHash, cappHash) assert.NotNil(commit.Commit) - // compare the commits (note Commit(2) has commit from Block(3)) + // compare the commits (note Commit(2) has commit from Blocks(3)) h = apph - 1 commit2, err := c.Commit(context.Background(), &h) require.NoError(err) diff --git a/state/state.go b/state/state.go index b3c4858b05..468558c5c6 100644 --- a/state/state.go +++ b/state/state.go @@ -25,7 +25,7 @@ var ( //----------------------------------------------------------------------------- -// InitStateVersion sets the Consensus.Block and Software versions, +// InitStateVersion sets the Consensus.Blocks and Software versions, // but leaves the Consensus.App version blank. // The Consensus.App version will be set during the Handshake, once // we hear from the app what protocol version it is running. @@ -159,7 +159,7 @@ func (state *State) ToProto() (*tmstate.State, error) { } sm.NextValidators = nVals - if state.LastBlockHeight >= 1 { // At Block 1 LastValidators is nil + if state.LastBlockHeight >= 1 { // At Blocks 1 LastValidators is nil lVals, err := state.LastValidators.ToProto() if err != nil { return nil, err @@ -208,7 +208,7 @@ func StateFromProto(pb *tmstate.State) (*State, error) { //nolint:golint } state.NextValidators = nVals - if state.LastBlockHeight >= 1 { // At Block 1 LastValidators is nil + if state.LastBlockHeight >= 1 { // At Blocks 1 LastValidators is nil lVals, err := types.ValidatorSetFromProto(pb.LastValidators) if err != nil { return nil, err diff --git a/state/validation.go b/state/validation.go index c116063f81..b2c8935d34 100644 --- a/state/validation.go +++ b/state/validation.go @@ -20,30 +20,30 @@ func validateBlock(state State, block *types.Block) error { // Validate basic info. if block.Version.App != state.Version.Consensus.App || block.Version.Block != state.Version.Consensus.Block { - return fmt.Errorf("wrong Block.Header.Version. Expected %v, got %v", + return fmt.Errorf("wrong Blocks.Header.Version. Expected %v, got %v", state.Version.Consensus, block.Version, ) } if block.ChainID != state.ChainID { - return fmt.Errorf("wrong Block.Header.ChainID. Expected %v, got %v", + return fmt.Errorf("wrong Blocks.Header.ChainID. Expected %v, got %v", state.ChainID, block.ChainID, ) } if state.LastBlockHeight == 0 && block.Height != state.InitialHeight { - return fmt.Errorf("wrong Block.Header.Height. Expected %v for initial block, got %v", + return fmt.Errorf("wrong Blocks.Header.Height. Expected %v for initial block, got %v", block.Height, state.InitialHeight) } if state.LastBlockHeight > 0 && block.Height != state.LastBlockHeight+1 { - return fmt.Errorf("wrong Block.Header.Height. Expected %v, got %v", + return fmt.Errorf("wrong Blocks.Header.Height. Expected %v, got %v", state.LastBlockHeight+1, block.Height, ) } // Validate prev block info. if !block.LastBlockID.Equals(state.LastBlockID) { - return fmt.Errorf("wrong Block.Header.LastBlockID. Expected %v, got %v", + return fmt.Errorf("wrong Blocks.Header.LastBlockID. Expected %v, got %v", state.LastBlockID, block.LastBlockID, ) @@ -51,32 +51,32 @@ func validateBlock(state State, block *types.Block) error { // Validate app info if !bytes.Equal(block.AppHash, state.AppHash) { - return fmt.Errorf("wrong Block.Header.AppHash. Expected %X, got %v", + return fmt.Errorf("wrong Blocks.Header.AppHash. Expected %X, got %v", state.AppHash, block.AppHash, ) } hashCP := types.HashConsensusParams(state.ConsensusParams) if !bytes.Equal(block.ConsensusHash, hashCP) { - return fmt.Errorf("wrong Block.Header.ConsensusHash. Expected %X, got %v", + return fmt.Errorf("wrong Blocks.Header.ConsensusHash. Expected %X, got %v", hashCP, block.ConsensusHash, ) } if !bytes.Equal(block.LastResultsHash, state.LastResultsHash) { - return fmt.Errorf("wrong Block.Header.LastResultsHash. Expected %X, got %v", + return fmt.Errorf("wrong Blocks.Header.LastResultsHash. Expected %X, got %v", state.LastResultsHash, block.LastResultsHash, ) } if !bytes.Equal(block.ValidatorsHash, state.Validators.Hash()) { - return fmt.Errorf("wrong Block.Header.ValidatorsHash. Expected %X, got %v", + return fmt.Errorf("wrong Blocks.Header.ValidatorsHash. Expected %X, got %v", state.Validators.Hash(), block.ValidatorsHash, ) } if !bytes.Equal(block.NextValidatorsHash, state.NextValidators.Hash()) { - return fmt.Errorf("wrong Block.Header.NextValidatorsHash. Expected %X, got %v", + return fmt.Errorf("wrong Blocks.Header.NextValidatorsHash. Expected %X, got %v", state.NextValidators.Hash(), block.NextValidatorsHash, ) diff --git a/store/store.go b/store/store.go index d03dab5bd4..81aa1bffe6 100644 --- a/store/store.go +++ b/store/store.go @@ -18,12 +18,12 @@ BlockStore is a simple low level store for blocks. There are three types of information stored: - BlockMeta: Meta information about each block - - Block part: Parts of each block, aggregated w/ PartSet + - Blocks part: Parts of each block, aggregated w/ PartSet - Commit: The commit part of each block, for gossiping precommit votes -Currently the precommit signatures are duplicated in the Block parts as +Currently the precommit signatures are duplicated in the Blocks parts as well as the Commit. In the future this may change, perhaps by moving -the Commit data outside the Block. (TODO) +the Commit data outside the Blocks. (TODO) The store can be assumed to contain all contiguous blocks between base and height (inclusive). @@ -366,7 +366,7 @@ func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, s panic(err) } - // Save block commit (duplicate and separate from the Block) + // Save block commit (duplicate and separate from the Blocks) pbc := block.LastCommit.ToProto() blockCommitBytes := mustEncode(pbc) if err := bs.db.Set(calcBlockCommitKey(height-1), blockCommitBytes); err != nil { diff --git a/test/maverick/consensus/reactor.go b/test/maverick/consensus/reactor.go index f937af63f4..151f8e059b 100644 --- a/test/maverick/consensus/reactor.go +++ b/test/maverick/consensus/reactor.go @@ -502,7 +502,7 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() - // Send proposal Block parts? + // Send proposal Blocks parts? if rs.ProposalBlockParts.HasHeader(prs.ProposalBlockPartSetHeader) { if index, ok := rs.ProposalBlockParts.BitArray().Sub(prs.ProposalBlockParts.Copy()).PickRandom(); ok { part := rs.ProposalBlockParts.GetPart(index) diff --git a/test/maverick/consensus/replay.go b/test/maverick/consensus/replay.go index beb0d70039..7d85a755fb 100644 --- a/test/maverick/consensus/replay.go +++ b/test/maverick/consensus/replay.go @@ -515,7 +515,7 @@ func assertAppHashEqualsOneFromBlock(appHash []byte, block *types.Block) { if !bytes.Equal(appHash, block.AppHash) { panic(fmt.Sprintf(`block.AppHash does not match AppHash after replay. Got %X, expected %X. -Block: %v +Blocks: %v `, appHash, block.AppHash, block)) } diff --git a/types/block.go b/types/block.go index 6bcfe4de78..7e95633431 100644 --- a/types/block.go +++ b/types/block.go @@ -3,6 +3,7 @@ package types import ( "bytes" "crypto/sha256" + "encoding/hex" "errors" "fmt" "math" @@ -63,6 +64,8 @@ type DataAvailabilityHeader struct { RowsRoots NmtRoots `json:"row_roots"` // ColumnRoot_j = root((M_{1,j} || M_{2,j} || ... || M_{2k,j} )) ColumnRoots NmtRoots `json:"column_roots"` + // cached result of Hash() not to be recomputed + hash []byte } type NmtRoots []namespace.IntervalDigest @@ -131,11 +134,30 @@ func (roots NmtRoots) Bytes() [][]byte { return res } +func (dah *DataAvailabilityHeader) String() string { + if dah == nil { + return "" + } + return strings.ToUpper(hex.EncodeToString(dah.Hash())) +} + +func (dah DataAvailabilityHeader) IsZero() bool { + return len(dah.RowsRoots) == 0 && len(dah.ColumnRoots) == 0 +} + +func (dah *DataAvailabilityHeader) Equal(to *DataAvailabilityHeader) bool { + return bytes.Equal(dah.Hash(), to.Hash()) +} + // Hash computes the root of the row and column roots func (dah *DataAvailabilityHeader) Hash() []byte { if dah == nil { return merkle.HashFromByteSlices(nil) } + if len(dah.hash) != 0 { + return dah.hash + } + colsCount := len(dah.ColumnRoots) rowsCount := len(dah.RowsRoots) slices := make([][]byte, colsCount+rowsCount) @@ -147,7 +169,8 @@ func (dah *DataAvailabilityHeader) Hash() []byte { } // The single data root is computed using a simple binary merkle tree. // Effectively being root(rowRoots || columnRoots): - return merkle.HashFromByteSlices(slices) + dah.hash = merkle.HashFromByteSlices(slices) + return dah.hash } func (dah *DataAvailabilityHeader) ToProto() *tmproto.DataAvailabilityHeader { @@ -1569,13 +1592,7 @@ func (blockID BlockID) Equals(other BlockID) bool { // Key returns a machine-readable string representation of the BlockID func (blockID BlockID) Key() string { - pbph := blockID.PartSetHeader.ToProto() - bz, err := pbph.Marshal() - if err != nil { - panic(err) - } - - return string(blockID.Hash) + string(bz) + return string(blockID.Hash) } // ValidateBasic performs basic validation. @@ -1598,9 +1615,7 @@ func (blockID BlockID) IsZero() bool { // IsComplete returns true if this is a valid BlockID of a non-nil block. func (blockID BlockID) IsComplete() bool { - return len(blockID.Hash) == tmhash.Size && - blockID.PartSetHeader.Total > 0 && - len(blockID.PartSetHeader.Hash) == tmhash.Size + return len(blockID.Hash) == tmhash.Size } // String returns a human readable string representation of the BlockID. diff --git a/types/events.go b/types/events.go index 1544ee94ea..f08db3e7b6 100644 --- a/types/events.go +++ b/types/events.go @@ -112,7 +112,7 @@ type EventDataCompleteProposal struct { Round int32 `json:"round"` Step string `json:"step"` - BlockID BlockID `json:"block_id"` + DAHeader *DataAvailabilityHeader `json:"da_header"` } type EventDataVote struct { diff --git a/types/evidence.go b/types/evidence.go index f59c6282bb..249059b931 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -576,9 +576,5 @@ func makeMockVote(height int64, round, index int32, addr Address, func randBlockID() BlockID { return BlockID{ Hash: tmrand.Bytes(tmhash.Size), - PartSetHeader: PartSetHeader{ - Total: 1, - Hash: tmrand.Bytes(tmhash.Size), - }, } } diff --git a/types/params.go b/types/params.go index bc7eb96bb4..65e736a299 100644 --- a/types/params.go +++ b/types/params.go @@ -131,7 +131,7 @@ func ValidateConsensusParams(params tmproto.ConsensusParams) error { } // Hash returns a hash of a subset of the parameters to store in the block header. -// Only the Block.MaxBytes and Block.MaxGas are included in the hash. +// Only the Blocks.MaxBytes and Blocks.MaxGas are included in the hash. // This allows the ConsensusParams to evolve more without breaking the block // protocol. No need for a Merkle tree here, just a small struct to hash. func HashConsensusParams(params tmproto.ConsensusParams) []byte { diff --git a/types/proposal.go b/types/proposal.go index fe71467720..4e6bc66418 100644 --- a/types/proposal.go +++ b/types/proposal.go @@ -27,14 +27,14 @@ type Proposal struct { Height int64 `json:"height"` Round int32 `json:"round"` // there can not be greater than 2_147_483_647 rounds POLRound int32 `json:"pol_round"` // -1 if null. - DAHeader DataAvailabilityHeader `json:"da_header"` + DAHeader *DataAvailabilityHeader `json:"da_header"` Timestamp time.Time `json:"timestamp"` Signature []byte `json:"signature"` } // NewProposal returns a new Proposal. // If there is no POLRound, polRound should be -1. -func NewProposal(height int64, round int32, polRound int32, daH DataAvailabilityHeader) *Proposal { +func NewProposal(height int64, round int32, polRound int32, daH *DataAvailabilityHeader) *Proposal { return &Proposal{ Type: tmproto.ProposalType, Height: height, @@ -78,7 +78,7 @@ func (p *Proposal) ValidateBasic() error { // // 1. height // 2. round -// 3. block ID +// 3. DAHeader // 4. POL round // 5. first 6 bytes of signature // 6. timestamp @@ -144,7 +144,7 @@ func ProposalFromProto(pp *tmproto.Proposal) (*Proposal, error) { return nil, err } - p.DAHeader = *dah + p.DAHeader = dah p.Type = pp.Type p.Height = pp.Height p.Round = pp.Round diff --git a/types/protobuf.go b/types/protobuf.go index 4d5fcb65a9..13da7b4120 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -65,7 +65,7 @@ func (tm2pb) Validator(val *Validator) abci.Validator { func (tm2pb) BlockID(blockID BlockID) tmproto.BlockID { return tmproto.BlockID{ Hash: blockID.Hash, - PartSetHeader: TM2PB.PartSetHeader(blockID.PartSetHeader), + PartSetHeader: TM2PB.PartSetHeader(PartSetHeader{}), } } diff --git a/types/vote.go b/types/vote.go index 309c800782..7996447fab 100644 --- a/types/vote.go +++ b/types/vote.go @@ -52,6 +52,7 @@ type Vote struct { Height int64 `json:"height"` Round int32 `json:"round"` // assume there will not be greater than 2_147_483_647 rounds BlockID BlockID `json:"block_id"` // zero if vote is nil. + DAHeader *DataAvailabilityHeader`json:"da_header"` Timestamp time.Time `json:"timestamp"` ValidatorAddress Address `json:"validator_address"` ValidatorIndex int32 `json:"validator_index"` @@ -213,6 +214,7 @@ func (vote *Vote) ToProto() *tmproto.Vote { Height: vote.Height, Round: vote.Round, BlockID: vote.BlockID.ToProto(), + DAHeader: *vote.DAHeader.ToProto(), Timestamp: vote.Timestamp, ValidatorAddress: vote.ValidatorAddress, ValidatorIndex: vote.ValidatorIndex, @@ -232,11 +234,17 @@ func VoteFromProto(pv *tmproto.Vote) (*Vote, error) { return nil, err } + dah, err := DataAvailabilityHeaderFromProto(&pv.DAHeader) + if err != nil { + return nil, err + } + vote := new(Vote) vote.Type = pv.Type vote.Height = pv.Height vote.Round = pv.Round vote.BlockID = *blockID + vote.DAHeader = dah vote.Timestamp = pv.Timestamp vote.ValidatorAddress = pv.ValidatorAddress vote.ValidatorIndex = pv.ValidatorIndex diff --git a/types/vote_set.go b/types/vote_set.go index 1d12ab36bb..e5c7a4b114 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -70,6 +70,7 @@ type VoteSet struct { votes []*Vote // Primary votes to share sum int64 // Sum of voting power for seen votes, discounting conflicts maj23 *BlockID // First 2/3 majority seen + maj23DA *DataAvailabilityHeader votesByBlock map[string]*blockVotes // string(blockHash|blockParts) -> blockVotes peerMaj23s map[P2PID]BlockID // Maj23 for each peer } @@ -90,6 +91,7 @@ func NewVoteSet(chainID string, height int64, round int32, votes: make([]*Vote, valSet.Size()), sum: 0, maj23: nil, + maj23DA: nil, votesByBlock: make(map[string]*blockVotes, valSet.Size()), peerMaj23s: make(map[P2PID]BlockID), } @@ -287,8 +289,8 @@ func (voteSet *VoteSet) addVerifiedVote( if origSum < quorum && quorum <= votesByBlock.sum { // Only consider the first quorum reached if voteSet.maj23 == nil { - maj23BlockID := vote.BlockID - voteSet.maj23 = &maj23BlockID + voteSet.maj23 = &vote.BlockID + voteSet.maj23DA = vote.DAHeader // And also copy votes over to voteSet.votes for i, vote := range votesByBlock.votes { if vote != nil { @@ -427,16 +429,16 @@ func (voteSet *VoteSet) HasAll() bool { // If there was a +2/3 majority for blockID, return blockID and true. // Else, return the empty BlockID{} and false. -func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool) { +func (voteSet *VoteSet) TwoThirdsMajority() (BlockID, *DataAvailabilityHeader, bool) { if voteSet == nil { - return BlockID{}, false + return BlockID{}, nil, false } voteSet.mtx.Lock() defer voteSet.mtx.Unlock() if voteSet.maj23 != nil { - return *voteSet.maj23, true + return *voteSet.maj23, voteSet.maj23DA, true } - return BlockID{}, false + return BlockID{}, nil, false } //-------------------------------------------------------------------------------- diff --git a/types/vote_set_test.go b/types/vote_set_test.go index e52a56b4b1..12b934d3b7 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -214,7 +214,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) { "there should be no 2/3 majority: last vote added was nil") } - // 68th validator voted for a different BlockParts PartSetHeader + // 68th validator voted for a different Blocks PartSetHeader { pubKey, err := privValidators[67].GetPubKey() require.NoError(t, err) @@ -228,7 +228,7 @@ func TestVoteSet_2_3MajorityRedux(t *testing.T) { "there should be no 2/3 majority: last vote added had different PartSetHeader Hash") } - // 69th validator voted for different BlockParts Total + // 69th validator voted for different Blocks Total { pubKey, err := privValidators[68].GetPubKey() require.NoError(t, err)