Compare commits

...

10 Commits

Author SHA1 Message Date
Tess Rinearson
bd1f43d793 changelog: prepare changelog for RC5 (#5494)
* changelog: prepare changelog for RC5

* Update CHANGELOG.md

Co-authored-by: Marko <marbar3778@yahoo.com>

* Update CHANGELOG.md

Co-authored-by: Marko <marbar3778@yahoo.com>

Co-authored-by: Marko <marbar3778@yahoo.com>
2020-10-13 20:00:59 +02:00
Marko
09982ae407 backport block size fixes (#5492)
* mempool: length prefix txs when getting them from mempool (#5483)

* correctly calculate evidence data size (#5482)

* block: use commit sig size instead of vote size (#5490)

* tx: reduce function to one parameter (#5493)
2020-10-13 18:07:54 +02:00
Callum Waters
7d5d417dc9 evidence: use bytes instead of quantity to limit size (#5449)(#5476) 2020-10-08 14:38:11 +02:00
Marko
dac18d73a7 fix RPC blockresults return (#5459) (#5463) 2020-10-07 12:01:40 +02:00
Tess Rinearson
383bc5337f changelog: add missing date to v0.33.5 release, fix indentation (#5454) (#5455)
I forgot to add the date when we cut 0.33.5. This fixes that. It also fixes a header indentation issue for 0.33.8.
2020-10-05 12:27:58 +02:00
Erik Grinaker
e74176ad1a privval: fix ping message encoding (#5442)
Fixes #5371.
2020-10-01 17:02:11 +02:00
Callum Waters
52994aa2a9 consensus: check block parts don't exceed maximum block bytes (#5436) 2020-10-01 16:11:54 +02:00
Erik Grinaker
6149f21cd6 privval: allow passing options to NewSignerDialerEndpoint (#5434) (#5437)
Required for #5291 to set timeouts for remote signers.
2020-10-01 16:06:34 +02:00
Erik Grinaker
1a2cc933a0 config: set statesync.rpc_servers when generating config file (#5433) (#5438)
Required for #5291, to generate configuration files with state sync RPC servers.
2020-10-01 15:55:57 +02:00
Anton Kaliaev
e0f686ccac mempool: fix nil pointer dereference (#5412)
previously, the second next could return nil, which would be the reason
for panic on line 275:

memTx := next.Value.(*mempoolTx)

Closes #5408
2020-09-30 08:56:01 +04:00
49 changed files with 743 additions and 731 deletions

View File

@@ -1,5 +1,31 @@
# Changelog
## v0.34.0-rc5
*October 13, 2020*
Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermint).
### BREAKING CHANGES
- Go API
- [evidence] [\#5499](https://github.com/tendermint/tendermint/pull/5449) `MaxNum` evidence consensus parameter has been changed to `MaxBytes` (@cmwaters)
- [mempool] [\#5493](https://github.com/tendermint/tendermint/issues/5493) reduce `ComputeProtoSizeForTxs` to take one parameter (@marbar3778)
### IMPROVEMENTS
- [config] [\#5433](https://github.com/tendermint/tendermint/issues/5433) `statesync.rpc_servers` is now properly set when writing the configuration file (@erikgrinaker)
- [privval] [\#5437](https://github.com/tendermint/tendermint/issues/5437) `NewSignerDialerEndpoint` can now be given `SignerServiceEndpointOption` (@erikgrinaker)
- [types] [\#5490](https://github.com/tendermint/tendermint/pull/5490) Use `Commit` and `CommitSig` max sizes instead of vote max size to calculate the maxiumum block size. (@cmwaters)
### BUG FIXES
- [privval] [\#5441](https://github.com/tendermint/tendermint/issues/5441) Fix faulty ping message encoding causing nil message errors in logs (@erikgrinaker)
- [rpc] [\#5459](https://github.com/tendermint/tendermint/issues/5459) Register the interface of public keys for json encoding (@marbar3778)
- [consensus] [\#5431](https://github.com/tendermint/tendermint/pull/5431) Check BlockParts do not exceed Maxium block size. (@cmwaters)
- [mempool] [\#5483](https://github.com/tendermint/tendermint/pull/5483) Check tx size does not exceed available free space in the block. (@marbar3778)
## v0.34.0-rc4
*September 24, 2020*
@@ -240,7 +266,7 @@ This release was removed, as a premature GitHub tag was recorded on sum.golang.o
*August 11, 2020*
## Go security update
### Go security update
Go reported a security vulnerability that affected the `encoding/binary` package. The most recent binary for tendermint is using 1.14.6, for this
reason the Tendermint engineering team has opted to conduct a release to aid users in using the correct version of Go. Read more about the security issue [here](https://github.com/golang/go/issues/40618).
@@ -322,6 +348,8 @@ need to update your code.**
## v0.33.5
*May 28, 2020*
Special thanks to external contributors on this release: @tau3,
Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermint).

View File

@@ -15,6 +15,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- P2P Protocol
- Go API
- [evidence] [\#5499](https://github.com/tendermint/tendermint/pull/5449) `MaxNum` evidence consensus parameter has been changed to `MaxBytes` (@cmwaters)
- Blockchain Protocol
@@ -22,5 +23,11 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### IMPROVEMENTS
- [config] \#5433 `statesync.rpc_servers` is now properly set when writing the configuration file (@erikgrinaker)
- [privval] \#5437 `NewSignerDialerEndpoint` can now be given `SignerServiceEndpointOption` (@erikgrinaker)
### BUG FIXES
- [privval] \#5441 Fix faulty ping message encoding causing nil message errors in logs (@erikgrinaker)
- [rpc] \#5459 Register the interface of public keys for json encoding (@marbar3778)

View File

@@ -97,7 +97,7 @@ func TestBlockchainMessageVectors(t *testing.T) {
BlockRequest: &bcproto.BlockRequest{Height: math.MaxInt64}}},
"0a0a08ffffffffffffffff7f"},
{"BlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_BlockResponse{
BlockResponse: &bcproto.BlockResponse{Block: bpb}}}, "1ab5010ab2010a5b0a02080b1803220b088092b8c398feffffff012a0212003a20c4da88e876062aa1543400d50d0eaa0dac88096057949cfb7bca7f3a48c04bf96a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855122f0a0b48656c6c6f20576f726c641220c4da88e876062aa1543400d50d0eaa0dac88096057949cfb7bca7f3a48c04bf91a221220e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},
BlockResponse: &bcproto.BlockResponse{Block: bpb}}}, "1a700a6e0a5b0a02080b1803220b088092b8c398feffffff012a0212003a20c4da88e876062aa1543400d50d0eaa0dac88096057949cfb7bca7f3a48c04bf96a20e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855120d0a0b48656c6c6f20576f726c641a00"},
{"NoBlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_NoBlockResponse{
NoBlockResponse: &bcproto.NoBlockResponse{Height: 1}}}, "12020801"},
{"NoBlockResponseMessage", &bcproto.Message{Sum: &bcproto.Message_NoBlockResponse{

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"path/filepath"
"strings"
"text/template"
tmos "github.com/tendermint/tendermint/libs/os"
@@ -17,7 +18,10 @@ var configTemplate *template.Template
func init() {
var err error
if configTemplate, err = template.New("configFileTemplate").Parse(defaultConfigTemplate); err != nil {
tmpl := template.New("configFileTemplate").Funcs(template.FuncMap{
"StringsJoin": strings.Join,
})
if configTemplate, err = tmpl.Parse(defaultConfigTemplate); err != nil {
panic(err)
}
}
@@ -350,7 +354,7 @@ enable = {{ .StateSync.Enable }}
#
# For Cosmos SDK-based chains, trust_period should usually be about 2/3 of the unbonding time (~2
# weeks) during which they can be financially punished (slashed) for misbehavior.
rpc_servers = ""
rpc_servers = "{{ StringsJoin .StateSync.RPCServers "," }}"
trust_height = {{ .StateSync.TrustHeight }}
trust_hash = "{{ .StateSync.TrustHash }}"
trust_period = "{{ .StateSync.TrustPeriod }}"
@@ -511,7 +515,7 @@ var testGenesisFmt = `{
"evidence": {
"max_age_num_blocks": "100000",
"max_age_duration": "172800000000000",
"max_num": 50
"max_bytes": "1048576"
},
"validator": {
"pub_key_types": [

View File

@@ -603,7 +603,7 @@ func ensureProposal(proposalCh <-chan tmpubsub.Message, height int64, round int3
panic(fmt.Sprintf("expected round %v, got %v", round, proposalEvent.Round))
}
if !proposalEvent.BlockID.Equals(propID) {
panic("Proposed block does not match expected block")
panic(fmt.Sprintf("Proposed block does not match expected block (%v != %v)", proposalEvent.BlockID, propID))
}
}
}

View File

@@ -167,11 +167,11 @@ func TestReactorWithEvidence(t *testing.T) {
// mock the evidence pool
// everyone includes evidence of another double signing
vIdx := (i + 1) % nValidators
ev := types.NewMockDuplicateVoteEvidenceWithValidator(1, defaultTestTime, privVals[vIdx], config.ChainID())
evpool := &statemocks.EvidencePool{}
evpool.On("CheckEvidence", mock.AnythingOfType("types.EvidenceList")).Return(nil)
evpool.On("PendingEvidence", mock.AnythingOfType("uint32")).Return([]types.Evidence{
types.NewMockDuplicateVoteEvidenceWithValidator(1, defaultTestTime, privVals[vIdx], config.ChainID()),
})
evpool.On("PendingEvidence", mock.AnythingOfType("int64")).Return([]types.Evidence{
ev}, int64(len(ev.Bytes())))
evpool.On("Update", mock.AnythingOfType("state.State")).Return()
evpool.On("ABCIEvidence", mock.AnythingOfType("int64"), mock.AnythingOfType("[]types.Evidence")).Return(
[]abci.Evidence{})

View File

@@ -1779,16 +1779,23 @@ func (cs *State) addProposalBlockPart(msg *BlockPartMessage, peerID p2p.ID) (add
if err != nil {
return added, err
}
if cs.ProposalBlockParts.ByteSize() > cs.state.ConsensusParams.Block.MaxBytes {
return added, fmt.Errorf("total size of proposal block parts exceeds maximum block bytes (%d > %d)",
cs.ProposalBlockParts.ByteSize(), cs.state.ConsensusParams.Block.MaxBytes,
)
}
if added && cs.ProposalBlockParts.IsComplete() {
bz, err := ioutil.ReadAll(cs.ProposalBlockParts.GetReader())
if err != nil {
return added, err
}
var pbb = new(tmproto.Block)
err = proto.Unmarshal(bz, pbb)
if err != nil {
return added, err
}
block, err := types.BlockFromProto(pbb)
if err != nil {
return added, err

View File

@@ -29,6 +29,7 @@ x * TestProposerSelection2 - round robin ordering, round 2++
x * TestEnterProposeNoValidator - timeout into prevote round
x * TestEnterPropose - finish propose without timing out (we have the proposal)
x * TestBadProposal - 2 vals, bad proposal (bad block state hash), should prevote and precommit nil
x * TestOversizedBlock - block with too many txs should be rejected
FullRoundSuite
x * TestFullRound1 - 1 val, full successful round
x * TestFullRoundNil - 1 val, full round of nil
@@ -238,6 +239,64 @@ func TestStateBadProposal(t *testing.T) {
signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
}
func TestStateOversizedBlock(t *testing.T) {
cs1, vss := randState(2)
cs1.state.ConsensusParams.Block.MaxBytes = 2000
height, round := cs1.Height, cs1.Round
vs2 := vss[1]
partSize := types.BlockPartSizeBytes
timeoutProposeCh := subscribe(cs1.eventBus, types.EventQueryTimeoutPropose)
voteCh := subscribe(cs1.eventBus, types.EventQueryVote)
propBlock, _ := cs1.createProposalBlock()
propBlock.Data.Txs = []types.Tx{tmrand.Bytes(2001)}
propBlock.Header.DataHash = propBlock.Data.Hash()
// make the second validator the proposer by incrementing round
round++
incrementRound(vss[1:]...)
propBlockParts := propBlock.MakePartSet(partSize)
blockID := types.BlockID{Hash: propBlock.Hash(), PartSetHeader: propBlockParts.Header()}
proposal := types.NewProposal(height, round, -1, blockID)
p := proposal.ToProto()
if err := vs2.SignProposal(config.ChainID(), p); err != nil {
t.Fatal("failed to sign bad proposal", err)
}
proposal.Signature = p.Signature
totalBytes := 0
for i := 0; i < int(propBlockParts.Total()); i++ {
part := propBlockParts.GetPart(i)
totalBytes += len(part.Bytes)
}
if err := cs1.SetProposalAndBlock(proposal, propBlock, propBlockParts, "some peer"); err != nil {
t.Fatal(err)
}
// start the machine
startTestRound(cs1, height, round)
t.Log("Block Sizes", "Limit", cs1.state.ConsensusParams.Block.MaxBytes, "Current", totalBytes)
// c1 should log an error with the block part message as it exceeds the consensus params. The
// block is not added to cs.ProposalBlock so the node timeouts.
ensureNewTimeout(timeoutProposeCh, height, round, cs1.config.Propose(round).Nanoseconds())
// and then should send nil prevote and precommit regardless of whether other validators prevote and
// precommit on it
ensurePrevote(voteCh, height, round)
validatePrevote(t, cs1, round, vss[0], nil)
signAddVotes(cs1, tmproto.PrevoteType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
ensurePrevote(voteCh, height, round)
ensurePrecommit(voteCh, height, round)
validatePrecommit(t, cs1, round, -1, vss[0], nil, nil)
signAddVotes(cs1, tmproto.PrecommitType, propBlock.Hash(), propBlock.MakePartSet(partSize).Header(), vs2)
}
//----------------------------------------------------------------------------------------------------
// FullRoundSuite

View File

@@ -5,9 +5,15 @@ import (
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/json"
pc "github.com/tendermint/tendermint/proto/tendermint/crypto"
)
func init() {
json.RegisterType((*pc.PublicKey)(nil), "tendermint.crypto.PublicKey")
json.RegisterType((*pc.PublicKey_Ed25519)(nil), "tendermint.crypto.PublicKey_Ed25519")
}
// PubKeyToProto takes crypto.PubKey and transforms it to a protobuf Pubkey
func PubKeyToProto(k crypto.PubKey) (pc.PublicKey, error) {
var kp pc.PublicKey

View File

@@ -32,7 +32,7 @@ All evidence is proto encoded to disk.
Proposing
When a new block is being proposed (in state/execution.go#CreateProposalBlock),
`PendingEvidence(maxNum)` is called to send up to the maxNum number of uncommitted evidence, from the evidence store,
`PendingEvidence(maxBytes)` is called to send up to the maxBytes of uncommitted evidence, from the evidence store,
prioritized in order of age. All evidence is checked for expiration.
When a node receives evidence in a block it will use the evidence module as a cache first to see if it has

View File

@@ -1,52 +0,0 @@
// Code generated by mockery v2.1.0. DO NOT EDIT.
package mocks
import (
mock "github.com/stretchr/testify/mock"
state "github.com/tendermint/tendermint/state"
types "github.com/tendermint/tendermint/types"
)
// StateStore is an autogenerated mock type for the StateStore type
type StateStore struct {
mock.Mock
}
// LoadState provides a mock function with given fields:
func (_m *StateStore) LoadState() state.State {
ret := _m.Called()
var r0 state.State
if rf, ok := ret.Get(0).(func() state.State); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(state.State)
}
return r0
}
// LoadValidators provides a mock function with given fields: height
func (_m *StateStore) LoadValidators(height int64) (*types.ValidatorSet, error) {
ret := _m.Called(height)
var r0 *types.ValidatorSet
if rf, ok := ret.Get(0).(func(int64) *types.ValidatorSet); ok {
r0 = rf(height)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.ValidatorSet)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(int64) error); ok {
r1 = rf(height)
} else {
r1 = ret.Error(1)
}
return r0, r1
}

View File

@@ -64,19 +64,16 @@ func NewPool(evidenceDB dbm.DB, stateDB sm.Store, blockStore BlockStore) (*Pool,
logger: log.NewNopLogger(),
evidenceStore: evidenceDB,
evidenceList: clist.New(),
evidenceSize: 0,
pruningHeight: state.LastBlockHeight,
pruningTime: state.LastBlockTime,
}
// if pending evidence already in db, in event of prior failure, then check for expiration,
// update the size and load it back to the evidenceList
pool.removeExpiredPendingEvidence()
evList, err := pool.listEvidence(baseKeyPending, -1)
pool.pruningHeight, pool.pruningTime = pool.removeExpiredPendingEvidence()
evList, _, err := pool.listEvidence(baseKeyPending, -1)
if err != nil {
return nil, err
}
atomic.AddUint32(&pool.evidenceSize, uint32(len(evList)))
atomic.StoreUint32(&pool.evidenceSize, uint32(len(evList)))
for _, ev := range evList {
pool.evidenceList.PushBack(ev)
}
@@ -85,12 +82,15 @@ func NewPool(evidenceDB dbm.DB, stateDB sm.Store, blockStore BlockStore) (*Pool,
}
// PendingEvidence is used primarily as part of block proposal and returns up to maxNum of uncommitted evidence.
func (evpool *Pool) PendingEvidence(maxNum uint32) []types.Evidence {
evidence, err := evpool.listEvidence(baseKeyPending, int64(maxNum))
func (evpool *Pool) PendingEvidence(maxBytes int64) ([]types.Evidence, int64) {
if atomic.LoadUint32(&evpool.evidenceSize) == 0 {
return []types.Evidence{}, 0
}
evidence, size, err := evpool.listEvidence(baseKeyPending, maxBytes)
if err != nil {
evpool.logger.Error("Unable to retrieve pending evidence", "err", err)
}
return evidence
return evidence, size
}
// Update pulls the latest state to be used for expiration and evidence params and then prunes all expired evidence
@@ -330,6 +330,7 @@ type info struct {
Time time.Time
Validators []*types.Validator
TotalVotingPower int64
ByteSize int64
}
// ToProto encodes into protobuf
@@ -381,6 +382,7 @@ func infoFromProto(proto *evproto.Info) (info, error) {
Time: proto.Time,
Validators: vals,
TotalVotingPower: proto.TotalVotingPower,
ByteSize: int64(proto.Evidence.Size()),
}, nil
}
@@ -489,31 +491,32 @@ func (evpool *Pool) removePendingEvidence(evidence types.Evidence) {
}
}
// listEvidence lists up to maxNum pieces of evidence for the given prefix key.
// If maxNum is -1, there's no cap on the size of returned evidence.
func (evpool *Pool) listEvidence(prefixKey byte, maxNum int64) ([]types.Evidence, error) {
var count int64
// listEvidence retrieves lists evidence from oldest to newest within maxBytes.
// If maxBytes is -1, there's no cap on the size of returned evidence.
func (evpool *Pool) listEvidence(prefixKey byte, maxBytes int64) ([]types.Evidence, int64, error) {
var totalSize int64
var evidence []types.Evidence
iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{prefixKey})
if err != nil {
return nil, fmt.Errorf("database error: %v", err)
return nil, totalSize, fmt.Errorf("database error: %v", err)
}
defer iter.Close()
for ; iter.Valid(); iter.Next() {
if count == maxNum {
return evidence, nil
}
count++
evInfo, err := bytesToInfo(iter.Value())
if err != nil {
return nil, err
return nil, totalSize, err
}
totalSize += evInfo.ByteSize
if maxBytes != -1 && totalSize > maxBytes {
return evidence, totalSize - evInfo.ByteSize, nil
}
evidence = append(evidence, evInfo.Evidence)
}
return evidence, nil
return evidence, totalSize, nil
}
func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) {
@@ -534,7 +537,8 @@ func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) {
if len(blockEvidenceMap) != 0 {
evpool.removeEvidenceFromList(blockEvidenceMap)
}
// return the time with which this evidence will have expired so we know when to prune next
// return the height and time with which this evidence will have expired so we know when to prune next
return evInfo.Evidence.Height() + evpool.State().ConsensusParams.Evidence.MaxAgeNumBlocks + 1,
evInfo.Time.Add(evpool.State().ConsensusParams.Evidence.MaxAgeDuration).Add(time.Second)
}

View File

@@ -32,7 +32,10 @@ func TestMain(m *testing.M) {
const evidenceChainID = "test_chain"
var defaultEvidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
var (
defaultEvidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
defaultEvidenceMaxBytes int64 = 1000
)
func TestEvidencePoolBasic(t *testing.T) {
var (
@@ -52,10 +55,12 @@ func TestEvidencePoolBasic(t *testing.T) {
pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore)
require.NoError(t, err)
pool.SetLogger(log.TestingLogger())
// evidence not seen yet:
evs := pool.PendingEvidence(10)
evs, size := pool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Equal(t, 0, len(evs))
assert.Zero(t, size)
ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime, privVals[0], evidenceChainID)
@@ -78,12 +83,14 @@ func TestEvidencePoolBasic(t *testing.T) {
next := pool.EvidenceFront()
assert.Equal(t, ev, next.Value.(types.Evidence))
evs = pool.PendingEvidence(10)
evs, size = pool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Equal(t, 1, len(evs))
assert.Equal(t, int64(357), size) // check that the size of the single evidence in bytes is correct
// shouldn't be able to add evidence twice
assert.Error(t, pool.AddEvidence(ev))
assert.Equal(t, 1, len(pool.PendingEvidence(10)))
evs, _ = pool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Equal(t, 1, len(evs))
}
@@ -183,12 +190,15 @@ func TestEvidencePoolUpdate(t *testing.T) {
},
}
assert.Equal(t, expectedByzVals, byzVals)
assert.Equal(t, 1, len(pool.PendingEvidence(10)))
evList, _ := pool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Equal(t, 1, len(evList))
pool.Update(state)
// a) Update marks evidence as committed so pending evidence should be empty
assert.Empty(t, pool.PendingEvidence(10))
evList, evSize := pool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Empty(t, evList)
assert.Zero(t, evSize)
// b) If we try to check this evidence again it should fail because it has already been committed
err = pool.CheckEvidence(types.EvidenceList{ev})
@@ -293,7 +303,6 @@ func TestCheckEvidenceWithLightClientAttack(t *testing.T) {
func TestRecoverPendingEvidence(t *testing.T) {
height := int64(10)
expiredEvidenceTime := time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC)
val := types.NewMockPV()
valAddress := val.PrivKey.PubKey().Address()
evidenceDB := dbm.NewMemDB()
@@ -301,21 +310,24 @@ func TestRecoverPendingEvidence(t *testing.T) {
state, err := stateStore.Load()
require.NoError(t, err)
blockStore := initializeBlockStore(dbm.NewMemDB(), state, valAddress)
// create previous pool and populate it
pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore)
require.NoError(t, err)
pool.SetLogger(log.TestingLogger())
goodEvidence := types.NewMockDuplicateVoteEvidenceWithValidator(height,
defaultEvidenceTime, val, evidenceChainID)
expiredEvidence := types.NewMockDuplicateVoteEvidenceWithValidator(int64(1),
expiredEvidenceTime, val, evidenceChainID)
defaultEvidenceTime, val, evidenceChainID)
err = pool.AddEvidence(goodEvidence)
require.NoError(t, err)
err = pool.AddEvidence(expiredEvidence)
require.NoError(t, err)
// now recover from the previous pool at a different time
newStateStore := &smmocks.Store{}
newStateStore.On("Load").Return(sm.State{
LastBlockTime: defaultEvidenceTime.Add(49 * time.Hour),
LastBlockHeight: height + 12,
LastBlockTime: defaultEvidenceTime.Add(25 * time.Minute),
LastBlockHeight: height + 15,
ConsensusParams: tmproto.ConsensusParams{
Block: tmproto.BlockParams{
MaxBytes: 22020096,
@@ -323,14 +335,15 @@ func TestRecoverPendingEvidence(t *testing.T) {
},
Evidence: tmproto.EvidenceParams{
MaxAgeNumBlocks: 20,
MaxAgeDuration: 1 * time.Hour,
MaxNum: 50,
MaxAgeDuration: 20 * time.Minute,
MaxBytes: 1000,
},
},
}, nil)
newPool, err := evidence.NewPool(evidenceDB, newStateStore, blockStore)
assert.NoError(t, err)
assert.Equal(t, 1, len(newPool.PendingEvidence(10)))
evList, _ := newPool.PendingEvidence(defaultEvidenceMaxBytes)
assert.Equal(t, 1, len(evList))
next := newPool.EvidenceFront()
assert.Equal(t, goodEvidence, next.Value.(types.Evidence))
@@ -356,7 +369,7 @@ func initializeStateFromValidatorSet(valSet *types.ValidatorSet, height int64) s
Evidence: tmproto.EvidenceParams{
MaxAgeNumBlocks: 20,
MaxAgeDuration: 20 * time.Minute,
MaxNum: 50,
MaxBytes: 1000,
},
},
}

View File

@@ -106,14 +106,17 @@ func _waitForEvidence(
pools []*evidence.Pool,
) {
evpool := pools[poolIdx]
for len(evpool.PendingEvidence(uint32(len(evs)))) != len(evs) {
var evList []types.Evidence
currentPoolSize := 0
for currentPoolSize != len(evs) {
evList, _ = evpool.PendingEvidence(int64(len(evs) * 500)) // each evidence should not be more than 500 bytes
currentPoolSize = len(evList)
time.Sleep(time.Millisecond * 100)
}
reapedEv := evpool.PendingEvidence(uint32(len(evs)))
// 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 {
for _, e := range evList {
evMap[string(e.Hash())] = e
}
for i, expectedEv := range evs {

View File

@@ -102,7 +102,7 @@ func TestVerifyLightClientAttack_Lunatic(t *testing.T) {
err = pool.CheckEvidence(evList)
assert.NoError(t, err)
pendingEvs := pool.PendingEvidence(2)
pendingEvs, _ := pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
assert.Equal(t, 1, len(pendingEvs))
pubKey, err := newPrivVal.GetPubKey()
@@ -206,7 +206,7 @@ func TestVerifyLightClientAttack_Equivocation(t *testing.T) {
err = pool.CheckEvidence(evList)
assert.NoError(t, err)
pendingEvs := pool.PendingEvidence(2)
pendingEvs, _ := pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
assert.Equal(t, 1, len(pendingEvs))
pubKey, err := conflictingPrivVals[0].GetPubKey()
@@ -303,7 +303,7 @@ func TestVerifyLightClientAttack_Amnesia(t *testing.T) {
err = pool.CheckEvidence(evList)
assert.NoError(t, err)
pendingEvs := pool.PendingEvidence(2)
pendingEvs, _ := pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
assert.Equal(t, 1, len(pendingEvs))
pubKey, err := conflictingPrivVals[0].GetPubKey()

View File

@@ -517,21 +517,21 @@ func (mem *CListMempool) ReapMaxBytesMaxGas(maxBytes, maxGas int64) types.Txs {
mem.updateMtx.RLock()
defer mem.updateMtx.RUnlock()
var (
totalBytes int64
totalGas int64
)
var totalGas int64
// 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, tmmath.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)
dataSize := types.ComputeProtoSizeForTxs(append(txs, memTx.tx))
// Check total size requirement
if maxBytes > -1 && totalBytes+int64(len(memTx.tx)) > maxBytes {
if maxBytes > -1 && dataSize > maxBytes {
return txs
}
totalBytes += int64(len(memTx.tx))
// Check total gas requirement.
// If maxGas is negative, skip this check.
// Since newTotalGas < masGas, which

View File

@@ -121,11 +121,11 @@ func TestReapMaxBytesMaxGas(t *testing.T) {
{20, 0, -1, 0},
{20, 0, 10, 0},
{20, 10, 10, 0},
{20, 20, 10, 1},
{20, 100, 5, 5},
{20, 200, -1, 10},
{20, 200, 10, 10},
{20, 200, 15, 10},
{20, 24, 10, 1},
{20, 240, 5, 5},
{20, 240, -1, 10},
{20, 240, 10, 10},
{20, 240, 15, 10},
{20, 20000, -1, 20},
{20, 20000, 5, 5},
{20, 20000, 30, 20},
@@ -159,15 +159,15 @@ func TestMempoolFilters(t *testing.T) {
}{
{10, nopPreFilter, nopPostFilter, 10},
{10, PreCheckMaxBytes(10), nopPostFilter, 0},
{10, PreCheckMaxBytes(20), nopPostFilter, 10},
{10, PreCheckMaxBytes(22), nopPostFilter, 10},
{10, nopPreFilter, PostCheckMaxGas(-1), 10},
{10, nopPreFilter, PostCheckMaxGas(0), 0},
{10, nopPreFilter, PostCheckMaxGas(1), 10},
{10, nopPreFilter, PostCheckMaxGas(3000), 10},
{10, PreCheckMaxBytes(10), PostCheckMaxGas(20), 0},
{10, PreCheckMaxBytes(30), PostCheckMaxGas(20), 10},
{10, PreCheckMaxBytes(20), PostCheckMaxGas(1), 10},
{10, PreCheckMaxBytes(20), PostCheckMaxGas(0), 0},
{10, PreCheckMaxBytes(22), PostCheckMaxGas(1), 10},
{10, PreCheckMaxBytes(22), PostCheckMaxGas(0), 0},
}
for tcIndex, tt := range tests {
err := mempool.Update(1, emptyTxArr, abciResponses(len(emptyTxArr), abci.CodeTypeOK), tt.preFilter, tt.postFilter)

View File

@@ -105,7 +105,8 @@ type TxInfo struct {
// PreCheckMaxBytes checks that the size of the transaction is smaller or equal to the expected maxBytes.
func PreCheckMaxBytes(maxBytes int64) PreCheckFunc {
return func(tx types.Tx) error {
txSize := int64(len(tx))
txSize := types.ComputeProtoSizeForTxs([]types.Tx{tx})
if txSize > maxBytes {
return fmt.Errorf("tx size is too big: %d, max: %d",
txSize, maxBytes)

View File

@@ -288,10 +288,11 @@ func (memR *Reactor) txs(next *clist.CElement, peerID uint16, peerHeight int64)
batch = append(batch, memTx.tx)
}
if next.Next() == nil {
n := next.Next()
if n == nil {
return batch
}
next = next.Next()
next = n
}
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/kvstore"
abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
tmrand "github.com/tendermint/tendermint/libs/rand"
@@ -64,6 +65,66 @@ func TestReactorBroadcastTxsMessage(t *testing.T) {
waitForTxsOnReactors(t, txs, reactors)
}
// regression test for https://github.com/tendermint/tendermint/issues/5408
func TestReactorConcurrency(t *testing.T) {
config := cfg.TestConfig()
const N = 2
reactors := makeAndConnectReactors(config, N)
defer func() {
for _, r := range reactors {
if err := r.Stop(); err != nil {
assert.NoError(t, err)
}
}
}()
for _, r := range reactors {
for _, peer := range r.Switch.Peers().List() {
peer.Set(types.PeerStateKey, peerState{1})
}
}
var wg sync.WaitGroup
const numTxs = 5
for i := 0; i < 1000; i++ {
wg.Add(2)
// 1. submit a bunch of txs
// 2. update the whole mempool
txs := checkTxs(t, reactors[0].mempool, numTxs, UnknownPeerID)
go func() {
defer wg.Done()
reactors[0].mempool.Lock()
defer reactors[0].mempool.Unlock()
deliverTxResponses := make([]*abci.ResponseDeliverTx, len(txs))
for i := range txs {
deliverTxResponses[i] = &abci.ResponseDeliverTx{Code: 0}
}
err := reactors[0].mempool.Update(1, txs, deliverTxResponses, nil, nil)
assert.NoError(t, err)
}()
// 1. submit a bunch of txs
// 2. update none
_ = checkTxs(t, reactors[1].mempool, numTxs, UnknownPeerID)
go func() {
defer wg.Done()
reactors[1].mempool.Lock()
defer reactors[1].mempool.Unlock()
err := reactors[1].mempool.Update(1, []types.Tx{}, make([]*abci.ResponseDeliverTx, 0), nil, nil)
assert.NoError(t, err)
}()
// 1. flush the mempool
reactors[1].mempool.Flush()
}
wg.Wait()
}
// Send a bunch of txs to the first reactor's mempool, claiming it came from peer
// ensure peer gets no txs.
func TestReactorNoBroadcastToSender(t *testing.T) {

View File

@@ -234,13 +234,14 @@ func TestCreateProposalBlock(t *testing.T) {
state, stateDB, privVals := state(1, height)
stateStore := sm.NewStore(stateDB)
maxBytes := 16384
maxEvidence := 10
var partSize uint32 = 256
maxEvidenceBytes := int64(maxBytes / 2)
state.ConsensusParams.Block.MaxBytes = int64(maxBytes)
state.ConsensusParams.Evidence.MaxNum = uint32(maxEvidence)
state.ConsensusParams.Evidence.MaxBytes = maxEvidenceBytes
proposerAddr, _ := state.Validators.GetByIndex(0)
// Make Mempool
memplMetrics := mempl.PrometheusMetrics("node_test")
memplMetrics := mempl.PrometheusMetrics("node_test_1")
mempool := mempl.NewCListMempool(
config.Mempool,
proxyApp.Mempool(),
@@ -260,16 +261,18 @@ func TestCreateProposalBlock(t *testing.T) {
// fill the evidence pool with more evidence
// than can fit in a block
for i := 0; i <= maxEvidence; i++ {
var currentBytes int64 = 0
for currentBytes <= maxEvidenceBytes {
ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
currentBytes += int64(len(ev.Bytes()))
err := evidencePool.AddEvidenceFromConsensus(ev, time.Now(), state.Validators)
require.NoError(t, err)
}
// fill the mempool with more txs
// than can fit in a block
txLength := 1000
for i := 0; i < maxBytes/txLength; i++ {
txLength := 100
for i := 0; i <= maxBytes/txLength; i++ {
tx := tmrand.Bytes(txLength)
err := mempool.CheckTx(tx, nil, mempl.TxInfo{})
assert.NoError(t, err)
@@ -290,10 +293,83 @@ func TestCreateProposalBlock(t *testing.T) {
proposerAddr,
)
// check that the part set does not exceed the maximum block size
partSet := block.MakePartSet(partSize)
assert.Less(t, partSet.ByteSize(), int64(maxBytes))
partSetFromHeader := types.NewPartSetFromHeader(partSet.Header())
for partSetFromHeader.Count() < partSetFromHeader.Total() {
added, err := partSetFromHeader.AddPart(partSet.GetPart(int(partSetFromHeader.Count())))
require.NoError(t, err)
require.True(t, added)
}
assert.EqualValues(t, partSetFromHeader.ByteSize(), partSet.ByteSize())
err = blockExec.ValidateBlock(state, block)
assert.NoError(t, err)
}
func TestMaxProposalBlockSize(t *testing.T) {
config := cfg.ResetTestRoot("node_create_proposal")
defer os.RemoveAll(config.RootDir)
cc := proxy.NewLocalClientCreator(kvstore.NewApplication())
proxyApp := proxy.NewAppConns(cc)
err := proxyApp.Start()
require.Nil(t, err)
defer proxyApp.Stop() //nolint:errcheck // ignore for tests
logger := log.TestingLogger()
var height int64 = 1
state, stateDB, _ := state(1, height)
stateStore := sm.NewStore(stateDB)
var maxBytes int64 = 16384
var partSize uint32 = 256
state.ConsensusParams.Block.MaxBytes = maxBytes
proposerAddr, _ := state.Validators.GetByIndex(0)
// Make Mempool
memplMetrics := mempl.PrometheusMetrics("node_test_2")
mempool := mempl.NewCListMempool(
config.Mempool,
proxyApp.Mempool(),
state.LastBlockHeight,
mempl.WithMetrics(memplMetrics),
mempl.WithPreCheck(sm.TxPreCheck(state)),
mempl.WithPostCheck(sm.TxPostCheck(state)),
)
mempool.SetLogger(logger)
// fill the mempool with one txs just below the maximum size
txLength := int(types.MaxDataBytesNoEvidence(maxBytes, 1))
tx := tmrand.Bytes(txLength - 4) // to account for the varint
err = mempool.CheckTx(tx, nil, mempl.TxInfo{})
assert.NoError(t, err)
blockExec := sm.NewBlockExecutor(
stateStore,
logger,
proxyApp.Consensus(),
mempool,
sm.EmptyEvidencePool{},
)
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
block, _ := blockExec.CreateProposalBlock(
height,
state, commit,
proposerAddr,
)
pb, err := block.ToProto()
require.NoError(t, err)
assert.Less(t, int64(pb.Size()), maxBytes)
// check that the part set does not exceed the maximum block size
partSet := block.MakePartSet(partSize)
assert.EqualValues(t, partSet.ByteSize(), int64(pb.Size()))
}
func TestNodeNewNodeCustomReactors(t *testing.T) {
config := cfg.ResetTestRoot("node_new_node_custom_reactors_test")
defer os.RemoveAll(config.RootDir)

View File

@@ -29,11 +29,11 @@ func mustWrapMsg(pb proto.Message) privvalproto.Message {
case *privvalproto.SignProposalRequest:
msg.Sum = &privvalproto.Message_SignProposalRequest{SignProposalRequest: pb}
case *privvalproto.PingRequest:
msg.Sum = &privvalproto.Message_PingRequest{}
msg.Sum = &privvalproto.Message_PingRequest{PingRequest: pb}
case *privvalproto.PingResponse:
msg.Sum = &privvalproto.Message_PingResponse{}
msg.Sum = &privvalproto.Message_PingResponse{PingResponse: pb}
default:
panic(fmt.Errorf("unknown message type %T", msg))
panic(fmt.Errorf("unknown message type %T", pb))
}
return msg

View File

@@ -78,8 +78,8 @@ func TestPrivvalVectors(t *testing.T) {
msg proto.Message
expBytes string
}{
{"ping request", &privproto.PingRequest{}, ""},
{"ping response", &privproto.PingResponse{}, ""},
{"ping request", &privproto.PingRequest{}, "3a00"},
{"ping response", &privproto.PingResponse{}, "4200"},
{"pubKey request", &privproto.PubKeyRequest{}, "0a00"},
{"pubKey response", &privproto.PubKeyResponse{PubKey: &ppk, Error: nil}, "12240a220a20556a436f1218d30942efe798420f51dc9b6a311b929c578257457d05c5fcf230"},
{"pubKey response with error", &privproto.PubKeyResponse{PubKey: nil, Error: remoteError}, "121212100801120c697427732061206572726f72"},

View File

@@ -48,6 +48,7 @@ type SignerDialerEndpoint struct {
func NewSignerDialerEndpoint(
logger log.Logger,
dialer SocketDialer,
options ...SignerServiceEndpointOption,
) *SignerDialerEndpoint {
sd := &SignerDialerEndpoint{
@@ -56,6 +57,10 @@ func NewSignerDialerEndpoint(
maxConnRetries: defaultMaxDialRetries,
}
for _, optionFunc := range options {
optionFunc(sd)
}
sd.BaseService = *service.NewBaseService(logger, "SignerDialerEndpoint", sd)
sd.signerEndpoint.timeoutReadWrite = defaultTimeoutReadWriteSeconds * time.Second

View File

@@ -217,7 +217,6 @@ func (*Evidence) XXX_OneofWrappers() []interface{} {
// EvidenceData contains any evidence of malicious wrong-doing by validators
type EvidenceData struct {
Evidence []Evidence `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence"`
Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
}
func (m *EvidenceData) Reset() { *m = EvidenceData{} }
@@ -260,13 +259,6 @@ func (m *EvidenceData) GetEvidence() []Evidence {
return nil
}
func (m *EvidenceData) GetHash() []byte {
if m != nil {
return m.Hash
}
return nil
}
func init() {
proto.RegisterType((*DuplicateVoteEvidence)(nil), "tendermint.types.DuplicateVoteEvidence")
proto.RegisterType((*LightClientAttackEvidence)(nil), "tendermint.types.LightClientAttackEvidence")
@@ -277,32 +269,32 @@ func init() {
func init() { proto.RegisterFile("tendermint/types/evidence.proto", fileDescriptor_6825fabc78e0a168) }
var fileDescriptor_6825fabc78e0a168 = []byte{
// 398 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcd, 0x6a, 0xea, 0x40,
0x14, 0x4e, 0xae, 0x3f, 0xc8, 0xe8, 0x05, 0x6f, 0xb8, 0xb6, 0x2a, 0x12, 0x4b, 0xba, 0xa8, 0x50,
0x9a, 0x80, 0x5d, 0x74, 0xd3, 0x8d, 0xa9, 0x05, 0x0b, 0xdd, 0x34, 0x8b, 0x2e, 0xba, 0x49, 0x27,
0x93, 0x69, 0x32, 0x98, 0xcc, 0x88, 0x4e, 0x84, 0x3e, 0x43, 0x37, 0x7d,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, 0x63, 0x77, 0x9d, 0x88, 0x2d, 0x3c, 0xad, 0x83, 0x5f,
0x49, 0x38, 0xcb, 0x4a, 0xd8, 0x1b, 0xe1, 0x40, 0xb2, 0x6a, 0xee, 0xde, 0x6c, 0x29, 0x68, 0x05,
0x31, 0xb1, 0x8d, 0x84, 0x7b, 0x1b, 0x0a, 0xfb, 0x1b, 0x9e, 0x24, 0xc2, 0xf3, 0x03, 0x56, 0xf7,
0x45, 0x36, 0x90, 0xac, 0x46, 0x70, 0x68, 0x68, 0x16, 0x40, 0x6e, 0x12, 0x85, 0xda, 0x33, 0xa8,
0xac, 0x5b, 0x7d, 0xc8, 0xa1, 0x72, 0x0d, 0x4a, 0x5b, 0xd6, 0x72, 0x9d, 0x72, 0xb7, 0x99, 0xa5,
0x4c, 0x97, 0xe4, 0x67, 0x9f, 0x6d, 0xc9, 0x4a, 0x7f, 0x28, 0x0a, 0xc8, 0xfb, 0x70, 0xe2, 0x0b,
0xb1, 0x15, 0x4b, 0xd4, 0xe6, 0xc3, 0x6c, 0xa1, 0xca, 0xf3, 0x85, 0x2a, 0x7f, 0x2d, 0x54, 0xf9,
0x7d, 0xa9, 0x4a, 0xf3, 0xa5, 0x2a, 0x7d, 0x2c, 0x55, 0xe9, 0xe9, 0xca, 0x23, 0xdc, 0x8f, 0x1c,
0x1d, 0xb1, 0xd0, 0xd8, 0x3e, 0xc8, 0x4d, 0x99, 0x1c, 0xee, 0xee, 0xb1, 0x3a, 0x45, 0xd1, 0xbf,
0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x75, 0x06, 0x32, 0x10, 0x03, 0x00, 0x00,
// 388 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x6a, 0xea, 0x40,
0x14, 0x4d, 0x9e, 0x4f, 0x91, 0xd1, 0x07, 0xbe, 0xf0, 0x7c, 0x55, 0x91, 0x58, 0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0x8c, 0x39, 0x56, 0x65, 0xa7, 0x4d, 0x20, 0xca, 0x19, 0xfa, 0x83,
0x79, 0x18, 0x72, 0x66, 0x0f, 0x49, 0xcc, 0x13, 0xeb, 0xe5, 0xac, 0x72, 0x02, 0xf6, 0x05, 0xa6,
0x7d, 0xc9, 0xa8, 0x98, 0x8a, 0x3b, 0xe8, 0xc4, 0xdb, 0x24, 0x62, 0x0b, 0x4f, 0x9b, 0xe0, 0xd7,
0x2b, 0x9c, 0x67, 0x57, 0x38, 0x18, 0x61, 0x5f, 0xb2, 0xaa, 0xde, 0xc1, 0x6c, 0x19, 0x6a, 0x06,
0xb1, 0xb0, 0x8d, 0x85, 0x7b, 0xdb, 0x11, 0xf6, 0xb7, 0x3a, 0x49, 0x84, 0x17, 0x47, 0xac, 0x1e,
0x8a, 0xac, 0x2f, 0x59, 0xf5, 0xe0, 0x58, 0xd1, 0xcc, 0xa3, 0xdc, 0x34, 0x0a, 0xb5, 0x01, 0x2a,
0x6f, 0xa0, 0x9e, 0x03, 0x8e, 0x72, 0x83, 0x8a, 0x3b, 0xd6, 0x72, 0xed, 0x52, 0xa7, 0x91, 0x95,
0x4c, 0x87, 0xfc, 0x9e, 0x7f, 0xb4, 0x24, 0x2b, 0xed, 0x30, 0x1f, 0xe6, 0x4b, 0x55, 0x5e, 0x2c,
0x55, 0xf9, 0x73, 0xa9, 0xca, 0x6f, 0x2b, 0x55, 0x5a, 0xac, 0x54, 0xe9, 0x7d, 0xa5, 0x4a, 0x4f,
0xd7, 0x3e, 0x85, 0x61, 0xe4, 0xea, 0x98, 0x87, 0xc6, 0xee, 0xf1, 0x6d, 0xbf, 0xc9, 0x91, 0xee,
0x1f, 0xa6, 0x5b, 0x10, 0xf8, 0xd5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc0, 0x7f, 0xe9, 0x7a,
0xfc, 0x02, 0x00, 0x00,
}
func (m *DuplicateVoteEvidence) Marshal() (dAtA []byte, err error) {
@@ -486,13 +478,6 @@ func (m *EvidenceData) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Hash) > 0 {
i -= len(m.Hash)
copy(dAtA[i:], m.Hash)
i = encodeVarintEvidence(dAtA, i, uint64(len(m.Hash)))
i--
dAtA[i] = 0x12
}
if len(m.Evidence) > 0 {
for iNdEx := len(m.Evidence) - 1; iNdEx >= 0; iNdEx-- {
{
@@ -602,10 +587,6 @@ func (m *EvidenceData) Size() (n int) {
n += 1 + l + sovEvidence(uint64(l))
}
}
l = len(m.Hash)
if l > 0 {
n += 1 + l + sovEvidence(uint64(l))
}
return n
}
@@ -1034,40 +1015,6 @@ func (m *EvidenceData) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowEvidence
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthEvidence
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthEvidence
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
if m.Hash == nil {
m.Hash = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipEvidence(dAtA[iNdEx:])

View File

@@ -28,5 +28,4 @@ message Evidence {
// EvidenceData contains any evidence of malicious wrong-doing by validators
message EvidenceData {
repeated Evidence evidence = 1 [(gogoproto.nullable) = false];
bytes hash = 2;
}

View File

@@ -179,11 +179,10 @@ type EvidenceParams struct {
// mechanism for handling [Nothing-At-Stake
// attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed).
MaxAgeDuration time.Duration `protobuf:"bytes,2,opt,name=max_age_duration,json=maxAgeDuration,proto3,stdduration" json:"max_age_duration"`
// This sets the maximum number of evidence that can be committed in a single block.
// and should fall comfortably under the max block bytes when we consider the size of
// each evidence (See MaxEvidenceBytes). The maximum number is MaxEvidencePerBlock.
// Default is 50
MaxNum uint32 `protobuf:"varint,3,opt,name=max_num,json=maxNum,proto3" json:"max_num,omitempty"`
// This sets the maximum size of total evidence in bytes that can be committed in a single block.
// and should fall comfortably under the max block bytes.
// Default is 1048576 or 1MB
MaxBytes int64 `protobuf:"varint,3,opt,name=max_bytes,json=maxBytes,proto3" json:"max_bytes,omitempty"`
}
func (m *EvidenceParams) Reset() { *m = EvidenceParams{} }
@@ -233,9 +232,9 @@ func (m *EvidenceParams) GetMaxAgeDuration() time.Duration {
return 0
}
func (m *EvidenceParams) GetMaxNum() uint32 {
func (m *EvidenceParams) GetMaxBytes() int64 {
if m != nil {
return m.MaxNum
return m.MaxBytes
}
return 0
}
@@ -398,42 +397,41 @@ func init() {
func init() { proto.RegisterFile("tendermint/types/params.proto", fileDescriptor_e12598271a686f57) }
var fileDescriptor_e12598271a686f57 = []byte{
// 545 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x4f, 0x6f, 0xd3, 0x30,
0x1c, 0xad, 0xd7, 0xb2, 0xb5, 0xbf, 0xae, 0xeb, 0x64, 0x21, 0x51, 0x86, 0x96, 0x94, 0x1c, 0xd0,
0x24, 0xa4, 0x44, 0x82, 0x03, 0x62, 0x97, 0x89, 0xc0, 0x34, 0x10, 0xea, 0x84, 0x22, 0xe0, 0xb0,
0x4b, 0xe4, 0xb4, 0x26, 0x8b, 0x56, 0xc7, 0x51, 0x6c, 0x57, 0xed, 0xb7, 0xe0, 0xb8, 0xe3, 0x2e,
0x48, 0x7c, 0x04, 0x3e, 0xc2, 0x8e, 0x3b, 0x72, 0x02, 0xd4, 0x5e,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 0x80, 0x64, 0xd9, 0x1c, 0xb6, 0xc4,
0x3d, 0x83, 0xed, 0xb7, 0x44, 0x9c, 0xd3, 0xc1, 0x9c, 0xfa, 0x04, 0xda, 0x3a, 0x95, 0x70, 0xbd,
0x92, 0x96, 0x1e, 0xf7, 0x4c, 0x2f, 0x0e, 0xb4, 0x16, 0xb8, 0x45, 0x3b, 0x4d, 0x83, 0x3a, 0x21,
0xc2, 0xff, 0xf4, 0x7d, 0x6a, 0xa1, 0xeb, 0xa9, 0x85, 0x6e, 0xa6, 0x16, 0xfa, 0x33, 0xb5, 0xd0,
0xd7, 0x99, 0x55, 0xb9, 0x99, 0x59, 0x95, 0x9f, 0x33, 0xab, 0x72, 0xf6, 0x22, 0x4e, 0xe4, 0xb9,
0x8a, 0xdc, 0x3e, 0x67, 0xde, 0xf2, 0x93, 0x5c, 0x7c, 0x96, 0x6f, 0x6e, 0xfd, 0xb9, 0x46, 0x9b,
0x7a, 0xfe, 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x53, 0x0a, 0x6c, 0x0d, 0xc9, 0x03, 0x00,
0x00,
// 537 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x31, 0x6f, 0xd3, 0x40,
0x18, 0xcd, 0xd5, 0xa5, 0x4d, 0xbe, 0x34, 0x4d, 0x75, 0x42, 0x22, 0x14, 0xd5, 0x0e, 0x1e, 0x50,
0x25, 0x24, 0x5b, 0x82, 0x01, 0xd1, 0xa5, 0xc2, 0x50, 0x15, 0x84, 0x82, 0x90, 0x05, 0x0c, 0x5d,
0xac, 0x73, 0x72, 0xb8, 0x56, 0x73, 0x3e, 0xcb, 0x77, 0x8e, 0x92, 0x7f, 0xc1, 0xd8, 0xb1, 0x23,
0xfc, 0x03, 0x7e, 0x42, 0xc7, 0x8e, 0x4c, 0x80, 0x92, 0x85, 0x9f, 0x81, 0x7c, 0xce,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a,
0x5a, 0x52, 0x1f, 0x41, 0x57, 0x25, 0x13, 0xac, 0xd7, 0xd2, 0x51, 0xe3, 0x81, 0xee, 0xc6, 0x86,
0x4e, 0x85, 0xab, 0x1a, 0x6a, 0x6b, 0xd4, 0x29, 0x11, 0xde, 0xc7, 0xaf, 0x73, 0x13, 0x5d, 0xcf,
0x4d, 0x74, 0x33, 0x37, 0xd1, 0xef, 0xb9, 0x89, 0xbe, 0x2c, 0xcc, 0xc6, 0xcd, 0xc2, 0x6c, 0xfc,
0x58, 0x98, 0x8d, 0xb3, 0x67, 0x51, 0x2c, 0xcf, 0xf3, 0xd0, 0x19, 0x72, 0xe6, 0xae, 0x3e, 0xcb,
0xea, 0xb3, 0x7c, 0x77, 0xeb, 0x4f, 0x36, 0xdc, 0x52, 0xf3, 0xa7, 0x7f, 0x03, 0x00, 0x00, 0xff,
0xff, 0xfe, 0xe0, 0x3d, 0x9c, 0xcd, 0x03, 0x00, 0x00,
}
func (this *ConsensusParams) Equal(that interface{}) bool {
@@ -524,7 +522,7 @@ func (this *EvidenceParams) Equal(that interface{}) bool {
if this.MaxAgeDuration != that1.MaxAgeDuration {
return false
}
if this.MaxNum != that1.MaxNum {
if this.MaxBytes != that1.MaxBytes {
return false
}
return true
@@ -730,8 +728,8 @@ func (m *EvidenceParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.MaxNum != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.MaxNum))
if m.MaxBytes != 0 {
i = encodeVarintParams(dAtA, i, uint64(m.MaxBytes))
i--
dAtA[i] = 0x18
}
@@ -993,8 +991,8 @@ func (m *EvidenceParams) Size() (n int) {
}
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAgeDuration)
n += 1 + l + sovParams(uint64(l))
if m.MaxNum != 0 {
n += 1 + sovParams(uint64(m.MaxNum))
if m.MaxBytes != 0 {
n += 1 + sovParams(uint64(m.MaxBytes))
}
return n
}
@@ -1425,9 +1423,9 @@ func (m *EvidenceParams) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field MaxNum", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field MaxBytes", wireType)
}
m.MaxNum = 0
m.MaxBytes = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowParams
@@ -1437,7 +1435,7 @@ func (m *EvidenceParams) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
m.MaxNum |= uint32(b&0x7F) << shift
m.MaxBytes |= int64(b&0x7F) << shift
if b < 0x80 {
break
}

View File

@@ -48,11 +48,10 @@ message EvidenceParams {
google.protobuf.Duration max_age_duration = 2
[(gogoproto.nullable) = false, (gogoproto.stdduration) = true];
// This sets the maximum number of evidence that can be committed in a single block.
// and should fall comfortably under the max block bytes when we consider the size of
// each evidence (See MaxEvidenceBytes). The maximum number is MaxEvidencePerBlock.
// Default is 50
uint32 max_num = 3;
// This sets the maximum size of total evidence in bytes that can be committed in a single block.
// and should fall comfortably under the max block bytes.
// Default is 1048576 or 1MB
int64 max_bytes = 3;
}
// ValidatorParams restrict the public key types validators can use.

View File

@@ -10,7 +10,6 @@ import (
_ "github.com/gogo/protobuf/types"
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
crypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
bits "github.com/tendermint/tendermint/proto/tendermint/libs/bits"
version "github.com/tendermint/tendermint/proto/tendermint/version"
io "io"
math "math"
@@ -422,8 +421,6 @@ type Data struct {
// NOTE: not all txs here are valid. We're just agreeing on the order first.
// This means that block.AppHash does not include these txs.
Txs [][]byte `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"`
// Volatile
Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
}
func (m *Data) Reset() { *m = Data{} }
@@ -466,13 +463,6 @@ func (m *Data) GetTxs() [][]byte {
return nil
}
func (m *Data) GetHash() []byte {
if m != nil {
return m.Hash
}
return nil
}
// Vote represents a prevote, precommit, or commit vote from validators for
// consensus.
type Vote struct {
@@ -577,12 +567,10 @@ func (m *Vote) GetSignature() []byte {
// Commit contains the evidence that a block was committed by a set of validators.
type Commit 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"`
BlockID BlockID `protobuf:"bytes,3,opt,name=block_id,json=blockId,proto3" json:"block_id"`
Signatures []CommitSig `protobuf:"bytes,4,rep,name=signatures,proto3" json:"signatures"`
Hash []byte `protobuf:"bytes,5,opt,name=hash,proto3" json:"hash,omitempty"`
BitArray *bits.BitArray `protobuf:"bytes,6,opt,name=bit_array,json=bitArray,proto3" json:"bit_array,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"`
BlockID BlockID `protobuf:"bytes,3,opt,name=block_id,json=blockId,proto3" json:"block_id"`
Signatures []CommitSig `protobuf:"bytes,4,rep,name=signatures,proto3" json:"signatures"`
}
func (m *Commit) Reset() { *m = Commit{} }
@@ -646,20 +634,6 @@ func (m *Commit) GetSignatures() []CommitSig {
return nil
}
func (m *Commit) GetHash() []byte {
if m != nil {
return m.Hash
}
return nil
}
func (m *Commit) GetBitArray() *bits.BitArray {
if m != nil {
return m.BitArray
}
return nil
}
// CommitSig is a part of the Vote included in a Commit.
type CommitSig struct {
BlockIdFlag BlockIDFlag `protobuf:"varint,1,opt,name=block_id_flag,json=blockIdFlag,proto3,enum=tendermint.types.BlockIDFlag" json:"block_id_flag,omitempty"`
@@ -1075,93 +1049,90 @@ func init() {
func init() { proto.RegisterFile("tendermint/types/types.proto", fileDescriptor_d3a6e55e2345de56) }
var fileDescriptor_d3a6e55e2345de56 = []byte{
// 1364 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00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3f, 0x3f, 0xa9, 0x48, 0x2f, 0x4e, 0x2a, 0xd2, 0x9f, 0x27, 0x15, 0xe9, 0xd9,
0xab, 0xca, 0xc2, 0x8b, 0x57, 0x95, 0x85, 0xdf, 0x5e, 0x55, 0x16, 0xbe, 0xfa, 0x68, 0x68, 0x93,
0xd1, 0xa4, 0xaf, 0x0d, 0xbc, 0x71, 0x2d, 0xfa, 0xbf, 0x63, 0xf6, 0xc8, 0xff, 0x21, 0x9d, 0xfe,
0x4f, 0xd2, 0x5f, 0x64, 0xf6, 0x3b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xf9, 0x01, 0xed,
0x76, 0x0d, 0x00, 0x00,
// 1314 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45,
0x14, 0xcf, 0xda, 0x9b, 0xd8, 0x7e, 0xb6, 0x13, 0x67, 0x95, 0xb6, 0xae, 0xdb, 0x38, 0x2b, 0x23,
0x20, 0x2d, 0x68, 0x53, 0x52, 0xc4, 0x9f, 0x03, 0x07, 0xdb, 0x49, 0x5b, 0xab, 0x89, 0x63, 0xd6,
0x6e, 0x11, 0x5c, 0x56, 0x6b, 0xef, 0xd4, 0x5e, 0xba, 0xde, 0x59, 0xed, 0x8c, 0x43, 0xd2, 0x4f,
0x80, 0x72, 0xea, 0x89, 0x5b, 0x4e, 0x70, 0xe0, 0xce, 0x17, 0x40, 0x9c, 0x7a, 0xec, 0x0d, 0x2e,
0x14, 0x94, 0x4a, 0x88, 0x8f, 0x81, 0xe6, 0x8f, 0xd7, 0xeb, 0x38, 0x86, 0xaa, 0xaa, 0xb8, 0x58,
0x3b, 0xef, 0xfd, 0xde, 0xcc, 0x7b, 0xbf, 0xf7, 0x9b, 0x3f, 0x86, 0xeb, 0x14, 0xf9, 0x0e, 0x0a,
0x87, 0xae, 0x4f, 0xb7, 0xe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2, 0x6c, 0xc4, 0x41, 0xeb, 0xa0, 0x5d,
0xdd, 0x2b, 0xe8, 0xa5, 0xc2, 0xc9, 0xa9, 0x9e, 0x1b, 0x1f, 0x86, 0x0c, 0x3f, 0xa9, 0xac, 0xf6,
0xf9, 0xb3, 0xb3, 0xb2, 0xf2, 0xfc, 0xac, 0xac, 0xfc, 0x79, 0x56, 0x56, 0x9e, 0xbe, 0x2c, 0x2f,
0x3c, 0x7f, 0x59, 0x5e, 0xf8, 0xed, 0x65, 0x79, 0xe1, 0xab, 0x8f, 0xfb, 0x2e, 0x1d, 0x8c, 0xba,
0x46, 0x0f, 0x0f, 0xb7, 0xe2, 0x7f, 0x09, 0x26, 0x9f, 0xe2, 0xaf, 0xc9, 0xf9, 0xbf, 0x0b, 0xdd,
0x25, 0x6e, 0xbf, 0xfd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x78, 0x43, 0xdf, 0xef, 0x0c,
0x00, 0x00,
}
func (m *PartSetHeader) Marshal() (dAtA []byte, err error) {
@@ -1430,13 +1401,6 @@ func (m *Data) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Hash) > 0 {
i -= len(m.Hash)
copy(dAtA[i:], m.Hash)
i = encodeVarintTypes(dAtA, i, uint64(len(m.Hash)))
i--
dAtA[i] = 0x12
}
if len(m.Txs) > 0 {
for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Txs[iNdEx])
@@ -1544,25 +1508,6 @@ func (m *Commit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.BitArray != nil {
{
size, err := m.BitArray.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTypes(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x32
}
if len(m.Hash) > 0 {
i -= len(m.Hash)
copy(dAtA[i:], m.Hash)
i = encodeVarintTypes(dAtA, i, uint64(len(m.Hash)))
i--
dAtA[i] = 0x2a
}
if len(m.Signatures) > 0 {
for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- {
{
@@ -1627,12 +1572,12 @@ func (m *CommitSig) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x22
}
n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
if err10 != nil {
return 0, err10
n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
if err9 != nil {
return 0, err9
}
i -= n10
i = encodeVarintTypes(dAtA, i, uint64(n10))
i -= n9
i = encodeVarintTypes(dAtA, i, uint64(n9))
i--
dAtA[i] = 0x1a
if len(m.ValidatorAddress) > 0 {
@@ -1677,12 +1622,12 @@ func (m *Proposal) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x3a
}
n11, err11 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
if err11 != nil {
return 0, err11
n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Timestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Timestamp):])
if err10 != nil {
return 0, err10
}
i -= n11
i = encodeVarintTypes(dAtA, i, uint64(n11))
i -= n10
i = encodeVarintTypes(dAtA, i, uint64(n10))
i--
dAtA[i] = 0x32
{
@@ -2044,10 +1989,6 @@ func (m *Data) Size() (n int) {
n += 1 + l + sovTypes(uint64(l))
}
}
l = len(m.Hash)
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
return n
}
@@ -2104,14 +2045,6 @@ func (m *Commit) Size() (n int) {
n += 1 + l + sovTypes(uint64(l))
}
}
l = len(m.Hash)
if l > 0 {
n += 1 + l + sovTypes(uint64(l))
}
if m.BitArray != nil {
l = m.BitArray.Size()
n += 1 + l + sovTypes(uint64(l))
}
return n
}
@@ -3181,40 +3114,6 @@ func (m *Data) Unmarshal(dAtA []byte) error {
m.Txs = append(m.Txs, make([]byte, postIndex-iNdEx))
copy(m.Txs[len(m.Txs)-1], dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
if m.Hash == nil {
m.Hash = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
@@ -3636,76 +3535,6 @@ func (m *Commit) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
if m.Hash == nil {
m.Hash = []byte{}
}
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BitArray", 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.BitArray == nil {
m.BitArray = &bits.BitArray{}
}
if err := m.BitArray.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])

View File

@@ -5,7 +5,6 @@ option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "tendermint/libs/bits/types.proto";
import "tendermint/crypto/proof.proto";
import "tendermint/version/types.proto";
import "tendermint/types/validator.proto";
@@ -88,8 +87,6 @@ message Data {
// NOTE: not all txs here are valid. We're just agreeing on the order first.
// This means that block.AppHash does not include these txs.
repeated bytes txs = 1;
// Volatile
bytes hash = 2;
}
// Vote represents a prevote, precommit, or commit vote from validators for
@@ -113,8 +110,6 @@ message Commit {
int32 round = 2;
BlockID block_id = 3 [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"];
repeated CommitSig signatures = 4 [(gogoproto.nullable) = false];
bytes hash = 5;
tendermint.libs.bits.BitArray bit_array = 6;
}
// CommitSig is a part of the Vote included in a Commit.

View File

@@ -290,7 +290,7 @@ func TestAppCalls(t *testing.T) {
h = apph - 1
commit2, err := c.Commit(context.Background(), &h)
require.NoError(err)
assert.Equal(block.Block.LastCommit, commit2.Commit)
assert.Equal(block.Block.LastCommitHash, commit2.Commit.Hash())
// and we got a proof that works!
_pres, err := c.ABCIQueryWithOptions(context.Background(), "/key", k, client.ABCIQueryOptions{Prove: true})

View File

@@ -100,10 +100,11 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
maxBytes := state.ConsensusParams.Block.MaxBytes
maxGas := state.ConsensusParams.Block.MaxGas
evidence := blockExec.evpool.PendingEvidence(state.ConsensusParams.Evidence.MaxNum)
evidence, evSize := blockExec.evpool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
// Fetch a limited amount of valid txs
maxDataBytes := types.MaxDataBytes(maxBytes, state.Validators.Size(), len(evidence))
maxDataBytes := types.MaxDataBytes(maxBytes, evSize, state.Validators.Size())
txs := blockExec.mempool.ReapMaxBytesMaxGas(maxDataBytes, maxGas)
return state.MakeBlock(height, txs, commit, evidence, proposerAddr)

View File

@@ -61,11 +61,11 @@ func (_m *EvidencePool) CheckEvidence(_a0 types.EvidenceList) error {
}
// PendingEvidence provides a mock function with given fields: _a0
func (_m *EvidencePool) PendingEvidence(_a0 uint32) []types.Evidence {
func (_m *EvidencePool) PendingEvidence(_a0 int64) ([]types.Evidence, int64) {
ret := _m.Called(_a0)
var r0 []types.Evidence
if rf, ok := ret.Get(0).(func(uint32) []types.Evidence); ok {
if rf, ok := ret.Get(0).(func(int64) []types.Evidence); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
@@ -73,7 +73,14 @@ func (_m *EvidencePool) PendingEvidence(_a0 uint32) []types.Evidence {
}
}
return r0
var r1 int64
if rf, ok := ret.Get(1).(func(int64) int64); ok {
r1 = rf(_a0)
} else {
r1 = ret.Get(1).(int64)
}
return r0, r1
}
// Update provides a mock function with given fields: _a0

View File

@@ -43,7 +43,7 @@ type BlockStore interface {
// EvidencePool defines the EvidencePool interface used by State.
type EvidencePool interface {
PendingEvidence(uint32) []types.Evidence
PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
AddEvidence(types.Evidence) error
Update(State)
CheckEvidence(types.EvidenceList) error
@@ -54,7 +54,9 @@ type EvidencePool interface {
// to the consensus evidence pool interface
type EmptyEvidencePool struct{}
func (EmptyEvidencePool) PendingEvidence(uint32) []types.Evidence { return nil }
func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) {
return nil, 0
}
func (EmptyEvidencePool) AddEvidence(types.Evidence) error { return nil }
func (EmptyEvidencePool) Update(State) {}
func (EmptyEvidencePool) CheckEvidence(evList types.EvidenceList) error { return nil }

View File

@@ -8,10 +8,9 @@ import (
// TxPreCheck returns a function to filter transactions before processing.
// The function limits the size of a transaction to the block's maximum data size.
func TxPreCheck(state State) mempl.PreCheckFunc {
maxDataBytes := types.MaxDataBytesUnknownEvidence(
maxDataBytes := types.MaxDataBytesNoEvidence(
state.ConsensusParams.Block.MaxBytes,
state.Validators.Size(),
state.ConsensusParams.Evidence.MaxNum,
)
return mempl.PreCheckMaxBytes(maxDataBytes)
}

View File

@@ -17,7 +17,7 @@ import (
func TestTxFilter(t *testing.T) {
genDoc := randomGenesisDoc()
genDoc.ConsensusParams.Block.MaxBytes = 3000
genDoc.ConsensusParams.Evidence.MaxNum = 1
genDoc.ConsensusParams.Evidence.MaxBytes = 1500
// Max size of Txs is much smaller than size of block,
// since we need to account for commits and evidence.
@@ -25,8 +25,8 @@ func TestTxFilter(t *testing.T) {
tx types.Tx
isErr bool
}{
{types.Tx(tmrand.Bytes(1680)), false},
{types.Tx(tmrand.Bytes(1853)), true},
{types.Tx(tmrand.Bytes(2187)), false},
{types.Tx(tmrand.Bytes(2188)), true},
{types.Tx(tmrand.Bytes(3000)), true},
}
@@ -37,7 +37,7 @@ func TestTxFilter(t *testing.T) {
state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc)
require.NoError(t, err)
f := sm.TxPreCheck(state) // current max size of a tx 1850
f := sm.TxPreCheck(state)
if tc.isErr {
assert.NotNil(t, f(tc.tx), "#%v", i)
} else {

View File

@@ -142,8 +142,8 @@ func validateBlock(evidencePool EvidencePool, state State, block *types.Block) e
block.Height, state.InitialHeight)
}
// Check evidence doesn't exceed the limit. MaxNumEvidence is capped at uint16, so conversion is always safe.
if max, got := int(state.ConsensusParams.Evidence.MaxNum), len(block.Evidence.Evidence); got > max {
// Check evidence doesn't exceed the limit amount of bytes.
if max, got := state.ConsensusParams.Evidence.MaxBytes, block.Evidence.ByteSize(); got > max {
return types.NewErrEvidenceOverflow(max, got)
}

View File

@@ -222,7 +222,7 @@ func TestValidateBlockEvidence(t *testing.T) {
evpool.On("ABCIEvidence", mock.AnythingOfType("int64"), mock.AnythingOfType("[]types.Evidence")).Return(
[]abci.Evidence{})
state.ConsensusParams.Evidence.MaxNum = 3
state.ConsensusParams.Evidence.MaxBytes = 1000
blockExec := sm.NewBlockExecutor(
stateStore,
log.TestingLogger(),
@@ -234,17 +234,19 @@ func TestValidateBlockEvidence(t *testing.T) {
for height := int64(1); height < validationTestsStopHeight; height++ {
proposerAddr := state.Validators.GetProposer().Address
maxNumEvidence := state.ConsensusParams.Evidence.MaxNum
maxBytesEvidence := state.ConsensusParams.Evidence.MaxBytes
if height > 1 {
/*
A block with too much evidence fails
*/
require.True(t, maxNumEvidence > 2)
evidence := make([]types.Evidence, 0)
// one more than the maximum allowed evidence
for i := uint32(0); i <= maxNumEvidence; i++ {
evidence = append(evidence, types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(),
privVals[proposerAddr.String()], chainID))
var currentBytes int64 = 0
// more bytes than the maximum allowed for evidence
for currentBytes <= maxBytesEvidence {
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(),
privVals[proposerAddr.String()], chainID)
evidence = append(evidence, newEv)
currentBytes += int64(len(newEv.Bytes()))
}
block, _ := state.MakeBlock(height, makeTxs(height), lastCommit, evidence, proposerAddr)
err := blockExec.ValidateBlock(state, block)
@@ -257,14 +259,17 @@ func TestValidateBlockEvidence(t *testing.T) {
/*
A good block with several pieces of good evidence passes
*/
require.True(t, maxNumEvidence > 2)
evidence := make([]types.Evidence, 0)
var currentBytes int64 = 0
// precisely the amount of allowed evidence
for i := int32(0); uint32(i) < maxNumEvidence; i++ {
// make different evidence for each validator
_, val := state.Validators.GetByIndex(i)
evidence = append(evidence, types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime,
privVals[val.Address.String()], chainID))
for {
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime,
privVals[proposerAddr.String()], chainID)
currentBytes += int64(len(newEv.Bytes()))
if currentBytes >= maxBytesEvidence {
break
}
evidence = append(evidence, newEv)
}
var err error

View File

@@ -273,12 +273,12 @@ func BlockFromProto(bp *tmproto.Block) (*Block, error) {
// MaxDataBytes returns the maximum size of block's data.
//
// XXX: Panics on negative result.
func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64 {
func MaxDataBytes(maxBytes, evidenceBytes int64, valsCount int) int64 {
maxDataBytes := maxBytes -
MaxOverheadForBlock -
MaxHeaderBytes -
int64(valsCount)*MaxVoteBytes -
int64(evidenceCount)*MaxEvidenceBytes
MaxCommitBytes(valsCount) -
evidenceBytes
if maxDataBytes < 0 {
panic(fmt.Sprintf(
@@ -289,21 +289,18 @@ func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64 {
}
return maxDataBytes
}
// MaxDataBytesUnknownEvidence returns the maximum size of block's data when
// MaxDataBytesNoEvidence returns the maximum size of block's data when
// evidence count is unknown. MaxEvidencePerBlock will be used for the size
// of evidence.
//
// XXX: Panics on negative result.
func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int, maxNumEvidence uint32) int64 {
maxEvidenceBytes := int64(maxNumEvidence) * MaxEvidenceBytes
func MaxDataBytesNoEvidence(maxBytes int64, valsCount int) int64 {
maxDataBytes := maxBytes -
MaxOverheadForBlock -
MaxHeaderBytes -
int64(valsCount)*MaxVoteBytes -
maxEvidenceBytes
MaxCommitBytes(valsCount)
if maxDataBytes < 0 {
panic(fmt.Sprintf(
@@ -583,6 +580,14 @@ const (
BlockIDFlagNil
)
const (
// Max size of commit without any commitSigs -> 82 for BlockID, 8 for Height, 4 for Round.
MaxCommitOverheadBytes int64 = 94
// Commit sig size is made up of 32 bytes for the signature, 20 bytes for the address,
// 1 byte for the flag and 14 bytes for the timestamp
MaxCommitSigBytes int64 = 77
)
// CommitSig is a part of the Vote included in a Commit.
type CommitSig struct {
BlockIDFlag BlockIDFlag `json:"block_id_flag"`
@@ -601,9 +606,10 @@ func NewCommitSigForBlock(signature []byte, valAddr Address, ts time.Time) Commi
}
}
// ForBlock returns true if CommitSig is for the block.
func (cs CommitSig) ForBlock() bool {
return cs.BlockIDFlag == BlockIDFlagCommit
func MaxCommitBytes(valCount int) int64 {
// From the repeated commit sig field
var protoEncodingOverhead int64 = 2
return MaxCommitOverheadBytes + ((MaxCommitSigBytes + protoEncodingOverhead) * int64(valCount))
}
// NewCommitSigAbsent returns new CommitSig with BlockIDFlagAbsent. Other
@@ -614,6 +620,11 @@ func NewCommitSigAbsent() CommitSig {
}
}
// ForBlock returns true if CommitSig is for the block.
func (cs CommitSig) ForBlock() bool {
return cs.BlockIDFlag == BlockIDFlagCommit
}
// Absent returns true if CommitSig is absent.
func (cs CommitSig) Absent() bool {
return cs.BlockIDFlag == BlockIDFlagAbsent
@@ -937,10 +948,7 @@ func (commit *Commit) ToProto() *tmproto.Commit {
c.Height = commit.Height
c.Round = commit.Round
c.BlockID = commit.BlockID.ToProto()
if commit.hash != nil {
c.Hash = commit.hash
}
c.BitArray = commit.bitArray.ToProto()
return c
}
@@ -952,8 +960,7 @@ func CommitFromProto(cp *tmproto.Commit) (*Commit, error) {
}
var (
commit = new(Commit)
bitArray *bits.BitArray
commit = new(Commit)
)
bi, err := BlockIDFromProto(&cp.BlockID)
@@ -961,8 +968,6 @@ func CommitFromProto(cp *tmproto.Commit) (*Commit, error) {
return nil, err
}
bitArray.FromProto(cp.BitArray)
sigs := make([]CommitSig, len(cp.Signatures))
for i := range cp.Signatures {
if err := sigs[i].FromProto(cp.Signatures[i]); err != nil {
@@ -974,8 +979,6 @@ func CommitFromProto(cp *tmproto.Commit) (*Commit, error) {
commit.Height = cp.Height
commit.Round = cp.Round
commit.BlockID = *bi
commit.hash = cp.Hash
commit.bitArray = bitArray
return commit, commit.ValidateBasic()
}
@@ -1037,10 +1040,6 @@ func (data *Data) ToProto() tmproto.Data {
tp.Txs = txBzs
}
if data.hash != nil {
tp.Hash = data.hash
}
return *tp
}
@@ -1062,8 +1061,6 @@ func DataFromProto(dp *tmproto.Data) (Data, error) {
data.Txs = Txs{}
}
data.hash = dp.Hash
return *data, nil
}
@@ -1073,8 +1070,9 @@ func DataFromProto(dp *tmproto.Data) (Data, error) {
type EvidenceData struct {
Evidence EvidenceList `json:"evidence"`
// Volatile
hash tmbytes.HexBytes
// Volatile. Used as cache
hash tmbytes.HexBytes
byteSize int64
}
// Hash returns the hash of the data.
@@ -1085,6 +1083,18 @@ func (data *EvidenceData) Hash() tmbytes.HexBytes {
return data.hash
}
// ByteSize returns the total byte size of all the evidence
func (data *EvidenceData) ByteSize() int64 {
if data.byteSize == 0 && len(data.Evidence) != 0 {
pb, err := data.ToProto()
if err != nil {
panic(err)
}
data.byteSize = int64(pb.Size())
}
return data.byteSize
}
// StringIndented returns a string representation of the evidence.
func (data *EvidenceData) StringIndented(indent string) string {
if data == nil {
@@ -1122,10 +1132,6 @@ func (data *EvidenceData) ToProto() (*tmproto.EvidenceData, error) {
}
evi.Evidence = eviBzs
if data.hash != nil {
evi.Hash = data.hash
}
return evi, nil
}
@@ -1144,8 +1150,7 @@ func (data *EvidenceData) FromProto(eviData *tmproto.EvidenceData) error {
eviBzs[i] = evi
}
data.Evidence = eviBzs
data.hash = eviData.GetHash()
data.byteSize = int64(eviData.Size())
return nil
}

View File

@@ -257,6 +257,62 @@ func TestCommitValidateBasic(t *testing.T) {
}
}
func TestMaxCommitSigBytes(t *testing.T) {
// time is varint encoded so need to pick the max.
// year int, month Month, day, hour, min, sec, nsec int, loc *Location
timestamp := time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC)
cs := &CommitSig{
BlockIDFlag: BlockIDFlagNil,
ValidatorAddress: crypto.AddressHash([]byte("validator_address")),
Timestamp: timestamp,
Signature: tmhash.Sum([]byte("signature")),
}
pb := cs.ToProto()
assert.EqualValues(t, MaxCommitSigBytes, pb.Size())
}
func TestMaxCommitBytes(t *testing.T) {
timestamp := time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC)
cs := CommitSig{
BlockIDFlag: BlockIDFlagNil,
ValidatorAddress: crypto.AddressHash([]byte("validator_address")),
Timestamp: timestamp,
Signature: tmhash.Sum([]byte("signature")),
}
// check size with a single commit
commit := &Commit{
Height: math.MaxInt64,
Round: math.MaxInt32,
BlockID: BlockID{
Hash: tmhash.Sum([]byte("blockID_hash")),
PartSetHeader: PartSetHeader{
Total: math.MaxInt32,
Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")),
},
},
Signatures: []CommitSig{cs},
}
pb := commit.ToProto()
assert.EqualValues(t, MaxCommitBytes(1), int64(pb.Size()))
// check the upper bound of the commit size
for i := 1; i < MaxVotesCount; i++ {
commit.Signatures = append(commit.Signatures, cs)
}
pb = commit.ToProto()
assert.EqualValues(t, MaxCommitBytes(MaxVotesCount), int64(pb.Size()))
}
func TestHeaderHash(t *testing.T) {
testCases := []struct {
desc string
@@ -401,58 +457,56 @@ func TestBlockMaxDataBytes(t *testing.T) {
testCases := []struct {
maxBytes int64
valsCount int
evidenceCount int
evidenceBytes int64
panics bool
result int64
}{
0: {-10, 1, 0, true, 0},
1: {10, 1, 0, true, 0},
2: {844, 1, 0, true, 0},
3: {846, 1, 0, false, 0},
4: {847, 1, 0, false, 1},
2: {809, 1, 0, true, 0},
3: {810, 1, 0, false, 0},
4: {811, 1, 0, false, 1},
}
for i, tc := range testCases {
tc := tc
if tc.panics {
assert.Panics(t, func() {
MaxDataBytes(tc.maxBytes, tc.valsCount, tc.evidenceCount)
MaxDataBytes(tc.maxBytes, tc.evidenceBytes, tc.valsCount)
}, "#%v", i)
} else {
assert.Equal(t,
tc.result,
MaxDataBytes(tc.maxBytes, tc.valsCount, tc.evidenceCount),
MaxDataBytes(tc.maxBytes, tc.evidenceBytes, tc.valsCount),
"#%v", i)
}
}
}
func TestBlockMaxDataBytesUnknownEvidence(t *testing.T) {
func TestBlockMaxDataBytesNoEvidence(t *testing.T) {
testCases := []struct {
maxBytes int64
maxEvidence uint32
valsCount int
panics bool
result int64
maxBytes int64
valsCount int
panics bool
result int64
}{
0: {-10, 0, 1, true, 0},
1: {10, 0, 1, true, 0},
2: {845, 0, 1, true, 0},
3: {846, 0, 1, false, 0},
4: {1290, 1, 1, false, 0},
5: {1291, 1, 1, false, 1},
0: {-10, 1, true, 0},
1: {10, 1, true, 0},
2: {809, 1, true, 0},
3: {810, 1, false, 0},
4: {811, 1, false, 1},
}
for i, tc := range testCases {
tc := tc
if tc.panics {
assert.Panics(t, func() {
MaxDataBytesUnknownEvidence(tc.maxBytes, tc.valsCount, tc.maxEvidence)
MaxDataBytesNoEvidence(tc.maxBytes, tc.valsCount)
}, "#%v", i)
} else {
assert.Equal(t,
tc.result,
MaxDataBytesUnknownEvidence(tc.maxBytes, tc.valsCount, tc.maxEvidence),
MaxDataBytesNoEvidence(tc.maxBytes, tc.valsCount),
"#%v", i)
}
}
@@ -620,7 +674,7 @@ func TestBlockProtoBuf(t *testing.T) {
require.NoError(t, err, tc.msg)
require.EqualValues(t, tc.b1.Header, block.Header, tc.msg)
require.EqualValues(t, tc.b1.Data, block.Data, tc.msg)
require.EqualValues(t, tc.b1.Evidence, block.Evidence, tc.msg)
require.EqualValues(t, tc.b1.Evidence.Evidence, block.Evidence.Evidence, tc.msg)
require.EqualValues(t, *tc.b1.LastCommit, *block.LastCommit, tc.msg)
} else {
require.Error(t, err, tc.msg)
@@ -630,9 +684,7 @@ func TestBlockProtoBuf(t *testing.T) {
func TestDataProtoBuf(t *testing.T) {
data := &Data{Txs: Txs{Tx([]byte{1}), Tx([]byte{2}), Tx([]byte{3})}}
_ = data.Hash()
data2 := &Data{Txs: Txs{}}
_ = data2.Hash()
testCases := []struct {
msg string
data1 *Data
@@ -653,6 +705,7 @@ func TestDataProtoBuf(t *testing.T) {
}
}
// TestEvidenceDataProtoBuf ensures parity in converting to and from proto.
func TestEvidenceDataProtoBuf(t *testing.T) {
val := NewMockPV()
blockID := makeBlockID(tmhash.Sum([]byte("blockhash")), math.MaxInt32, tmhash.Sum([]byte("partshash")))
@@ -662,7 +715,7 @@ func TestEvidenceDataProtoBuf(t *testing.T) {
v2 := makeVote(t, val, chainID, math.MaxInt32, math.MaxInt64, 2, 0x01, blockID2, time.Now())
ev := NewDuplicateVoteEvidence(v2, v)
data := &EvidenceData{Evidence: EvidenceList{ev}}
_ = data.Hash()
_ = data.ByteSize()
testCases := []struct {
msg string
data1 *EvidenceData

View File

@@ -25,11 +25,6 @@ type Evidence interface {
String() string // string format of the evidence
}
const (
// MaxEvidenceBytes is a maximum size of any evidence (including amino overhead).
MaxEvidenceBytes int64 = 444
)
//--------------------------------------------------------------------------------------
// DuplicateVoteEvidence contains evidence a validator signed two conflicting
@@ -365,20 +360,20 @@ func (err *ErrInvalidEvidence) Error() string {
return fmt.Sprintf("Invalid evidence: %v. Evidence: %v", err.Reason, err.Evidence)
}
// ErrEvidenceOverflow is for when there is too much evidence in a block.
// ErrEvidenceOverflow is for when there the amount of evidence exceeds the max bytes.
type ErrEvidenceOverflow struct {
MaxNum int
GotNum int
Max int64
Got int64
}
// NewErrEvidenceOverflow returns a new ErrEvidenceOverflow where got > max.
func NewErrEvidenceOverflow(max, got int) *ErrEvidenceOverflow {
func NewErrEvidenceOverflow(max, got int64) *ErrEvidenceOverflow {
return &ErrEvidenceOverflow{max, got}
}
// Error returns a string representation of the error.
func (err *ErrEvidenceOverflow) Error() string {
return fmt.Sprintf("Too much evidence: Max %d, got %d", err.MaxNum, err.GotNum)
return fmt.Sprintf("Too much evidence: Max %d, got %d", err.Max, err.Got)
}
//-------------------------------------------- MOCKING --------------------------------------

View File

@@ -27,37 +27,6 @@ func TestEvidenceList(t *testing.T) {
assert.False(t, evl.Has(&DuplicateVoteEvidence{}))
}
func TestMaxEvidenceBytes(t *testing.T) {
val := NewMockPV()
blockID := makeBlockID(tmhash.Sum([]byte("blockhash")), math.MaxInt32, tmhash.Sum([]byte("partshash")))
blockID2 := makeBlockID(tmhash.Sum([]byte("blockhash2")), math.MaxInt32, tmhash.Sum([]byte("partshash")))
maxTime := time.Date(9999, 0, 0, 0, 0, 0, 0, time.UTC)
const chainID = "mychain"
ev := &DuplicateVoteEvidence{
VoteA: makeVote(t, val, chainID, math.MaxInt32, math.MaxInt64, math.MaxInt32, math.MaxInt64, blockID, maxTime),
VoteB: makeVote(t, val, chainID, math.MaxInt32, math.MaxInt64, math.MaxInt32, math.MaxInt64, blockID2, maxTime),
}
//TODO: Add other types of evidence to test and set MaxEvidenceBytes accordingly
testCases := []struct {
testName string
evidence Evidence
}{
{"DuplicateVote", ev},
}
for _, tt := range testCases {
pb, err := EvidenceToProto(tt.evidence)
require.NoError(t, err, tt.testName)
bz, err := pb.Marshal()
require.NoError(t, err, tt.testName)
assert.LessOrEqual(t, int64(len(bz)), MaxEvidenceBytes, tt.testName)
}
}
func randomDuplicateVoteEvidence(t *testing.T) *DuplicateVoteEvidence {
val := NewMockPV()
blockID := makeBlockID([]byte("blockhash"), 1000, []byte("partshash"))

View File

@@ -19,9 +19,6 @@ const (
// MaxBlockPartsCount is the maximum number of block parts.
MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1
// Restrict the upper bound of the amount of evidence (uses uint16 for safe conversion)
MaxEvidencePerBlock = 65535
)
// DefaultConsensusParams returns a default ConsensusParams.
@@ -48,7 +45,7 @@ func DefaultEvidenceParams() tmproto.EvidenceParams {
return tmproto.EvidenceParams{
MaxAgeNumBlocks: 100000, // 27.8 hrs at 1block/s
MaxAgeDuration: 48 * time.Hour,
MaxNum: 50,
MaxBytes: 1048576, // 1MB
}
}
@@ -98,23 +95,23 @@ func ValidateConsensusParams(params tmproto.ConsensusParams) error {
}
if params.Evidence.MaxAgeNumBlocks <= 0 {
return fmt.Errorf("evidenceParams.MaxAgeNumBlocks must be greater than 0. Got %d",
return fmt.Errorf("evidence.MaxAgeNumBlocks must be greater than 0. Got %d",
params.Evidence.MaxAgeNumBlocks)
}
if params.Evidence.MaxAgeDuration <= 0 {
return fmt.Errorf("evidenceParams.MaxAgeDuration must be grater than 0 if provided, Got %v",
return fmt.Errorf("evidence.MaxAgeDuration must be grater than 0 if provided, Got %v",
params.Evidence.MaxAgeDuration)
}
if params.Evidence.MaxNum > MaxEvidencePerBlock {
return fmt.Errorf("evidenceParams.MaxNumEvidence is greater than upper bound, %d > %d",
params.Evidence.MaxNum, MaxEvidencePerBlock)
if params.Evidence.MaxBytes > params.Block.MaxBytes {
return fmt.Errorf("evidence.MaxBytesEvidence is greater than upper bound, %d > %d",
params.Evidence.MaxBytes, params.Block.MaxBytes)
}
if int64(params.Evidence.MaxNum)*MaxEvidenceBytes > params.Block.MaxBytes {
return fmt.Errorf("total possible evidence size is bigger than block.MaxBytes, %d > %d",
int64(params.Evidence.MaxNum)*MaxEvidenceBytes, params.Block.MaxBytes)
if params.Evidence.MaxBytes < 0 {
return fmt.Errorf("evidence.MaxBytes must be non negative. Got: %d",
params.Evidence.MaxBytes)
}
if len(params.Validator.PubKeyTypes) == 0 {
@@ -174,7 +171,7 @@ func UpdateConsensusParams(params tmproto.ConsensusParams, params2 *abci.Consens
if params2.Evidence != nil {
res.Evidence.MaxAgeNumBlocks = params2.Evidence.MaxAgeNumBlocks
res.Evidence.MaxAgeDuration = params2.Evidence.MaxAgeDuration
res.Evidence.MaxNum = params2.Evidence.MaxNum
res.Evidence.MaxBytes = params2.Evidence.MaxBytes
}
if params2.Validator != nil {
// Copy params2.Validator.PubkeyTypes, and set result's value to the copy.

View File

@@ -33,7 +33,7 @@ func TestConsensusParamsValidation(t *testing.T) {
8: {makeParams(1, 0, -10, 2, 0, valEd25519), false},
// test evidence params
9: {makeParams(1, 0, 10, 0, 0, valEd25519), false},
10: {makeParams(1, 0, 10, 2, 1, valEd25519), false},
10: {makeParams(1, 0, 10, 2, 2, valEd25519), false},
11: {makeParams(1000, 0, 10, 2, 1, valEd25519), true},
12: {makeParams(1, 0, 10, -1, 0, valEd25519), false},
// test no pubkey type provided
@@ -54,7 +54,7 @@ func makeParams(
blockBytes, blockGas int64,
blockTimeIotaMs int64,
evidenceAge int64,
maxEvidence uint32,
maxEvidenceBytes int64,
pubkeyTypes []string,
) tmproto.ConsensusParams {
return tmproto.ConsensusParams{
@@ -66,7 +66,7 @@ func makeParams(
Evidence: tmproto.EvidenceParams{
MaxAgeNumBlocks: evidenceAge,
MaxAgeDuration: time.Duration(evidenceAge),
MaxNum: maxEvidence,
MaxBytes: maxEvidenceBytes,
},
Validator: tmproto.ValidatorParams{
PubKeyTypes: pubkeyTypes,
@@ -124,7 +124,7 @@ func TestConsensusParamsUpdate(t *testing.T) {
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: 300,
MaxAgeDuration: time.Duration(300),
MaxNum: 50,
MaxBytes: 50,
},
Validator: &tmproto.ValidatorParams{
PubKeyTypes: valEd25519,

View File

@@ -121,7 +121,7 @@ func (psh PartSetHeader) ValidateBasic() error {
return nil
}
// ToProto converts BloPartSetHeaderckID to protobuf
// ToProto converts PartSetHeader to protobuf
func (psh *PartSetHeader) ToProto() tmproto.PartSetHeader {
if psh == nil {
return tmproto.PartSetHeader{}
@@ -155,6 +155,9 @@ type PartSet struct {
parts []*Part
partsBitArray *bits.BitArray
count uint32
// a count of the total size (in bytes). Used to ensure that the
// part set doesn't exceed the maximum block bytes
byteSize int64
}
// Returns an immutable, full PartSet from the data bytes.
@@ -186,6 +189,7 @@ func NewPartSetFromData(data []byte, partSize uint32) *PartSet {
parts: parts,
partsBitArray: partsBitArray,
count: total,
byteSize: int64(len(data)),
}
}
@@ -197,6 +201,7 @@ func NewPartSetFromHeader(header PartSetHeader) *PartSet {
parts: make([]*Part, header.Total),
partsBitArray: bits.NewBitArray(int(header.Total)),
count: 0,
byteSize: 0,
}
}
@@ -244,6 +249,13 @@ func (ps *PartSet) Count() uint32 {
return ps.count
}
func (ps *PartSet) ByteSize() int64 {
if ps == nil {
return 0
}
return ps.byteSize
}
func (ps *PartSet) Total() uint32 {
if ps == nil {
return 0
@@ -277,6 +289,7 @@ func (ps *PartSet) AddPart(part *Part) (bool, error) {
ps.parts[part.Index] = part
ps.partsBitArray.SetIndex(int(part.Index), true)
ps.count++
ps.byteSize += int64(len(part.Bytes))
return true, nil
}

View File

@@ -17,15 +17,17 @@ const (
func TestBasicPartSet(t *testing.T) {
// Construct random data of size partSize * 100
data := tmrand.Bytes(testPartSize * 100)
nParts := 100
data := tmrand.Bytes(testPartSize * nParts)
partSet := NewPartSetFromData(data, testPartSize)
assert.NotEmpty(t, partSet.Hash())
assert.EqualValues(t, 100, partSet.Total())
assert.Equal(t, 100, partSet.BitArray().Size())
assert.EqualValues(t, nParts, partSet.Total())
assert.Equal(t, nParts, partSet.BitArray().Size())
assert.True(t, partSet.HashesTo(partSet.Hash()))
assert.True(t, partSet.IsComplete())
assert.EqualValues(t, 100, partSet.Count())
assert.EqualValues(t, nParts, partSet.Count())
assert.EqualValues(t, testPartSize*nParts, partSet.ByteSize())
// Test adding parts to a new partSet.
partSet2 := NewPartSetFromHeader(partSet.Header())
@@ -49,7 +51,8 @@ func TestBasicPartSet(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, partSet.Hash(), partSet2.Hash())
assert.EqualValues(t, 100, partSet2.Total())
assert.EqualValues(t, nParts, partSet2.Total())
assert.EqualValues(t, nParts*testPartSize, partSet.ByteSize())
assert.True(t, partSet2.IsComplete())
// Reconstruct data, assert that they are equal.

View File

@@ -137,3 +137,11 @@ func TxProofFromProto(pb tmproto.TxProof) (TxProof, error) {
return pbtp, nil
}
// ComputeProtoSizeForTxs wraps the transactions in tmproto.Data{} and calculates the size.
// https://developers.google.com/protocol-buffers/docs/encoding
func ComputeProtoSizeForTxs(txs []Tx) int64 {
data := Data{Txs: txs}
pdData := data.ToProto()
return int64(pdData.Size())
}

View File

@@ -13,9 +13,7 @@ import (
)
const (
// MaxVoteBytes is a maximum vote size (including amino overhead).
MaxVoteBytes int64 = 209
nilVoteStr string = "nil-Vote"
nilVoteStr string = "nil-Vote"
)
var (

View File

@@ -1,7 +1,6 @@
package types
import (
"math"
"testing"
"time"
@@ -218,38 +217,6 @@ func TestVoteVerify(t *testing.T) {
}
}
func TestMaxVoteBytes(t *testing.T) {
// time is varint encoded so need to pick the max.
// year int, month Month, day, hour, min, sec, nsec int, loc *Location
timestamp := time.Date(math.MaxInt64, 0, 0, 0, 0, 0, math.MaxInt64, time.UTC)
vote := &Vote{
ValidatorAddress: crypto.AddressHash([]byte("validator_address")),
ValidatorIndex: math.MaxInt32,
Height: math.MaxInt64,
Round: math.MaxInt32,
Timestamp: timestamp,
Type: tmproto.PrevoteType,
BlockID: BlockID{
Hash: tmhash.Sum([]byte("blockID_hash")),
PartSetHeader: PartSetHeader{
Total: math.MaxInt32,
Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")),
},
},
}
v := vote.ToProto()
privVal := NewMockPV()
err := privVal.SignVote("test_chain_id", v)
require.NoError(t, err)
bz, err := proto.Marshal(v)
require.NoError(t, err)
assert.EqualValues(t, MaxVoteBytes, len(bz))
}
func TestVoteString(t *testing.T) {
str := examplePrecommit().String()
expected := `Vote{56789:6AF1F4111082 12345/02/SIGNED_MSG_TYPE_PRECOMMIT(Precommit) 8B01023386C3 000000000000 @ 2017-12-25T03:00:01.234Z}` //nolint:lll //ignore line length for tests