Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions foundations/proofs/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,18 @@ const patchedShardState = rebuild(newShardState, path, accountState) // And repl

Another interesting point is how we access the hash of the last known `ShardBlock`.

```tact title="Tact"
inline fun findShardInBinTree(root: Cell, address: Address, shardBitLen: Int): ShardDescr {
let curCs = root.beginParse();
// It's std address, but we parse it as VarAddress to get hash part as Slice, not as Int
let accountId = myParseVarAddress(address.asSlice()).address;
```tolk title="Tolk"
@pure
fun slice.preloadIthRef(self, idx: int): cell
asm "PLDREFVAR"
Comment thread
novusnota marked this conversation as resolved.

@inline
fun findShardInBinTree(root: cell, addr: address, shardBitLen: int): ShardDescr {
var curCs = root.beginParse();
// Cast the address to a slice and skip the 11-bit prefix
// (3 tag bits + 8 workchain bits) to reach the account ID bits.
var accountId = addr as slice;
accountId.skipBits(11);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consider using this function

val (wc, hashPart) = in.senderAddress.getWorkchainAndHash();

repeat (shardBitLen) {
if (accountId.loadBool()) {
// If the bit is 1, we go to the right child
Expand All @@ -222,12 +229,12 @@ inline fun findShardInBinTree(root: Cell, address: Address, shardBitLen: Int): S

// ...

let mcBlockExtra = McBlockExtra.fromCell(blockHeader.extra.loadRef().beginParse().preloadIthRef(3));
// shardHashes is a hashmap (workchain -> ShardDescr)
// Therefore, we only need to retrieve the ShardDescr for workchain 0, as we are working in basechain.
// We can use a non-null assertion, as we already proved that it is a valid block, and a valid masterchain block must have a ShardDescr for workchain 0.
let binTreeWithShardDescr: Cell = mcBlockExtra.shardHashes.get(0)!!;
let shardDescr = findShardInBinTree(binTreeWithShardDescr, jettonMaster, shardBitLen);
val mcBlockExtra = McBlockExtra.fromCell(blockHeader.extra.loadRef().beginParse().preloadIthRef(3));
// shardHashes is a hashmap (workchain -> ShardDescr).
// We only need to retrieve the ShardDescr for workchain 0, since we are working in basechain.
// `mustGet` is safe here, as we already proved that it is a valid block, and a valid masterchain block must have a ShardDescr for workchain 0.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[HIGH] Comment uses “we” in technical documentation

The inline code comment uses first‑person plural phrasing (“we are working in basechain” and “we already proved that it is a valid block”). The project style guide explicitly prohibits first‑person references (“we”/“I”) in documentation and code comments, requiring an impersonal, fact‑focused tone. This violates that HIGH‑severity style rule and could lead to inconsistent tone across the technical documentation. The surrounding code and comments in foundations/proofs/overview.mdx confirm that only these lines introduce the disallowed first‑person language.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

val binTreeWithShardDescr: cell = mcBlockExtra.shardHashes.mustGet(0);
val shardDescr = findShardInBinTree(binTreeWithShardDescr, jettonMaster, shardBitLen);
```

```tlb
Expand Down
Loading