all: refactor txpool into it's own package in prep for 4844
This commit is contained in:
+2
-1
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
@@ -39,7 +40,7 @@ import (
|
||||
// to offer all the functions here.
|
||||
type Backend interface {
|
||||
BlockChain() *core.BlockChain
|
||||
TxPool() *core.TxPool
|
||||
TxPool() *txpool.TxPool
|
||||
}
|
||||
|
||||
// Config is the configuration parameters of mining.
|
||||
|
||||
+5
-4
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
@@ -37,10 +38,10 @@ import (
|
||||
|
||||
type mockBackend struct {
|
||||
bc *core.BlockChain
|
||||
txPool *core.TxPool
|
||||
txPool *txpool.TxPool
|
||||
}
|
||||
|
||||
func NewMockBackend(bc *core.BlockChain, txPool *core.TxPool) *mockBackend {
|
||||
func NewMockBackend(bc *core.BlockChain, txPool *txpool.TxPool) *mockBackend {
|
||||
return &mockBackend{
|
||||
bc: bc,
|
||||
txPool: txPool,
|
||||
@@ -51,7 +52,7 @@ func (m *mockBackend) BlockChain() *core.BlockChain {
|
||||
return m.bc
|
||||
}
|
||||
|
||||
func (m *mockBackend) TxPool() *core.TxPool {
|
||||
func (m *mockBackend) TxPool() *txpool.TxPool {
|
||||
return m.txPool
|
||||
}
|
||||
|
||||
@@ -263,7 +264,7 @@ func createMiner(t *testing.T) (*Miner, *event.TypeMux, func(skipMiner bool)) {
|
||||
statedb, _ := state.New(common.Hash{}, state.NewDatabase(chainDB), nil)
|
||||
blockchain := &testBlockChain{statedb, 10000000, new(event.Feed)}
|
||||
|
||||
pool := core.NewTxPool(testTxPoolConfig, chainConfig, blockchain)
|
||||
pool := txpool.NewTxPool(testTxPoolConfig, chainConfig, blockchain)
|
||||
backend := NewMockBackend(bc, pool)
|
||||
// Create event Mux
|
||||
mux := new(event.TypeMux)
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
@@ -245,7 +246,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
||||
SyncMode: downloader.FullSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Ethash: ethconfig.Defaults.Ethash,
|
||||
Miner: miner.Config{
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/beacon"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
@@ -484,7 +485,7 @@ func makeFullNode(genesis *core.Genesis) (*node.Node, *eth.Ethereum, *ethcatalys
|
||||
SyncMode: downloader.FullSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Ethash: ethconfig.Defaults.Ethash,
|
||||
Miner: miner.Config{
|
||||
@@ -535,7 +536,7 @@ func makeLightNode(genesis *core.Genesis) (*node.Node, *les.LightEthereum, *lesc
|
||||
SyncMode: downloader.LightSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Ethash: ethconfig.Defaults.Ethash,
|
||||
LightPeers: 10,
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
@@ -206,7 +207,7 @@ func makeSealer(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
||||
SyncMode: downloader.FullSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Miner: miner.Config{
|
||||
GasCeil: genesis.GasLimit * 11 / 10,
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/eth"
|
||||
@@ -175,7 +176,7 @@ func makeMiner(genesis *core.Genesis) (*node.Node, *eth.Ethereum, error) {
|
||||
SyncMode: downloader.FullSync,
|
||||
DatabaseCache: 256,
|
||||
DatabaseHandles: 256,
|
||||
TxPool: core.DefaultTxPoolConfig,
|
||||
TxPool: txpool.DefaultConfig,
|
||||
GPO: ethconfig.Defaults.GPO,
|
||||
Ethash: ethconfig.Defaults.Ethash,
|
||||
Miner: miner.Config{
|
||||
|
||||
+1
-1
@@ -917,7 +917,7 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
|
||||
env.tcount++
|
||||
txs.Shift()
|
||||
|
||||
case errors.Is(err, core.ErrTxTypeNotSupported):
|
||||
case errors.Is(err, types.ErrTxTypeNotSupported):
|
||||
// Pop the unsupported transaction without shifting in the next from the account
|
||||
log.Trace("Skipping unsupported transaction type", "sender", from, "type", tx.Type())
|
||||
txs.Pop()
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
@@ -51,7 +52,7 @@ const (
|
||||
|
||||
var (
|
||||
// Test chain configurations
|
||||
testTxPoolConfig core.TxPoolConfig
|
||||
testTxPoolConfig txpool.Config
|
||||
ethashChainConfig *params.ChainConfig
|
||||
cliqueChainConfig *params.ChainConfig
|
||||
|
||||
@@ -74,7 +75,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
testTxPoolConfig = core.DefaultTxPoolConfig
|
||||
testTxPoolConfig = txpool.DefaultConfig
|
||||
testTxPoolConfig.Journal = ""
|
||||
ethashChainConfig = new(params.ChainConfig)
|
||||
*ethashChainConfig = *params.TestChainConfig
|
||||
@@ -111,7 +112,7 @@ func init() {
|
||||
// testWorkerBackend implements worker.Backend interfaces and wraps all information needed during the testing.
|
||||
type testWorkerBackend struct {
|
||||
db ethdb.Database
|
||||
txPool *core.TxPool
|
||||
txPool *txpool.TxPool
|
||||
chain *core.BlockChain
|
||||
genesis *core.Genesis
|
||||
uncleBlock *types.Block
|
||||
@@ -134,7 +135,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
|
||||
t.Fatalf("unexpected consensus engine type: %T", engine)
|
||||
}
|
||||
chain, _ := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec, nil, engine, vm.Config{}, nil, nil)
|
||||
txpool := core.NewTxPool(testTxPoolConfig, chainConfig, chain)
|
||||
txpool := txpool.NewTxPool(testTxPoolConfig, chainConfig, chain)
|
||||
|
||||
// Generate a small n-block chain and an uncle block for it
|
||||
var uncle *types.Block
|
||||
@@ -166,7 +167,7 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
|
||||
}
|
||||
|
||||
func (b *testWorkerBackend) BlockChain() *core.BlockChain { return b.chain }
|
||||
func (b *testWorkerBackend) TxPool() *core.TxPool { return b.txPool }
|
||||
func (b *testWorkerBackend) TxPool() *txpool.TxPool { return b.txPool }
|
||||
func (b *testWorkerBackend) StateAtBlock(block *types.Block, reexec uint64, base *state.StateDB, checkLive bool, preferDisk bool) (statedb *state.StateDB, err error) {
|
||||
return nil, errors.New("not supported")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user