Skip to content

[Storehouse] 007 Payloadless Checkpoint (v7)#8578

Open
zhangchiqing wants to merge 7 commits into
leo/payloadless-execution-builderfrom
leo/payloadless-checkpoint-v7
Open

[Storehouse] 007 Payloadless Checkpoint (v7)#8578
zhangchiqing wants to merge 7 commits into
leo/payloadless-execution-builderfrom
leo/payloadless-checkpoint-v7

Conversation

@zhangchiqing

@zhangchiqing zhangchiqing commented Jun 9, 2026

Copy link
Copy Markdown
Member
  • Add Version7 Checkpoint file format (Payloadless).
  • Compactor will still use V6 checkpointer. V7 support will be added in the future.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a413d126-6421-40e9-a289-7d070b2c0637

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leo/payloadless-checkpoint-v7

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

// Read the V6 checkpoint fully — the V6 reader already reads the 16 subtrie
// part files concurrently. The resulting tries share sub-tries via Go pointer
// identity, which lets FromV6Tries memoize and avoid redundant conversion.
v6Tries, err := LoadCheckpoint(v6Header, logger)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This loads the entire checkpoint in memory, which requires a lot of memory. An improvement would be streaming the file, iterate each node, if it's a leaf node, then convert into payload less. This could save lots of memory. Skipped for now, because that requires additional code, can be implemented later.

return nil, nil
}
if index > totalSubTrieNodeCount {
nodePos := index - totalSubTrieNodeCount

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This part is same logic as v6 (getNodeByIndex) but slightly different in style, where v6 extracted it into getTopNodeByIndex, which adds little value. Instead, the logic here for getPayloadlessTopNodeByIndex is inlined.

@@ -0,0 +1,421 @@
package wal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

vimdiff ledger/complete/wal/checkpoint_v6_reader.go ledger/complete/wal/checkpoint_v7_reader.go

This file is similar to v6_reader, except some minimal coding style changes. Some read functions are not copied over but reused, such as readCheckpointHeader, allPartFileExist, readSubTriesFooter etc

@@ -0,0 +1,484 @@
package wal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

vimdiff ledger/complete/wal/checkpoint_v6_writer.go ledger/complete/wal/checkpoint_v7_writer.go

v7 is similar to v6 except some comments changes.

@@ -0,0 +1,372 @@
package payloadless

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

mirrored from ledger/complete/mtrie/flattener/encoding.go and ledger/complete/mtrie/flattener/iterator.go

encNodeIndexSize = 8
encRegCountSize = 8

encLeafHashFlagSize = 1

@zhangchiqing zhangchiqing Jun 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

encRegSizeSize and encPayloadLengthSize in v6 checkpoint node (see ledger/complete/mtrie/flattener/encoding.go) is replaced by encLeafHashFlagSize in payloadless

return nil, fmt.Errorf("cannot read leaf hash flag: %w", err)
}

flag := scratch[0]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this part is different from readPayloadFromReader


type EncodedTrie struct {
RootIndex uint64
RegCount uint64

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

RegSize is removed

Comment on lines +64 to +65
encLeafHashFlagSize +
encLeafHashSize

@zhangchiqing zhangchiqing Jun 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

encPayloadLengthSize + encPayloadSize is replaced by encLeafHashFlagSize + encLeafHashSize in payloadless

copy(buf[pos:], path[:])
pos += encPathSize

// Encode leaf hash flag (1 byte) and optional leaf hash (0 or 32 bytes)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this part is different from full trie node's encodeLeafNode

@zhangchiqing zhangchiqing force-pushed the leo/payloadless-checkpoint-v7 branch from 7b14692 to 2625248 Compare June 9, 2026 21:05
}

lastCheckpointNum, err := c.checkpointer.LatestCheckpoint()
lastCheckpointNum, err := c.checkpointer.LatestCheckpointV6()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The compactor will eventually need to support both V6 and V7, but this PR only supports V6. To avoid ambiguity, I renamed the function to LatestCheckpointV6.

@zhangchiqing zhangchiqing marked this pull request as ready for review June 9, 2026 21:52
@zhangchiqing zhangchiqing requested a review from a team as a code owner June 9, 2026 21:52
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.

1 participant