Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeboost auction resolution queue handling #2764

Conversation

Tristan-Wilson
Copy link
Member

@Tristan-Wilson Tristan-Wilson commented Oct 30, 2024

If there were auction resolution transactions in the timeboostAuctionResolutionTxQueue but no normal transactions came through the txQueue, then the auction resolution tx would not be processed because the main createBlock loop was waiting on the txQueue channel and not the auction resolution queue. We had tried to use the same pattern as we had used for the txRetryQueue but this is not correct as the auction resolution queue, like the txQueue, can have items added to it asynchronously, whereas the txRetryQueue is only added to from the createBlock itself.

This commit makes the timeboostAuctionResolutionTxQueue also a channel so that it can be waited on in the same select statement and handle asynchronous events correctly.

This also fixes two issues related to shutdown. The first was a race condition with shutting down and txRetryQueue handling, and the second was that we were missing adding forwarding for outstanding auction resolution txs upon shutdown.

Fixes NIT-2878

Testing done

Express lane system test passes

go test -v -count=1 -run TestSequencerFeed_ExpressLaneAuction_ExpressLaneTxsHaveAdvantage ./system_tests

Confirmed fix by re-running manual repro test with nitro-testnode.

Followed instructions in OffchainLabs/nitro-testnode#95 to start nitro testnode in timeboost mode and made a bid. As soon as the auction was resolved it was picked up immediately by the sequencer.

timeboost-bid-validator-1  | INFO [10-30|18:20:11.773] Validated bid                            bidder=
0xC3c76AaAA7C483c5099aeC225bA5E4269373F16b amount=0x3b9aca00 round=0xc elapsed="645.456µs"             
timeboost-auctioneer-1     | INFO [10-30|18:20:11.905] Consumed validated bid                   bidder=
0xC3c76AaAA7C483c5099aeC225bA5E4269373F16b amount=0x3b9aca00 round=0xc                                 
timeboost-auctioneer-1     | INFO [10-30|18:20:45.000] New auction closing time reached         closing
Time=2024-10-30T18:20:45+0000 totalBids=1                                                              
timeboost-auctioneer-1     | INFO [10-30|18:20:47.004] Resolving auction with single bid        round=1
2              
sequencer-1                | INFO [10-30|18:20:47.004] Prioritizing auction resolution transaction from
 auctioneer txHash=0x505037fc7347e76861209cd7f1cc2b01efe5b31a55af2ed6e71935f882d93e27                  
sequencer-1                | INFO [10-30|18:20:47.004] Popped the auction resolution tx         txHash=
505037..d93e27                                                                                         
sequencer-1                | INFO [10-30|18:20:47.248] New express lane controller assigned     round=1
2 controller=0xC3c76AaAA7C483c5099aeC225bA5E4269373F16b                                                
sequencer-1                | WARN [10-30|18:20:47.250] New express lane controller did not match previo
us controller round=12 previous=0x0000000000000000000000000000000000000000 new=0xC3c76AaAA7C483c5099aeC
225bA5E4269373F16b    

If there were auction resolution transactions in the
timeboostAuctionResolutionTxQueue but no normal transactions came
through the txQueue, then the auction resolution tx would not be
processed because the main createBlock loop was waiting on the txQueue channel
and not the auction resolution queue. We had tried to use the same pattern
as we had used for the txRetryQueue but this is not correct as the
auction resolution queue, like the txQueue, can have items added to it
asynchronously, whereas the txRetryQueue is only added to from the
createBlock itself.

This commit makes the timeboostAuctionResolutionTxQueue also a channel
so that it can be waited on in the same select statement and handle
asynchronous events correctly.

This also fixes two issues related to shutdown. The first was a race condition
with shutting down and txRetryQueue handling, and the second was that
we were missing adding forwarding for outstanding auction resolution txs upon
shutdown.

Fixes NIT-2878
@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Oct 30, 2024
Copy link
Contributor

@ganeshvanahalli ganeshvanahalli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)
LGTM (with a minor suggestion)

@@ -332,12 +332,36 @@ func (c nonceFailureCache) Add(err NonceError, queueItem txQueueItem) {
}
}

type synchronizedTxQueue struct {
Copy link
Contributor

@ganeshvanahalli ganeshvanahalli Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth it to change this to something like SynchronizedQueue[T any] and add it to containers package? Seems like it can be used in other places as well

@Tristan-Wilson Tristan-Wilson merged commit 6933b94 into express-lane-timeboost Nov 20, 2024
3 of 9 checks passed
@Tristan-Wilson Tristan-Wilson deleted the express-lane-timeboost-fix-auction-resolution-queue-handling branch November 20, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants