-
Notifications
You must be signed in to change notification settings - Fork 379
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
Avoid freq switch of non-4844 to 4844 batch post #2158
Conversation
Logic to prevent switching from non-4844 batches to 4844 batches too often, so that blocks can be filled efficiently. The geth txpool rejects txs for accounts that already have the other type of txs in the pool with "address already reserved". This logic makes sure that, if there is a backlog, that enough non-4844 batches have been posted to fill a block before switching.
@@ -1350,3 +1365,56 @@ func (b *BatchPoster) StopAndWait() { | |||
b.dataPoster.StopAndWait() | |||
b.redisLock.StopAndWait() | |||
} | |||
|
|||
type BoolRing struct { | |||
buffer []bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to arbutil and make it generic over T so it can be used in the future
LGTM otherwise |
LGTM |
Suggestion: If maintaining the history of each past batch isn't required then I think we could use a counter for previous continuous non-4844 batches and a threshold (in this case 16) to implement the rule when there is backlog |
Good idea, I think I started with the ring buffer because I thought the rule would be more complex than it turned out to be. I'll try switching to a counter. |
The ring buffer was not necessary, a simple counter will suffice to implement the same logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I've been able to reproduce my manual tests with the simplified code. Merging. |
Logic to prevent switching from non-4844 batches to 4844 batches too often, so that blocks can be filled efficiently. The geth txpool rejects txs for accounts that already have the other type of txs in the pool with "address already reserved". This logic makes sure that, if there is a backlog, that enough non-4844 batches have been posted to fill a block before switching.
Testing Done
Nitro needs to be started with a smaller batch size limit and longer max-delay so we can create a backlog easliy, and with 4844 posting enabled. The sequencer max-tx-data-size also needs to be set so that it will fit within the batch size.
Non 4844 cheaper than 4844
Tested manually on my local devnet that Nitro switches from 4844 to non-4844 batch posting when the blob gas price gets too expensive.
How?
Spam blobs from multiple accounts with gas price on L1
Spam txs from multiple accounts on L2
4844 goes back to being cheaper than non-4844, with backlog
Tested manually on my local devnet that when there is a backlog, Nitro switches from non-4844 to 4844 batch posting after at least 16 non-4844 batches have been posted.
How?
Continued from the previous test, then blob spam was disabled around
01:57:20
. There are 16 more batches posted after that as non-4844 (numBlobs=0) and then the next batch has numBlobs=1.4844 goes back to being cheaper than non-4844, no backlog
How?
Spam blobs on l1 and txs on l2 as in the first test to switch Nitro from 4844 to non-4844 batch posting initially.
Then disable blob spam to allow blob price to return to normal, and l2 tx spam to allow the backlog to dissipate. Then occasionally send a few l2 transactions. Before 16 non-4844 batches have been posted, there will be a 4844 tx posted.