Conversation
crates/stages/src/stages/senders.rs
Outdated
| let max_block = input.previous_stage.map(|(_, num)| num).unwrap_or_default(); | ||
| let mut body_cursor = tx.cursor_mut::<tables::BlockBodies>()?; | ||
| let mut body_walker = | ||
| body_cursor.walk((start_block, start_hash).into())?.take_while(|res| { |
There was a problem hiding this comment.
We shoild add a helper method for walkers over range of blocks, maybe even just passing it StageInput
|
@gakonst Yes, either way is fine for MVP. We can start profiling once we're over that stage as the difference in implementation probably won't differ much, so switching to either one afterwards should be fine. |
|
OK sounds good - thank you! Let's unblock this and move forward with the current approach then @rkrasiuk |
|
I plan to add some stage db utils in a follow up PR |
Codecov Report
@@ Coverage Diff @@
## main #181 +/- ##
==========================================
+ Coverage 73.20% 73.54% +0.34%
==========================================
Files 224 225 +1
Lines 20144 20347 +203
==========================================
+ Hits 14746 14964 +218
+ Misses 5398 5383 -15
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
gakonst
left a comment
There was a problem hiding this comment.
LGTM. Feel free to merge and add the helpers requested in a follow up PR.
|
|
||
| let start_hash = tx.get::<tables::CanonicalHeaders>(start_block)?.unwrap(); | ||
| let mut body_cursor = tx.cursor::<tables::BlockBodies>()?; | ||
| let mut body_walker = body_cursor.walk((start_block, start_hash).into())?; |
There was a problem hiding this comment.
Let's add get body walker by 1. block hash and 2. Block number helpers
| let (_, body) = entry?; | ||
| for tx_id in body.base_tx_id..body.base_tx_id + body.tx_amount { | ||
| let transaction = tx | ||
| .get::<tables::Transactions>(tx_id)? |
There was a problem hiding this comment.
This is a hash right? Normally at least. Are txs are written by number in the test dbs?
There was a problem hiding this comment.
that's not a hash, that's encoded tx data TransactionSigned
| let tx = db.get_mut(); | ||
|
|
||
| // Look up the hash of the unwind block | ||
| if let Some(unwind_hash) = tx.get::<tables::CanonicalHeaders>(input.unwind_to)? { |
| hash: unwind_hash, | ||
| })?; | ||
|
|
||
| unwind_table_by_num::<DB, tables::TxSenders>(tx, latest_tx - 1)?; |
There was a problem hiding this comment.
consider block 1 with 2 transactions and block 2 with 3 transactions. the transactions would be enumerated 0..4 (inclusive). if we need to unwind to block 1, we'd just need to look up the tx count at unwind block (2 in this case) and turn it into the tx_id of the last transaction
| let mut tx_cursor = tx.cursor::<tables::Transactions>()?; | ||
| // Walk the transactions from start to end index (exclusive) | ||
| let entries = tx_cursor | ||
| .walk(start_tx_index)? |
There was a problem hiding this comment.
We should have helpers for these "range walkers" cursor.walk_range(range: Range)
|
linter error unrelated |
…xyz#181) * chore: update readme for running nodes with suggested flags * feat: set experimental engine as default for opBNB --------- Co-authored-by: yutianwu <wzxingbupt@gmail.com>
Implement sender recovery stage.
closes #180
blocked by #190 and #204