-
Notifications
You must be signed in to change notification settings - Fork 222
feat: Combined layout for transactions #3304
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
base: dat/migrate-block-transactions
Are you sure you want to change the base?
Conversation
51d15ae to
6c07e08
Compare
805ba7f to
4656507
Compare
6c07e08 to
5817864
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dat/block-transactions #3304 +/- ##
==========================================================
+ Coverage 75.60% 75.76% +0.16%
==========================================================
Files 352 352
Lines 33350 33352 +2
==========================================================
+ Hits 25214 25270 +56
+ Misses 6338 6268 -70
- Partials 1798 1814 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4656507 to
d8b7d95
Compare
5817864 to
4d5ee18
Compare
d8b7d95 to
a2282bd
Compare
4d5ee18 to
85e62f4
Compare
a2282bd to
efab75b
Compare
2dfe1e7 to
dd31f0b
Compare
efab75b to
d22252f
Compare
dd31f0b to
d591c8e
Compare
d40c6dc to
ef27574
Compare
d591c8e to
860ab7f
Compare
ef27574 to
8b51892
Compare
860ab7f to
5700fe2
Compare
c016cdb to
27e2db3
Compare
5051fb3 to
0834f3d
Compare
rodrodros
left a comment
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.
Looks very good! Couldn't find any problems.
I've just added some nitpicks that I think it can help with its reading and some questions of two small things that are not super clear to me
| txHash := (*felt.TransactionHash)(txn.Hash()) | ||
| for _, tx := range blockTransactions.Transactions { | ||
| txHash := (*felt.TransactionHash)(tx.Hash()) | ||
| if err := TransactionBlockNumbersAndIndicesByHashBucket.Delete(batch, txHash); err != nil { |
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.
nitpick: I know this line is outside the scope of the PR but could you split the assignment from the if
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.
Is there any particular reason why we favor breaking it into 2 lines? IMO it's a good feature to scope the declaration of err, which avoid (possibly) wrong reuse of err.
|
|
||
| if l1handler, ok := txn.(*L1HandlerTransaction); ok { | ||
| if l1handler, ok := tx.(*L1HandlerTransaction); ok { | ||
| if err := DeleteL1HandlerTxnHashByMsgHash(batch, l1handler.MessageHash()); err != nil { |
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.
Similarly here
| } | ||
|
|
||
| minBlock := min(transactions, receipts) | ||
| minBlock -= minBlock % batchSize |
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.
nitpick: parentization would help a bit here in my opinion
As I understand it, here you want to start through the oldest non-migrated block transactions or receipts, in case the migration was interrupted (I assume). I don't understand very well the logic though.
If the first block with transactions to migrate is t = 5 and the first one with receipts to migrate is r = 10 with batch size b = 2 then:
- The minimum is
min = min(t, r)->min = min(10, 5)->min = 5 - The result is
res = min - (min % 2) - Which then becomes ->
res = 5 - (5 % 2)->res = 5 - 1->res = 4. - The block we should then start from is block
4and not5🤔 – what am I missing.
Additionally, if either transactions and receipts is zero, min block will be zero as well 🤔
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.
It's mainly to "normalize" the batch start and end to be multiples of batchSize, which is currently 10. The main benefits are to guarantee that multiple runs use consistent batches. For example, we always run batch 0 -> 9, 10 -> 19, 20 -> 29,... but never get batch 5 -> 14. This is to avoid unexpected batch that isn't created during the experiments, which may create unexpected spike in resource usage.
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.
Now I remember one more strict reason why we need this. Imagine that the actual next block to migrate is block 20, but block 20 doesn't have any transaction nor receipt. The the first batch will be 21 -> 30 instead of 20 -> 29.
Before rounds of benchmark, I chose batch of 100, which may this approach okay-ish because it only fails in the case where there are 100 consecutive empty blocks. However, now the batch size is 10, which means probably I'll need a better approach, since 10 consecutive empty blocks will fail.
dde7821 to
6ffad37
Compare
| end = b.Indexes.Receipts[0] | ||
| } | ||
|
|
||
| return indexed.NewLazySlice[Transaction](b.Indexes.Transactions, b.Data[:end]) |
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.
What's the reasoning behind b.Data[:end]? It looks similar to just passing b.Data.
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.
First half of the data is for transactions, second half is for receipts. We're utilizing end of data as the end for the last item, so for transactions case, we need to slice at the beginning of the first receipt
a35c29f to
8feb714
Compare
8feb714 to
ec27349
Compare
ec27349 to
520180c
Compare
f208739 to
d8b4ae2
Compare
34f4feb to
9e15688
Compare
8367591 to
492d696
Compare
9e15688 to
257bf49
Compare
b650e4f to
60b4f1a
Compare
257bf49 to
3e6a8b8
Compare
No description provided.