Merge pull request #1520 from nspcc-dev/tune-some-limits

Tune some limits
This commit is contained in:
Roman Khimov 2020-11-06 15:35:44 +03:00 committed by GitHub
commit bdd073aad7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 31 additions and 13 deletions

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 5195086 Magic: 5195086
MaxTraceableBlocks: 2102400
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 1 SecondsPerBlock: 1
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 56753 Magic: 56753
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 1951352142 Magic: 1951352142
MaxTraceableBlocks: 2102400
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 42 Magic: 42
MaxTraceableBlocks: 200000
SecondsPerBlock: 1 SecondsPerBlock: 1
MemPoolSize: 100 MemPoolSize: 100
StandbyCommittee: StandbyCommittee:

View file

@ -1,5 +1,6 @@
ProtocolConfiguration: ProtocolConfiguration:
Magic: 42 Magic: 42
MaxTraceableBlocks: 200000
SecondsPerBlock: 15 SecondsPerBlock: 15
MemPoolSize: 50000 MemPoolSize: 50000
StandbyCommittee: StandbyCommittee:

View file

@ -9,6 +9,8 @@ type (
ProtocolConfiguration struct { ProtocolConfiguration struct {
Magic netmode.Magic `yaml:"Magic"` Magic netmode.Magic `yaml:"Magic"`
MemPoolSize int `yaml:"MemPoolSize"` MemPoolSize int `yaml:"MemPoolSize"`
// MaxTraceableBlocks is the length of the chain accessible to smart contracts.
MaxTraceableBlocks uint32 `yaml:"MaxTraceableBlocks"`
// P2PSigExtensions enables additional signature-related transaction attributes // P2PSigExtensions enables additional signature-related transaction attributes
P2PSigExtensions bool `yaml:"P2PSigExtensions"` P2PSigExtensions bool `yaml:"P2PSigExtensions"`
// ReservedAttributes allows to have reserved attributes range for experimental or private purposes. // ReservedAttributes allows to have reserved attributes range for experimental or private purposes.

View file

@ -40,8 +40,9 @@ const (
headerBatchCount = 2000 headerBatchCount = 2000
version = "0.1.0" version = "0.1.0"
defaultMemPoolSize = 50000 defaultMemPoolSize = 50000
verificationGasLimit = 100000000 // 1 GAS defaultMaxTraceableBlocks = 2102400 // 1 year of 15s blocks
verificationGasLimit = 100000000 // 1 GAS
) )
var ( var (
@ -148,6 +149,10 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
cfg.MemPoolSize = defaultMemPoolSize cfg.MemPoolSize = defaultMemPoolSize
log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize)) log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize))
} }
if cfg.MaxTraceableBlocks == 0 {
cfg.MaxTraceableBlocks = defaultMaxTraceableBlocks
log.Info("MaxTraceableBlocks is not set or wrong, using default value", zap.Uint32("MaxTraceableBlocks", cfg.MaxTraceableBlocks))
}
committee, err := committeeFromConfig(cfg) committee, err := committeeFromConfig(cfg)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -924,7 +924,7 @@ func TestSubscriptions(t *testing.T) {
txGood1 := transaction.New(netmode.UnitTestNet, script.Bytes(), 0) txGood1 := transaction.New(netmode.UnitTestNet, script.Bytes(), 0)
txGood1.Signers = []transaction.Signer{{Account: neoOwner}} txGood1.Signers = []transaction.Signer{{Account: neoOwner}}
txGood1.Nonce = 1 txGood1.Nonce = 1
txGood1.ValidUntilBlock = 100500 txGood1.ValidUntilBlock = 1024
require.NoError(t, signTx(bc, txGood1)) require.NoError(t, signTx(bc, txGood1))
// Reset() reuses the script buffer and we need to keep scripts. // Reset() reuses the script buffer and we need to keep scripts.
@ -936,7 +936,7 @@ func TestSubscriptions(t *testing.T) {
txBad := transaction.New(netmode.UnitTestNet, script.Bytes(), 0) txBad := transaction.New(netmode.UnitTestNet, script.Bytes(), 0)
txBad.Signers = []transaction.Signer{{Account: neoOwner}} txBad.Signers = []transaction.Signer{{Account: neoOwner}}
txBad.Nonce = 2 txBad.Nonce = 2
txBad.ValidUntilBlock = 100500 txBad.ValidUntilBlock = 1024
require.NoError(t, signTx(bc, txBad)) require.NoError(t, signTx(bc, txBad))
script = io.NewBufBinWriter() script = io.NewBufBinWriter()
@ -946,7 +946,7 @@ func TestSubscriptions(t *testing.T) {
txGood2 := transaction.New(netmode.UnitTestNet, script.Bytes(), 0) txGood2 := transaction.New(netmode.UnitTestNet, script.Bytes(), 0)
txGood2.Signers = []transaction.Signer{{Account: neoOwner}} txGood2.Signers = []transaction.Signer{{Account: neoOwner}}
txGood2.Nonce = 3 txGood2.Nonce = 3
txGood2.ValidUntilBlock = 100500 txGood2.ValidUntilBlock = 1024
require.NoError(t, signTx(bc, txGood2)) require.NoError(t, signTx(bc, txGood2))
invBlock := newBlock(bc.config, bc.BlockHeight()+1, bc.CurrentHeaderHash(), txGood1, txBad, txGood2) invBlock := newBlock(bc.config, bc.BlockHeight()+1, bc.CurrentHeaderHash(), txGood1, txBad, txGood2)

View file

@ -26,9 +26,6 @@ const (
// MaxStorageValueLen is the maximum length of a value for storage items. // MaxStorageValueLen is the maximum length of a value for storage items.
// It is set to be the maximum value for uint16. // It is set to be the maximum value for uint16.
MaxStorageValueLen = 65535 MaxStorageValueLen = 65535
// MaxTraceableBlocks is the maximum number of blocks before current chain
// height we're able to give information about.
MaxTraceableBlocks = transaction.MaxValidUntilBlockIncrement
// MaxEventNameLen is the maximum length of a name for event. // MaxEventNameLen is the maximum length of a name for event.
MaxEventNameLen = 32 MaxEventNameLen = 32
// MaxNotificationSize is the maximum length of a runtime log message. // MaxNotificationSize is the maximum length of a runtime log message.
@ -155,6 +152,7 @@ func getTransactionAndHeight(cd *dao.Cached, v *vm.VM) (*transaction.Transaction
// the block with index specified. // the block with index specified.
func isTraceableBlock(ic *interop.Context, index uint32) bool { func isTraceableBlock(ic *interop.Context, index uint32) bool {
height := ic.Chain.BlockHeight() height := ic.Chain.BlockHeight()
MaxTraceableBlocks := ic.Chain.GetConfig().MaxTraceableBlocks
return index <= height && index+MaxTraceableBlocks > height return index <= height && index+MaxTraceableBlocks > height
} }

View file

@ -2,6 +2,7 @@ package transaction
import ( import (
"errors" "errors"
"math"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
) )
@ -16,7 +17,8 @@ type OracleResponse struct {
Result []byte `json:"result"` Result []byte `json:"result"`
} }
const maxResultSize = 1024 // MaxOracleResultSize is the maximum allowed oracle answer size.
const MaxOracleResultSize = math.MaxUint16
// Enumeration of possible oracle response types. // Enumeration of possible oracle response types.
const ( const (
@ -46,7 +48,7 @@ func (r *OracleResponse) DecodeBinary(br *io.BinReader) {
br.Err = ErrInvalidResponseCode br.Err = ErrInvalidResponseCode
return return
} }
r.Result = br.ReadVarBytes(maxResultSize) r.Result = br.ReadVarBytes(MaxOracleResultSize)
if r.Code != Success && len(r.Result) > 0 { if r.Code != Success && len(r.Result) > 0 {
br.Err = ErrInvalidResult br.Err = ErrInvalidResult
} }

View file

@ -20,9 +20,10 @@ const (
// MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is // MaxTransactionSize is the upper limit size in bytes that a transaction can reach. It is
// set to be 102400. // set to be 102400.
MaxTransactionSize = 102400 MaxTransactionSize = 102400
// MaxValidUntilBlockIncrement is the upper increment size of blockhain height in blocs after // MaxValidUntilBlockIncrement is the upper increment size of blockhain height in blocks
// exceeding that a transaction should fail validation. It is set to be 2102400. // exceeding that a transaction should fail validation. It is set to estimated daily number
MaxValidUntilBlockIncrement = 2102400 // of blocks with 15s interval.
MaxValidUntilBlockIncrement = 5760
// MaxAttributes is maximum number of attributes including signers that can be contained // MaxAttributes is maximum number of attributes including signers that can be contained
// within a transaction. It is set to be 16. // within a transaction. It is set to be 16.
MaxAttributes = 16 MaxAttributes = 16