Merge pull request #2826 from nspcc-dev/check-for-max-block-sysfee

core: filter out txes with system fee > MaxBlockSystemFee
This commit is contained in:
Roman Khimov 2022-11-29 14:57:10 +07:00 committed by GitHub
commit 6912695b9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -2467,6 +2467,9 @@ func (bc *Blockchain) verifyAndPoolTx(t *transaction.Transaction, pool *mempool.
// Only one %w can be used.
return fmt.Errorf("%w: %v", ErrPolicy, err)
}
if t.SystemFee > bc.config.MaxBlockSystemFee {
return fmt.Errorf("%w: too big system fee (%d > MaxBlockSystemFee %d)", ErrPolicy, t.SystemFee, bc.config.MaxBlockSystemFee)
}
size := t.Size()
if size > transaction.MaxTransactionSize {
return fmt.Errorf("%w: (%d > MaxTransactionSize %d)", ErrTxTooBig, size, transaction.MaxTransactionSize)

View file

@ -1131,6 +1131,12 @@ func TestBlockchain_VerifyTx(t *testing.T) {
require.NoError(t, accs[0].SignTx(netmode.UnitTestNet, tx))
checkErr(t, core.ErrInsufficientFunds, tx)
})
t.Run("TooBigSystemFee", func(t *testing.T) {
tx := newTestTx(t, h, testScript)
tx.SystemFee = bc.GetConfig().MaxBlockSystemFee + 100500
require.NoError(t, accs[0].SignTx(netmode.UnitTestNet, tx))
checkErr(t, core.ErrPolicy, tx)
})
t.Run("TooBigTx", func(t *testing.T) {
script := make([]byte, transaction.MaxTransactionSize)
tx := newTestTx(t, h, script)