diff --git a/cmd/devp2p/internal/ethtest/conn.go b/cmd/devp2p/internal/ethtest/conn.go index ff9700ccda82..e13f47082a9d 100644 --- a/cmd/devp2p/internal/ethtest/conn.go +++ b/cmd/devp2p/internal/ethtest/conn.go @@ -342,7 +342,7 @@ loop: if err := c.Write(ethProto, eth.StatusMsg, status); err != nil { return fmt.Errorf("write to connection failed: %v", err) } - case eth.UpgradeStatusMsg + +protoOffset(ethProto): + case eth.UpgradeStatusMsg + protoOffset(ethProto): msg := new(eth.UpgradeStatusPacket) if err := rlp.DecodeBytes(data, &msg); err != nil { return fmt.Errorf("error decoding status packet: %w", err) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 8a0dd59037f3..e1242912f26f 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -93,7 +93,7 @@ var ( utils.BlobPoolPriceBumpFlag, utils.SyncModeFlag, utils.TriesVerifyModeFlag, - utils.SyncTargetFlag, + // utils.SyncTargetFlag, utils.ExitWhenSyncedFlag, utils.GCModeFlag, utils.SnapshotFlag, diff --git a/core/gen_genesis.go b/core/gen_genesis.go index 5cd006917c85..38614252a380 100644 --- a/core/gen_genesis.go +++ b/core/gen_genesis.go @@ -31,8 +31,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) { GasUsed math.HexOrDecimal64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` - ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas,omitempty" toml:",omitempty"` - BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty" toml:",omitempty"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` } var enc Genesis enc.Config = g.Config @@ -74,8 +74,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { GasUsed *math.HexOrDecimal64 `json:"gasUsed"` ParentHash *common.Hash `json:"parentHash"` BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"` - ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas,omitempty" toml:",omitempty"` - BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed,omitempty" toml:",omitempty"` + ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` + BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { diff --git a/core/genesis.go b/core/genesis.go index 96d25013fa46..1070f470e6fc 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -64,9 +64,9 @@ type Genesis struct { Number uint64 `json:"number"` GasUsed uint64 `json:"gasUsed"` ParentHash common.Hash `json:"parentHash"` - BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559 - ExcessBlobGas *uint64 `json:"excessBlobGas,omitempty"` // EIP-4844, TODO(Nathan): remove tag `omitempty` after cancun fork - BlobGasUsed *uint64 `json:"blobGasUsed,omitempty"` // EIP-4844, TODO(Nathan): remove tag `omitempty` after cancun fork + BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559 + ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844 + BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844 } func ReadGenesis(db ethdb.Database) (*Genesis, error) { diff --git a/core/txpool/blobpool/blobpool.go b/core/txpool/blobpool/blobpool.go index e889d4b19723..c9f72b5ea813 100644 --- a/core/txpool/blobpool/blobpool.go +++ b/core/txpool/blobpool/blobpool.go @@ -313,6 +313,8 @@ type BlobPool struct { discoverFeed event.Feed // Event feed to send out new tx events on pool discovery (reorg excluded) insertFeed event.Feed // Event feed to send out new tx events on pool inclusion (reorg included) + reannoTxFeed event.Feed // Event feed for announcing transactions again + scope event.SubscriptionScope lock sync.RWMutex // Mutex protecting the pool during reorg handling } @@ -1502,7 +1504,7 @@ func (p *BlobPool) SubscribeTransactions(ch chan<- core.NewTxsEvent, reorgs bool // SubscribeReannoTxsEvent registers a subscription of ReannoTxsEvent and // starts sending event to the given channel. func (pool *BlobPool) SubscribeReannoTxsEvent(ch chan<- core.ReannoTxsEvent) event.Subscription { - panic("not supported") + return pool.scope.Track(pool.reannoTxFeed.Subscribe(ch)) } // Nonce returns the next nonce of an account, with all transactions executable diff --git a/eth/backend.go b/eth/backend.go index 63766298a779..d60e24605ced 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -37,6 +37,7 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state/pruner" "github.com/ethereum/go-ethereum/core/txpool" + "github.com/ethereum/go-ethereum/core/txpool/blobpool" "github.com/ethereum/go-ethereum/core/txpool/legacypool" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -282,16 +283,14 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.BlobPool.Datadir != "" { config.BlobPool.Datadir = stack.ResolvePath(config.BlobPool.Datadir) } - // TODO(Nathan): blob is not ready now, it will cause panic. - // blobPool := blobpool.New(config.BlobPool, eth.blockchain) + blobPool := blobpool.New(config.BlobPool, eth.blockchain) if config.TxPool.Journal != "" { config.TxPool.Journal = stack.ResolvePath(config.TxPool.Journal) } legacyPool := legacypool.New(config.TxPool, eth.blockchain) - // TODO(Nathan): eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool, blobPool}) - eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool}) + eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool, blobPool}) if err != nil { return nil, err } @@ -302,7 +301,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { Chain: eth.blockchain, TxPool: eth.txPool, Merger: eth.merger, - Network: config.NetworkId, + Network: networkID, Sync: config.SyncMode, BloomCache: uint64(cacheLimit), EventMux: eth.eventMux, diff --git a/eth/handler.go b/eth/handler.go index 5aac65b7fa75..648e9499322d 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -990,4 +990,7 @@ func (h *handler) enableSyncedFeatures() { log.Info("Snap sync complete, auto disabling") h.snapSync.Store(false) } + // if h.chain.TrieDB().Scheme() == rawdb.PathScheme { + // h.chain.TrieDB().SetBufferSize(pathdb.DefaultBufferSize) + // } } diff --git a/eth/peerset.go b/eth/peerset.go index 07615af94b64..ff4215eda3ec 100644 --- a/eth/peerset.go +++ b/eth/peerset.go @@ -289,6 +289,12 @@ func (ps *peerSet) waitTrustExtension(peer *eth.Peer) (*trust.Peer, error) { delete(ps.trustWait, id) ps.lock.Unlock() return nil, errPeerWaitTimeout + + case <-ps.quitCh: + ps.lock.Lock() + delete(ps.trustWait, id) + ps.lock.Unlock() + return nil, errPeerSetClosed } } @@ -348,6 +354,12 @@ func (ps *peerSet) waitBscExtension(peer *eth.Peer) (*bsc.Peer, error) { } } } + + case <-ps.quitCh: + ps.lock.Lock() + delete(ps.bscWait, id) + ps.lock.Unlock() + return nil, errPeerSetClosed } } diff --git a/miner/worker.go b/miner/worker.go index e4b9d9a6f9db..8caa089ba7b1 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -1127,7 +1127,7 @@ LOOP: sub := w.eth.TxPool().SubscribeTransactions(txsCh, true) // if TxPool has been stopped, `sub` would be nil, it could happen on shutdown. if sub == nil { - log.Info("commitWork SubscribeNewTxsEvent return nil") + log.Info("commitWork SubscribeTransactions return nil") } else { defer sub.Unsubscribe() }