core/config: move MaxTraceableBlocks to configuration file

Follow neo-project/neo#2042, use 2102400 setting for mainnet/testnet and
200000 for private networks.
This commit is contained in:
Roman Khimov 2020-11-05 22:01:12 +03:00
parent 39a38dc5f5
commit b327308df8
13 changed files with 20 additions and 5 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,6 +9,8 @@ type (
ProtocolConfiguration struct {
Magic netmode.Magic `yaml:"Magic"`
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 bool `yaml:"P2PSigExtensions"`
// ReservedAttributes allows to have reserved attributes range for experimental or private purposes.

View file

@ -40,8 +40,9 @@ const (
headerBatchCount = 2000
version = "0.1.0"
defaultMemPoolSize = 50000
verificationGasLimit = 100000000 // 1 GAS
defaultMemPoolSize = 50000
defaultMaxTraceableBlocks = 2102400 // 1 year of 15s blocks
verificationGasLimit = 100000000 // 1 GAS
)
var (
@ -148,6 +149,10 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
cfg.MemPoolSize = defaultMemPoolSize
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)
if err != nil {
return nil, err

View file

@ -26,9 +26,6 @@ const (
// MaxStorageValueLen is the maximum length of a value for storage items.
// It is set to be the maximum value for uint16.
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 = 32
// 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.
func isTraceableBlock(ic *interop.Context, index uint32) bool {
height := ic.Chain.BlockHeight()
MaxTraceableBlocks := ic.Chain.GetConfig().MaxTraceableBlocks
return index <= height && index+MaxTraceableBlocks > height
}