From 2ddc3d1f9aa9a50f577303b3d3bea161714d04f9 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 08:54:16 +1000 Subject: [PATCH 01/11] 1. broadcast + announce --- eth/handler.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/handler.go b/eth/handler.go index 6939a4d6823b..a29f3e79b9ae 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -512,11 +512,13 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) { directPeers++ directCount += len(hashes) peer.AsyncSendTransactions(hashes) + log.Debug("Transactions being broadcasted to", "peer", peer.String(), "len", len(hashes)) } for peer, hashes := range annos { annoPeers++ annoCount += len(hashes) peer.AsyncSendPooledTransactionHashes(hashes) + log.Debug("Transactions being announced to", "peer", peer.String(), "len", len(hashes)) } log.Debug("Transaction broadcast", "txs", len(txs), "announce packs", annoPeers, "announced hashes", annoCount, From 781d263284b41e96f4443542795067f75afc0b24 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 10:30:23 +1000 Subject: [PATCH 02/11] 2. broadcast --- eth/protocols/eth/broadcast.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eth/protocols/eth/broadcast.go b/eth/protocols/eth/broadcast.go index 95bb05ac7a56..d150047f227f 100644 --- a/eth/protocols/eth/broadcast.go +++ b/eth/protocols/eth/broadcast.go @@ -21,6 +21,7 @@ import ( "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/log" ) const ( @@ -92,10 +93,13 @@ func (p *Peer) broadcastTransactions() { if len(txs) > 0 { done = make(chan struct{}) go func() { + log.Debug("Sending transactions", "count", len(txs)) if err := p.SendTransactions(txs); err != nil { + log.Debug("Sending transactions", "count", len(txs), "err", err) fail <- err return } + log.Debug("Sent transactions", "count", len(txs)) close(done) p.Log().Trace("Sent transactions", "count", len(txs)) }() @@ -110,6 +114,7 @@ func (p *Peer) broadcastTransactions() { } // New batch of transactions to be broadcast, queue them (with cap) queue = append(queue, hashes...) + log.Debug("Queue size in broadcastTransactions ", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxs", maxQueuedTxs) if len(queue) > maxQueuedTxs { // Fancy copy and resize to ensure buffer doesn't grow indefinitely queue = queue[:copy(queue, queue[len(queue)-maxQueuedTxs:])] From 0a730db575fd4ccba826fcab743e1a8adee739ec Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 11:40:46 +1000 Subject: [PATCH 03/11] 3. broadcast --- eth/protocols/eth/handlers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index ba091f9cee1b..877863e7dd72 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -378,11 +378,14 @@ func handleTransactions(backend Backend, msg Decoder, peer *Peer) error { // Transactions can be processed, parse all of them and deliver to the pool var txs TransactionsPacket if err := msg.Decode(&txs); err != nil { + log.Debug("Failed to decode transactions", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } + log.Debug("handleTransactions", "peer", peer.String(), "len(txs)", len(txs)) for i, tx := range txs { // Validate and mark the remote transaction if tx == nil { + log.Debug("handleTransactions", "peer", peer.String(), "transaction is nil", i) return fmt.Errorf("%w: transaction %d is nil", errDecode, i) } peer.markTransaction(tx.Hash()) From f6a3c2ef3360a62f1e136f806beaf351b9ee1094 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 11:55:35 +1000 Subject: [PATCH 04/11] 5. announce --- eth/protocols/eth/broadcast.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/protocols/eth/broadcast.go b/eth/protocols/eth/broadcast.go index d150047f227f..2aaf615d1fb3 100644 --- a/eth/protocols/eth/broadcast.go +++ b/eth/protocols/eth/broadcast.go @@ -164,10 +164,13 @@ func (p *Peer) announceTransactions() { if len(pending) > 0 { done = make(chan struct{}) go func() { + log.Debug("Sending transaction announcements", "count", len(pending)) if err := p.sendPooledTransactionHashes(pending); err != nil { + log.Debug("Sending transaction announcements", "count", len(pending), "err", err) fail <- err return } + log.Debug("Sent transaction announcements", "count", len(pending)) close(done) p.Log().Trace("Sent transaction announcements", "count", len(pending)) }() @@ -182,6 +185,7 @@ func (p *Peer) announceTransactions() { } // New batch of transactions to be broadcast, queue them (with cap) queue = append(queue, hashes...) + log.Debug("Queue size in announceTransactions ", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxAnns", maxQueuedTxAnns) if len(queue) > maxQueuedTxAnns { // Fancy copy and resize to ensure buffer doesn't grow indefinitely queue = queue[:copy(queue, queue[len(queue)-maxQueuedTxAnns:])] From 3dcaf8db0779cfaf3da236d841cc70156c86c8c4 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 11:58:39 +1000 Subject: [PATCH 05/11] 6. announce --- eth/protocols/eth/handlers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 877863e7dd72..23af5e9a698c 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -323,9 +323,11 @@ func handleNewPooledTransactionHashes(backend Backend, msg Decoder, peer *Peer) } ann := new(NewPooledTransactionHashesPacket) if err := msg.Decode(ann); err != nil { + log.Debug("Failed to decode new pooled transaction hashes", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } // Schedule all the unknown hashes for retrieval + log.Debug("handleNewPooledTransactionHashes", "peer", peer.String(), "len(ann)", len(*ann)) for _, hash := range *ann { peer.markTransaction(hash) } From 6d95eb28a8753305401c57eccb8d7d9024cf9be8 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 12:13:27 +1000 Subject: [PATCH 06/11] 7. announce --- eth/fetcher/tx_fetcher.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index c4845a34d713..4906921aa860 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -790,6 +790,9 @@ func (f *TxFetcher) scheduleFetches(timer *mclock.Timer, timeout chan struct{}, } return true // continue in the for-each }) + + log.Debug("Scheduling transaction retrieval", "peer", peer, "len(f.announces[peer])", f.announces[peer], "len(hashes)", len(hashes)) + // If any hashes were allocated, request them from the peer if len(hashes) > 0 { f.requests[peer] = &txRequest{hashes: hashes, time: f.clock.Now()} From c9a027ac9441a7c92abdb870b4efa1aee4e10aea Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 13:26:58 +1000 Subject: [PATCH 07/11] 8. announce --- eth/protocols/eth/peer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eth/protocols/eth/peer.go b/eth/protocols/eth/peer.go index 20f959a8edf9..7f69fbbc5568 100644 --- a/eth/protocols/eth/peer.go +++ b/eth/protocols/eth/peer.go @@ -25,6 +25,7 @@ import ( "github.com/scroll-tech/go-ethereum/common" "github.com/scroll-tech/go-ethereum/core/types" + "github.com/scroll-tech/go-ethereum/log" "github.com/scroll-tech/go-ethereum/p2p" "github.com/scroll-tech/go-ethereum/rlp" ) @@ -419,6 +420,8 @@ func (p *Peer) RequestTxs(hashes []common.Hash) error { p.Log().Debug("Fetching batch of transactions", "count", len(hashes)) id := rand.Uint64() + log.Debug("Requesting transactions", "RequestId", id, "Peer.id", p.id, "count", len(hashes)) + requestTracker.Track(p.id, p.version, GetPooledTransactionsMsg, PooledTransactionsMsg, id) return p2p.Send(p.rw, GetPooledTransactionsMsg, &GetPooledTransactionsPacket66{ RequestId: id, From 4961a5230fc158ab66f3e420a2f80511e6a6b263 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 13:34:33 +1000 Subject: [PATCH 08/11] 9. announce --- eth/protocols/eth/handlers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 23af5e9a698c..b6ab2d008082 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -338,9 +338,11 @@ func handleGetPooledTransactions66(backend Backend, msg Decoder, peer *Peer) err // Decode the pooled transactions retrieval message var query GetPooledTransactionsPacket66 if err := msg.Decode(&query); err != nil { + log.Debug("Failed to decode get pooled transactions", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } hashes, txs := answerGetPooledTransactions(backend, query.GetPooledTransactionsPacket, peer) + log.Debug("handleGetPooledTransactions", "peer", peer.String(), "RequestId", query.RequestId, "len(query)", len(query.GetPooledTransactionsPacket), "retrieved", len(hashes)) return peer.ReplyPooledTransactionsRLP(query.RequestId, hashes, txs) } From 12c199fdcd855c35af0e7f05841ef895bca19a05 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 13:40:15 +1000 Subject: [PATCH 09/11] 10. announce --- eth/protocols/eth/handlers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index b6ab2d008082..692a57eb2009 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -405,11 +405,13 @@ func handlePooledTransactions66(backend Backend, msg Decoder, peer *Peer) error // Transactions can be processed, parse all of them and deliver to the pool var txs PooledTransactionsPacket66 if err := msg.Decode(&txs); err != nil { + log.Debug("Failed to decode pooled transactions", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } for i, tx := range txs.PooledTransactionsPacket { // Validate and mark the remote transaction if tx == nil { + log.Debug("handlePooledTransactions", "peer", peer.String(), "transaction is nil", i) return fmt.Errorf("%w: transaction %d is nil", errDecode, i) } peer.markTransaction(tx.Hash()) From c2b98b292fb7e012e25aa6f24e32d7fb90dfb42e Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 13:57:50 +1000 Subject: [PATCH 10/11] minor --- eth/fetcher/tx_fetcher.go | 2 +- eth/protocols/eth/broadcast.go | 4 ++-- eth/protocols/eth/handlers.go | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 4906921aa860..e8fcf1a5cfcb 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -791,7 +791,7 @@ func (f *TxFetcher) scheduleFetches(timer *mclock.Timer, timeout chan struct{}, return true // continue in the for-each }) - log.Debug("Scheduling transaction retrieval", "peer", peer, "len(f.announces[peer])", f.announces[peer], "len(hashes)", len(hashes)) + log.Debug("Scheduling transaction retrieval", "peer", peer, "len(f.announces[peer])", len(f.announces[peer]), "len(hashes)", len(hashes)) // If any hashes were allocated, request them from the peer if len(hashes) > 0 { diff --git a/eth/protocols/eth/broadcast.go b/eth/protocols/eth/broadcast.go index 2aaf615d1fb3..692749b17a96 100644 --- a/eth/protocols/eth/broadcast.go +++ b/eth/protocols/eth/broadcast.go @@ -114,7 +114,7 @@ func (p *Peer) broadcastTransactions() { } // New batch of transactions to be broadcast, queue them (with cap) queue = append(queue, hashes...) - log.Debug("Queue size in broadcastTransactions ", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxs", maxQueuedTxs) + log.Debug("Queue size in broadcastTransactions", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxs", maxQueuedTxs) if len(queue) > maxQueuedTxs { // Fancy copy and resize to ensure buffer doesn't grow indefinitely queue = queue[:copy(queue, queue[len(queue)-maxQueuedTxs:])] @@ -185,7 +185,7 @@ func (p *Peer) announceTransactions() { } // New batch of transactions to be broadcast, queue them (with cap) queue = append(queue, hashes...) - log.Debug("Queue size in announceTransactions ", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxAnns", maxQueuedTxAnns) + log.Debug("Queue size in announceTransactions", "len(hashes)", len(hashes), "len(queue)", len(queue), "maxQueuedTxAnns", maxQueuedTxAnns) if len(queue) > maxQueuedTxAnns { // Fancy copy and resize to ensure buffer doesn't grow indefinitely queue = queue[:copy(queue, queue[len(queue)-maxQueuedTxAnns:])] diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 692a57eb2009..c3e76139a9f4 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -323,7 +323,7 @@ func handleNewPooledTransactionHashes(backend Backend, msg Decoder, peer *Peer) } ann := new(NewPooledTransactionHashesPacket) if err := msg.Decode(ann); err != nil { - log.Debug("Failed to decode new pooled transaction hashes", "peer", peer.String(), "err", err) + log.Debug("Failed to decode `NewPooledTransactionHashesPacket`", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } // Schedule all the unknown hashes for retrieval @@ -338,7 +338,7 @@ func handleGetPooledTransactions66(backend Backend, msg Decoder, peer *Peer) err // Decode the pooled transactions retrieval message var query GetPooledTransactionsPacket66 if err := msg.Decode(&query); err != nil { - log.Debug("Failed to decode get pooled transactions", "peer", peer.String(), "err", err) + log.Debug("Failed to decode `GetPooledTransactionsPacket66`", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } hashes, txs := answerGetPooledTransactions(backend, query.GetPooledTransactionsPacket, peer) @@ -382,14 +382,14 @@ func handleTransactions(backend Backend, msg Decoder, peer *Peer) error { // Transactions can be processed, parse all of them and deliver to the pool var txs TransactionsPacket if err := msg.Decode(&txs); err != nil { - log.Debug("Failed to decode transactions", "peer", peer.String(), "err", err) + log.Debug("Failed to decode `TransactionsPacket`", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } log.Debug("handleTransactions", "peer", peer.String(), "len(txs)", len(txs)) for i, tx := range txs { // Validate and mark the remote transaction if tx == nil { - log.Debug("handleTransactions", "peer", peer.String(), "transaction is nil", i) + log.Debug("handleTransactions: transaction is nil", "peer", peer.String(), "i", i) return fmt.Errorf("%w: transaction %d is nil", errDecode, i) } peer.markTransaction(tx.Hash()) @@ -405,13 +405,13 @@ func handlePooledTransactions66(backend Backend, msg Decoder, peer *Peer) error // Transactions can be processed, parse all of them and deliver to the pool var txs PooledTransactionsPacket66 if err := msg.Decode(&txs); err != nil { - log.Debug("Failed to decode pooled transactions", "peer", peer.String(), "err", err) + log.Debug("Failed to decode `PooledTransactionsPacket66`", "peer", peer.String(), "err", err) return fmt.Errorf("%w: message %v: %v", errDecode, msg, err) } for i, tx := range txs.PooledTransactionsPacket { // Validate and mark the remote transaction if tx == nil { - log.Debug("handlePooledTransactions", "peer", peer.String(), "transaction is nil", i) + log.Debug("handlePooledTransactions: transaction is nil", "peer", peer.String(), "i", i) return fmt.Errorf("%w: transaction %d is nil", errDecode, i) } peer.markTransaction(tx.Hash()) From e25f1090243d4339e50343e20f252196f4fd3c14 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 27 Aug 2024 04:14:37 +0000 Subject: [PATCH 11/11] =?UTF-8?q?chore:=20auto=20version=20bump=E2=80=89[b?= =?UTF-8?q?ot]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index 44aa95662f6d..1baba734a90d 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 5 // Major version component of the current release VersionMinor = 7 // Minor version component of the current release - VersionPatch = 1 // Patch version component of the current release + VersionPatch = 2 // Patch version component of the current release VersionMeta = "mainnet" // Version metadata to append to the version string )