Skip to content

Hot fix: Liteserver GetMasterchainInfo/GetTransactions#100

Merged
bvscd merged 1 commit into
masterfrom
release/node/v0.5.1
Apr 17, 2026
Merged

Hot fix: Liteserver GetMasterchainInfo/GetTransactions#100
bvscd merged 1 commit into
masterfrom
release/node/v0.5.1

Conversation

@bvscd
Copy link
Copy Markdown
Collaborator

@bvscd bvscd commented Apr 17, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 17, 2026 13:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 key BlockInfo/state-update references so Merkle proofs include the required cells.
  • Adds a directed dictionary traversal helper (find_nearest_tx_cell) and rewrites list_block_transactions_internal to page through account blocks/transactions without collecting and sorting all transactions.
  • Switches UsageTree::with_params(..., false) in list_block_transactions_internal to 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)
};
@bvscd bvscd merged commit 2ec1e2d into master Apr 17, 2026
9 checks passed
@bvscd bvscd deleted the release/node/v0.5.1 branch April 17, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants