Hot fix: Liteserver GetMasterchainInfo/GetTransactions#100
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts LiteServer block/transaction handling to address correctness issues around Merkle proof construction and to optimize listBlockTransactions traversal by avoiding full transaction deserialization.
Changes:
- Introduces
visit_block_info()to force-visiting keyBlockInfo/state-update references so Merkle proofs include the required cells. - Adds a directed dictionary traversal helper (
find_nearest_tx_cell) and rewriteslist_block_transactions_internalto page through account blocks/transactions without collecting and sorting all transactions. - Switches
UsageTree::with_params(..., false)inlist_block_transactions_internalto reduce eager visiting, relying on targeted traversal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| let reverse = mode & REVERSE_ORDER != 0; | ||
| let forward = !reverse; | ||
| let need = count as usize; |
| // Determine starting point | ||
| let (mut cur_addr, mut cur_lt): (AccountId, u64) = if mode & AFTER_PRESENT != 0 { | ||
| let after_id = | ||
| after.ok_or_else(|| error!("AFTER_PRESENT flag is set but `after` is None"))?; |
Comment on lines
+2064
to
2107
| let mut result_txs: Vec<(UInt256, u64, Cell)> = Vec::new(); | ||
| let mut allow_same = true; | ||
| let mut incomplete = true; | ||
|
|
||
| while result_txs.len() < need { | ||
| // Find nearest account block via directed traversal | ||
| let (acc_id, acc_block) = | ||
| match acc_blocks.find_leaf(&cur_addr, forward, allow_same, false)? { | ||
| Some(pair) => pair, | ||
| None => { | ||
| incomplete = false; | ||
| break; | ||
| } | ||
| }; | ||
|
|
||
| if !after_id.account.is_zero() { | ||
| if let Some(idx) = all_txs.iter().position(|(tid, _)| { | ||
| tid.account == after_id.account && tid.lt == after_id.lt | ||
| }) { | ||
| all_txs.drain(..=idx); | ||
| allow_same = false; | ||
|
|
||
| // If moved to a different account, reset transaction lt to boundary | ||
| if acc_id != cur_addr { | ||
| cur_lt = boundary_lt; | ||
| } | ||
| cur_addr = acc_id; | ||
|
|
||
| let acc_uint = cur_addr.clone().get_next_hash()?; | ||
|
|
||
| // Traverse transactions in this account using directed lookup | ||
| let transactions = acc_block.transactions(); | ||
| loop { | ||
| if result_txs.len() >= need { | ||
| break; | ||
| } | ||
| } else { | ||
| if mode & REVERSE_ORDER != 0 { | ||
| all_txs.retain(|(tid, _)| tid.lt < after_id.lt); | ||
| } else { | ||
| all_txs.retain(|(tid, _)| tid.lt > after_id.lt); | ||
|
|
||
| match find_nearest_tx_cell(transactions, cur_lt, forward)? { | ||
| Some((lt, tx_cell)) => { | ||
| result_txs.push((acc_uint.clone(), lt, tx_cell)); | ||
| cur_lt = lt; | ||
| } | ||
| None => { | ||
| cur_lt = boundary_lt; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } |
Comment on lines
+2048
to
+2062
| let reverse = mode & REVERSE_ORDER != 0; | ||
| let forward = !reverse; | ||
| let need = count as usize; | ||
| let boundary_lt: u64 = if reverse { u64::MAX } else { 0 }; | ||
|
|
||
| if mode & AFTER_PRESENT != 0 { | ||
| // Determine starting point | ||
| let (mut cur_addr, mut cur_lt): (AccountId, u64) = if mode & AFTER_PRESENT != 0 { | ||
| let after_id = | ||
| after.ok_or_else(|| error!("AFTER_PRESENT flag is set but `after` is None"))?; | ||
| (AccountId::from(&after_id.account), after_id.lt as u64) | ||
| } else if reverse { | ||
| (AccountId::from([0xFF; 32]), u64::MAX) | ||
| } else { | ||
| (AccountId::from([0x00; 32]), 0u64) | ||
| }; |
Sumrachek
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.