From d73c5cbdb16e35624885f73e7e5c4897094d73be Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 8 Aug 2018 16:03:58 +0400 Subject: [PATCH 1/7] reap max bytes from the mempool & check transaction size See ADR 020: Limiting txs size inside a block docs/architecture/adr-020-block-size.md Refs #2035 --- Gopkg.lock | 1 - abci/types/types.pb.go | 402 +++++++++++------------- abci/types/types.proto | 3 +- abci/types/types_test.go | 31 -- consensus/mempool_test.go | 2 +- consensus/reactor_test.go | 5 +- consensus/state.go | 22 +- docs/architecture/adr-020-block-size.md | 72 +++++ evidence/pool.go | 7 +- evidence/reactor_test.go | 4 +- evidence/store.go | 20 +- evidence/store_test.go | 8 +- mempool/mempool.go | 68 +++- mempool/mempool_test.go | 8 +- mempool/reactor_test.go | 2 +- node/node.go | 7 +- rpc/client/rpc_test.go | 2 +- rpc/core/mempool.go | 2 +- rpc/core/pipe.go | 5 +- state/execution.go | 8 +- state/services.go | 40 ++- state/state_test.go | 21 +- types/block.go | 11 + types/block_test.go | 46 ++- types/evidence.go | 5 + types/evidence_test.go | 33 +- types/params.go | 14 +- types/params_test.go | 56 ++-- types/protobuf.go | 11 +- types/protobuf_test.go | 4 +- types/tx.go | 5 + types/vote.go | 5 + types/vote_test.go | 22 +- 33 files changed, 548 insertions(+), 404 deletions(-) delete mode 100644 abci/types/types_test.go create mode 100644 docs/architecture/adr-020-block-size.md diff --git a/Gopkg.lock b/Gopkg.lock index 012bf2eda..aecf4de72 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -525,7 +525,6 @@ "github.com/gogo/protobuf/gogoproto", "github.com/gogo/protobuf/jsonpb", "github.com/gogo/protobuf/proto", - "github.com/gogo/protobuf/types", "github.com/golang/protobuf/proto", "github.com/golang/protobuf/ptypes/timestamp", "github.com/gorilla/websocket", diff --git a/abci/types/types.pb.go b/abci/types/types.pb.go index 79e160065..7873f0975 100644 --- a/abci/types/types.pb.go +++ b/abci/types/types.pb.go @@ -60,7 +60,7 @@ func (m *Request) Reset() { *m = Request{} } func (m *Request) String() string { return proto.CompactTextString(m) } func (*Request) ProtoMessage() {} func (*Request) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{0} + return fileDescriptor_types_c68d3007ea320b94, []int{0} } func (m *Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -482,7 +482,7 @@ func (m *RequestEcho) Reset() { *m = RequestEcho{} } func (m *RequestEcho) String() string { return proto.CompactTextString(m) } func (*RequestEcho) ProtoMessage() {} func (*RequestEcho) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{1} + return fileDescriptor_types_c68d3007ea320b94, []int{1} } func (m *RequestEcho) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -528,7 +528,7 @@ func (m *RequestFlush) Reset() { *m = RequestFlush{} } func (m *RequestFlush) String() string { return proto.CompactTextString(m) } func (*RequestFlush) ProtoMessage() {} func (*RequestFlush) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{2} + return fileDescriptor_types_c68d3007ea320b94, []int{2} } func (m *RequestFlush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -568,7 +568,7 @@ func (m *RequestInfo) Reset() { *m = RequestInfo{} } func (m *RequestInfo) String() string { return proto.CompactTextString(m) } func (*RequestInfo) ProtoMessage() {} func (*RequestInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{3} + return fileDescriptor_types_c68d3007ea320b94, []int{3} } func (m *RequestInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -617,7 +617,7 @@ func (m *RequestSetOption) Reset() { *m = RequestSetOption{} } func (m *RequestSetOption) String() string { return proto.CompactTextString(m) } func (*RequestSetOption) ProtoMessage() {} func (*RequestSetOption) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{4} + return fileDescriptor_types_c68d3007ea320b94, []int{4} } func (m *RequestSetOption) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -675,7 +675,7 @@ func (m *RequestInitChain) Reset() { *m = RequestInitChain{} } func (m *RequestInitChain) String() string { return proto.CompactTextString(m) } func (*RequestInitChain) ProtoMessage() {} func (*RequestInitChain) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{5} + return fileDescriptor_types_c68d3007ea320b94, []int{5} } func (m *RequestInitChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -753,7 +753,7 @@ func (m *RequestQuery) Reset() { *m = RequestQuery{} } func (m *RequestQuery) String() string { return proto.CompactTextString(m) } func (*RequestQuery) ProtoMessage() {} func (*RequestQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{6} + return fileDescriptor_types_c68d3007ea320b94, []int{6} } func (m *RequestQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -825,7 +825,7 @@ func (m *RequestBeginBlock) Reset() { *m = RequestBeginBlock{} } func (m *RequestBeginBlock) String() string { return proto.CompactTextString(m) } func (*RequestBeginBlock) ProtoMessage() {} func (*RequestBeginBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{7} + return fileDescriptor_types_c68d3007ea320b94, []int{7} } func (m *RequestBeginBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,7 +893,7 @@ func (m *RequestCheckTx) Reset() { *m = RequestCheckTx{} } func (m *RequestCheckTx) String() string { return proto.CompactTextString(m) } func (*RequestCheckTx) ProtoMessage() {} func (*RequestCheckTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{8} + return fileDescriptor_types_c68d3007ea320b94, []int{8} } func (m *RequestCheckTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -940,7 +940,7 @@ func (m *RequestDeliverTx) Reset() { *m = RequestDeliverTx{} } func (m *RequestDeliverTx) String() string { return proto.CompactTextString(m) } func (*RequestDeliverTx) ProtoMessage() {} func (*RequestDeliverTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{9} + return fileDescriptor_types_c68d3007ea320b94, []int{9} } func (m *RequestDeliverTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -987,7 +987,7 @@ func (m *RequestEndBlock) Reset() { *m = RequestEndBlock{} } func (m *RequestEndBlock) String() string { return proto.CompactTextString(m) } func (*RequestEndBlock) ProtoMessage() {} func (*RequestEndBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{10} + return fileDescriptor_types_c68d3007ea320b94, []int{10} } func (m *RequestEndBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1033,7 +1033,7 @@ func (m *RequestCommit) Reset() { *m = RequestCommit{} } func (m *RequestCommit) String() string { return proto.CompactTextString(m) } func (*RequestCommit) ProtoMessage() {} func (*RequestCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{11} + return fileDescriptor_types_c68d3007ea320b94, []int{11} } func (m *RequestCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1086,7 +1086,7 @@ func (m *Response) Reset() { *m = Response{} } func (m *Response) String() string { return proto.CompactTextString(m) } func (*Response) ProtoMessage() {} func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{12} + return fileDescriptor_types_c68d3007ea320b94, []int{12} } func (m *Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1539,7 +1539,7 @@ func (m *ResponseException) Reset() { *m = ResponseException{} } func (m *ResponseException) String() string { return proto.CompactTextString(m) } func (*ResponseException) ProtoMessage() {} func (*ResponseException) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{13} + return fileDescriptor_types_c68d3007ea320b94, []int{13} } func (m *ResponseException) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1586,7 +1586,7 @@ func (m *ResponseEcho) Reset() { *m = ResponseEcho{} } func (m *ResponseEcho) String() string { return proto.CompactTextString(m) } func (*ResponseEcho) ProtoMessage() {} func (*ResponseEcho) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{14} + return fileDescriptor_types_c68d3007ea320b94, []int{14} } func (m *ResponseEcho) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1632,7 +1632,7 @@ func (m *ResponseFlush) Reset() { *m = ResponseFlush{} } func (m *ResponseFlush) String() string { return proto.CompactTextString(m) } func (*ResponseFlush) ProtoMessage() {} func (*ResponseFlush) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{15} + return fileDescriptor_types_c68d3007ea320b94, []int{15} } func (m *ResponseFlush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1675,7 +1675,7 @@ func (m *ResponseInfo) Reset() { *m = ResponseInfo{} } func (m *ResponseInfo) String() string { return proto.CompactTextString(m) } func (*ResponseInfo) ProtoMessage() {} func (*ResponseInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{16} + return fileDescriptor_types_c68d3007ea320b94, []int{16} } func (m *ResponseInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1747,7 +1747,7 @@ func (m *ResponseSetOption) Reset() { *m = ResponseSetOption{} } func (m *ResponseSetOption) String() string { return proto.CompactTextString(m) } func (*ResponseSetOption) ProtoMessage() {} func (*ResponseSetOption) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{17} + return fileDescriptor_types_c68d3007ea320b94, []int{17} } func (m *ResponseSetOption) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1809,7 +1809,7 @@ func (m *ResponseInitChain) Reset() { *m = ResponseInitChain{} } func (m *ResponseInitChain) String() string { return proto.CompactTextString(m) } func (*ResponseInitChain) ProtoMessage() {} func (*ResponseInitChain) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{18} + return fileDescriptor_types_c68d3007ea320b94, []int{18} } func (m *ResponseInitChain) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1871,7 +1871,7 @@ func (m *ResponseQuery) Reset() { *m = ResponseQuery{} } func (m *ResponseQuery) String() string { return proto.CompactTextString(m) } func (*ResponseQuery) ProtoMessage() {} func (*ResponseQuery) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{19} + return fileDescriptor_types_c68d3007ea320b94, []int{19} } func (m *ResponseQuery) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1967,7 +1967,7 @@ func (m *ResponseBeginBlock) Reset() { *m = ResponseBeginBlock{} } func (m *ResponseBeginBlock) String() string { return proto.CompactTextString(m) } func (*ResponseBeginBlock) ProtoMessage() {} func (*ResponseBeginBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{20} + return fileDescriptor_types_c68d3007ea320b94, []int{20} } func (m *ResponseBeginBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2020,7 +2020,7 @@ func (m *ResponseCheckTx) Reset() { *m = ResponseCheckTx{} } func (m *ResponseCheckTx) String() string { return proto.CompactTextString(m) } func (*ResponseCheckTx) ProtoMessage() {} func (*ResponseCheckTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{21} + return fileDescriptor_types_c68d3007ea320b94, []int{21} } func (m *ResponseCheckTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2115,7 +2115,7 @@ func (m *ResponseDeliverTx) Reset() { *m = ResponseDeliverTx{} } func (m *ResponseDeliverTx) String() string { return proto.CompactTextString(m) } func (*ResponseDeliverTx) ProtoMessage() {} func (*ResponseDeliverTx) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{22} + return fileDescriptor_types_c68d3007ea320b94, []int{22} } func (m *ResponseDeliverTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2206,7 +2206,7 @@ func (m *ResponseEndBlock) Reset() { *m = ResponseEndBlock{} } func (m *ResponseEndBlock) String() string { return proto.CompactTextString(m) } func (*ResponseEndBlock) ProtoMessage() {} func (*ResponseEndBlock) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{23} + return fileDescriptor_types_c68d3007ea320b94, []int{23} } func (m *ResponseEndBlock) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2268,7 +2268,7 @@ func (m *ResponseCommit) Reset() { *m = ResponseCommit{} } func (m *ResponseCommit) String() string { return proto.CompactTextString(m) } func (*ResponseCommit) ProtoMessage() {} func (*ResponseCommit) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{24} + return fileDescriptor_types_c68d3007ea320b94, []int{24} } func (m *ResponseCommit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2319,7 +2319,7 @@ func (m *ConsensusParams) Reset() { *m = ConsensusParams{} } func (m *ConsensusParams) String() string { return proto.CompactTextString(m) } func (*ConsensusParams) ProtoMessage() {} func (*ConsensusParams) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{25} + return fileDescriptor_types_c68d3007ea320b94, []int{25} } func (m *ConsensusParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2372,8 +2372,7 @@ func (m *ConsensusParams) GetBlockGossip() *BlockGossip { // BlockSize contains limits on the block size. type BlockSize struct { MaxBytes int32 `protobuf:"varint,1,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"` - MaxTxs int32 `protobuf:"varint,2,opt,name=max_txs,json=maxTxs,proto3" json:"max_txs,omitempty"` - MaxGas int64 `protobuf:"varint,3,opt,name=max_gas,json=maxGas,proto3" json:"max_gas,omitempty"` + MaxGas int64 `protobuf:"varint,2,opt,name=max_gas,json=maxGas,proto3" json:"max_gas,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -2383,7 +2382,7 @@ func (m *BlockSize) Reset() { *m = BlockSize{} } func (m *BlockSize) String() string { return proto.CompactTextString(m) } func (*BlockSize) ProtoMessage() {} func (*BlockSize) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{26} + return fileDescriptor_types_c68d3007ea320b94, []int{26} } func (m *BlockSize) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2419,13 +2418,6 @@ func (m *BlockSize) GetMaxBytes() int32 { return 0 } -func (m *BlockSize) GetMaxTxs() int32 { - if m != nil { - return m.MaxTxs - } - return 0 -} - func (m *BlockSize) GetMaxGas() int64 { if m != nil { return m.MaxGas @@ -2446,7 +2438,7 @@ func (m *TxSize) Reset() { *m = TxSize{} } func (m *TxSize) String() string { return proto.CompactTextString(m) } func (*TxSize) ProtoMessage() {} func (*TxSize) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{27} + return fileDescriptor_types_c68d3007ea320b94, []int{27} } func (m *TxSize) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2503,7 +2495,7 @@ func (m *BlockGossip) Reset() { *m = BlockGossip{} } func (m *BlockGossip) String() string { return proto.CompactTextString(m) } func (*BlockGossip) ProtoMessage() {} func (*BlockGossip) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{28} + return fileDescriptor_types_c68d3007ea320b94, []int{28} } func (m *BlockGossip) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2551,7 +2543,7 @@ func (m *LastCommitInfo) Reset() { *m = LastCommitInfo{} } func (m *LastCommitInfo) String() string { return proto.CompactTextString(m) } func (*LastCommitInfo) ProtoMessage() {} func (*LastCommitInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{29} + return fileDescriptor_types_c68d3007ea320b94, []int{29} } func (m *LastCommitInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2624,7 +2616,7 @@ func (m *Header) Reset() { *m = Header{} } func (m *Header) String() string { return proto.CompactTextString(m) } func (*Header) ProtoMessage() {} func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{30} + return fileDescriptor_types_c68d3007ea320b94, []int{30} } func (m *Header) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2770,7 +2762,7 @@ func (m *BlockID) Reset() { *m = BlockID{} } func (m *BlockID) String() string { return proto.CompactTextString(m) } func (*BlockID) ProtoMessage() {} func (*BlockID) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{31} + return fileDescriptor_types_c68d3007ea320b94, []int{31} } func (m *BlockID) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2825,7 +2817,7 @@ func (m *PartSetHeader) Reset() { *m = PartSetHeader{} } func (m *PartSetHeader) String() string { return proto.CompactTextString(m) } func (*PartSetHeader) ProtoMessage() {} func (*PartSetHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{32} + return fileDescriptor_types_c68d3007ea320b94, []int{32} } func (m *PartSetHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2882,7 +2874,7 @@ func (m *Validator) Reset() { *m = Validator{} } func (m *Validator) String() string { return proto.CompactTextString(m) } func (*Validator) ProtoMessage() {} func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{33} + return fileDescriptor_types_c68d3007ea320b94, []int{33} } func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2938,7 +2930,7 @@ func (m *ValidatorUpdate) Reset() { *m = ValidatorUpdate{} } func (m *ValidatorUpdate) String() string { return proto.CompactTextString(m) } func (*ValidatorUpdate) ProtoMessage() {} func (*ValidatorUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{34} + return fileDescriptor_types_c68d3007ea320b94, []int{34} } func (m *ValidatorUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -2994,7 +2986,7 @@ func (m *VoteInfo) Reset() { *m = VoteInfo{} } func (m *VoteInfo) String() string { return proto.CompactTextString(m) } func (*VoteInfo) ProtoMessage() {} func (*VoteInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{35} + return fileDescriptor_types_c68d3007ea320b94, []int{35} } func (m *VoteInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3049,7 +3041,7 @@ func (m *PubKey) Reset() { *m = PubKey{} } func (m *PubKey) String() string { return proto.CompactTextString(m) } func (*PubKey) ProtoMessage() {} func (*PubKey) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{36} + return fileDescriptor_types_c68d3007ea320b94, []int{36} } func (m *PubKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -3107,7 +3099,7 @@ func (m *Evidence) Reset() { *m = Evidence{} } func (m *Evidence) String() string { return proto.CompactTextString(m) } func (*Evidence) ProtoMessage() {} func (*Evidence) Descriptor() ([]byte, []int) { - return fileDescriptor_types_bafb6deff4c77e13, []int{37} + return fileDescriptor_types_c68d3007ea320b94, []int{37} } func (m *Evidence) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -4688,9 +4680,6 @@ func (this *BlockSize) Equal(that interface{}) bool { if this.MaxBytes != that1.MaxBytes { return false } - if this.MaxTxs != that1.MaxTxs { - return false - } if this.MaxGas != that1.MaxGas { return false } @@ -5212,7 +5201,8 @@ func (c *aBCIApplicationClient) EndBlock(ctx context.Context, in *RequestEndBloc return out, nil } -// ABCIApplicationServer is the server API for ABCIApplication service. +// Server API for ABCIApplication service + type ABCIApplicationServer interface { Echo(context.Context, *RequestEcho) (*ResponseEcho, error) Flush(context.Context, *RequestFlush) (*ResponseFlush, error) @@ -6821,13 +6811,8 @@ func (m *BlockSize) MarshalTo(dAtA []byte) (int, error) { i++ i = encodeVarintTypes(dAtA, i, uint64(m.MaxBytes)) } - if m.MaxTxs != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintTypes(dAtA, i, uint64(m.MaxTxs)) - } if m.MaxGas != 0 { - dAtA[i] = 0x18 + dAtA[i] = 0x10 i++ i = encodeVarintTypes(dAtA, i, uint64(m.MaxGas)) } @@ -7899,16 +7884,12 @@ func NewPopulatedBlockSize(r randyTypes, easy bool) *BlockSize { if r.Intn(2) == 0 { this.MaxBytes *= -1 } - this.MaxTxs = int32(r.Int31()) - if r.Intn(2) == 0 { - this.MaxTxs *= -1 - } this.MaxGas = int64(r.Int63()) if r.Intn(2) == 0 { this.MaxGas *= -1 } if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedTypes(r, 4) + this.XXX_unrecognized = randUnrecognizedTypes(r, 3) } return this } @@ -8905,9 +8886,6 @@ func (m *BlockSize) Size() (n int) { if m.MaxBytes != 0 { n += 1 + sovTypes(uint64(m.MaxBytes)) } - if m.MaxTxs != 0 { - n += 1 + sovTypes(uint64(m.MaxTxs)) - } if m.MaxGas != 0 { n += 1 + sovTypes(uint64(m.MaxGas)) } @@ -12960,25 +12938,6 @@ func (m *BlockSize) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxTxs", wireType) - } - m.MaxTxs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxTxs |= (int32(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MaxGas", wireType) } @@ -14664,144 +14623,143 @@ var ( ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_bafb6deff4c77e13) } +func init() { proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_c68d3007ea320b94) } func init() { - golang_proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_bafb6deff4c77e13) -} - -var fileDescriptor_types_bafb6deff4c77e13 = []byte{ - // 2115 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcf, 0x6e, 0x1b, 0xc9, - 0xd1, 0xd7, 0x50, 0x14, 0xc9, 0x29, 0x4a, 0xa4, 0xdc, 0xb6, 0x25, 0x9a, 0xfb, 0x7d, 0x92, 0x31, - 0x49, 0xbc, 0x52, 0x56, 0x2b, 0x6d, 0xb4, 0x71, 0x20, 0xaf, 0x37, 0x8b, 0x88, 0xb6, 0xb3, 0x12, - 0x76, 0x93, 0x28, 0x63, 0x5b, 0x01, 0x82, 0x00, 0x83, 0x26, 0xa7, 0x45, 0x0e, 0x4c, 0xce, 0xcc, - 0x4e, 0x37, 0xb5, 0x94, 0x9f, 0x61, 0x0f, 0x7b, 0x08, 0x90, 0x73, 0x6e, 0x79, 0x81, 0x00, 0x39, - 0xe6, 0x14, 0xec, 0x31, 0x08, 0x12, 0xe4, 0xe6, 0x24, 0x0a, 0x72, 0x48, 0x9e, 0x20, 0xc7, 0xa0, - 0xab, 0x7b, 0xfe, 0x6a, 0x68, 0xd8, 0xce, 0x2d, 0x17, 0x72, 0xba, 0xab, 0xaa, 0xbb, 0xab, 0xba, - 0xaa, 0x7e, 0x55, 0x0d, 0x6b, 0xb4, 0x3f, 0xf0, 0xf6, 0xc4, 0x45, 0xc8, 0xb8, 0xfa, 0xdd, 0x0d, - 0xa3, 0x40, 0x04, 0x64, 0x09, 0x07, 0xdd, 0x77, 0x87, 0x9e, 0x18, 0x4d, 0xfb, 0xbb, 0x83, 0x60, - 0xb2, 0x37, 0x0c, 0x86, 0xc1, 0x1e, 0x52, 0xfb, 0xd3, 0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0b, 0x30, 0xb0, 0x9d, 0x83, 0x81, 0xe2, 0xc2, 0x39, 0x1c, 0xb8, 0x57, 0x82, 0x03, 0xc5, 0xe3, - 0xcf, 0x01, 0x82, 0x7b, 0x25, 0x40, 0xd0, 0xb9, 0xb2, 0x57, 0x29, 0x12, 0xec, 0xe4, 0x91, 0xa0, - 0xa8, 0x4e, 0x01, 0x0a, 0x3e, 0x2c, 0x83, 0x82, 0x5b, 0x05, 0x99, 0xb9, 0x58, 0xf0, 0xfe, 0x15, - 0x2c, 0x58, 0x2b, 0x88, 0x96, 0x80, 0xc1, 0xbd, 0x5c, 0x96, 0x86, 0x52, 0xdd, 0xca, 0xd3, 0x34, - 0xf9, 0xce, 0x55, 0x1c, 0x59, 0x2f, 0x5e, 0x6d, 0x19, 0x90, 0xec, 0x15, 0x80, 0xe4, 0x66, 0xf1, - 0x94, 0x05, 0x24, 0x49, 0xf1, 0x60, 0x5b, 0xc6, 0x7d, 0xc1, 0xd3, 0x64, 0x8e, 0x60, 0x51, 0x14, - 0x44, 0x3a, 0x61, 0xab, 0x81, 0xb5, 0x25, 0x33, 0x51, 0xea, 0x5f, 0x2f, 0xc1, 0x0e, 0x74, 0xfa, - 0x8c, 0x77, 0x59, 0xbf, 0x30, 0x52, 0x59, 0x8c, 0xe8, 0x6c, 0x16, 0x33, 0x75, 0x16, 0xcb, 0x40, - 0x4a, 0x25, 0x07, 0x29, 0xe4, 0x9b, 0x70, 0x0d, 0xd3, 0x08, 0xda, 0xc5, 0xc9, 0xa5, 0xb5, 0xb6, - 0x24, 0x28, 0x83, 0xa8, 0xfc, 0xf6, 0x2e, 0x5c, 0xcf, 0xf0, 0xca, 0x14, 0x8b, 0x29, 0xac, 0x8a, - 0xc1, 0xbb, 0x9a, 0x70, 0x1f, 0x86, 0xe1, 0x11, 0xe5, 0x23, 0xeb, 0x07, 0xa9, 0xfe, 0x29, 0x5c, - 0x11, 0xa8, 0x0e, 0x02, 0x57, 0xa9, 0xb5, 0x62, 0xe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, 0xbb, 0x84, 0x79, 0x4f, 0x9e, 0xdd, 0xb9, 0x3d, 0xb0, 0x94, 0x4f, - 0x8b, 0xb3, 0x79, 0x2f, 0x77, 0xdd, 0xb9, 0xcd, 0x22, 0x39, 0x80, 0x7a, 0x5c, 0xb4, 0x96, 0x3f, - 0x4a, 0x76, 0xe7, 0xf4, 0xa7, 0xd2, 0x3c, 0xaa, 0xf0, 0x2f, 0x7b, 0x39, 0xed, 0x96, 0x36, 0xd1, - 0xe4, 0x2e, 0xd4, 0x74, 0x15, 0x52, 0xfa, 0x30, 0xd9, 0x2d, 0xef, 0x32, 0xa5, 0x92, 0x69, 0xeb, - 0x33, 0xef, 0x75, 0xb7, 0x3b, 0xb7, 0xdb, 0x27, 0x87, 0x00, 0x99, 0x62, 0x7f, 0xee, 0xb3, 0x6d, - 0x77, 0x7e, 0x17, 0x4f, 0xee, 0x43, 0x23, 0x7d, 0x99, 0x29, 0x7f, 0x88, 0xed, 0xce, 0x6b, 0xac, - 0x7b, 0xff, 0xf7, 0xef, 0xbf, 0x6d, 0x18, 0xbf, 0xba, 0xdc, 0x30, 0x7e, 0x73, 0xb9, 0x61, 0x7c, - 0x75, 0xb9, 0x61, 0xfc, 0xfe, 0x72, 0xc3, 0xf8, 0xeb, 0xe5, 0x86, 0xf1, 0xdb, 0xbf, 0x6f, 0x18, - 0xfd, 0x1a, 0xba, 0xff, 0xfb, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x32, 0xa1, 0x6a, 0x3b, + golang_proto.RegisterFile("abci/types/types.proto", fileDescriptor_types_c68d3007ea320b94) +} + +var fileDescriptor_types_c68d3007ea320b94 = []byte{ + // 2099 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0x4f, 0x73, 0x1b, 0x49, + 0x15, 0xf7, 0x48, 0xb2, 0xfe, 0x3c, 0xd9, 0x92, 0xd3, 0x76,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, 0x43, 0x8e, 0x60, + 0x65, 0xe0, 0x7b, 0x9c, 0x79, 0x7c, 0xca, 0xed, 0x80, 0x86, 0x74, 0xc2, 0x75, 0x94, 0x44, 0x1f, + 0xee, 0x41, 0x44, 0x3e, 0x45, 0xaa, 0xd5, 0x1e, 0x64, 0x17, 0xc8, 0x07, 0x00, 0x17, 0x74, 0xec, + 0x3a, 0x54, 0xf8, 0x21, 0xef, 0x54, 0x6e, 0x97, 0x53, 0xc2, 0x67, 0x11, 0xe1, 0x69, 0xe0, 0x50, + 0xc1, 0x7a, 0x15, 0x79, 0x33, 0x2b, 0xc5, 0x4f, 0xee, 0x40, 0x9b, 0x06, 0x81, 0xcd, 0x05, 0x15, + 0xcc, 0xee, 0x5f, 0x0a, 0xc6, 0x31, 0x92, 0x96, 0xac, 0x65, 0x1a, 0x04, 0x8f, 0xe5, 0x6a, 0x4f, + 0x2e, 0x9a, 0x4e, 0xfc, 0x1d, 0xd0, 0xc9, 0x09, 0x81, 0x8a, 0x43, 0x05, 0x45, 0x6b, 0x2c, 0x59, + 0x38, 0x96, 0x6b, 0x01, 0x15, 0x23, 0xad, 0x23, 0x8e, 0xc9, 0x3a, 0x54, 0x47, 0xcc, 0x1d, 0x8e, + 0x04, 0xaa, 0x55, 0xb6, 0xf4, 0x4c, 0x1a, 0x3e, 0x08, 0xfd, 0x0b, 0x86, 0x71, 0x5e, 0xb7, 0xd4, + 0xc4, 0xfc, 0x97, 0x01, 0x37, 0xae, 0x05, 0x86, 0xdc, 0x77, 0x44, 0xf9, 0x28, 0x3a, 0x4b, 0x8e, + 0xc9, 0xdb, 0x72, 0x5f, 0xea, 0xb0, 0x50, 0xe7, 0x9f, 0x65, 0xad, 0xf1, 0x31, 0x2e, 0x6a, 0x45, + 0x35, 0x0b, 0x79, 0x04, 0x2b, 0x63, 0xca, 0x85, 0xad, 0xfc, 0xd7, 0xc6, 0xfc, 0x52, 0xce, 0xc4, + 0xd4, 0x27, 0x34, 0xf2, 0x73, 0xe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xef, 0x5f, 0xc7, + 0x91, 0x8d, 0xfc, 0xa7, 0x2d, 0x02, 0x92, 0xfd, 0x1c, 0x90, 0xdc, 0xcc, 0xdf, 0x32, 0x87, 0x24, + 0x09, 0x1e, 0xec, 0xc8, 0xb8, 0xcf, 0x79, 0x9a, 0xcc, 0x11, 0x2c, 0x0c, 0xfd, 0x50, 0x27, 0x6c, + 0x35, 0x31, 0xb7, 0x65, 0x26, 0x4a, 0xfc, 0xeb, 0x25, 0xd8, 0x81, 0x4e, 0x9f, 0xf2, 0x2e, 0xf3, + 0x57, 0x46, 0x22, 0x8b, 0x11, 0x9d, 0xce, 0x62, 0x0d, 0x9d, 0xc5, 0x52, 0x90, 0x52, 0xca, 0x40, + 0x0a, 0xf9, 0x0e, 0xdc, 0xc0, 0x34, 0x82, 0x76, 0xb1, 0x33, 0x69, 0xad, 0x2d, 0x09, 0xca, 0x20, + 0x2a, 0xbf, 0xbd, 0x03, 0xab, 0x29, 0x5e, 0x99, 0x62, 0x31, 0x85, 0x55, 0x30, 0x78, 0x57, 0x62, + 0xee, 0xa3, 0x20, 0x38, 0xa6, 0x7c, 0x64, 0xfe, 0x38, 0xd1, 0x3f, 0x81, 0x2b, 0x02, 0x95, 0x81, + 0xef, 0x28, 0xb5, 0x96, 0x2d, 0x1c, 0x4b, 0x08, 0x1b, 0xfb, 0x43, 0x3c, 0xb5, 0x61, 0xc9, 0xa1, + 0xe4, 0x8a, 0x23, 0xa5, 0xa1, 0x42, 0xc2, 0xfc, 0xa5, 0x91, 0xec, 0x97, 0x20, 0x58, 0x11, 0xd8, + 0x18, 0xff, 0x0f, 0xd8, 0x94, 0x5e, 0x0f, 0x6c, 0xcc, 0xdf, 0x1a, 0xc9, 0x17, 0x89, 0x61, 0xe4, + 0xcd, 0x54, 0x94, 0xce, 0xe1, 0x7a, 0x0e, 0x9b, 0x61, 0xc0, 0x97, 0x2d, 0x35, 0x89, 0x10, 0xbe, + 0x8a, 0x66, 0xce, 0x22, 0x7c, 0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xee, 0x43, 0x3d, 0x79, 0x80, 0x29, 0x7e, 0x6f, 0xed, 0xce, 0xeb, 0x9f, + 0x7b, 0x5f, 0xff, 0xef, 0x3f, 0x36, 0x8d, 0xdf, 0x5c, 0x6d, 0x1a, 0xbf, 0xbb, 0xda, 0x34, 0xbe, + 0xbc, 0xda, 0x34, 0xfe, 0x78, 0xb5, 0x69, 0xfc, 0xfd, 0x6a, 0xd3, 0xf8, 0xfd, 0x3f, 0x37, 0x8d, + 0x7e, 0x15, 0xdd, 0xff, 0xbd, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x48, 0x26, 0x13, 0xca, 0x22, 0x18, 0x00, 0x00, } diff --git a/abci/types/types.proto b/abci/types/types.proto index ae550c0a5..75a53ac46 100644 --- a/abci/types/types.proto +++ b/abci/types/types.proto @@ -207,8 +207,7 @@ message ConsensusParams { // BlockSize contains limits on the block size. message BlockSize { int32 max_bytes = 1; - int32 max_txs = 2; - int64 max_gas = 3; + int64 max_gas = 2; } // TxSize contains limits on the tx size. diff --git a/abci/types/types_test.go b/abci/types/types_test.go deleted file mode 100644 index baa8155cd..000000000 --- a/abci/types/types_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package types - -import ( - "testing" - - asrt "github.com/stretchr/testify/assert" -) - -func TestConsensusParams(t *testing.T) { - assert := asrt.New(t) - - params := &ConsensusParams{ - BlockSize: &BlockSize{MaxGas: 12345}, - BlockGossip: &BlockGossip{BlockPartSizeBytes: 54321}, - } - var noParams *ConsensusParams // nil - - // no error with nil fields - assert.Nil(noParams.GetBlockSize()) - assert.EqualValues(noParams.GetBlockSize().GetMaxGas(), 0) - - // get values with real fields - assert.NotNil(params.GetBlockSize()) - assert.EqualValues(params.GetBlockSize().GetMaxTxs(), 0) - assert.EqualValues(params.GetBlockSize().GetMaxGas(), 12345) - assert.NotNil(params.GetBlockGossip()) - assert.EqualValues(params.GetBlockGossip().GetBlockPartSizeBytes(), 54321) - assert.Nil(params.GetTxSize()) - assert.EqualValues(params.GetTxSize().GetMaxBytes(), 0) - -} diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index 81d7693f9..16a167fd6 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -148,7 +148,7 @@ func TestMempoolRmBadTx(t *testing.T) { // check for the tx for { - txs := cs.mempool.Reap(1) + txs := cs.mempool.ReapMaxBytes(len(txBytes)) if len(txs) == 0 { emptyMempoolCh <- struct{}{} return diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 4a6d4b9dc..364b6fb0a 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -194,7 +194,8 @@ func newMockEvidencePool(val []byte) *mockEvidencePool { } } -func (m *mockEvidencePool) PendingEvidence() []types.Evidence { +// NOTE: maxBytes is ignored +func (m *mockEvidencePool) PendingEvidence(maxBytes int) []types.Evidence { if m.height > 0 { return m.ev } @@ -207,7 +208,7 @@ func (m *mockEvidencePool) Update(block *types.Block, state sm.State) { panic("block has no evidence") } } - m.height += 1 + m.height++ } //------------------------------------ diff --git a/consensus/state.go b/consensus/state.go index debe94dad..65f5b6b36 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -153,6 +153,7 @@ func NewConsensusState( cs.setProposal = cs.defaultSetProposal cs.updateToState(state) + // Don't call scheduleRound0 yet. // We do that upon Start(). cs.reconstructLastCommit(state) @@ -946,14 +947,25 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts return } + maxBytes := cs.state.ConsensusParams.BlockSize.MaxBytes + // bound evidence to 1/10th of the block + evidence := cs.evpool.PendingEvidence(maxBytes / 10) // Mempool validated transactions - txs := cs.mempool.Reap(cs.state.ConsensusParams.BlockSize.MaxTxs) - evidence := cs.evpool.PendingEvidence() + txs := cs.mempool.ReapMaxBytes(maxDataBytes(maxBytes, cs.state.Validators.Size(), len(evidence))) proposerAddr := cs.privValidator.GetAddress() block, parts := cs.state.MakeBlock(cs.Height, txs, commit, evidence, proposerAddr) + return block, parts } +func maxDataBytes(maxBytes, valsCount, evidenceCount int) int { + return maxBytes - + types.MaxAminoOverheadForBlock - + types.MaxHeaderBytes - + (valsCount * types.MaxVoteBytes) - + (evidenceCount * types.MaxEvidenceBytes) +} + // Enter: `timeoutPropose` after entering Propose. // Enter: proposal block and POL is ready. // Enter: any +2/3 prevotes for future round. @@ -1438,7 +1450,11 @@ func (cs *ConsensusState) addProposalBlockPart(msg *BlockPartMessage, peerID p2p } if added && cs.ProposalBlockParts.IsComplete() { // Added and completed! - _, err = cdc.UnmarshalBinaryReader(cs.ProposalBlockParts.GetReader(), &cs.ProposalBlock, int64(cs.state.ConsensusParams.BlockSize.MaxBytes)) + _, err = cdc.UnmarshalBinaryReader( + cs.ProposalBlockParts.GetReader(), + &cs.ProposalBlock, + int64(cs.state.ConsensusParams.BlockSize.MaxBytes), + ) if err != nil { return true, err } diff --git a/docs/architecture/adr-020-block-size.md b/docs/architecture/adr-020-block-size.md new file mode 100644 index 000000000..d40766b52 --- /dev/null +++ b/docs/architecture/adr-020-block-size.md @@ -0,0 +1,72 @@ +# ADR 020: Limiting txs size inside a block + +## Changelog + +13-08-2018: Initial Draft +15-08-2018: Second version after Dev's comments +28-08-2018: Third version after Ethan's comments +30-08-2018: AminoOverheadForBlock => MaxAminoOverheadForBlock, added MaxAminoOverheadForTx + +## Context + +We currently use MaxTxs to reap txs from the mempool when proposing a block, +but enforce MaxBytes when unmarshalling a block, so we could easily propose a +block thats too large to be valid. + +We should just remove MaxTxs all together and stick with MaxBytes, and have a +`mempool.ReapMaxBytes`. + +But we can't just reap BlockSize.MaxBytes, since MaxBytes is for the entire block, +not for the txs inside the block. There's extra amino overhead + the actual +headers on top of the actual transactions + evidence + last commit. + +## Proposed solution + +Therefore, we should + +1) Get rid of MaxTxs. +2) Rename MaxTxsBytes to MaxBytes. + +When we need to ReapMaxBytes from the mempool, we calculate the upper bound as follows: + +``` +ExactLastCommitBytes = {number of validators currently enabled} * {MaxVoteBytes} +MaxEvidenceBytesPerBlock = MaxBytes / 10 +ExactEvidenceBytes = cs.evpool.PendingEvidence(MaxEvidenceBytesPerBlock) * MaxEvidenceBytes + +mempool.ReapMaxBytes(MaxBytes - MaxAminoOverheadForBlock - ExactLastCommitBytes - ExactEvidenceBytes - MaxHeaderBytes) +``` + +where MaxVoteBytes, MaxEvidenceBytes, MaxHeaderBytes and MaxAminoOverheadForBlock +are constants defined inside the `types` package: + +- MaxVoteBytes - 170 bytes +- MaxEvidenceBytes - 364 bytes +- MaxHeaderBytes - 476 bytes (~276 bytes hashes + 200 bytes - 50 UTF-8 encoded + symbols of chain ID 4 bytes each in the worst case + amino overhead) +- MaxAminoOverheadForBlock - 4 bytes (assuming MaxHeaderBytes includes amino + overhead for encoding header, MaxVoteBytes - for encoding vote, etc.) + +NOTE while reaping the `max int` bytes in mempool, we should account that every +transaction will take `len(tx)+aminoOverhead`, where aminoOverhead=1-4 bytes. +Therefore, MaxAminoOverheadForTx should be added. + +We should write a test that fails if the underlying structs got changed, but +MaxXXX stayed the same. + +## Status + +Proposed. + +## Consequences + +### Positive + +* one way to limit the size of a block +* less variables to configure + +### Negative + +* constants that need to be adjusted if the underlying structs got changed + +### Neutral diff --git a/evidence/pool.go b/evidence/pool.go index 247629b6b..21cab5e07 100644 --- a/evidence/pool.go +++ b/evidence/pool.go @@ -57,9 +57,10 @@ func (evpool *EvidencePool) PriorityEvidence() []types.Evidence { return evpool.evidenceStore.PriorityEvidence() } -// PendingEvidence returns all uncommitted evidence. -func (evpool *EvidencePool) PendingEvidence() []types.Evidence { - return evpool.evidenceStore.PendingEvidence() +// PendingEvidence returns uncommitted evidence up to maxBytes. +// If maxBytes is -1, all evidence is returned. +func (evpool *EvidencePool) PendingEvidence(maxBytes int) []types.Evidence { + return evpool.evidenceStore.PendingEvidence(maxBytes) } // State returns the current state of the evpool. diff --git a/evidence/reactor_test.go b/evidence/reactor_test.go index 1687f25a3..23fd008af 100644 --- a/evidence/reactor_test.go +++ b/evidence/reactor_test.go @@ -79,11 +79,11 @@ func waitForEvidence(t *testing.T, evs types.EvidenceList, reactors []*EvidenceR func _waitForEvidence(t *testing.T, wg *sync.WaitGroup, evs types.EvidenceList, reactorIdx int, reactors []*EvidenceReactor) { evpool := reactors[reactorIdx].evpool - for len(evpool.PendingEvidence()) != len(evs) { + for len(evpool.PendingEvidence(-1)) != len(evs) { time.Sleep(time.Millisecond * 100) } - reapedEv := evpool.PendingEvidence() + reapedEv := evpool.PendingEvidence(-1) // put the reaped evidence in a map so we can quickly check we got everything evMap := make(map[string]types.Evidence) for _, e := range reapedEv { diff --git a/evidence/store.go b/evidence/store.go index ba2e0afdd..60656f052 100644 --- a/evidence/store.go +++ b/evidence/store.go @@ -78,7 +78,7 @@ func NewEvidenceStore(db dbm.DB) *EvidenceStore { // PriorityEvidence returns the evidence from the outqueue, sorted by highest priority. func (store *EvidenceStore) PriorityEvidence() (evidence []types.Evidence) { // reverse the order so highest priority is first - l := store.ListEvidence(baseKeyOutqueue) + l := store.listEvidence(baseKeyOutqueue, -1) l2 := make([]types.Evidence, len(l)) for i := range l { l2[i] = l[len(l)-1-i] @@ -86,18 +86,26 @@ func (store *EvidenceStore) PriorityEvidence() (evidence []types.Evidence) { return l2 } -// PendingEvidence returns all known uncommitted evidence. -func (store *EvidenceStore) PendingEvidence() (evidence []types.Evidence) { - return store.ListEvidence(baseKeyPending) +// PendingEvidence returns known uncommitted evidence up to maxBytes. +// If maxBytes is -1, all evidence is returned. +func (store *EvidenceStore) PendingEvidence(maxBytes int) (evidence []types.Evidence) { + return store.listEvidence(baseKeyPending, maxBytes) } -// ListEvidence lists the evidence for the given prefix key. +// listEvidence lists the evidence for the given prefix key up to maxBytes. // It is wrapped by PriorityEvidence and PendingEvidence for convenience. -func (store *EvidenceStore) ListEvidence(prefixKey string) (evidence []types.Evidence) { +// If maxBytes is -1, there's no cap on the size of returned evidence. +func (store *EvidenceStore) listEvidence(prefixKey string, maxBytes int) (evidence []types.Evidence) { + var bytes int iter := dbm.IteratePrefix(store.db, []byte(prefixKey)) for ; iter.Valid(); iter.Next() { val := iter.Value() + if maxBytes > 0 && bytes+len(val) > maxBytes { + return evidence + } + bytes += len(val) + var ei EvidenceInfo err := cdc.UnmarshalBinaryBare(val, &ei) if err != nil { diff --git a/evidence/store_test.go b/evidence/store_test.go index 1eb5b7f6a..35eb28d01 100644 --- a/evidence/store_test.go +++ b/evidence/store_test.go @@ -35,7 +35,7 @@ func TestStoreMark(t *testing.T) { // before we do anything, priority/pending are empty priorityEv := store.PriorityEvidence() - pendingEv := store.PendingEvidence() + pendingEv := store.PendingEvidence(-1) assert.Equal(0, len(priorityEv)) assert.Equal(0, len(pendingEv)) @@ -53,21 +53,21 @@ func TestStoreMark(t *testing.T) { // new evidence should be returns in priority/pending priorityEv = store.PriorityEvidence() - pendingEv = store.PendingEvidence() + pendingEv = store.PendingEvidence(-1) assert.Equal(1, len(priorityEv)) assert.Equal(1, len(pendingEv)) // priority is now empty store.MarkEvidenceAsBroadcasted(ev) priorityEv = store.PriorityEvidence() - pendingEv = store.PendingEvidence() + pendingEv = store.PendingEvidence(-1) assert.Equal(0, len(priorityEv)) assert.Equal(1, len(pendingEv)) // priority and pending are now empty store.MarkEvidenceAsCommitted(ev) priorityEv = store.PriorityEvidence() - pendingEv = store.PendingEvidence() + pendingEv = store.PendingEvidence(-1) assert.Equal(0, len(priorityEv)) assert.Equal(0, len(pendingEv)) diff --git a/mempool/mempool.go b/mempool/mempool.go index b86dd81f3..ec93202e3 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -80,6 +80,8 @@ type Mempool struct { recheckEnd *clist.CElement // re-checking stops here notifiedTxsAvailable bool txsAvailable chan struct{} // fires once for each height, when the mempool is not empty + // Filter mempool to only accept txs for which filter(tx) returns true. + filter func(types.Tx) bool // Keep a cache of already-seen txs. // This reduces the pressure on the proxyApp. @@ -139,6 +141,14 @@ func (mem *Mempool) SetLogger(l log.Logger) { mem.logger = l } +// SetFilter sets a filter for mempool to only accept txs for which f(tx) +// returns true. +func (mem *Mempool) SetFilter(f func(types.Tx) bool) { + mem.proxyMtx.Lock() + mem.filter = f + mem.proxyMtx.Unlock() +} + // WithMetrics sets the metrics. func WithMetrics(metrics *Metrics) MempoolOption { return func(mem *Mempool) { mem.metrics = metrics } @@ -240,6 +250,10 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) { return ErrMempoolIsFull } + if mem.filter != nil && !mem.filter(tx) { + return + } + // CACHE if !mem.cache.Push(tx) { return ErrTxInCache @@ -367,9 +381,10 @@ func (mem *Mempool) notifyTxsAvailable() { } } -// Reap returns a list of transactions currently in the mempool. -// If maxTxs is -1, there is no cap on the number of returned transactions. -func (mem *Mempool) Reap(maxTxs int) types.Txs { +// ReapMaxBytes reaps transactions from the mempool up to n bytes total. +// If max is negative, there is no cap on the size of all returned +// transactions (~ all available transactions). +func (mem *Mempool) ReapMaxBytes(max int) types.Txs { mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() @@ -378,19 +393,39 @@ func (mem *Mempool) Reap(maxTxs int) types.Txs { time.Sleep(time.Millisecond * 10) } - txs := mem.collectTxs(maxTxs) + var cur int + // TODO: we will get a performance boost if we have a good estimate of avg + // size per tx, and set the initial capacity based off of that. + // txs := make([]types.Tx, 0, cmn.MinInt(mem.txs.Len(), max/mem.avgTxSize)) + txs := make([]types.Tx, 0, mem.txs.Len()) + for e := mem.txs.Front(); e != nil; e = e.Next() { + memTx := e.Value.(*mempoolTx) + if max > 0 && cur+len(memTx.tx)+types.MaxAminoOverheadForTx > max { + return txs + } + cur += len(memTx.tx) + types.MaxAminoOverheadForTx + txs = append(txs, memTx.tx) + } return txs } -// maxTxs: -1 means uncapped, 0 means none -func (mem *Mempool) collectTxs(maxTxs int) types.Txs { - if maxTxs == 0 { - return []types.Tx{} - } else if maxTxs < 0 { - maxTxs = mem.txs.Len() +// ReapMaxTxs reaps up to max transactions from the mempool. +// If max is negative, function panics. +func (mem *Mempool) ReapMaxTxs(max int) types.Txs { + mem.proxyMtx.Lock() + defer mem.proxyMtx.Unlock() + + if max < 0 { + panic("Called ReapMaxTxs with negative max") + } + + for atomic.LoadInt32(&mem.rechecking) > 0 { + // TODO: Something better? + time.Sleep(time.Millisecond * 10) } - txs := make([]types.Tx, 0, cmn.MinInt(mem.txs.Len(), maxTxs)) - for e := mem.txs.Front(); e != nil && len(txs) < maxTxs; e = e.Next() { + + txs := make([]types.Tx, 0, cmn.MinInt(mem.txs.Len(), max)) + for e := mem.txs.Front(); e != nil && len(txs) <= max; e = e.Next() { memTx := e.Value.(*mempoolTx) txs = append(txs, memTx.tx) } @@ -400,7 +435,7 @@ func (mem *Mempool) collectTxs(maxTxs int) types.Txs { // Update informs the mempool that the given txs were committed and can be discarded. // NOTE: this should be called *after* block is committed by consensus. // NOTE: unsafe; Lock/Unlock must be managed by caller -func (mem *Mempool) Update(height int64, txs types.Txs) error { +func (mem *Mempool) Update(height int64, txs types.Txs, filter func(types.Tx) bool) error { // First, create a lookup map of txns in new txs. txsMap := make(map[string]struct{}, len(txs)) for _, tx := range txs { @@ -411,6 +446,10 @@ func (mem *Mempool) Update(height int64, txs types.Txs) error { mem.height = height mem.notifiedTxsAvailable = false + if filter != nil { + mem.filter = filter + } + // Remove transactions that are already in txs. goodTxs := mem.filterTxs(txsMap) // Recheck mempool txs if any txs were committed in the block @@ -423,7 +462,10 @@ func (mem *Mempool) Update(height int64, txs types.Txs) error { // mem.recheckCursor re-scans mem.txs and possibly removes some txs. // Before mem.Reap(), we should wait for mem.recheckCursor to be nil. } + + // Update metrics mem.metrics.Size.Set(float64(mem.Size())) + return nil } diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index c29578efd..0dbe2bb6f 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -91,7 +91,7 @@ func TestTxsAvailable(t *testing.T) { // it should fire once now for the new height // since there are still txs left committedTxs, txs := txs[:50], txs[50:] - if err := mempool.Update(1, committedTxs); err != nil { + if err := mempool.Update(1, committedTxs, nil); err != nil { t.Error(err) } ensureFire(t, mempool.TxsAvailable(), timeoutMS) @@ -103,7 +103,7 @@ func TestTxsAvailable(t *testing.T) { // now call update with all the txs. it should not fire as there are no txs left committedTxs = append(txs, moreTxs...) - if err := mempool.Update(2, committedTxs); err != nil { + if err := mempool.Update(2, committedTxs, nil); err != nil { t.Error(err) } ensureNoFire(t, mempool.TxsAvailable(), timeoutMS) @@ -149,7 +149,7 @@ func TestSerialReap(t *testing.T) { } reapCheck := func(exp int) { - txs := mempool.Reap(-1) + txs := mempool.ReapMaxBytes(-1) require.Equal(t, len(txs), exp, fmt.Sprintf("Expected to reap %v txs but got %v", exp, len(txs))) } @@ -160,7 +160,7 @@ func TestSerialReap(t *testing.T) { binary.BigEndian.PutUint64(txBytes, uint64(i)) txs = append(txs, txBytes) } - if err := mempool.Update(0, txs); err != nil { + if err := mempool.Update(0, txs, nil); err != nil { t.Error(err) } } diff --git a/mempool/reactor_test.go b/mempool/reactor_test.go index b4362032a..8ac400b0a 100644 --- a/mempool/reactor_test.go +++ b/mempool/reactor_test.go @@ -86,7 +86,7 @@ func _waitForTxs(t *testing.T, wg *sync.WaitGroup, txs types.Txs, reactorIdx int time.Sleep(time.Millisecond * 100) } - reapedTxs := mempool.Reap(len(txs)) + reapedTxs := mempool.ReapMaxTxs(len(txs)) for i, tx := range txs { assert.Equal(t, tx, reapedTxs[i], fmt.Sprintf("txs at index %d on reactor %d don't match: %v vs %v", i, reactorIdx, tx, reapedTxs[i])) } diff --git a/node/node.go b/node/node.go index 7f96e0e0a..7e6603d9d 100644 --- a/node/node.go +++ b/node/node.go @@ -83,7 +83,7 @@ func DefaultNewNode(config *cfg.Config, logger log.Logger) (*Node, error) { // Generate node PrivKey nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { - return nil,err + return nil, err } return NewNode(config, privval.LoadOrGenFilePV(config.PrivValidatorFile()), @@ -248,6 +248,8 @@ func NewNode(config *cfg.Config, mempl.WithMetrics(memplMetrics), ) mempool.SetLogger(mempoolLogger) + maxBytes := state.ConsensusParams.TxSize.MaxBytes + mempool.SetFilter(func(tx types.Tx) bool { return len(tx) <= maxBytes }) mempool.InitWAL() // no need to have the mempool wal during tests mempoolReactor := mempl.NewMempoolReactor(config.Mempool, mempool) mempoolReactor.SetLogger(mempoolLogger) @@ -401,7 +403,7 @@ func NewNode(config *cfg.Config, sw: sw, addrBook: addrBook, - nodeKey: nodeKey, + nodeKey: nodeKey, stateDB: stateDB, blockStore: blockStore, @@ -434,7 +436,6 @@ func (n *Node) OnStart() error { n.Logger.With("module", "p2p")) n.sw.AddListener(l) - nodeInfo := n.makeNodeInfo(n.nodeKey.ID()) n.sw.SetNodeInfo(nodeInfo) n.sw.SetNodeKey(n.nodeKey) diff --git a/rpc/client/rpc_test.go b/rpc/client/rpc_test.go index e7e9042a7..3eabaa979 100644 --- a/rpc/client/rpc_test.go +++ b/rpc/client/rpc_test.go @@ -242,7 +242,7 @@ func TestBroadcastTxSync(t *testing.T) { require.Equal(initMempoolSize+1, mempool.Size()) - txs := mempool.Reap(1) + txs := mempool.ReapMaxTxs(len(tx)) require.EqualValues(tx, txs[0]) mempool.Flush() } diff --git a/rpc/core/mempool.go b/rpc/core/mempool.go index 47776d3e4..728d77f63 100644 --- a/rpc/core/mempool.go +++ b/rpc/core/mempool.go @@ -243,7 +243,7 @@ func UnconfirmedTxs(limit int) (*ctypes.ResultUnconfirmedTxs, error) { // reuse per_page validator limit = validatePerPage(limit) - txs := mempool.Reap(limit) + txs := mempool.ReapMaxTxs(limit) return &ctypes.ResultUnconfirmedTxs{len(txs), txs}, nil } diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index 9c162e9e4..1d1f61466 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -7,6 +7,7 @@ import ( crypto "github.com/tendermint/tendermint/crypto" dbm "github.com/tendermint/tendermint/libs/db" "github.com/tendermint/tendermint/libs/log" + mempl "github.com/tendermint/tendermint/mempool" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/proxy" sm "github.com/tendermint/tendermint/state" @@ -53,7 +54,6 @@ var ( // interfaces defined in types and above stateDB dbm.DB blockStore sm.BlockStore - mempool sm.Mempool evidencePool sm.EvidencePool consensusState Consensus p2pSwitch P2P @@ -65,6 +65,7 @@ var ( txIndexer txindex.TxIndexer consensusReactor *consensus.ConsensusReactor eventBus *types.EventBus // thread safe + mempool *mempl.Mempool logger log.Logger ) @@ -77,7 +78,7 @@ func SetBlockStore(bs sm.BlockStore) { blockStore = bs } -func SetMempool(mem sm.Mempool) { +func SetMempool(mem *mempl.Mempool) { mempool = mem } diff --git a/state/execution.go b/state/execution.go index ab689f5fb..b1859c220 100644 --- a/state/execution.go +++ b/state/execution.go @@ -92,7 +92,7 @@ func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, b } // Lock mempool, commit app state, update mempoool. - appHash, err := blockExec.Commit(block) + appHash, err := blockExec.Commit(state, block) if err != nil { return state, fmt.Errorf("Commit failed for application: %v", err) } @@ -119,7 +119,7 @@ func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, b // It returns the result of calling abci.Commit (the AppHash), and an error. // The Mempool must be locked during commit and update because state is typically reset on Commit and old txs must be replayed // against committed state before new txs are run in the mempool, lest they be invalid. -func (blockExec *BlockExecutor) Commit(block *types.Block) ([]byte, error) { +func (blockExec *BlockExecutor) Commit(state State, block *types.Block) ([]byte, error) { blockExec.mempool.Lock() defer blockExec.mempool.Unlock() @@ -145,7 +145,9 @@ func (blockExec *BlockExecutor) Commit(block *types.Block) ([]byte, error) { "appHash", fmt.Sprintf("%X", res.Data)) // Update mempool. - if err := blockExec.mempool.Update(block.Height, block.Txs); err != nil { + maxBytes := state.ConsensusParams.TxSize.MaxBytes + filter := func(tx types.Tx) bool { return len(tx) <= maxBytes } + if err := blockExec.mempool.Update(block.Height, block.Txs, filter); err != nil { return nil, err } diff --git a/state/services.go b/state/services.go index c51fa9752..13ab7383f 100644 --- a/state/services.go +++ b/state/services.go @@ -22,8 +22,8 @@ type Mempool interface { Size() int CheckTx(types.Tx, func(*abci.Response)) error - Reap(int) types.Txs - Update(height int64, txs types.Txs) error + ReapMaxBytes(max int) types.Txs + Update(height int64, txs types.Txs, filter func(types.Tx) bool) error Flush() FlushAppConn() error @@ -32,19 +32,18 @@ type Mempool interface { } // MockMempool is an empty implementation of a Mempool, useful for testing. -type MockMempool struct { -} - -func (m MockMempool) Lock() {} -func (m MockMempool) Unlock() {} -func (m MockMempool) Size() int { return 0 } -func (m MockMempool) CheckTx(tx types.Tx, cb func(*abci.Response)) error { return nil } -func (m MockMempool) Reap(n int) types.Txs { return types.Txs{} } -func (m MockMempool) Update(height int64, txs types.Txs) error { return nil } -func (m MockMempool) Flush() {} -func (m MockMempool) FlushAppConn() error { return nil } -func (m MockMempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) } -func (m MockMempool) EnableTxsAvailable() {} +type MockMempool struct{} + +func (MockMempool) Lock() {} +func (MockMempool) Unlock() {} +func (MockMempool) Size() int { return 0 } +func (MockMempool) CheckTx(tx types.Tx, cb func(*abci.Response)) error { return nil } +func (MockMempool) ReapMaxBytes(max int) types.Txs { return types.Txs{} } +func (MockMempool) Update(height int64, txs types.Txs, filter func(types.Tx) bool) error { return nil } +func (MockMempool) Flush() {} +func (MockMempool) FlushAppConn() error { return nil } +func (MockMempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) } +func (MockMempool) EnableTxsAvailable() {} //------------------------------------------------------ // blockstore @@ -72,15 +71,14 @@ type BlockStore interface { // EvidencePool defines the EvidencePool interface used by the ConsensusState. type EvidencePool interface { - PendingEvidence() []types.Evidence + PendingEvidence(int) []types.Evidence AddEvidence(types.Evidence) error Update(*types.Block, State) } // MockMempool is an empty implementation of a Mempool, useful for testing. -type MockEvidencePool struct { -} +type MockEvidencePool struct{} -func (m MockEvidencePool) PendingEvidence() []types.Evidence { return nil } -func (m MockEvidencePool) AddEvidence(types.Evidence) error { return nil } -func (m MockEvidencePool) Update(*types.Block, State) {} +func (m MockEvidencePool) PendingEvidence(int) []types.Evidence { return nil } +func (m MockEvidencePool) AddEvidence(types.Evidence) error { return nil } +func (m MockEvidencePool) Update(*types.Block, State) {} diff --git a/state/state_test.go b/state/state_test.go index d8a8c0b82..9a793c8e7 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -373,13 +373,10 @@ func TestConsensusParamsChangesSaveLoad(t *testing.T) { } } -func makeParams(blockBytes, blockTx, blockGas, txBytes, - txGas, partSize int) types.ConsensusParams { - +func makeParams(txsBytes, blockGas, txBytes, txGas, partSize int) types.ConsensusParams { return types.ConsensusParams{ BlockSize: types.BlockSize{ - MaxBytes: blockBytes, - MaxTxs: blockTx, + MaxBytes: txsBytes, MaxGas: int64(blockGas), }, TxSize: types.TxSize{ @@ -397,7 +394,7 @@ func pk() []byte { } func TestApplyUpdates(t *testing.T) { - initParams := makeParams(1, 2, 3, 4, 5, 6) + initParams := makeParams(1, 2, 3, 4, 5) cases := [...]struct { init types.ConsensusParams @@ -412,19 +409,19 @@ func TestApplyUpdates(t *testing.T) { MaxBytes: 123, }, }, - makeParams(1, 2, 3, 123, 5, 6)}, + makeParams(1, 2, 123, 4, 5)}, 3: {initParams, abci.ConsensusParams{ BlockSize: &abci.BlockSize{ - MaxTxs: 44, - MaxGas: 55, + MaxBytes: 1, + MaxGas: 55, }, }, - makeParams(1, 44, 55, 4, 5, 6)}, + makeParams(1, 55, 3, 4, 5)}, 4: {initParams, abci.ConsensusParams{ BlockSize: &abci.BlockSize{ - MaxTxs: 789, + MaxBytes: 1, }, TxSize: &abci.TxSize{ MaxGas: 888, @@ -433,7 +430,7 @@ func TestApplyUpdates(t *testing.T) { BlockPartSizeBytes: 2002, }, }, - makeParams(1, 789, 3, 4, 888, 2002)}, + makeParams(1, 2, 3, 888, 2002)}, } for i, tc := range cases { diff --git a/types/block.go b/types/block.go index 8588d5571..1037caccc 100644 --- a/types/block.go +++ b/types/block.go @@ -13,6 +13,17 @@ import ( cmn "github.com/tendermint/tendermint/libs/common" ) +const ( + // MaxHeaderBytes is a maximum header size (including amino overhead). + MaxHeaderBytes = 478 + + // MaxAminoOverheadForBlock - amino overhead to encode the block. + MaxAminoOverheadForBlock = 4 + + // MaxChainIDLen is a maximum length of the chain ID. + MaxChainIDLen = 50 +) + // Block defines the atomic unit of a Tendermint blockchain. // TODO: add Version byte type Block struct { diff --git a/types/block_test.go b/types/block_test.go index 8e5957761..3ca1da616 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -2,11 +2,13 @@ package types import ( "testing" + "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/tmhash" cmn "github.com/tendermint/tendermint/libs/common" ) @@ -118,7 +120,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) { partSet := MakeBlock(h, txs, commit, evList).MakePartSet(1024) assert.NotNil(t, partSet) - assert.Equal(t, 3, partSet.Total()) + assert.Equal(t, 2, partSet.Total()) } func TestBlockHashesTo(t *testing.T) { @@ -159,16 +161,16 @@ func TestBlockString(t *testing.T) { } func makeBlockIDRandom() BlockID { - blockHash, blockPartsHeader := crypto.CRandBytes(32), PartSetHeader{123, crypto.CRandBytes(32)} + blockHash, blockPartsHeader := crypto.CRandBytes(tmhash.Size), PartSetHeader{123, crypto.CRandBytes(tmhash.Size)} return BlockID{blockHash, blockPartsHeader} } -func makeBlockID(hash string, partSetSize int, partSetHash string) BlockID { +func makeBlockID(hash []byte, partSetSize int, partSetHash []byte) BlockID { return BlockID{ - Hash: []byte(hash), + Hash: hash, PartsHeader: PartSetHeader{ Total: partSetSize, - Hash: []byte(partSetHash), + Hash: partSetHash, }, } @@ -233,6 +235,40 @@ func TestCommitValidateBasic(t *testing.T) { assert.Error(t, commit.ValidateBasic()) } +func TestMaxHeaderBytes(t *testing.T) { + // Construct a UTF-8 string of MaxChainIDLen length using the supplementary + // characters. + // Each supplementary character takes 4 bytes. + // http://www.i18nguy.com/unicode/supplementary-test.html + maxChainID := "" + for i := 0; i < MaxChainIDLen; i++ { + maxChainID += "𠜎" + } + + h := Header{ + ChainID: maxChainID, + Height: 10, + Time: time.Now().UTC(), + NumTxs: 100, + TotalTxs: 200, + LastBlockID: makeBlockID(make([]byte, 20), 300, make([]byte, 20)), + LastCommitHash: tmhash.Sum([]byte("last_commit_hash")), + DataHash: tmhash.Sum([]byte("data_hash")), + ValidatorsHash: tmhash.Sum([]byte("validators_hash")), + NextValidatorsHash: tmhash.Sum([]byte("next_validators_hash")), + ConsensusHash: tmhash.Sum([]byte("consensus_hash")), + AppHash: tmhash.Sum([]byte("app_hash")), + LastResultsHash: tmhash.Sum([]byte("last_results_hash")), + EvidenceHash: tmhash.Sum([]byte("evidence_hash")), + ProposerAddress: tmhash.Sum([]byte("proposer_address")), + } + + bz, err := cdc.MarshalBinary(h) + require.NoError(t, err) + + assert.Equal(t, MaxHeaderBytes, len(bz)) +} + func randCommit() *Commit { lastID := makeBlockIDRandom() h := int64(3) diff --git a/types/evidence.go b/types/evidence.go index 92675868f..096e3503f 100644 --- a/types/evidence.go +++ b/types/evidence.go @@ -10,6 +10,11 @@ import ( "github.com/tendermint/tendermint/crypto/merkle" ) +const ( + // MaxEvidenceBytes is a maximum size of any evidence (including amino overhead). + MaxEvidenceBytes = 364 +) + // ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid. type ErrEvidenceInvalid struct { Evidence Evidence diff --git a/types/evidence_test.go b/types/evidence_test.go index 54eba01cd..fab26b618 100644 --- a/types/evidence_test.go +++ b/types/evidence_test.go @@ -4,6 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto/tmhash" ) type voteData struct { @@ -31,10 +34,11 @@ func makeVote(val PrivValidator, chainID string, valIndex int, height int64, rou func TestEvidence(t *testing.T) { val := NewMockPV() val2 := NewMockPV() - blockID := makeBlockID("blockhash", 1000, "partshash") - blockID2 := makeBlockID("blockhash2", 1000, "partshash") - blockID3 := makeBlockID("blockhash", 10000, "partshash") - blockID4 := makeBlockID("blockhash", 10000, "partshash2") + + blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash")) + blockID2 := makeBlockID([]byte("blockhash2"), 1000, []byte("partshash")) + blockID3 := makeBlockID([]byte("blockhash"), 10000, []byte("partshash")) + blockID4 := makeBlockID([]byte("blockhash"), 10000, []byte("partshash2")) const chainID = "mychain" @@ -89,10 +93,27 @@ func TestEvidenceList(t *testing.T) { assert.False(t, evl.Has(&DuplicateVoteEvidence{})) } +func TestMaxEvidenceBytes(t *testing.T) { + val := NewMockPV() + blockID := makeBlockID(tmhash.Sum([]byte("blockhash")), 1000, tmhash.Sum([]byte("partshash"))) + blockID2 := makeBlockID(tmhash.Sum([]byte("blockhash2")), 1000, tmhash.Sum([]byte("partshash"))) + const chainID = "mychain" + ev := &DuplicateVoteEvidence{ + PubKey: secp256k1.GenPrivKey().PubKey(), // use secp because it's pubkey is longer + VoteA: makeVote(val, chainID, 0, 10, 2, 1, blockID), + VoteB: makeVote(val, chainID, 0, 10, 2, 1, blockID2), + } + + bz, err := cdc.MarshalBinary(ev) + require.NoError(t, err) + + assert.Equal(t, MaxEvidenceBytes, len(bz)) +} + func randomDuplicatedVoteEvidence() *DuplicateVoteEvidence { val := NewMockPV() - blockID := makeBlockID("blockhash", 1000, "partshash") - blockID2 := makeBlockID("blockhash2", 1000, "partshash") + blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash")) + blockID2 := makeBlockID([]byte("blockhash2"), 1000, []byte("partshash")) const chainID = "mychain" return &DuplicateVoteEvidence{ VoteA: makeVote(val, chainID, 0, 10, 2, 1, blockID), diff --git a/types/params.go b/types/params.go index 3056c82a0..77f68eb7b 100644 --- a/types/params.go +++ b/types/params.go @@ -22,9 +22,8 @@ type ConsensusParams struct { // BlockSize contain limits on the block size. type BlockSize struct { - MaxBytes int `json:"max_bytes"` // NOTE: must not be 0 nor greater than 100MB - MaxTxs int `json:"max_txs"` - MaxGas int64 `json:"max_gas"` + MaxBytes int `json:"max_txs_bytes"` // NOTE: must not be 0 nor greater than 100MB + MaxGas int64 `json:"max_gas"` } // TxSize contain limits on the tx size. @@ -56,9 +55,8 @@ func DefaultConsensusParams() *ConsensusParams { // DefaultBlockSize returns a default BlockSize. func DefaultBlockSize() BlockSize { return BlockSize{ - MaxBytes: 22020096, // 21MB - MaxTxs: 10000, - MaxGas: -1, + MaxBytes: 22020096, // 21MB + MaxGas: -1, } } @@ -110,7 +108,6 @@ func (params *ConsensusParams) Hash() []byte { "block_gossip_part_size_bytes": aminoHasher(params.BlockGossip.BlockPartSizeBytes), "block_size_max_bytes": aminoHasher(params.BlockSize.MaxBytes), "block_size_max_gas": aminoHasher(params.BlockSize.MaxGas), - "block_size_max_txs": aminoHasher(params.BlockSize.MaxTxs), "tx_size_max_bytes": aminoHasher(params.TxSize.MaxBytes), "tx_size_max_gas": aminoHasher(params.TxSize.MaxGas), }) @@ -132,9 +129,6 @@ func (params ConsensusParams) Update(params2 *abci.ConsensusParams) ConsensusPar if params2.BlockSize.MaxBytes > 0 { res.BlockSize.MaxBytes = int(params2.BlockSize.MaxBytes) } - if params2.BlockSize.MaxTxs > 0 { - res.BlockSize.MaxTxs = int(params2.BlockSize.MaxTxs) - } if params2.BlockSize.MaxGas > 0 { res.BlockSize.MaxGas = params2.BlockSize.MaxGas } diff --git a/types/params_test.go b/types/params_test.go index e8e13dba0..119109ce0 100644 --- a/types/params_test.go +++ b/types/params_test.go @@ -9,9 +9,9 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -func newConsensusParams(blockSize, partSize int) ConsensusParams { +func newConsensusParams(txsBytes, partSize int) ConsensusParams { return ConsensusParams{ - BlockSize: BlockSize{MaxBytes: blockSize}, + BlockSize: BlockSize{MaxBytes: txsBytes}, BlockGossip: BlockGossip{BlockPartSizeBytes: partSize}, } } @@ -33,22 +33,19 @@ func TestConsensusParamsValidation(t *testing.T) { {newConsensusParams(101*1024*1024, 400), false}, {newConsensusParams(1024*1024*1024, 400), false}, } - for _, testCase := range testCases { - if testCase.valid { - assert.NoError(t, testCase.params.Validate(), "expected no error for valid params") + for _, tc := range testCases { + if tc.valid { + assert.NoError(t, tc.params.Validate(), "expected no error for valid params") } else { - assert.Error(t, testCase.params.Validate(), "expected error for non valid params") + assert.Error(t, tc.params.Validate(), "expected error for non valid params") } } } -func makeParams(blockBytes, blockTx, blockGas, txBytes, - txGas, partSize int) ConsensusParams { - +func makeParams(txsBytes, blockGas, txBytes, txGas, partSize int) ConsensusParams { return ConsensusParams{ BlockSize: BlockSize{ - MaxBytes: blockBytes, - MaxTxs: blockTx, + MaxBytes: txsBytes, MaxGas: int64(blockGas), }, TxSize: TxSize{ @@ -63,14 +60,11 @@ func makeParams(blockBytes, blockTx, blockGas, txBytes, func TestConsensusParamsHash(t *testing.T) { params := []ConsensusParams{ - makeParams(1, 2, 3, 4, 5, 6), - makeParams(7, 2, 3, 4, 5, 6), - makeParams(1, 7, 3, 4, 5, 6), - makeParams(1, 2, 7, 4, 5, 6), - makeParams(1, 2, 3, 7, 5, 6), - makeParams(1, 2, 3, 4, 7, 6), - makeParams(1, 2, 3, 4, 5, 7), - makeParams(6, 5, 4, 3, 2, 1), + makeParams(6, 2, 3, 4, 5), + makeParams(1, 6, 3, 4, 5), + makeParams(1, 2, 6, 4, 5), + makeParams(1, 2, 3, 6, 5), + makeParams(1, 2, 3, 4, 6), } hashes := make([][]byte, len(params)) @@ -96,18 +90,17 @@ func TestConsensusParamsUpdate(t *testing.T) { }{ // empty updates { - makeParams(1, 2, 3, 4, 5, 6), + makeParams(1, 2, 3, 4, 5), &abci.ConsensusParams{}, - makeParams(1, 2, 3, 4, 5, 6), + makeParams(1, 2, 3, 4, 5), }, // negative BlockPartSizeBytes { - makeParams(1, 2, 3, 4, 5, 6), + makeParams(1, 2, 3, 4, 5), &abci.ConsensusParams{ BlockSize: &abci.BlockSize{ MaxBytes: -100, - MaxTxs: -200, - MaxGas: -300, + MaxGas: -200, }, TxSize: &abci.TxSize{ MaxBytes: -400, @@ -117,26 +110,25 @@ func TestConsensusParamsUpdate(t *testing.T) { BlockPartSizeBytes: -600, }, }, - makeParams(1, 2, 3, 4, 5, 6), + makeParams(1, 2, 3, 4, 5), }, // fine updates { - makeParams(1, 2, 3, 4, 5, 6), + makeParams(1, 2, 3, 4, 5), &abci.ConsensusParams{ BlockSize: &abci.BlockSize{ MaxBytes: 100, - MaxTxs: 200, - MaxGas: 300, + MaxGas: 200, }, TxSize: &abci.TxSize{ - MaxBytes: 400, - MaxGas: 500, + MaxBytes: 300, + MaxGas: 400, }, BlockGossip: &abci.BlockGossip{ - BlockPartSizeBytes: 600, + BlockPartSizeBytes: 500, }, }, - makeParams(100, 200, 300, 400, 500, 600), + makeParams(100, 200, 300, 400, 500), }, } for _, tc := range testCases { diff --git a/types/protobuf.go b/types/protobuf.go index 30e74f15e..9c448cd84 100644 --- a/types/protobuf.go +++ b/types/protobuf.go @@ -115,10 +115,8 @@ func (tm2pb) ValidatorUpdates(vals *ValidatorSet) []abci.ValidatorUpdate { func (tm2pb) ConsensusParams(params *ConsensusParams) *abci.ConsensusParams { return &abci.ConsensusParams{ BlockSize: &abci.BlockSize{ - - MaxBytes: int32(params.BlockSize.MaxBytes), - MaxTxs: int32(params.BlockSize.MaxTxs), - MaxGas: params.BlockSize.MaxGas, + MaxBytes: int32(params.BlockSize.MaxBytes), + MaxGas: params.BlockSize.MaxGas, }, TxSize: &abci.TxSize{ MaxBytes: int32(params.TxSize.MaxBytes), @@ -217,9 +215,8 @@ func (pb2tm) ValidatorUpdates(vals []abci.ValidatorUpdate) ([]*Validator, error) func (pb2tm) ConsensusParams(csp *abci.ConsensusParams) ConsensusParams { return ConsensusParams{ BlockSize: BlockSize{ - MaxBytes: int(csp.BlockSize.MaxBytes), // XXX - MaxTxs: int(csp.BlockSize.MaxTxs), // XXX - MaxGas: csp.BlockSize.MaxGas, + MaxBytes: int(csp.BlockSize.MaxBytes), // XXX + MaxGas: csp.BlockSize.MaxGas, }, TxSize: TxSize{ MaxBytes: int(csp.TxSize.MaxBytes), // XXX diff --git a/types/protobuf_test.go b/types/protobuf_test.go index 8bdf094ba..2a511225b 100644 --- a/types/protobuf_test.go +++ b/types/protobuf_test.go @@ -89,8 +89,8 @@ func TestABCIHeader(t *testing.T) { func TestABCIEvidence(t *testing.T) { val := NewMockPV() - blockID := makeBlockID("blockhash", 1000, "partshash") - blockID2 := makeBlockID("blockhash2", 1000, "partshash") + blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash")) + blockID2 := makeBlockID([]byte("blockhash2"), 1000, []byte("partshash")) const chainID = "mychain" ev := &DuplicateVoteEvidence{ PubKey: val.GetPubKey(), diff --git a/types/tx.go b/types/tx.go index 489f0b232..53fd79c5b 100644 --- a/types/tx.go +++ b/types/tx.go @@ -11,6 +11,11 @@ import ( cmn "github.com/tendermint/tendermint/libs/common" ) +const ( + // MaxAminoOverheadForTx - amino overhead to encode a transaction. + MaxAminoOverheadForTx = 4 +) + // Tx is an arbitrary byte array. // NOTE: Tx has no types at this level, so when wire encoded it's just length-prefixed. // Might we want types here ? diff --git a/types/vote.go b/types/vote.go index 9a6180d75..ac163e8de 100644 --- a/types/vote.go +++ b/types/vote.go @@ -10,6 +10,11 @@ import ( cmn "github.com/tendermint/tendermint/libs/common" ) +const ( + // MaxVoteBytes is a maximum vote size (including amino overhead). + MaxVoteBytes = 170 +) + var ( ErrVoteUnexpectedStep = errors.New("Unexpected step") ErrVoteInvalidValidatorIndex = errors.New("Invalid validator index") diff --git a/types/vote_test.go b/types/vote_test.go index 836baa615..679fcd569 100644 --- a/types/vote_test.go +++ b/types/vote_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/tmhash" ) func examplePrevote() *Vote { @@ -24,17 +25,17 @@ func exampleVote(t byte) *Vote { } return &Vote{ - ValidatorAddress: []byte("addr"), + ValidatorAddress: tmhash.Sum([]byte("validator_address")), ValidatorIndex: 56789, Height: 12345, Round: 2, Timestamp: stamp, Type: t, BlockID: BlockID{ - Hash: []byte("hash"), + Hash: tmhash.Sum([]byte("blockID_hash")), PartsHeader: PartSetHeader{ Total: 1000000, - Hash: []byte("parts_hash"), + Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")), }, }, } @@ -45,7 +46,7 @@ func TestVoteSignable(t *testing.T) { signBytes := vote.SignBytes("test_chain_id") signStr := string(signBytes) - expected := `{"@chain_id":"test_chain_id","@type":"vote","block_id":{"hash":"68617368","parts":{"hash":"70617274735F68617368","total":"1000000"}},"height":"12345","round":"2","timestamp":"2017-12-25T03:00:01.234Z","type":2}` + expected := `{"@chain_id":"test_chain_id","@type":"vote","block_id":{"hash":"8B01023386C371778ECB6368573E539AFC3CC860","parts":{"hash":"72DB3D959635DFF1BB567BEDAA70573392C51596","total":"1000000"}},"height":"12345","round":"2","timestamp":"2017-12-25T03:00:01.234Z","type":2}` if signStr != expected { // NOTE: when this fails, you probably want to fix up consensus/replay_test too t.Errorf("Got unexpected sign string for Vote. Expected:\n%v\nGot:\n%v", expected, signStr) @@ -119,3 +120,16 @@ func TestVoteVerify(t *testing.T) { assert.Equal(t, ErrVoteInvalidSignature, err) } } + +func TestMaxVoteBytes(t *testing.T) { + vote := examplePrevote() + + privVal := NewMockPV() + err := privVal.SignVote("test_chain_id", vote) + require.NoError(t, err) + + bz, err := cdc.MarshalBinary(vote) + require.NoError(t, err) + + assert.Equal(t, MaxVoteBytes, len(bz)) +} From 0f7485690e51c81c9169a889c922913ab4e5c93b Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 30 Aug 2018 12:59:05 +0400 Subject: [PATCH 2/7] limit chain ID to 50 symbols max --- types/block.go | 3 --- types/genesis.go | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/types/block.go b/types/block.go index 1037caccc..7d4551e5b 100644 --- a/types/block.go +++ b/types/block.go @@ -19,9 +19,6 @@ const ( // MaxAminoOverheadForBlock - amino overhead to encode the block. MaxAminoOverheadForBlock = 4 - - // MaxChainIDLen is a maximum length of the chain ID. - MaxChainIDLen = 50 ) // Block defines the atomic unit of a Tendermint blockchain. diff --git a/types/genesis.go b/types/genesis.go index ccfd019c7..0594c0e3e 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -10,6 +10,11 @@ import ( cmn "github.com/tendermint/tendermint/libs/common" ) +const ( + // MaxChainIDLen is a maximum length of the chain ID. + MaxChainIDLen = 50 +) + //------------------------------------------------------------ // core types for a genesis definition @@ -52,10 +57,12 @@ func (genDoc *GenesisDoc) ValidatorHash() []byte { // ValidateAndComplete checks that all necessary fields are present // and fills in defaults for optional fields left empty func (genDoc *GenesisDoc) ValidateAndComplete() error { - if genDoc.ChainID == "" { return cmn.NewError("Genesis doc must include non-empty chain_id") } + if len(genDoc.ChainID) > MaxChainIDLen { + return cmn.NewError(fmt.Sprintf("chain_id in genesis doc is too long (max: %d)", MaxChainIDLen)) + } if genDoc.ConsensusParams == nil { genDoc.ConsensusParams = DefaultConsensusParams() From ad3d42981a4c92e0d99b3e7ed46e3bca8d5988e5 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 30 Aug 2018 12:59:29 +0400 Subject: [PATCH 3/7] update Gopkg.lock --- Gopkg.lock | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index aecf4de72..8deb06378 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -11,14 +11,14 @@ [[projects]] branch = "master" - digest = "1:6aabc1566d6351115d561d038da82a4c19b46c3b6e17f4a0a2fa60260663dc79" + digest = "1:2c00f064ba355903866cbfbf3f7f4c0fe64af6638cc7d1b8bdcf3181bc67f1d8" name = "github.com/btcsuite/btcd" packages = ["btcec"] pruneopts = "UT" revision = "f5e261fc9ec3437697fb31d8b38453c293204b29" [[projects]] - digest = "1:df684ed7fed3fb406ec421424aaf5fc9c63ccc2f428b25b842da78e634482e4b" + digest = "1:1d8e1cb71c33a9470bbbae09bfec09db43c6bf358dfcae13cd8807c4e2a9a2bf" name = "github.com/btcsuite/btcutil" packages = [ "base58", @@ -59,7 +59,7 @@ version = "v1.4.7" [[projects]] - digest = "1:fa30c0652956e159cdb97dcb2ef8b8db63ed668c02a5c3a40961c8f0641252fe" + digest = "1:fdf5169073fb0ad6dc12a70c249145e30f4058647bea25f0abd48b6d9f228a11" name = "github.com/go-kit/kit" packages = [ "log", @@ -91,7 +91,7 @@ version = "v1.7.0" [[projects]] - digest = "1:212285efb97b9ec2e20550d81f0446cb7897e57cbdfd7301b1363ab113d8be45" + digest = "1:35621fe20f140f05a0c4ef662c26c0ab4ee50bca78aa30fe87d33120bd28165e" name = "github.com/gogo/protobuf" packages = [ "gogoproto", @@ -106,7 +106,7 @@ version = "v1.1.1" [[projects]] - digest = "1:cb22af0ed7c72d495d8be1106233ee553898950f15fd3f5404406d44c2e86888" + digest = "1:17fe264ee908afc795734e8c4e63db2accabaf57326dbf21763a7d6b86096260" name = "github.com/golang/protobuf" packages = [ "proto", @@ -137,7 +137,7 @@ [[projects]] branch = "master" - digest = "1:8951fe6e358876736d8fa1f3992624fdbb2dec6bc49401c1381d1ef8abbb544f" + digest = "1:12247a2e99a060cc692f6680e5272c8adf0b8f572e6bce0d7095e624c958a240" name = "github.com/hashicorp/hcl" packages = [ ".", @@ -225,7 +225,7 @@ version = "v1.0.0" [[projects]] - digest = "1:98225904b7abff96c052b669b25788f18225a36673fba022fb93514bb9a2a64e" + digest = "1:c1a04665f9613e082e1209cf288bf64f4068dcd6c87a64bf1c4ff006ad422ba0" name = "github.com/prometheus/client_golang" packages = [ "prometheus", @@ -236,7 +236,7 @@ [[projects]] branch = "master" - digest = "1:0f37e09b3e92aaeda5991581311f8dbf38944b36a3edec61cc2d1991f527554a" + digest = "1:2d5cd61daa5565187e1d96bae64dbbc6080dacf741448e9629c64fd93203b0d4" name = "github.com/prometheus/client_model" packages = ["go"] pruneopts = "UT" @@ -244,7 +244,7 @@ [[projects]] branch = "master" - digest = "1:dad2e5a2153ee7a6c9ab8fc13673a16ee4fb64434a7da980965a3741b0c981a3" + digest = "1:63b68062b8968092eb86bedc4e68894bd096ea6b24920faca8b9dcf451f54bb5" name = "github.com/prometheus/common" packages = [ "expfmt", @@ -256,7 +256,7 @@ [[projects]] branch = "master" - digest = "1:a37c98f4b7a66bb5c539c0539f0915a74ef1c8e0b3b6f45735289d94cae92bfd" + digest = "1:8c49953a1414305f2ff5465147ee576dd705487c35b15918fcd4efdc0cb7a290" name = "github.com/prometheus/procfs" packages = [ ".", @@ -275,7 +275,7 @@ revision = "e2704e165165ec55d062f5919b4b29494e9fa790" [[projects]] - digest = "1:37ace7f35375adec11634126944bdc45a673415e2fcc07382d03b75ec76ea94c" + digest = "1:bd1ae00087d17c5a748660b8e89e1043e1e5479d0fea743352cda2f8dd8c4f84" name = "github.com/spf13/afero" packages = [ ".", @@ -294,7 +294,7 @@ version = "v1.2.0" [[projects]] - digest = "1:627ab2f549a6a55c44f46fa24a4307f4d0da81bfc7934ed0473bf38b24051d26" + digest = "1:7ffc0983035bc7e297da3688d9fe19d60a420e9c38bef23f845c53788ed6a05e" name = "github.com/spf13/cobra" packages = ["."] pruneopts = "UT" @@ -326,7 +326,7 @@ version = "v1.0.0" [[projects]] - digest = "1:73697231b93fb74a73ebd8384b68b9a60c57ea6b13c56d2425414566a72c8e6d" + digest = "1:7e8d267900c7fa7f35129a2a37596e38ed0f11ca746d6d9ba727980ee138f9f6" name = "github.com/stretchr/testify" packages = [ "assert", @@ -338,7 +338,7 @@ [[projects]] branch = "master" - digest = "1:922191411ad8f61bcd8018ac127589bb489712c1d1a0ab2497aca4b16de417d2" + digest = "1:b3cfb8d82b1601a846417c3f31c03a7961862cb2c98dcf0959c473843e6d9a2b" name = "github.com/syndtr/goleveldb" packages = [ "leveldb", @@ -358,7 +358,7 @@ revision = "c4c61651e9e37fa117f53c5a906d3b63090d8445" [[projects]] - digest = "1:34a30b75b54e4b73090d0cafc7884950f020272e36813201ba3860822c46c6dd" + digest = "1:605b6546f3f43745695298ec2d342d3e952b6d91cdf9f349bea9315f677d759f" name = "github.com/tendermint/btcd" packages = ["btcec"] pruneopts = "UT" @@ -366,7 +366,7 @@ [[projects]] branch = "master" - digest = "1:203b409c21115233a576f99e8f13d8e07ad82b25500491f7e1cca12588fb3232" + digest = "1:087aaa7920e5d0bf79586feb57ce01c35c830396ab4392798112e8aae8c47722" name = "github.com/tendermint/ed25519" packages = [ ".", @@ -386,7 +386,7 @@ [[projects]] branch = "master" - digest = "1:df132ec33d5acb4a1ab58d637f1bc3557be49456ca59b9198f5c1e7fa32e0d31" + digest = "1:c31a37cafc12315b8bd745c8ad6a006ac25350472488162a821e557b3e739d67" name = "golang.org/x/crypto" packages = [ "bcrypt", @@ -408,7 +408,7 @@ revision = "56440b844dfe139a8ac053f4ecac0b20b79058f4" [[projects]] - digest = "1:04dda8391c3e2397daf254ac68003f30141c069b228d06baec8324a5f81dc1e9" + digest = "1:d36f55a999540d29b6ea3c2ea29d71c76b1d9853fdcd3e5c5cb4836f2ba118f1" name = "golang.org/x/net" packages = [ "context", @@ -425,7 +425,7 @@ [[projects]] branch = "master" - digest = "1:70656e26ab4a96e683a21d677630edb5239a3d60b2d54bdc861c808ab5aa42c7" + digest = "1:bb0fe59917bdd5b89f49b9a8b26e5f465e325d9223b3a8e32254314bdf51e0f1" name = "golang.org/x/sys" packages = [ "cpu", @@ -435,7 +435,7 @@ revision = "3dc4335d56c789b04b0ba99b7a37249d9b614314" [[projects]] - digest = "1:7509ba4347d1f8de6ae9be8818b0cd1abc3deeffe28aeaf4be6d4b6b5178d9ca" + digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18" name = "golang.org/x/text" packages = [ "collate", @@ -466,7 +466,7 @@ revision = "daca94659cb50e9f37c1b834680f2e46358f10b0" [[projects]] - digest = "1:4515e3030c440845b046354fd5d57671238428b820deebce2e9dabb5cd3c51ac" + digest = "1:2dab32a43451e320e49608ff4542fdfc653c95dcc35d0065ec9c6c3dd540ed74" name = "google.golang.org/grpc" packages = [ ".", @@ -525,6 +525,7 @@ "github.com/gogo/protobuf/gogoproto", "github.com/gogo/protobuf/jsonpb", "github.com/gogo/protobuf/proto", + "github.com/gogo/protobuf/types", "github.com/golang/protobuf/proto", "github.com/golang/protobuf/ptypes/timestamp", "github.com/gorilla/websocket", From e957f322c7ce17f7e2c7696f6af479816e40bcf9 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 30 Aug 2018 13:07:39 +0400 Subject: [PATCH 4/7] be more precise in comments --- types/block.go | 3 ++- types/block_test.go | 3 +-- types/tx.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/block.go b/types/block.go index 7d4551e5b..b13b3ac1d 100644 --- a/types/block.go +++ b/types/block.go @@ -17,7 +17,8 @@ const ( // MaxHeaderBytes is a maximum header size (including amino overhead). MaxHeaderBytes = 478 - // MaxAminoOverheadForBlock - amino overhead to encode the block. + // MaxAminoOverheadForBlock - maximum amino overhead to encode a block (up to + // MaxBlockSizeBytes in size). MaxAminoOverheadForBlock = 4 ) diff --git a/types/block_test.go b/types/block_test.go index 3ca1da616..4c74439c1 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -107,7 +107,6 @@ func TestBlockMakePartSet(t *testing.T) { func TestBlockMakePartSetWithEvidence(t *testing.T) { assert.Nil(t, (*Block)(nil).MakePartSet(2)) - txs := []Tx{Tx("foo"), Tx("bar")} lastID := makeBlockIDRandom() h := int64(3) @@ -118,7 +117,7 @@ func TestBlockMakePartSetWithEvidence(t *testing.T) { ev := NewMockGoodEvidence(h, 0, valSet.Validators[0].Address) evList := []Evidence{ev} - partSet := MakeBlock(h, txs, commit, evList).MakePartSet(1024) + partSet := MakeBlock(h, []Tx{Tx("Hello World")}, commit, evList).MakePartSet(1024) assert.NotNil(t, partSet) assert.Equal(t, 2, partSet.Total()) } diff --git a/types/tx.go b/types/tx.go index 53fd79c5b..896d7be07 100644 --- a/types/tx.go +++ b/types/tx.go @@ -12,7 +12,8 @@ import ( ) const ( - // MaxAminoOverheadForTx - amino overhead to encode a transaction. + // MaxAminoOverheadForTx - maximum amino overhead to encode a transaction + // (ranges from 1 to 4 bytes). MaxAminoOverheadForTx = 4 ) From e873fed81540b916c803120fa3b0639bffdec383 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 31 Aug 2018 15:55:07 +0400 Subject: [PATCH 5/7] calculate amino overhead on the fly --- mempool/mempool.go | 9 +++++++-- types/tx.go | 6 ------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index ec93202e3..6ee6c42bc 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -4,6 +4,7 @@ import ( "bytes" "container/list" "crypto/sha256" + "encoding/binary" "fmt" "sync" "sync/atomic" @@ -385,6 +386,8 @@ func (mem *Mempool) notifyTxsAvailable() { // If max is negative, there is no cap on the size of all returned // transactions (~ all available transactions). func (mem *Mempool) ReapMaxBytes(max int) types.Txs { + var buf [binary.MaxVarintLen64]byte + mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() @@ -400,10 +403,12 @@ func (mem *Mempool) ReapMaxBytes(max int) types.Txs { txs := make([]types.Tx, 0, mem.txs.Len()) for e := mem.txs.Front(); e != nil; e = e.Next() { memTx := e.Value.(*mempoolTx) - if max > 0 && cur+len(memTx.tx)+types.MaxAminoOverheadForTx > max { + // amino.UvarintSize is not used here because it won't be possible to reuse buf + aminoOverhead := binary.PutUvarint(buf[:], uint64(len(memTx.tx))) + if max > 0 && cur+len(memTx.tx)+aminoOverhead > max { return txs } - cur += len(memTx.tx) + types.MaxAminoOverheadForTx + cur += len(memTx.tx) + aminoOverhead txs = append(txs, memTx.tx) } return txs diff --git a/types/tx.go b/types/tx.go index 896d7be07..489f0b232 100644 --- a/types/tx.go +++ b/types/tx.go @@ -11,12 +11,6 @@ import ( cmn "github.com/tendermint/tendermint/libs/common" ) -const ( - // MaxAminoOverheadForTx - maximum amino overhead to encode a transaction - // (ranges from 1 to 4 bytes). - MaxAminoOverheadForTx = 4 -) - // Tx is an arbitrary byte array. // NOTE: Tx has no types at this level, so when wire encoded it's just length-prefixed. // Might we want types here ? From 02d1b03abbe5d59f6caf8e6d63228b24b2670c97 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 31 Aug 2018 15:55:30 +0400 Subject: [PATCH 6/7] update comment for MaxBlockSizeBytes --- types/block.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types/block.go b/types/block.go index b13b3ac1d..18214c57c 100644 --- a/types/block.go +++ b/types/block.go @@ -18,8 +18,12 @@ const ( MaxHeaderBytes = 478 // MaxAminoOverheadForBlock - maximum amino overhead to encode a block (up to - // MaxBlockSizeBytes in size). - MaxAminoOverheadForBlock = 4 + // MaxBlockSizeBytes in size) not including it's parts (only varint len + + // fields without data). + // + // Uvarint length of MaxBlockSizeBytes: 4 bytes + // 4 fields: 4 bytes + MaxAminoOverheadForBlock = 8 ) // Block defines the atomic unit of a Tendermint blockchain. From 4147f856dc8329e367b8f870366751799aa39866 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Fri, 31 Aug 2018 16:10:41 +0400 Subject: [PATCH 7/7] update arch doc --- docs/architecture/adr-020-block-size.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/architecture/adr-020-block-size.md b/docs/architecture/adr-020-block-size.md index d40766b52..aebf3069c 100644 --- a/docs/architecture/adr-020-block-size.md +++ b/docs/architecture/adr-020-block-size.md @@ -5,7 +5,8 @@ 13-08-2018: Initial Draft 15-08-2018: Second version after Dev's comments 28-08-2018: Third version after Ethan's comments -30-08-2018: AminoOverheadForBlock => MaxAminoOverheadForBlock, added MaxAminoOverheadForTx +30-08-2018: AminoOverheadForBlock => MaxAminoOverheadForBlock +31-08-2018: Bounding evidence and chain ID ## Context @@ -44,12 +45,16 @@ are constants defined inside the `types` package: - MaxEvidenceBytes - 364 bytes - MaxHeaderBytes - 476 bytes (~276 bytes hashes + 200 bytes - 50 UTF-8 encoded symbols of chain ID 4 bytes each in the worst case + amino overhead) -- MaxAminoOverheadForBlock - 4 bytes (assuming MaxHeaderBytes includes amino +- MaxAminoOverheadForBlock - 8 bytes (assuming MaxHeaderBytes includes amino overhead for encoding header, MaxVoteBytes - for encoding vote, etc.) +ChainID needs to bound to 50 symbols max. + +When reaping evidence, we use MaxBytes to calculate the upper bound (e.g. 1/10) +to save some space for transactions. + NOTE while reaping the `max int` bytes in mempool, we should account that every transaction will take `len(tx)+aminoOverhead`, where aminoOverhead=1-4 bytes. -Therefore, MaxAminoOverheadForTx should be added. We should write a test that fails if the underlying structs got changed, but MaxXXX stayed the same.