From a6ceeddb7c9ad7548eb83de2b2953efeb07f87f9 Mon Sep 17 00:00:00 2001 From: Roberto Bayardo Date: Mon, 22 Jul 2024 14:32:45 -0700 Subject: [PATCH] Replace blob announcement time travel with skipping of waitlist. Signed-off-by: Roberto Bayardo --- eth/fetcher/tx_fetcher.go | 26 +++++++++++++++++--------- eth/fetcher/tx_fetcher_test.go | 18 ++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index 49f906f910..139bf97e6a 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -464,6 +464,22 @@ func (f *TxFetcher) loop() { } continue } + // If this is a blob tx, schedule it to fetch without being + // waitlisted since blob txs should not be broadcast. If its + // hash is already on the waitlist, it was previously announced + // as a non-blob (or unknown) tx type. In this case we'll just + // eat the delay and continue handling it as a waitlisted tx to + // keep things simple. + if ann.metas[i].kind == types.BlobTxType && f.waitlist[hash] == nil { + f.announced[hash] = map[string]struct{}{ann.origin: {}} + if announces := f.announces[ann.origin]; announces != nil { + announces[hash] = ann.metas[i] + } else { + f.announces[ann.origin] = map[common.Hash]txMetadata{hash: ann.metas[i]} + } + f.scheduleFetches(timeoutTimer, timeoutTrigger, map[string]struct{}{ann.origin: {}}) + continue + } // If the transaction is already known to the fetcher, but not // yet downloading, add the peer as an alternate origin in the // waiting list. @@ -485,15 +501,7 @@ func (f *TxFetcher) loop() { } // Transaction unknown to the fetcher, insert it into the waiting list f.waitlist[hash] = map[string]struct{}{ann.origin: {}} - if ann.metas[i].kind == types.BlobTxType { - // blob transactions are never broadcast, so to force them - // to be fetched immediately we pretend they arrived - // earlier. - f.waittime[hash] = f.clock.Now() - mclock.AbsTime(txArriveTimeout) - idleWait = true // may need to reschedule fetcher due to "time travel" - } else { - f.waittime[hash] = f.clock.Now() - } + f.waittime[hash] = f.clock.Now() if waitslots := f.waitslots[ann.origin]; waitslots != nil { waitslots[hash] = ann.metas[i] diff --git a/eth/fetcher/tx_fetcher_test.go b/eth/fetcher/tx_fetcher_test.go index 26b177ad41..d115c6f3ff 100644 --- a/eth/fetcher/tx_fetcher_test.go +++ b/eth/fetcher/tx_fetcher_test.go @@ -180,9 +180,8 @@ func TestTransactionFetcherWaiting(t *testing.T) { }), isScheduled{tracking: nil, fetching: nil}, // Announce a non-conflicting blob tx, which should immediately go - // to fetching after a trivial wait. + // to fetching without hitting the waitlist doTxNotify{peer: "D", hashes: []common.Hash{{0x0b}}, types: []byte{types.BlobTxType}, sizes: []uint32{1000}}, - doWait{time: 0, step: true}, isWaiting(map[string][]announce{ "A": { {common.Hash{0x01}, types.LegacyTxType, 111}, @@ -239,8 +238,9 @@ func TestTransactionFetcherWaiting(t *testing.T) { }, }, fetching: map[string][]common.Hash{ // Depends on deterministic test randomizer - "A": {{0x01}, {0x02}, {0x03}, {0x05}}, - "B": {{0x04}}, + "A": {{0x02}, {0x05}}, + "B": {{0x03}, {0x04}}, + "C": {{0x01}}, "D": {{0x0B}}, }, }, @@ -279,8 +279,9 @@ func TestTransactionFetcherWaiting(t *testing.T) { }, }, fetching: map[string][]common.Hash{ - "A": {{0x01}, {0x02}, {0x03}, {0x05}}, - "B": {{0x04}}, + "A": {{0x02}, {0x05}}, + "B": {{0x03}, {0x04}}, + "C": {{0x01}}, "D": {{0x0B}}, }, }, @@ -314,8 +315,9 @@ func TestTransactionFetcherWaiting(t *testing.T) { }, }, fetching: map[string][]common.Hash{ - "A": {{0x01}, {0x02}, {0x03}, {0x05}}, - "B": {{0x04}}, + "A": {{0x02}, {0x05}}, + "B": {{0x03}, {0x04}}, + "C": {{0x01}}, "D": {{0x0B}}, "E": {{0x06}, {0x07}}, },