core: remove config fields related to free transactions

In NEO3 every transaction must have some gas attached.

Closes #1064.
This commit is contained in:
Evgenii Stratonikov 2020-06-18 22:21:19 +03:00
parent 84387b2416
commit 2f724b792c
4 changed files with 1 additions and 43 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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"`

View file

@ -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: