core: remove transaction priority
There is no such thing as high/low priority transactions, as there are no free transactions anymore and they are ordered by fees contained in transaction itself. Closes #1063.
This commit is contained in:
parent
2f724b792c
commit
5354352d63
17 changed files with 8 additions and 54 deletions
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 5195086
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.001
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 1
|
||||
LowPriorityThreshold: 0.001
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 56753
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 1951352142
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 023e9b32ea89b94d066e649b124fd50e396ee91369e8e2a6ae1b11c170d022256d
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
ProtocolConfiguration:
|
||||
Magic: 42
|
||||
SecondsPerBlock: 15
|
||||
LowPriorityThreshold: 0.000
|
||||
MemPoolSize: 50000
|
||||
StandbyValidators:
|
||||
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
// ProtocolConfiguration represents the protocol config.
|
||||
type (
|
||||
ProtocolConfiguration struct {
|
||||
LowPriorityThreshold float64 `yaml:"LowPriorityThreshold"`
|
||||
Magic netmode.Magic `yaml:"Magic"`
|
||||
MaxTransactionsPerBlock int `yaml:"MaxTransactionsPerBlock"`
|
||||
MemPoolSize int `yaml:"MemPoolSize"`
|
||||
|
|
|
@ -229,10 +229,6 @@ func newTestChain(t *testing.T) *core.Blockchain {
|
|||
return chain
|
||||
}
|
||||
|
||||
type feer struct{}
|
||||
|
||||
func (fs *feer) IsLowPriority(util.Fixed8) bool { return false }
|
||||
|
||||
var neoOwner = testchain.MultisigScriptHash()
|
||||
|
||||
func addSender(t *testing.T, txs ...*transaction.Transaction) {
|
||||
|
|
|
@ -1088,12 +1088,6 @@ func (bc *Blockchain) FeePerByte() util.Fixed8 {
|
|||
return util.Fixed8(1000)
|
||||
}
|
||||
|
||||
// IsLowPriority checks given fee for being less than configured
|
||||
// LowPriorityThreshold.
|
||||
func (bc *Blockchain) IsLowPriority(fee util.Fixed8) bool {
|
||||
return fee < util.Fixed8FromFloat(bc.GetConfig().LowPriorityThreshold)
|
||||
}
|
||||
|
||||
// GetMemPool returns the memory pool of the blockchain.
|
||||
func (bc *Blockchain) GetMemPool() *mempool.Pool {
|
||||
return &bc.memPool
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
// Feer is an interface that abstract the implementation of the fee calculation.
|
||||
type Feer interface {
|
||||
IsLowPriority(util.Fixed8) bool
|
||||
FeePerByte() util.Fixed8
|
||||
GetUtilityTokenBalance(util.Uint160) util.Fixed8
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ var (
|
|||
type item struct {
|
||||
txn *transaction.Transaction
|
||||
timeStamp time.Time
|
||||
isLowPrio bool
|
||||
}
|
||||
|
||||
// items is a slice of item.
|
||||
|
@ -63,14 +62,6 @@ func (p *item) CompareTo(otherP *item) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
if !p.isLowPrio && otherP.isLowPrio {
|
||||
return 1
|
||||
}
|
||||
|
||||
if p.isLowPrio && !otherP.isLowPrio {
|
||||
return -1
|
||||
}
|
||||
|
||||
// Fees sorted ascending.
|
||||
if ret := p.txn.FeePerByte().CompareTo(otherP.txn.FeePerByte()); ret != 0 {
|
||||
return ret
|
||||
|
@ -151,7 +142,6 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error {
|
|||
txn: t,
|
||||
timeStamp: time.Now().UTC(),
|
||||
}
|
||||
pItem.isLowPrio = fee.IsLowPriority(pItem.txn.NetworkFee)
|
||||
mp.lock.Lock()
|
||||
if !mp.checkTxConflicts(t, fee) {
|
||||
mp.lock.Unlock()
|
||||
|
|
|
@ -13,12 +13,7 @@ import (
|
|||
)
|
||||
|
||||
type FeerStub struct {
|
||||
lowPriority bool
|
||||
feePerByte util.Fixed8
|
||||
}
|
||||
|
||||
func (fs *FeerStub) IsLowPriority(util.Fixed8) bool {
|
||||
return fs.lowPriority
|
||||
feePerByte util.Fixed8
|
||||
}
|
||||
|
||||
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
||||
|
@ -50,14 +45,12 @@ func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) {
|
|||
}
|
||||
|
||||
func TestMemPoolAddRemove(t *testing.T) {
|
||||
var fs = &FeerStub{lowPriority: false}
|
||||
t.Run("low priority", func(t *testing.T) { testMemPoolAddRemoveWithFeer(t, fs) })
|
||||
fs.lowPriority = true
|
||||
t.Run("high priority", func(t *testing.T) { testMemPoolAddRemoveWithFeer(t, fs) })
|
||||
var fs = &FeerStub{}
|
||||
testMemPoolAddRemoveWithFeer(t, fs)
|
||||
}
|
||||
|
||||
func TestOverCapacity(t *testing.T) {
|
||||
var fs = &FeerStub{lowPriority: true}
|
||||
var fs = &FeerStub{}
|
||||
const mempoolSize = 10
|
||||
mp := NewMemPool(mempoolSize)
|
||||
|
||||
|
@ -110,9 +103,9 @@ func TestOverCapacity(t *testing.T) {
|
|||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
|
||||
// High priority always wins over low priority.
|
||||
fs.lowPriority = false
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.NetworkFee = util.Fixed8FromFloat(0.00008)
|
||||
tx.Nonce = txcnt
|
||||
txcnt++
|
||||
require.NoError(t, mp.Add(tx, fs))
|
||||
|
@ -120,16 +113,16 @@ func TestOverCapacity(t *testing.T) {
|
|||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
}
|
||||
// Good luck with low priority now.
|
||||
fs.lowPriority = true
|
||||
tx = transaction.New(netmode.UnitTestNet, []byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = txcnt
|
||||
tx.NetworkFee = util.Fixed8FromFloat(0.00007)
|
||||
require.Error(t, mp.Add(tx, fs))
|
||||
require.Equal(t, mempoolSize, mp.Count())
|
||||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
}
|
||||
|
||||
func TestGetVerified(t *testing.T) {
|
||||
var fs = &FeerStub{lowPriority: true}
|
||||
var fs = &FeerStub{}
|
||||
const mempoolSize = 10
|
||||
mp := NewMemPool(mempoolSize)
|
||||
|
||||
|
@ -152,7 +145,7 @@ func TestGetVerified(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveStale(t *testing.T) {
|
||||
var fs = &FeerStub{lowPriority: true}
|
||||
var fs = &FeerStub{}
|
||||
const mempoolSize = 10
|
||||
mp := NewMemPool(mempoolSize)
|
||||
|
||||
|
|
|
@ -123,10 +123,6 @@ func (chain testChain) GetMemPool() *mempool.Pool {
|
|||
panic("TODO")
|
||||
}
|
||||
|
||||
func (chain testChain) IsLowPriority(util.Fixed8) bool {
|
||||
panic("TODO")
|
||||
}
|
||||
|
||||
func (chain testChain) GetGoverningTokenBalance(acc util.Uint160) (util.Fixed8, uint32) {
|
||||
panic("TODO")
|
||||
}
|
||||
|
|
|
@ -85,10 +85,6 @@ func initServerWithInMemoryChain(t *testing.T) (*core.Blockchain, *Server, *http
|
|||
|
||||
type FeerStub struct{}
|
||||
|
||||
func (fs *FeerStub) IsLowPriority(util.Fixed8) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (fs *FeerStub) FeePerByte() util.Fixed8 {
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue