ZTYP: typing for ZRNT - SSZ, Merkle partials, full caching and immutable typed state.
MIT License
Another approach to SSZ, focused on typing around merkle-tree-representations of state.
ZTYP mirrors most features of my Python
implementation remerkleable
,
In addition to tree structures and views,
ZTYP also provides encoding/decoding utils for flat native Go structures, in the codec
package.
ZRNT uses both the ZTYP tree structures (state) and flat utils (messages) to implement the Eth2 API spec.
Construction:
Node
, build with:
Commit
: combines two subtreesRoot
: a bytes32. Can be a summary root of an unexpanded subtree, or a just a leaf node.TypeDef
and BasicTypeDef
are implemented to describe the raw type information.
Root
and sub-index into a typed sub-view by attaching a basic type definition.View
is used to interact with a subtree. A general view only tracks its backing.
Uint256Type
, Uint64Type
, Uint32Type
, Uint16Type
, Uint8Type
, BoolType
(uint128
is not supported)Container
, ComplexList
, ComplexVector
UnionType
BasicList
, BasicVector
BitVector
, BitList
SmallByteVecMeta
: to derive any BytesN
(N <= 32
) from.RootView
for an efficient 32 byte (single node) immutable view.SubtreeView
ReadProp
/WriteProp
functions can be used to describe reusable Getter/Setter -> View -> *my-type*
pipelines.
ReadPropFn
and WritePropFn
with your own function types to not repeat the boilerplate.BackingHook
s enable you to create smaller views attached to their parent views.H(a [32]byte, b [32]byte) [32]byte
and plug it into Hash
and InitZeroHashes
.MIT, see license file.