From 2f724b792c62f465ece9627fb82d03640ab02bb7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 18 Jun 2020 22:21:19 +0300 Subject: [PATCH] core: remove config fields related to free transactions In NEO3 every transaction must have some gas attached. Closes #1064. --- config/protocol.mainnet.yml | 3 --- config/protocol.testnet.yml | 3 --- pkg/config/protocol_config.go | 9 +-------- pkg/core/blockchain.go | 29 ----------------------------- 4 files changed, 1 insertion(+), 43 deletions(-) diff --git a/config/protocol.mainnet.yml b/config/protocol.mainnet.yml index 8088ae6bb..0c8644653 100644 --- a/config/protocol.mainnet.yml +++ b/config/protocol.mainnet.yml @@ -20,9 +20,6 @@ ProtocolConfiguration: VerifyBlocks: true VerifyTransactions: false MaxTransactionsPerBlock: 500 - MaxFreeTransactionsPerBlock: 20 - MaxFreeTransactionSize: 1024 - FeePerExtraByte: 0.00001 ApplicationConfiguration: # LogPath could be set up in case you need stdout logs to some proper file. diff --git a/config/protocol.testnet.yml b/config/protocol.testnet.yml index 41ca65e51..4e6f63d71 100644 --- a/config/protocol.testnet.yml +++ b/config/protocol.testnet.yml @@ -20,9 +20,6 @@ ProtocolConfiguration: VerifyBlocks: true VerifyTransactions: false MaxTransactionsPerBlock: 500 - MaxFreeTransactionsPerBlock: 20 - MaxFreeTransactionSize: 1024 - FeePerExtraByte: 0.00001 ApplicationConfiguration: # LogPath could be set up in case you need stdout logs to some proper file. diff --git a/pkg/config/protocol_config.go b/pkg/config/protocol_config.go index 96cba7502..78bda30b7 100644 --- a/pkg/config/protocol_config.go +++ b/pkg/config/protocol_config.go @@ -7,17 +7,10 @@ import ( // ProtocolConfiguration represents the protocol config. type ( ProtocolConfiguration struct { - // FeePerExtraByte sets the expected per-byte fee for - // transactions exceeding the MaxFreeTransactionSize. - FeePerExtraByte float64 `yaml:"FeePerExtraByte"` LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"` Magic netmode.Magic `yaml:"Magic"` MaxTransactionsPerBlock int `yaml:"MaxTransactionsPerBlock"` - // Maximum size of low priority transaction in bytes. - MaxFreeTransactionSize int `yaml:"MaxFreeTransactionSize"` - // Maximum number of low priority transactions accepted into block. - MaxFreeTransactionsPerBlock int `yaml:"MaxFreeTransactionsPerBlock"` - MemPoolSize int `yaml:"MemPoolSize"` + MemPoolSize int `yaml:"MemPoolSize"` // SaveStorageBatch enables storage batch saving before every persist. SaveStorageBatch bool `yaml:"SaveStorageBatch"` SecondsPerBlock int `yaml:"SecondsPerBlock"` diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index cfec49171..8969d1aa0 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -156,18 +156,6 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L cfg.MaxTransactionsPerBlock = 0 log.Info("MaxTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxTransactionsPerBlock", cfg.MaxTransactionsPerBlock)) } - if cfg.MaxFreeTransactionsPerBlock <= 0 { - cfg.MaxFreeTransactionsPerBlock = 0 - log.Info("MaxFreeTransactionsPerBlock is not set or wrong, setting default value (unlimited)", zap.Int("MaxFreeTransactionsPerBlock", cfg.MaxFreeTransactionsPerBlock)) - } - if cfg.MaxFreeTransactionSize <= 0 { - cfg.MaxFreeTransactionSize = 0 - log.Info("MaxFreeTransactionSize is not set or wrong, setting default value (unlimited)", zap.Int("MaxFreeTransactionSize", cfg.MaxFreeTransactionSize)) - } - if cfg.FeePerExtraByte <= 0 { - cfg.FeePerExtraByte = 0 - log.Info("FeePerExtraByte is not set or wrong, setting default value", zap.Float64("FeePerExtraByte", cfg.FeePerExtraByte)) - } bc := &Blockchain{ config: cfg, dao: dao.NewSimple(s, cfg.Magic), @@ -1117,15 +1105,6 @@ func (bc *Blockchain) ApplyPolicyToTxSet(txes []*transaction.Transaction) []*tra if bc.config.MaxTransactionsPerBlock != 0 && len(txes) > bc.config.MaxTransactionsPerBlock { txes = txes[:bc.config.MaxTransactionsPerBlock] } - maxFree := bc.config.MaxFreeTransactionsPerBlock - if maxFree != 0 { - lowStart := sort.Search(len(txes), func(i int) bool { - return bc.IsLowPriority(txes[i].NetworkFee) - }) - if lowStart+maxFree < len(txes) { - txes = txes[:lowStart+maxFree] - } - } return txes } @@ -1225,14 +1204,6 @@ func (bc *Blockchain) PoolTx(t *transaction.Transaction) error { return err } // Policying. - txSize := io.GetVarSize(t) - maxFree := bc.config.MaxFreeTransactionSize - if maxFree != 0 && txSize > maxFree { - if bc.IsLowPriority(t.NetworkFee) || - t.NetworkFee < util.Fixed8FromFloat(bc.config.FeePerExtraByte)*util.Fixed8(txSize-maxFree) { - return ErrPolicy - } - } if err := bc.memPool.Add(t, bc); err != nil { switch err { case mempool.ErrOOM: