mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 22:23:11 +00:00
Update master (#4087)
* cs: panic only when WAL#WriteSync fails - modify WAL#Write and WAL#WriteSync to return an error * fix test * types: validate Part#Proof add ValidateBasic to crypto/merkle/SimpleProof * cs: limit max bit array size and block parts count * cs: test new limits * cs: only assert important stuff * update changelog and bump version to 0.32.7 * fixes after Ethan's review * align max wal msg and max consensus msg sizes * fix tests * fix test * add change log for 31.11
This commit is contained in:
@@ -14,6 +14,9 @@ const (
|
||||
|
||||
// BlockPartSizeBytes is the size of one block part.
|
||||
BlockPartSizeBytes = 65536 // 64kB
|
||||
|
||||
// MaxBlockPartsCount is the maximum count of block parts.
|
||||
MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1
|
||||
)
|
||||
|
||||
// ConsensusParams contains consensus critical parameters that determine the
|
||||
|
||||
@@ -26,10 +26,13 @@ type Part struct {
|
||||
// ValidateBasic performs basic validation.
|
||||
func (part *Part) ValidateBasic() error {
|
||||
if part.Index < 0 {
|
||||
return errors.New("Negative Index")
|
||||
return errors.New("negative Index")
|
||||
}
|
||||
if len(part.Bytes) > BlockPartSizeBytes {
|
||||
return fmt.Errorf("Too big (max: %d)", BlockPartSizeBytes)
|
||||
return errors.Errorf("too big: %d bytes, max: %d", len(part.Bytes), BlockPartSizeBytes)
|
||||
}
|
||||
if err := part.Proof.ValidateBasic(); err != nil {
|
||||
return errors.Wrap(err, "wrong Proof")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/merkle"
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
)
|
||||
|
||||
@@ -115,6 +116,13 @@ func TestPartValidateBasic(t *testing.T) {
|
||||
{"Good Part", func(pt *Part) {}, false},
|
||||
{"Negative index", func(pt *Part) { pt.Index = -1 }, true},
|
||||
{"Too big part", func(pt *Part) { pt.Bytes = make([]byte, BlockPartSizeBytes+1) }, true},
|
||||
{"Too big proof", func(pt *Part) {
|
||||
pt.Proof = merkle.SimpleProof{
|
||||
Total: 1,
|
||||
Index: 1,
|
||||
LeafHash: make([]byte, 1024*1024),
|
||||
}
|
||||
}, true},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -11,6 +11,12 @@ import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
)
|
||||
|
||||
const (
|
||||
// MaxVotesCount is the maximum votes count. Used in ValidateBasic funcs for
|
||||
// protection against DOS attacks.
|
||||
MaxVotesCount = 10000
|
||||
)
|
||||
|
||||
// UNSTABLE
|
||||
// XXX: duplicate of p2p.ID to avoid dependence between packages.
|
||||
// Perhaps we can have a minimal types package containing this (and other things?)
|
||||
|
||||
Reference in New Issue
Block a user