Skip to content

Commit 458802d

Browse files
wemeetagainclaude
andcommitted
feat: add StructContainerTreeView, model Validator as StructContainerType
Add StructContainerTreeView — a tree view for fixed-size containers that stores the value as a flat Zig struct. Fields are read and written in O(1) via direct struct access. Dirty fields are tracked with a StaticBitSet. On commit, only changed fields are spliced into the merkle tree via setNodesAtDepth. The pool has no special node types — this is purely a view-level optimization. - Add StructContainerTreeView with StaticBitSet dirty tracking - Parameterize FixedContainerType with TreeViewType enum - StructContainerType selects StructContainerTreeView via the enum - Model phase0 Validator as StructContainerType - set() skips write and dirty-marking when value is unchanged - serializeIntoBytes/toValue read from the struct directly (no commit needed) - commit has clear ownership phases with correct errdefer cleanup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ce6370e commit 458802d

File tree

7 files changed

+458
-4
lines changed

7 files changed

+458
-4
lines changed

src/consensus_types/phase0.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub const Checkpoint = ssz.FixedContainerType(struct {
1919
root: p.Root,
2020
});
2121

22-
pub const Validator = ssz.FixedContainerType(struct {
22+
pub const Validator = ssz.StructContainerType(struct {
2323
pubkey: p.BLSPubkey,
2424
withdrawal_credentials: p.Root,
2525
effective_balance: p.Gwei,

src/ssz/root.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub const VariableVectorType = types.VariableVectorType;
3333

3434
pub const FixedContainerType = types.FixedContainerType;
3535
pub const VariableContainerType = types.VariableContainerType;
36+
pub const StructContainerType = types.StructContainerType;
3637

3738
pub const getPathGindex = types.getPathGindex;
3839

@@ -42,6 +43,7 @@ pub const HasherData = hasher.HasherData;
4243

4344
const tree_view = @import("tree_view/root.zig");
4445
pub const ContainerTreeView = tree_view.ContainerTreeView;
46+
pub const StructContainerTreeView = tree_view.StructContainerTreeView;
4547
pub const ArrayBasicTreeView = tree_view.ArrayBasicTreeView;
4648
pub const ArrayCompositeTreeView = tree_view.ArrayCompositeTreeView;
4749
pub const ListBasicTreeView = tree_view.ListBasicTreeView;

0 commit comments

Comments
 (0)