From d6784e8f45ab68e93fe8d62390473b723da27012 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 22 Jan 2020 17:28:02 +0300 Subject: [PATCH] config: add MemPoolSize configuration parameter Allow tuning/experimenting with mempool. --- config/config.go | 1 + config/protocol.mainnet.yml | 1 + config/protocol.privnet.docker.four.yml | 1 + config/protocol.privnet.docker.one.yml | 1 + config/protocol.privnet.docker.single.yml | 1 + config/protocol.privnet.docker.three.yml | 1 + config/protocol.privnet.docker.two.yml | 1 + config/protocol.privnet.yml | 1 + config/protocol.testnet.yml | 1 + config/protocol.unit_testnet.yml | 1 + pkg/core/blockchain.go | 8 +++++++- 11 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index bda9d07c4..f45430432 100644 --- a/config/config.go +++ b/config/config.go @@ -47,6 +47,7 @@ type ( SecondsPerBlock int `yaml:"SecondsPerBlock"` LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"` MaxTransactionsPerBlock int64 `yaml:"MaxTransactionsPerBlock"` + MemPoolSize int `yaml:"MemPoolSize"` StandbyValidators []string `yaml:"StandbyValidators"` SeedList []string `yaml:"SeedList"` SystemFee SystemFee `yaml:"SystemFee"` diff --git a/config/protocol.mainnet.yml b/config/protocol.mainnet.yml index 2e50755ae..93aeae641 100644 --- a/config/protocol.mainnet.yml +++ b/config/protocol.mainnet.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.001 + MemPoolSize: 50000 StandbyValidators: - 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c - 02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093 diff --git a/config/protocol.privnet.docker.four.yml b/config/protocol.privnet.docker.four.yml index 2fe502d32..94e37b0ff 100644 --- a/config/protocol.privnet.docker.four.yml +++ b/config/protocol.privnet.docker.four.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/config/protocol.privnet.docker.one.yml b/config/protocol.privnet.docker.one.yml index 95792063c..180db8c2b 100644 --- a/config/protocol.privnet.docker.one.yml +++ b/config/protocol.privnet.docker.one.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/config/protocol.privnet.docker.single.yml b/config/protocol.privnet.docker.single.yml index fbc946ac8..1a56ec1ad 100644 --- a/config/protocol.privnet.docker.single.yml +++ b/config/protocol.privnet.docker.single.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 1 LowPriorityThreshold: 0.001 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 SeedList: diff --git a/config/protocol.privnet.docker.three.yml b/config/protocol.privnet.docker.three.yml index b36dae766..4d3ab9553 100644 --- a/config/protocol.privnet.docker.three.yml +++ b/config/protocol.privnet.docker.three.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/config/protocol.privnet.docker.two.yml b/config/protocol.privnet.docker.two.yml index 8406c4a19..1c6f80e02 100644 --- a/config/protocol.privnet.docker.two.yml +++ b/config/protocol.privnet.docker.two.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/config/protocol.privnet.yml b/config/protocol.privnet.yml index 6166bd308..8e2c092d6 100644 --- a/config/protocol.privnet.yml +++ b/config/protocol.privnet.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/config/protocol.testnet.yml b/config/protocol.testnet.yml index f936dc261..91b594bb8 100644 --- a/config/protocol.testnet.yml +++ b/config/protocol.testnet.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 0327da12b5c40200e9f65569476bbff2218da4f32548ff43b6387ec1416a231ee8 - 026ce35b29147ad09e4afe4ec4a7319095f08198fa8babbe3c56e970b143528d22 diff --git a/config/protocol.unit_testnet.yml b/config/protocol.unit_testnet.yml index 09cfef518..7a89c606f 100644 --- a/config/protocol.unit_testnet.yml +++ b/config/protocol.unit_testnet.yml @@ -3,6 +3,7 @@ ProtocolConfiguration: AddressVersion: 23 SecondsPerBlock: 15 LowPriorityThreshold: 0.000 + MemPoolSize: 50000 StandbyValidators: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index c24de0535..4b3fe33d7 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -37,6 +37,8 @@ const ( // contain any relationship between the two, so we should follow this // behavior. registeredAssetLifetime = 2 * 2000000 + + defaultMemPoolSize = 50000 ) var ( @@ -95,6 +97,10 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L return nil, errors.New("empty logger") } + if cfg.MemPoolSize <= 0 { + cfg.MemPoolSize = defaultMemPoolSize + log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize)) + } bc := &Blockchain{ config: cfg, dao: newDao(s), @@ -102,7 +108,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L headersOpDone: make(chan struct{}), stopCh: make(chan struct{}), runToExitCh: make(chan struct{}), - memPool: mempool.NewMemPool(50000), + memPool: mempool.NewMemPool(cfg.MemPoolSize), keyCache: make(map[util.Uint160]map[string]*keys.PublicKey), log: log, }