Skip to content

Commit

Permalink
Replace blob announcement time travel with skipping of waitlist.
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-bayardo committed Jul 30, 2024
1 parent 8cd3051 commit efcd01c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
26 changes: 17 additions & 9 deletions eth/fetcher/tx_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,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.
Expand All @@ -493,15 +509,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]
Expand Down
18 changes: 10 additions & 8 deletions eth/fetcher/tx_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,8 @@ func TestTransactionFetcherWaitingWithMeta(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},
isWaitingWithMeta(map[string][]announce{
"A": {
{common.Hash{0x01}, types.LegacyTxType, 111},
Expand Down Expand Up @@ -336,8 +335,9 @@ func TestTransactionFetcherWaitingWithMeta(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}},
},
},
Expand Down Expand Up @@ -376,8 +376,9 @@ func TestTransactionFetcherWaitingWithMeta(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}},
},
},
Expand Down Expand Up @@ -411,8 +412,9 @@ func TestTransactionFetcherWaitingWithMeta(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}},
},
Expand Down

0 comments on commit efcd01c

Please sign in to comment.