consensus: check transactions count during PrepareRequest verification
This commit is contained in:
parent
23a3514cc0
commit
38103dcc7a
2 changed files with 14 additions and 3 deletions
|
@ -466,9 +466,10 @@ func (s *service) verifyBlock(b block.Block) bool {
|
|||
}
|
||||
|
||||
var (
|
||||
errInvalidPrevHash = errors.New("invalid PrevHash")
|
||||
errInvalidVersion = errors.New("invalid Version")
|
||||
errInvalidStateRoot = errors.New("state root mismatch")
|
||||
errInvalidPrevHash = errors.New("invalid PrevHash")
|
||||
errInvalidVersion = errors.New("invalid Version")
|
||||
errInvalidStateRoot = errors.New("state root mismatch")
|
||||
errInvalidTransactionsCount = errors.New("invalid transactions count")
|
||||
)
|
||||
|
||||
func (s *service) verifyRequest(p payload.ConsensusPayload) error {
|
||||
|
@ -487,6 +488,9 @@ func (s *service) verifyRequest(p payload.ConsensusPayload) error {
|
|||
return fmt.Errorf("%w: %s != %s", errInvalidStateRoot, sr.Root, req.stateRoot)
|
||||
}
|
||||
}
|
||||
if len(req.TransactionHashes()) > int(s.ProtocolConfiguration.MaxTransactionsPerBlock) {
|
||||
return fmt.Errorf("%w: max = %d, got %d", errInvalidTransactionsCount, s.ProtocolConfiguration.MaxTransactionsPerBlock, len(req.TransactionHashes()))
|
||||
}
|
||||
// Save lastProposal for getVerified().
|
||||
s.lastProposal = req.transactionHashes
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue