From c97cc3093b467053a0ee120984ed912888ffb886 Mon Sep 17 00:00:00 2001 From: evan-forbes Date: Wed, 28 Jul 2021 14:05:45 +0200 Subject: [PATCH 1/5] remove the part set header from state.State --- node/node_test.go | 1 - proto/tendermint/state/types.pb.go | 218 +++++++++++------------------ proto/tendermint/state/types.proto | 19 ++- state/execution.go | 2 +- state/state.go | 31 ++-- state/validation.go | 3 +- state/validation_test.go | 4 +- statesync/stateprovider.go | 1 - types/validator_set.go | 10 +- 9 files changed, 105 insertions(+), 184 deletions(-) diff --git a/node/node_test.go b/node/node_test.go index 1a3569b862..15ce51c9d6 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -467,7 +467,6 @@ func TestMaxProposalBlockSize(t *testing.T) { timestamp := time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC) // change state in order to produce the largest accepted header state.LastBlockID = blockID - state.LastPartSetHeader = psh state.LastBlockHeight = math.MaxInt64 - 1 state.LastBlockTime = timestamp state.LastResultsHash = tmhash.Sum([]byte("last_results_hash")) diff --git a/proto/tendermint/state/types.pb.go b/proto/tendermint/state/types.pb.go index 300bcaf207..de240eff70 100644 --- a/proto/tendermint/state/types.pb.go +++ b/proto/tendermint/state/types.pb.go @@ -257,28 +257,27 @@ type State struct { ChainID string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` InitialHeight int64 `protobuf:"varint,15,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height,omitempty"` // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) - LastBlockHeight int64 `protobuf:"varint,3,opt,name=last_block_height,json=lastBlockHeight,proto3" json:"last_block_height,omitempty"` - LastBlockID types1.BlockID `protobuf:"bytes,4,opt,name=last_block_id,json=lastBlockId,proto3" json:"last_block_id"` - LastPartSetHeader *types1.PartSetHeader `protobuf:"bytes,5,opt,name=last_part_set_header,json=lastPartSetHeader,proto3" json:"last_part_set_header,omitempty"` - LastBlockTime time.Time `protobuf:"bytes,6,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time"` + LastBlockHeight int64 `protobuf:"varint,3,opt,name=last_block_height,json=lastBlockHeight,proto3" json:"last_block_height,omitempty"` + LastBlockID types1.BlockID `protobuf:"bytes,4,opt,name=last_block_id,json=lastBlockId,proto3" json:"last_block_id"` + LastBlockTime time.Time `protobuf:"bytes,5,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time"` // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change, // so we can query for historical validator sets. // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1 // Extra +1 due to nextValSet delay. - NextValidators *types1.ValidatorSet `protobuf:"bytes,7,opt,name=next_validators,json=nextValidators,proto3" json:"next_validators,omitempty"` - Validators *types1.ValidatorSet `protobuf:"bytes,8,opt,name=validators,proto3" json:"validators,omitempty"` - LastValidators *types1.ValidatorSet `protobuf:"bytes,9,opt,name=last_validators,json=lastValidators,proto3" json:"last_validators,omitempty"` - LastHeightValidatorsChanged int64 `protobuf:"varint,10,opt,name=last_height_validators_changed,json=lastHeightValidatorsChanged,proto3" json:"last_height_validators_changed,omitempty"` + NextValidators *types1.ValidatorSet `protobuf:"bytes,6,opt,name=next_validators,json=nextValidators,proto3" json:"next_validators,omitempty"` + Validators *types1.ValidatorSet `protobuf:"bytes,7,opt,name=validators,proto3" json:"validators,omitempty"` + LastValidators *types1.ValidatorSet `protobuf:"bytes,8,opt,name=last_validators,json=lastValidators,proto3" json:"last_validators,omitempty"` + LastHeightValidatorsChanged int64 `protobuf:"varint,9,opt,name=last_height_validators_changed,json=lastHeightValidatorsChanged,proto3" json:"last_height_validators_changed,omitempty"` // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. - ConsensusParams types1.ConsensusParams `protobuf:"bytes,11,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"` - LastHeightConsensusParamsChanged int64 `protobuf:"varint,12,opt,name=last_height_consensus_params_changed,json=lastHeightConsensusParamsChanged,proto3" json:"last_height_consensus_params_changed,omitempty"` + ConsensusParams types1.ConsensusParams `protobuf:"bytes,10,opt,name=consensus_params,json=consensusParams,proto3" json:"consensus_params"` + LastHeightConsensusParamsChanged int64 `protobuf:"varint,11,opt,name=last_height_consensus_params_changed,json=lastHeightConsensusParamsChanged,proto3" json:"last_height_consensus_params_changed,omitempty"` // Merkle root of the results from executing prev block - LastResultsHash []byte `protobuf:"bytes,13,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` + LastResultsHash []byte `protobuf:"bytes,12,opt,name=last_results_hash,json=lastResultsHash,proto3" json:"last_results_hash,omitempty"` // the latest AppHash we've received from calling abci.Commit() - AppHash []byte `protobuf:"bytes,14,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` + AppHash []byte `protobuf:"bytes,13,opt,name=app_hash,json=appHash,proto3" json:"app_hash,omitempty"` } func (m *State) Reset() { *m = State{} } @@ -349,13 +348,6 @@ func (m *State) GetLastBlockID() types1.BlockID { return types1.BlockID{} } -func (m *State) GetLastPartSetHeader() *types1.PartSetHeader { - if m != nil { - return m.LastPartSetHeader - } - return nil -} - func (m *State) GetLastBlockTime() time.Time { if m != nil { return m.LastBlockTime @@ -430,58 +422,56 @@ func init() { func init() { proto.RegisterFile("tendermint/state/types.proto", fileDescriptor_ccfacf933f22bf93) } var fileDescriptor_ccfacf933f22bf93 = []byte{ - // 809 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x4e, 0xf3, 0x46, - 0x14, 0x8d, 0x9b, 0x0f, 0x92, 0x8c, 0x49, 0x42, 0x07, 0x16, 0x26, 0x14, 0x27, 0xa4, 0x3f, 0x42, - 0x95, 0xea, 0x48, 0x74, 0x55, 0xa9, 0x42, 0xc2, 0x49, 0x55, 0x22, 0xa1, 0x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2f, 0x0f, 0x31, 0xf6, 0x03, 0x9c, 0x2b, 0xcb, 0xaf, 0xbc, 0x34, - 0x97, 0xbf, 0x9e, 0xc1, 0xfa, 0x9f, 0x76, 0xb2, 0xcd, 0xe3, 0x5f, 0xff, 0x13, 0x00, 0x00, 0xff, - 0xff, 0x9d, 0xd6, 0x60, 0x0f, 0x84, 0x07, 0x00, 0x00, + // 776 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcf, 0x4f, 0xe3, 0x46, + 0x14, 0xc7, 0xe3, 0x06, 0x48, 0x32, 0x26, 0x84, 0x0e, 0x3d, 0x98, 0x50, 0x9c, 0x90, 0xfe, 0x10, + 0xaa, 0x54, 0x47, 0xa2, 0xa7, 0x4a, 0x15, 0x12, 0x4e, 0xaa, 0x12, 0x09, 0x55, 0x95, 0x41, 0x1c, + 0x7a, 0xb1, 0x26, 0xf6, 0x60, 0x5b, 0x75, 0x6c, 0xcb, 0x33, 0x49, 0xa1, 0xf7, 0xde, 0xb9, 0xf6, + 0x3f, 0xe2, 0xc8, 0xb1, 0xda, 0x03, 0xbb, 0x1b, 0xfe, 0x91, 0xd5, 0xfc, 0xb0, 0x33, 0x49, 0x16, + 0x89, 0xd5, 0xde, 0xc6, 0xf3, 0xbe, 0xef, 0x33, 0xdf, 0x79, 0xf3, 0x9e, 0x0c, 0xbe, 0xa6, 0x38, + 0xf1, 0x71, 0x3e, 0x89, 0x12, 0xda, 0x27, 0x14, 0x51, 0xdc, 0xa7, 0x77, 0x19, 0x26, 0x56, 0x96, + 0xa7, 0x34, 0x85, 0xbb, 0x8b, 0xa8, 0xc5, 0xa3, 0xed, 0xaf, 0x82, 0x34, 0x48, 0x79, 0xb0, 0xcf, + 0x56, 0x42, 0xd7, 0x3e, 0x50, 0x28, 0x68, 0xec, 0x45, 0x2a, 0xa4, 0xad, 0x1e, 0xc1, 0xf7, 0x97, + 0x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75, 0x94, 0x65, 0x42, 0xd2, 0xe4, 0x92, 0x1a, 0xca, 0x32, 0x16, 0xb2, + 0xaf, 0x1f, 0xe6, 0xa6, 0xf6, 0x38, 0x37, 0xb5, 0x77, 0x73, 0x53, 0xbb, 0x7f, 0x36, 0x2b, 0x8f, + 0xcf, 0x66, 0xe5, 0xff, 0x67, 0xb3, 0xf2, 0xe7, 0x2f, 0x41, 0x44, 0xc3, 0xe9, 0xd8, 0xf2, 0xd2, + 0x49, 0x3f, 0x46, 0xff, 0xdc, 0xc5, 0xd8, 0x0f, 0x70, 0xae, 0x2c, 0x7f, 0xf4, 0xd2, 0x5c, 0xfe, + 0x28, 0xfa, 0xab, 0xff, 0xc5, 0xf1, 0x16, 0xdf, 0xff, 0xe9, 0x43, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x62, 0x98, 0xd0, 0xfd, 0x32, 0x07, 0x00, 0x00, } func (m *ABCIResponses) Marshal() (dAtA []byte, err error) { @@ -693,19 +683,19 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AppHash) i = encodeVarintTypes(dAtA, i, uint64(len(m.AppHash))) i-- - dAtA[i] = 0x72 + dAtA[i] = 0x6a } if len(m.LastResultsHash) > 0 { i -= len(m.LastResultsHash) copy(dAtA[i:], m.LastResultsHash) i = encodeVarintTypes(dAtA, i, uint64(len(m.LastResultsHash))) i-- - dAtA[i] = 0x6a + dAtA[i] = 0x62 } if m.LastHeightConsensusParamsChanged != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.LastHeightConsensusParamsChanged)) i-- - dAtA[i] = 0x60 + dAtA[i] = 0x58 } { size, err := m.ConsensusParams.MarshalToSizedBuffer(dAtA[:i]) @@ -716,11 +706,11 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x5a + dAtA[i] = 0x52 if m.LastHeightValidatorsChanged != 0 { i = encodeVarintTypes(dAtA, i, uint64(m.LastHeightValidatorsChanged)) i-- - dAtA[i] = 0x50 + dAtA[i] = 0x48 } if m.LastValidators != nil { { @@ -732,7 +722,7 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x42 } if m.Validators != nil { { @@ -744,7 +734,7 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a } if m.NextValidators != nil { { @@ -756,7 +746,7 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x32 } n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) if err10 != nil { @@ -765,19 +755,7 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= n10 i = encodeVarintTypes(dAtA, i, uint64(n10)) i-- - dAtA[i] = 0x32 - if m.LastPartSetHeader != nil { - { - size, err := m.LastPartSetHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } + dAtA[i] = 0x2a { size, err := m.LastBlockID.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -909,10 +887,6 @@ func (m *State) Size() (n int) { } l = m.LastBlockID.Size() n += 1 + l + sovTypes(uint64(l)) - if m.LastPartSetHeader != nil { - l = m.LastPartSetHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - } l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime) n += 1 + l + sovTypes(uint64(l)) if m.NextValidators != nil { @@ -1580,42 +1554,6 @@ func (m *State) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastPartSetHeader", 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.LastPartSetHeader == nil { - m.LastPartSetHeader = &types1.PartSetHeader{} - } - if err := m.LastPartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastBlockTime", wireType) } @@ -1648,7 +1586,7 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NextValidators", wireType) } @@ -1684,7 +1622,7 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Validators", wireType) } @@ -1720,7 +1658,7 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastValidators", wireType) } @@ -1756,7 +1694,7 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastHeightValidatorsChanged", wireType) } @@ -1775,7 +1713,7 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } - case 11: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusParams", wireType) } @@ -1808,7 +1746,7 @@ func (m *State) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 12: + case 11: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field LastHeightConsensusParamsChanged", wireType) } @@ -1827,7 +1765,7 @@ func (m *State) Unmarshal(dAtA []byte) error { break } } - case 13: + case 12: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LastResultsHash", wireType) } @@ -1861,7 +1799,7 @@ func (m *State) Unmarshal(dAtA []byte) error { m.LastResultsHash = []byte{} } iNdEx = postIndex - case 14: + case 13: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AppHash", wireType) } diff --git a/proto/tendermint/state/types.proto b/proto/tendermint/state/types.proto index b6854b5df7..aeae576004 100644 --- a/proto/tendermint/state/types.proto +++ b/proto/tendermint/state/types.proto @@ -48,8 +48,7 @@ message State { int64 last_block_height = 3; tendermint.types.BlockID last_block_id = 4 [(gogoproto.nullable) = false, (gogoproto.customname) = "LastBlockID"]; - tendermint.types.PartSetHeader last_part_set_header = 5; - google.protobuf.Timestamp last_block_time = 6 + google.protobuf.Timestamp last_block_time = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; // LastValidators is used to validate block.LastCommit. @@ -58,19 +57,19 @@ message State { // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1 // Extra +1 due to nextValSet delay. - tendermint.types.ValidatorSet next_validators = 7; - tendermint.types.ValidatorSet validators = 8; - tendermint.types.ValidatorSet last_validators = 9; - int64 last_height_validators_changed = 10; + tendermint.types.ValidatorSet next_validators = 6; + tendermint.types.ValidatorSet validators = 7; + tendermint.types.ValidatorSet last_validators = 8; + int64 last_height_validators_changed = 9; // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. - tendermint.types.ConsensusParams consensus_params = 11 [(gogoproto.nullable) = false]; - int64 last_height_consensus_params_changed = 12; + tendermint.types.ConsensusParams consensus_params = 10 [(gogoproto.nullable) = false]; + int64 last_height_consensus_params_changed = 11; // Merkle root of the results from executing prev block - bytes last_results_hash = 13; + bytes last_results_hash = 12; // the latest AppHash we've received from calling abci.Commit() - bytes app_hash = 14; + bytes app_hash = 13; } diff --git a/state/execution.go b/state/execution.go index 5a7cf0fd30..6098158483 100644 --- a/state/execution.go +++ b/state/execution.go @@ -452,6 +452,7 @@ func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, return nil } +// todo(evan): remove psh from args // updateState returns a new State updated according to the header and responses. func updateState( state State, @@ -507,7 +508,6 @@ func updateState( InitialHeight: state.InitialHeight, LastBlockHeight: header.Height, LastBlockID: blockID, - LastPartSetHeader: partSetHeader, LastBlockTime: header.Time, NextValidators: nValSet, Validators: state.NextValidators.Copy(), diff --git a/state/state.go b/state/state.go index d465b21967..f0d547c53b 100644 --- a/state/state.go +++ b/state/state.go @@ -54,10 +54,10 @@ type State struct { InitialHeight int64 // should be 1, not 0, when starting from height 1 // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) - LastBlockHeight int64 - LastBlockID types.BlockID - LastPartSetHeader types.PartSetHeader - LastBlockTime time.Time + LastBlockHeight int64 + LastBlockID types.BlockID + + LastBlockTime time.Time // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change, @@ -90,10 +90,9 @@ func (state State) Copy() State { ChainID: state.ChainID, InitialHeight: state.InitialHeight, - LastBlockHeight: state.LastBlockHeight, - LastBlockID: state.LastBlockID, - LastPartSetHeader: state.LastPartSetHeader, - LastBlockTime: state.LastBlockTime, + LastBlockHeight: state.LastBlockHeight, + LastBlockID: state.LastBlockID, + LastBlockTime: state.LastBlockTime, NextValidators: state.NextValidators.Copy(), Validators: state.Validators.Copy(), @@ -134,6 +133,7 @@ func (state State) IsEmpty() bool { return state.Validators == nil // XXX can't compare to Empty } +// todo(evan): remove the psh from the state proto // ToProto takes the local state type and returns the equivalent proto type func (state *State) ToProto() (*tmstate.State, error) { if state == nil { @@ -148,8 +148,6 @@ func (state *State) ToProto() (*tmstate.State, error) { sm.LastBlockHeight = state.LastBlockHeight sm.LastBlockID = state.LastBlockID.ToProto() - lpsh := state.LastPartSetHeader.ToProto() - sm.LastPartSetHeader = &lpsh sm.LastBlockTime = state.LastBlockTime vals, err := state.Validators.ToProto() if err != nil { @@ -198,12 +196,6 @@ func StateFromProto(pb *tmstate.State) (*State, error) { //nolint:golint } state.LastBlockID = *bi - lpsh, err := types.PartSetHeaderFromProto(pb.LastPartSetHeader) - if err != nil { - return nil, err - } - state.LastPartSetHeader = *lpsh - state.LastBlockHeight = pb.LastBlockHeight state.LastBlockTime = pb.LastBlockTime @@ -353,10 +345,9 @@ func MakeGenesisState(genDoc *types.GenesisDoc) (State, error) { ChainID: genDoc.ChainID, InitialHeight: genDoc.InitialHeight, - LastBlockHeight: 0, - LastBlockID: types.BlockID{}, - LastPartSetHeader: types.PartSetHeader{}, - LastBlockTime: genDoc.GenesisTime, + LastBlockHeight: 0, + LastBlockID: types.BlockID{}, + LastBlockTime: genDoc.GenesisTime, NextValidators: nextValidatorSet, Validators: validatorSet, diff --git a/state/validation.go b/state/validation.go index bb0fbdd2fd..bd0264957f 100644 --- a/state/validation.go +++ b/state/validation.go @@ -89,8 +89,9 @@ func validateBlock(state State, block *types.Block) error { } } else { // LastCommit.Signatures length is checked in VerifyCommit. + // todo(evan): remove psh from args if err := state.LastValidators.VerifyCommit( - state.ChainID, state.LastBlockID, state.LastPartSetHeader, block.Height-1, block.LastCommit); err != nil { + state.ChainID, state.LastBlockID, types.PartSetHeader{}, block.Height-1, block.LastCommit); err != nil { return err } } diff --git a/state/validation_test.go b/state/validation_test.go index 61bb56da33..5aa47fa507 100644 --- a/state/validation_test.go +++ b/state/validation_test.go @@ -142,7 +142,7 @@ func TestValidateBlockCommit(t *testing.T) { wrongHeightVote, err := types.MakeVote( height, state.LastBlockID, - state.LastPartSetHeader, + types.PartSetHeader{}, // todo(evan): replace state.Validators, privVals[proposerAddr.String()], chainID, @@ -154,7 +154,7 @@ func TestValidateBlockCommit(t *testing.T) { wrongHeightVote.Round, state.LastBlockID, []types.CommitSig{wrongHeightVote.CommitSig()}, - state.LastPartSetHeader, + types.PartSetHeader{}, // todo(evan): replace ) block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) diff --git a/statesync/stateprovider.go b/statesync/stateprovider.go index 7f82740737..75f37aa081 100644 --- a/statesync/stateprovider.go +++ b/statesync/stateprovider.go @@ -161,7 +161,6 @@ func (s *lightClientStateProvider) State(ctx context.Context, height uint64) (sm state.LastBlockHeight = lastLightBlock.Height state.LastBlockTime = lastLightBlock.Time state.LastBlockID = lastLightBlock.Commit.BlockID - state.LastPartSetHeader = lastLightBlock.Commit.PartSetHeader state.AppHash = curLightBlock.AppHash state.LastResultsHash = curLightBlock.LastResultsHash state.LastValidators = lastLightBlock.ValidatorSet diff --git a/types/validator_set.go b/types/validator_set.go index 17078568f8..f5ecd49288 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -659,6 +659,7 @@ func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error { // application that depends on the LastCommitInfo sent in BeginBlock, which // includes which validators signed. For instance, Gaia incentivizes proposers // with a bonus for including more than +2/3 of the signatures. +// todo(evan): remove the partsetheader from verify commit func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, partSetHeader PartSetHeader, height int64, commit *Commit) error { if commit == nil { @@ -678,10 +679,7 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, blockID, commit.BlockID) } - if !partSetHeader.Equals(commit.PartSetHeader) { - return fmt.Errorf("invalid commit -- wrong Part Set eader: want %v, got %v", - partSetHeader, commit.PartSetHeader) - } + // todo(evan): point out that the PSH is no longer verified talliedVotingPower := int64(0) votingPowerNeeded := vals.TotalVotingPower() * 2 / 3 @@ -740,10 +738,6 @@ func (vals *ValidatorSet) VerifyCommitLight(chainID string, blockID BlockID, return fmt.Errorf("invalid commit -- wrong block ID: want %v, got %v", blockID, commit.BlockID) } - if !partSetHeader.Equals(commit.PartSetHeader) { - return fmt.Errorf("invalid commit -- wrong PartSetHeader: want %v, got %v", - partSetHeader, commit.PartSetHeader) - } talliedVotingPower := int64(0) votingPowerNeeded := vals.TotalVotingPower() * 2 / 3 From 368aaf773ee190ac5b63fede3d9a4bdecd920f77 Mon Sep 17 00:00:00 2001 From: evan-forbes Date: Thu, 29 Jul 2021 12:24:38 +0200 Subject: [PATCH 2/5] remove the partsetheader from VoteSetMaj23 and VoteSetBits --- consensus/msgs.go | 48 ++--- consensus/msgs_test.go | 48 +++-- consensus/reactor.go | 81 ++++---- consensus/reactor_test.go | 47 ++--- consensus/types/height_vote_set.go | 3 +- proto/tendermint/consensus/types.pb.go | 251 +++++++------------------ proto/tendermint/consensus/types.proto | 4 +- types/vote_set.go | 5 +- types/vote_set_test.go | 6 +- 9 files changed, 162 insertions(+), 331 deletions(-) diff --git a/consensus/msgs.go b/consensus/msgs.go index 8dc64079da..98093be00f 100644 --- a/consensus/msgs.go +++ b/consensus/msgs.go @@ -109,30 +109,26 @@ func MsgToProto(msg Message) (*tmcons.Message, error) { } case *VoteSetMaj23Message: bi := msg.BlockID.ToProto() - psh := msg.PartSetHeader.ToProto() pb = tmcons.Message{ Sum: &tmcons.Message_VoteSetMaj23{ VoteSetMaj23: &tmcons.VoteSetMaj23{ - Height: msg.Height, - Round: msg.Round, - Type: msg.Type, - BlockID: bi, - PartSetHeader: &psh, + Height: msg.Height, + Round: msg.Round, + Type: msg.Type, + BlockID: bi, }, }, } case *VoteSetBitsMessage: bi := msg.BlockID.ToProto() - psh := msg.PartSetHeader.ToProto() bits := msg.Votes.ToProto() vsb := &tmcons.Message_VoteSetBits{ VoteSetBits: &tmcons.VoteSetBits{ - Height: msg.Height, - Round: msg.Round, - Type: msg.Type, - BlockID: bi, - PartSetHeader: &psh, + Height: msg.Height, + Round: msg.Round, + Type: msg.Type, + BlockID: bi, }, } @@ -242,26 +238,17 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { if err != nil { return nil, fmt.Errorf("voteSetMaj23 msg to proto error: %w", err) } - psh, err := types.PartSetHeaderFromProto(msg.VoteSetMaj23.PartSetHeader) - if err != nil { - return nil, fmt.Errorf("voteSetMaj23 msg to proto error: %w", err) - } pb = &VoteSetMaj23Message{ - Height: msg.VoteSetMaj23.Height, - Round: msg.VoteSetMaj23.Round, - Type: msg.VoteSetMaj23.Type, - BlockID: *bi, - PartSetHeader: *psh, + Height: msg.VoteSetMaj23.Height, + Round: msg.VoteSetMaj23.Round, + Type: msg.VoteSetMaj23.Type, + BlockID: *bi, } case *tmcons.Message_VoteSetBits: bi, err := types.BlockIDFromProto(&msg.VoteSetBits.BlockID) if err != nil { return nil, fmt.Errorf("block ID to proto error: %w", err) } - psh, err := types.PartSetHeaderFromProto(msg.VoteSetBits.PartSetHeader) - if err != nil { - return nil, fmt.Errorf("part set header to proto error: %w", err) - } bits := new(bits.BitArray) err = bits.FromProto(&msg.VoteSetBits.Votes) if err != nil { @@ -269,12 +256,11 @@ func MsgFromProto(msg *tmcons.Message) (Message, error) { } pb = &VoteSetBitsMessage{ - Height: msg.VoteSetBits.Height, - Round: msg.VoteSetBits.Round, - Type: msg.VoteSetBits.Type, - BlockID: *bi, - PartSetHeader: *psh, - Votes: bits, + Height: msg.VoteSetBits.Height, + Round: msg.VoteSetBits.Round, + Type: msg.VoteSetBits.Type, + BlockID: *bi, + Votes: bits, } default: return nil, fmt.Errorf("consensus: message not recognized: %T", msg) diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index 9e40f63973..8213afb778 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -162,38 +162,34 @@ func TestMsgToProto(t *testing.T) { }, }, false}, {"successful VoteSetMaj23", &VoteSetMaj23Message{ - Height: 1, - Round: 1, - Type: 1, - BlockID: bi, - PartSetHeader: psh, + Height: 1, + Round: 1, + Type: 1, + BlockID: bi, }, &tmcons.Message{ Sum: &tmcons.Message_VoteSetMaj23{ VoteSetMaj23: &tmcons.VoteSetMaj23{ - Height: 1, - Round: 1, - Type: 1, - BlockID: pbBi, - PartSetHeader: &pbPsh, + Height: 1, + Round: 1, + Type: 1, + BlockID: pbBi, }, }, }, false}, {"successful VoteSetBits", &VoteSetBitsMessage{ - Height: 1, - Round: 1, - Type: 1, - BlockID: bi, - PartSetHeader: psh, - Votes: bits, + Height: 1, + Round: 1, + Type: 1, + BlockID: bi, + Votes: bits, }, &tmcons.Message{ Sum: &tmcons.Message_VoteSetBits{ VoteSetBits: &tmcons.VoteSetBits{ - Height: 1, - Round: 1, - Type: 1, - BlockID: pbBi, - PartSetHeader: &pbPsh, - Votes: *pbBits, + Height: 1, + Round: 1, + Type: 1, + BlockID: pbBi, + Votes: *pbBits, }, }, }, false}, @@ -424,11 +420,11 @@ func TestConsMsgsVectors(t *testing.T) { Type: tmproto.PrevoteType, Index: math.MaxInt32}}}, "3a1808ffffffffffffffff7f10ffffffff07180120ffffffff07"}, {"VoteSetMaj23", &tmcons.Message{Sum: &tmcons.Message_VoteSetMaj23{ - VoteSetMaj23: &tmcons.VoteSetMaj23{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi, PartSetHeader: &pbPsh}}}, - "425008011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"}, + VoteSetMaj23: &tmcons.VoteSetMaj23{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi}}}, + "422a08011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d"}, {"VoteSetBits", &tmcons.Message{Sum: &tmcons.Message_VoteSetBits{ - VoteSetBits: &tmcons.VoteSetBits{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi, PartSetHeader: &pbPsh, Votes: *pbBits}}}, - "4a5708011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a24080112206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d32050801120100"}, + VoteSetBits: &tmcons.VoteSetBits{Height: 1, Round: 1, Type: tmproto.PrevoteType, BlockID: pbBi, Votes: *pbBits}}}, + "4a3108011001180122220a206164645f6d6f72655f6578636c616d6174696f6e5f6d61726b735f636f64652d2a050801120100"}, } for _, tc := range testCases { diff --git a/consensus/reactor.go b/consensus/reactor.go index 63cde5b622..a49544304f 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -275,7 +275,8 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { return } // Peer claims to have a maj23 for some BlockID at H,R,S, - err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.peer.ID(), msg.BlockID, msg.PartSetHeader) + // todo(evan): remove the psh placeholder + err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.peer.ID(), msg.BlockID) if err != nil { conR.Switch.StopPeerForError(src, err) return @@ -285,19 +286,18 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { var ourVotes *bits.BitArray switch msg.Type { case tmproto.PrevoteType: - ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID, msg.PartSetHeader) + ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID) case tmproto.PrecommitType: - ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID, msg.PartSetHeader) + ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID) default: panic("Bad VoteSetBitsMessage field Type. Forgot to add a check in ValidateBasic?") } src.TrySend(VoteSetBitsChannel, MustEncode(&VoteSetBitsMessage{ - Height: msg.Height, - Round: msg.Round, - Type: msg.Type, - BlockID: msg.BlockID, - PartSetHeader: msg.PartSetHeader, - Votes: ourVotes, + Height: msg.Height, + Round: msg.Round, + Type: msg.Type, + BlockID: msg.BlockID, + Votes: ourVotes, })) default: conR.Logger.Error(fmt.Sprintf("Unknown message type %v", reflect.TypeOf(msg))) @@ -360,9 +360,9 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { var ourVotes *bits.BitArray switch msg.Type { case tmproto.PrevoteType: - ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID, msg.PartSetHeader) + ourVotes = votes.Prevotes(msg.Round).BitArrayByBlockID(msg.BlockID) case tmproto.PrecommitType: - ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID, msg.PartSetHeader) + ourVotes = votes.Precommits(msg.Round).BitArrayByBlockID(msg.BlockID) default: panic("Bad VoteSetBitsMessage field Type. Forgot to add a check in ValidateBasic?") } @@ -779,13 +779,12 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() if rs.Height == prs.Height { - if maj23, maj23PSH, 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, - Type: tmproto.PrevoteType, - BlockID: maj23, - PartSetHeader: maj23PSH, + Height: prs.Height, + Round: prs.Round, + Type: tmproto.PrevoteType, + BlockID: maj23, })) time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration) } @@ -797,13 +796,12 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() if rs.Height == prs.Height { - if maj23, maj23PSH, 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, - Type: tmproto.PrecommitType, - BlockID: maj23, - PartSetHeader: maj23PSH, + Height: prs.Height, + Round: prs.Round, + Type: tmproto.PrecommitType, + BlockID: maj23, })) time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration) } @@ -815,13 +813,12 @@ OUTER_LOOP: rs := conR.conS.GetRoundState() prs := ps.GetRoundState() if rs.Height == prs.Height && prs.ProposalPOLRound >= 0 { - if maj23, maj23PSH, 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, - Type: tmproto.PrevoteType, - BlockID: maj23, - PartSetHeader: maj23PSH, + Height: prs.Height, + Round: prs.ProposalPOLRound, + Type: tmproto.PrevoteType, + BlockID: maj23, })) time.Sleep(conR.conS.config.PeerQueryMaj23SleepDuration) } @@ -1665,11 +1662,10 @@ func (m *HasVoteMessage) String() string { // VoteSetMaj23Message is sent to indicate that a given BlockID has seen +2/3 votes. type VoteSetMaj23Message struct { - Height int64 - Round int32 - Type tmproto.SignedMsgType - BlockID types.BlockID - PartSetHeader types.PartSetHeader + Height int64 + Round int32 + Type tmproto.SignedMsgType + BlockID types.BlockID } // ValidateBasic performs basic validation. @@ -1686,9 +1682,6 @@ func (m *VoteSetMaj23Message) ValidateBasic() error { if err := m.BlockID.ValidateBasic(); err != nil { return fmt.Errorf("wrong BlockID: %w", err) } - if err := m.PartSetHeader.ValidateBasic(); err != nil { - return fmt.Errorf("wrong PartSetHeader: %w", err) - } return nil } @@ -1701,12 +1694,11 @@ func (m *VoteSetMaj23Message) String() string { // VoteSetBitsMessage is sent to communicate the bit-array of votes seen for the BlockID. type VoteSetBitsMessage struct { - Height int64 - Round int32 - Type tmproto.SignedMsgType - BlockID types.BlockID - PartSetHeader types.PartSetHeader - Votes *bits.BitArray + Height int64 + Round int32 + Type tmproto.SignedMsgType + BlockID types.BlockID + Votes *bits.BitArray } // ValidateBasic performs basic validation. @@ -1720,9 +1712,6 @@ func (m *VoteSetBitsMessage) ValidateBasic() error { if err := m.BlockID.ValidateBasic(); err != nil { return fmt.Errorf("wrong BlockID: %v", err) } - if err := m.PartSetHeader.ValidateBasic(); err != nil { - return fmt.Errorf("wrong PartSetHeader: %w", err) - } // NOTE: Votes.Size() can be zero if the node does not have any if m.Votes.Size() > types.MaxVotesCount { return fmt.Errorf("votes bit array is too big: %d, max: %d", m.Votes.Size(), types.MaxVotesCount) diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index bc09911a82..c4871cd26f 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -926,13 +926,8 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) { ) validBlockID := types.BlockID{} - validPSH := types.PartSetHeader{} invalidBlockID := types.BlockID{ - Hash: bytes.HexBytes{}, - } - invalidPSH := types.PartSetHeader{ - Total: 1, - Hash: []byte{0}, + Hash: bytes.HexBytes("invalid"), } testCases := []struct { // nolint: maligned @@ -942,24 +937,22 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) { testName string messageType tmproto.SignedMsgType messageBlockID types.BlockID - messagePSH types.PartSetHeader }{ - {false, 0, 0, "Valid Message", validSignedMsgType, validBlockID, validPSH}, - {true, -1, 0, "Invalid Message", validSignedMsgType, validBlockID, validPSH}, - {true, 0, -1, "Invalid Message", validSignedMsgType, validBlockID, validPSH}, - {true, 0, 0, "Invalid Message", invalidSignedMsgType, validBlockID, validPSH}, - {true, 0, 0, "Invalid Message", validSignedMsgType, invalidBlockID, invalidPSH}, + {false, 0, 0, "Valid Message", validSignedMsgType, validBlockID}, + {true, -1, 0, "Invalid Message", validSignedMsgType, validBlockID}, + {true, 0, -1, "Invalid Message", validSignedMsgType, validBlockID}, + {true, 0, 0, "Invalid Message", invalidSignedMsgType, validBlockID}, + {true, 0, 0, "Invalid Message", validSignedMsgType, invalidBlockID}, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { message := VoteSetMaj23Message{ - Height: tc.messageHeight, - Round: tc.messageRound, - Type: tc.messageType, - BlockID: tc.messageBlockID, - PartSetHeader: tc.messagePSH, + Height: tc.messageHeight, + Round: tc.messageRound, + Type: tc.messageType, + BlockID: tc.messageBlockID, } assert.Equal(t, tc.expectErr, message.ValidateBasic() != nil, "Validate Basic had an unexpected result") @@ -975,15 +968,6 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) { {func(msg *VoteSetBitsMessage) {}, ""}, {func(msg *VoteSetBitsMessage) { msg.Height = -1 }, "negative Height"}, {func(msg *VoteSetBitsMessage) { msg.Type = 0x03 }, "invalid Type"}, - {func(msg *VoteSetBitsMessage) { - msg.BlockID = types.BlockID{ - Hash: bytes.HexBytes{}, - } - msg.PartSetHeader = types.PartSetHeader{ - Total: 1, - Hash: []byte{0}, - } - }, "wrong PartSetHeader: wrong Hash:"}, {func(msg *VoteSetBitsMessage) { msg.Votes = bits.NewBitArray(types.MaxVotesCount + 1) }, "votes bit array is too big: 10001, max: 10000"}, } @@ -992,12 +976,11 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) { tc := tc t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) { msg := &VoteSetBitsMessage{ - Height: 1, - Round: 0, - Type: 0x01, - Votes: bits.NewBitArray(1), - BlockID: types.BlockID{}, - PartSetHeader: types.PartSetHeader{}, + Height: 1, + Round: 0, + Type: 0x01, + Votes: bits.NewBitArray(1), + BlockID: types.BlockID{}, } tc.malleateFn(msg) diff --git a/consensus/types/height_vote_set.go b/consensus/types/height_vote_set.go index 322db1c147..fd4a82dc4c 100644 --- a/consensus/types/height_vote_set.go +++ b/consensus/types/height_vote_set.go @@ -187,7 +187,6 @@ func (hvs *HeightVoteSet) SetPeerMaj23( voteType tmproto.SignedMsgType, peerID p2p.ID, blockID types.BlockID, - partSetHeader types.PartSetHeader, ) error { hvs.mtx.Lock() defer hvs.mtx.Unlock() @@ -198,7 +197,7 @@ func (hvs *HeightVoteSet) SetPeerMaj23( if voteSet == nil { return nil // something we don't know about yet } - return voteSet.SetPeerMaj23(types.P2PID(peerID), blockID, partSetHeader) + return voteSet.SetPeerMaj23(types.P2PID(peerID), blockID) } //--------------------------------------------------------- diff --git a/proto/tendermint/consensus/types.pb.go b/proto/tendermint/consensus/types.pb.go index 5f387e4b34..43ff41a7fe 100644 --- a/proto/tendermint/consensus/types.pb.go +++ b/proto/tendermint/consensus/types.pb.go @@ -465,11 +465,10 @@ func (m *HasVote) GetIndex() int32 { // VoteSetMaj23 is sent to indicate that a given BlockID has seen +2/3 votes. type VoteSetMaj23 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"` - Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` - BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` - PartSetHeader *types.PartSetHeader `protobuf:"bytes,5,opt,name=part_set_header,json=partSetHeader,proto3" json:"part_set_header,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"` + Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` + BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` } func (m *VoteSetMaj23) Reset() { *m = VoteSetMaj23{} } @@ -533,21 +532,13 @@ func (m *VoteSetMaj23) GetBlockID() types.BlockID { return types.BlockID{} } -func (m *VoteSetMaj23) GetPartSetHeader() *types.PartSetHeader { - if m != nil { - return m.PartSetHeader - } - return nil -} - // VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. type VoteSetBits 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"` - Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` - BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` - PartSetHeader *types.PartSetHeader `protobuf:"bytes,5,opt,name=part_set_header,json=partSetHeader,proto3" json:"part_set_header,omitempty"` - Votes bits.BitArray `protobuf:"bytes,6,opt,name=votes,proto3" json:"votes"` + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Round int32 `protobuf:"varint,2,opt,name=round,proto3" json:"round,omitempty"` + Type types.SignedMsgType `protobuf:"varint,3,opt,name=type,proto3,enum=tendermint.types.SignedMsgType" json:"type,omitempty"` + BlockID types.BlockID `protobuf:"bytes,4,opt,name=block_id,json=blockId,proto3" json:"block_id"` + Votes bits.BitArray `protobuf:"bytes,5,opt,name=votes,proto3" json:"votes"` } func (m *VoteSetBits) Reset() { *m = VoteSetBits{} } @@ -611,13 +602,6 @@ func (m *VoteSetBits) GetBlockID() types.BlockID { return types.BlockID{} } -func (m *VoteSetBits) GetPartSetHeader() *types.PartSetHeader { - if m != nil { - return m.PartSetHeader - } - return nil -} - func (m *VoteSetBits) GetVotes() bits.BitArray { if m != nil { return m.Votes @@ -817,62 +801,61 @@ func init() { func init() { proto.RegisterFile("tendermint/consensus/types.proto", fileDescriptor_81a22d2efc008981) } var fileDescriptor_81a22d2efc008981 = []byte{ - // 877 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0xb7, 0x93, 0xdd, 0xec, 0xe6, 0x6d, 0x36, 0x81, 0x51, 0x5a, 0x99, 0x00, 0x9b, 0x60, 0x2e, - 0x11, 0x02, 0x2f, 0xda, 0x1c, 0x90, 0x2a, 0x24, 0x8a, 0xf9, 0x53, 0xb7, 0x6a, 0xda, 0xd5, 0x6c, - 0x55, 0xa1, 0x5e, 0x2c, 0xef, 0x7a, 0xe4, 0x1d, 0x6a, 0x7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xce, 0xe6, 0x75, 0x24, 0x1a, 0x37, 0x52, 0x92, 0x78, 0x5a, 0x6f, 0xfd, 0x36, 0xac, - 0xf3, 0x93, 0xcc, 0x7f, 0xf2, 0xec, 0x62, 0x60, 0x3f, 0xbf, 0x18, 0xd8, 0x7f, 0x5e, 0x0c, 0xec, - 0x5f, 0x2e, 0x07, 0xd6, 0xf3, 0xcb, 0x81, 0xf5, 0xc7, 0xe5, 0xc0, 0x7a, 0x72, 0x3b, 0xa1, 0x62, - 0x7e, 0x32, 0xf5, 0x66, 0x2c, 0x1b, 0xa6, 0xd1, 0x8f, 0xe7, 0x29, 0x89, 0x13, 0x52, 0x1a, 0xcb, - 0x4f, 0x66, 0xac, 0x24, 0xc3, 0xea, 0x67, 0xa8, 0xe9, 0x77, 0x6a, 0xba, 0xa1, 0x6c, 0x47, 0xff, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x23, 0xdb, 0x51, 0xd3, 0x6d, 0x09, 0x00, 0x00, + // 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,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0xb1, 0x3b, 0xa1, 0x59, 0x2f, 0x8d, 0x7e, 0x58, 0xa4, 0x38, 0x4e, 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, } func (m *NewRoundStep) Marshal() (dAtA []byte, err error) { @@ -1205,18 +1188,6 @@ func (m *VoteSetMaj23) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.PartSetHeader != nil { - { - size, err := m.PartSetHeader.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]) if err != nil { @@ -1274,19 +1245,7 @@ func (m *VoteSetBits) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 - if m.PartSetHeader != nil { - { - size, err := m.PartSetHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } + dAtA[i] = 0x2a { size, err := m.BlockID.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -1691,10 +1650,6 @@ func (m *VoteSetMaj23) Size() (n int) { } l = m.BlockID.Size() n += 1 + l + sovTypes(uint64(l)) - if m.PartSetHeader != nil { - l = m.PartSetHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - } return n } @@ -1715,10 +1670,6 @@ func (m *VoteSetBits) Size() (n int) { } l = m.BlockID.Size() n += 1 + l + sovTypes(uint64(l)) - if m.PartSetHeader != nil { - l = m.PartSetHeader.Size() - n += 1 + l + sovTypes(uint64(l)) - } l = m.Votes.Size() n += 1 + l + sovTypes(uint64(l)) return n @@ -2829,42 +2780,6 @@ func (m *VoteSetMaj23) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartSetHeader", 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.PartSetHeader == nil { - m.PartSetHeader = &types.PartSetHeader{} - } - if err := m.PartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTypes(dAtA[iNdEx:]) @@ -3006,42 +2921,6 @@ func (m *VoteSetBits) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PartSetHeader", 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.PartSetHeader == nil { - m.PartSetHeader = &types.PartSetHeader{} - } - if err := m.PartSetHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Votes", wireType) } diff --git a/proto/tendermint/consensus/types.proto b/proto/tendermint/consensus/types.proto index 432bd200e1..36bf40b27a 100644 --- a/proto/tendermint/consensus/types.proto +++ b/proto/tendermint/consensus/types.proto @@ -66,7 +66,6 @@ message VoteSetMaj23 { int32 round = 2; tendermint.types.SignedMsgType type = 3; tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - tendermint.types.PartSetHeader part_set_header = 5; } // VoteSetBits is sent to communicate the bit-array of votes seen for the BlockID. @@ -75,8 +74,7 @@ message VoteSetBits { int32 round = 2; tendermint.types.SignedMsgType type = 3; tendermint.types.BlockID block_id = 4 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; - tendermint.types.PartSetHeader part_set_header = 5; - tendermint.libs.bits.BitArray votes = 6 [(gogoproto.nullable) = false]; + tendermint.libs.bits.BitArray votes = 5 [(gogoproto.nullable) = false]; } message Message { diff --git a/types/vote_set.go b/types/vote_set.go index 0c4257c18a..143832b19c 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -309,7 +309,7 @@ func (voteSet *VoteSet) addVerifiedVote( // this can cause memory issues. // TODO: implement ability to remove peers too // NOTE: VoteSet must not be nil -func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID, partSetHeader PartSetHeader) error { +func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error { if voteSet == nil { panic("SetPeerMaj23() on nil VoteSet") } @@ -354,7 +354,7 @@ func (voteSet *VoteSet) BitArray() *bits.BitArray { return voteSet.votesBitArray.Copy() } -func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID, partSetHeader PartSetHeader) *bits.BitArray { +func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *bits.BitArray { if voteSet == nil { return nil } @@ -430,6 +430,7 @@ 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. +// todo(evan): don't return the psh func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, partSetHeader PartSetHeader, ok bool) { if voteSet == nil { return BlockID{}, PartSetHeader{}, false diff --git a/types/vote_set_test.go b/types/vote_set_test.go index f6a0a1a2dd..793b3364cc 100644 --- a/types/vote_set_test.go +++ b/types/vote_set_test.go @@ -287,7 +287,7 @@ func TestVoteSet_Conflicts(t *testing.T) { } // start tracking blockHash1 - err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash1}, PartSetHeader{}) + err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash1}) require.NoError(t, err) // val0 votes again for blockHash1. @@ -299,7 +299,7 @@ func TestVoteSet_Conflicts(t *testing.T) { } // attempt tracking blockHash2, should fail because already set for peerA. - err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash2}, PartSetHeader{}) + err = voteSet.SetPeerMaj23("peerA", BlockID{blockHash2}) require.Error(t, err) // val0 votes again for blockHash1. @@ -351,7 +351,7 @@ func TestVoteSet_Conflicts(t *testing.T) { } // now attempt tracking blockHash1 - err = voteSet.SetPeerMaj23("peerB", BlockID{blockHash1}, PartSetHeader{}) + err = voteSet.SetPeerMaj23("peerB", BlockID{blockHash1}) require.NoError(t, err) // val2 votes for blockHash1. From ec3d00ef0b195e98458c325ace6186bc159157f2 Mon Sep 17 00:00:00 2001 From: evan-forbes Date: Thu, 29 Jul 2021 15:47:38 +0200 Subject: [PATCH 3/5] clean up todos --- consensus/reactor.go | 1 - state/execution.go | 4 +--- state/export_test.go | 2 +- state/state.go | 1 - state/validation.go | 3 +-- state/validation_test.go | 4 ++-- types/block_test.go | 2 +- types/validator_set.go | 6 +----- types/validator_set_test.go | 4 ++-- types/vote_set.go | 1 - 10 files changed, 9 insertions(+), 19 deletions(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index a49544304f..03a339137b 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -275,7 +275,6 @@ func (conR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { return } // Peer claims to have a maj23 for some BlockID at H,R,S, - // todo(evan): remove the psh placeholder err := votes.SetPeerMaj23(msg.Round, msg.Type, ps.peer.ID(), msg.BlockID) if err != nil { conR.Switch.StopPeerForError(src, err) diff --git a/state/execution.go b/state/execution.go index 6098158483..45033fff92 100644 --- a/state/execution.go +++ b/state/execution.go @@ -220,7 +220,7 @@ func (blockExec *BlockExecutor) ApplyBlock( } // Update the state with the block and responses. - state, err = updateState(state, blockID, partSetHeader, &block.Header, abciResponses, validatorUpdates) + state, err = updateState(state, blockID, &block.Header, abciResponses, validatorUpdates) if err != nil { return state, 0, fmt.Errorf("commit failed for application: %v", err) } @@ -452,12 +452,10 @@ func validateValidatorUpdates(abciUpdates []abci.ValidatorUpdate, return nil } -// todo(evan): remove psh from args // updateState returns a new State updated according to the header and responses. func updateState( state State, blockID types.BlockID, - partSetHeader types.PartSetHeader, header *types.Header, abciResponses *tmstate.ABCIResponses, validatorUpdates []*types.Validator, diff --git a/state/export_test.go b/state/export_test.go index e9f23e1a4e..15c901f778 100644 --- a/state/export_test.go +++ b/state/export_test.go @@ -31,7 +31,7 @@ func UpdateState( abciResponses *tmstate.ABCIResponses, validatorUpdates []*types.Validator, ) (State, error) { - return updateState(state, blockID, partSetHeader, header, abciResponses, validatorUpdates) + return updateState(state, blockID, header, abciResponses, validatorUpdates) } // ValidateValidatorUpdates is an alias for validateValidatorUpdates exported diff --git a/state/state.go b/state/state.go index f0d547c53b..c9e5867ffa 100644 --- a/state/state.go +++ b/state/state.go @@ -133,7 +133,6 @@ func (state State) IsEmpty() bool { return state.Validators == nil // XXX can't compare to Empty } -// todo(evan): remove the psh from the state proto // ToProto takes the local state type and returns the equivalent proto type func (state *State) ToProto() (*tmstate.State, error) { if state == nil { diff --git a/state/validation.go b/state/validation.go index bd0264957f..c116063f81 100644 --- a/state/validation.go +++ b/state/validation.go @@ -89,9 +89,8 @@ func validateBlock(state State, block *types.Block) error { } } else { // LastCommit.Signatures length is checked in VerifyCommit. - // todo(evan): remove psh from args if err := state.LastValidators.VerifyCommit( - state.ChainID, state.LastBlockID, types.PartSetHeader{}, block.Height-1, block.LastCommit); err != nil { + state.ChainID, state.LastBlockID, block.Height-1, block.LastCommit); err != nil { return err } } diff --git a/state/validation_test.go b/state/validation_test.go index 5aa47fa507..116486cad2 100644 --- a/state/validation_test.go +++ b/state/validation_test.go @@ -142,7 +142,7 @@ func TestValidateBlockCommit(t *testing.T) { wrongHeightVote, err := types.MakeVote( height, state.LastBlockID, - types.PartSetHeader{}, // todo(evan): replace + types.PartSetHeader{}, state.Validators, privVals[proposerAddr.String()], chainID, @@ -154,7 +154,7 @@ func TestValidateBlockCommit(t *testing.T) { wrongHeightVote.Round, state.LastBlockID, []types.CommitSig{wrongHeightVote.CommitSig()}, - types.PartSetHeader{}, // todo(evan): replace + types.PartSetHeader{}, ) block, _ := state.MakeBlock(height, makeTxs(height), nil, nil, types.Messages{}, wrongHeightCommit, proposerAddr) err = blockExec.ValidateBlock(state, block) diff --git a/types/block_test.go b/types/block_test.go index b20b63bb4b..3b397a893f 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -631,7 +631,7 @@ func TestCommitToVoteSetWithVotesForNilBlock(t *testing.T) { if tc.valid { commit := voteSet.MakeCommit() // panics without > 2/3 valid votes assert.NotNil(t, commit) - err := valSet.VerifyCommit(voteSet.ChainID(), blockID, psh, height-1, commit) + err := valSet.VerifyCommit(voteSet.ChainID(), blockID, height-1, commit) assert.Nil(t, err) } else { assert.Panics(t, func() { voteSet.MakeCommit() }) diff --git a/types/validator_set.go b/types/validator_set.go index f5ecd49288..13127f993a 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -659,9 +659,7 @@ func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error { // application that depends on the LastCommitInfo sent in BeginBlock, which // includes which validators signed. For instance, Gaia incentivizes proposers // with a bonus for including more than +2/3 of the signatures. -// todo(evan): remove the partsetheader from verify commit -func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, - partSetHeader PartSetHeader, height int64, commit *Commit) error { +func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error { if commit == nil { return errors.New("nil commit") } @@ -679,8 +677,6 @@ func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, blockID, commit.BlockID) } - // todo(evan): point out that the PSH is no longer verified - talliedVotingPower := int64(0) votingPowerNeeded := vals.TotalVotingPower() * 2 / 3 for idx, commitSig := range commit.Signatures { diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 8326532026..ab8e93e97c 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -724,7 +724,7 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.description, func(t *testing.T) { - err := vset.VerifyCommit(tc.chainID, tc.blockID, tc.partSetHeader, tc.height, tc.commit) + err := vset.VerifyCommit(tc.chainID, tc.blockID, tc.height, tc.commit) if tc.expErr { if assert.Error(t, err, "VerifyCommit") { assert.Contains(t, err.Error(), tc.description, "VerifyCommit") @@ -765,7 +765,7 @@ func TestValidatorSet_VerifyCommit_CheckAllSignatures(t *testing.T) { vote.Signature = v.Signature commit.Signatures[3] = vote.CommitSig() - err = valSet.VerifyCommit(chainID, blockID, psh, h, commit) + err = valSet.VerifyCommit(chainID, blockID, h, commit) if assert.Error(t, err) { assert.Contains(t, err.Error(), "wrong signature (#3)") } diff --git a/types/vote_set.go b/types/vote_set.go index 143832b19c..3dfe3831e6 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -430,7 +430,6 @@ 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. -// todo(evan): don't return the psh func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, partSetHeader PartSetHeader, ok bool) { if voteSet == nil { return BlockID{}, PartSetHeader{}, false From 7fa327aa6f73a63cfe3fcbf0227bbdc3814ad079 Mon Sep 17 00:00:00 2001 From: Evan Forbes <42654277+evan-forbes@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:48:19 -0500 Subject: [PATCH 4/5] get rid of not needed space Co-authored-by: John Adler --- state/state.go | 1 - 1 file changed, 1 deletion(-) diff --git a/state/state.go b/state/state.go index c9e5867ffa..f90f87a7fe 100644 --- a/state/state.go +++ b/state/state.go @@ -56,7 +56,6 @@ type State struct { // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockID types.BlockID - LastBlockTime time.Time // LastValidators is used to validate block.LastCommit. From bad91694cac6f66752461de571854b70eddbaac3 Mon Sep 17 00:00:00 2001 From: evan-forbes Date: Wed, 4 Aug 2021 11:18:52 +0200 Subject: [PATCH 5/5] run gofmt -s --- state/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/state.go b/state/state.go index f90f87a7fe..38b1324215 100644 --- a/state/state.go +++ b/state/state.go @@ -56,7 +56,7 @@ type State struct { // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockID types.BlockID - LastBlockTime time.Time + LastBlockTime time.Time // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change,