From b3b028174a0184d264cb290c62ca02a6ee561fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 20 Feb 2024 15:52:01 +0200 Subject: [PATCH] eth: make tx propagation dependent on local node id too --- eth/backend.go | 1 + eth/handler.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/eth/backend.go b/eth/backend.go index 0a0813aafa..09e1dbd258 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -236,6 +236,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { // Permit the downloader to use the trie cache allowance during fast sync cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit + cacheConfig.SnapshotLimit if eth.handler, err = newHandler(&handlerConfig{ + NodeID: eth.p2pServer.Self().ID(), Database: chainDb, Chain: eth.blockchain, TxPool: eth.txPool, diff --git a/eth/handler.go b/eth/handler.go index 9ae24ef8b6..f7984f24d9 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -42,6 +42,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/p2p" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/triedb/pathdb" "golang.org/x/crypto/sha3" ) @@ -86,6 +87,7 @@ type txPool interface { // handlerConfig is the collection of initialization parameters to create a full // node network handler. type handlerConfig struct { + NodeID enode.ID // P2P node ID used for tx propagation topology Database ethdb.Database // Database for direct sync insertions Chain *core.BlockChain // Blockchain to serve data from TxPool txPool // Transaction pool to propagate from @@ -98,6 +100,7 @@ type handlerConfig struct { } type handler struct { + nodeID enode.ID networkID uint64 forkFilter forkid.Filter // Fork ID filter, constant across the lifetime of the node @@ -139,6 +142,7 @@ func newHandler(config *handlerConfig) (*handler, error) { config.EventMux = new(event.TypeMux) // Nicety initialization for tests } h := &handler{ + nodeID: config.NodeID, networkID: config.Network, forkFilter: forkid.NewFilter(config.Chain), eventMux: config.EventMux, @@ -647,6 +651,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { var broadcast bool if maybeDirect { hasher.Reset() + hasher.Write(h.nodeID.Bytes()) hasher.Write(peer.Node().ID().Bytes()) from, _ := types.Sender(signer, tx) // Ignore error, we only use the addr as a propagation target splitter