# Han (weihan) - Update 8 ## Summary I had completed most of the required codes related to leaf node which includes the addition of new state epoch metadata and new Verkle proof format. ## Development I've finished most of the development related to state epoch metadata and leaf node modification. I'm almost done with modifying the Verkle proof component. Check out my development branch [here](https://github.com/weiihann/go-verkle/tree/state-expiry-tree). ## Code Notes Navigating through the Verkle commitment seemed daunting at first, but it wasn't so bad when I got hands on. The following is the notes for the `NewLeafNode` function in the *tree.go* file: 1. Load Lagrange Precompile file ```go! cfg := GetConfig() ``` 2. For the first 128 values, build the polynomial for C1 ```go! var c1poly [NodeWidth]Fr var c1 *Point count, err := fillSuffixTreePoly(c1poly[:], values[:NodeWidth/2]) ``` 3. Create the commitment for C1 ```go! c1 = cfg.CommitToPoly(c1poly[:], NodeWidth-count) ``` 4. For the last 128 values, build the polynomial for C2 ```go! var c2poly [NodeWidth]Fr count, err = fillSuffixTreePoly(c2poly[:], values[NodeWidth/2:]) ``` 5. Create the commitment for C2 ```go! c2 := cfg.CommitToPoly(c2poly[:], NodeWidth-count) ``` 6. Create the commitment of leaf node. First step is to get the stem (31 bytes). Then it sets the first position of polynomial to 1 (this is constant). Then, it sets the second position of the polynomial to the stem. Then, it sets the position of 2 and 3 to c1 and c2. This is consistent with the commitment formula C(1, Stem, C1, C2). ```go! // Root commitment preparation for calculation. stem = stem[:StemSize] // enforce a 31-byte length var poly [NodeWidth]Fr poly[0].SetUint64(1) if err := StemFromBytes(&poly[1], stem); err != nil { return nil, err } banderwagon.BatchMapToScalarField([]*Fr{&poly[2], &poly[3]}, []*Point{c1, c2}) ``` 7. Build LeafNode object and return it. It will create the commitment of the node using the polynomial constructed. At this point, poly[0:5] = [1, Stem, C1, C2]. But do take note that the polynomial has a length of 256, so the rest of the elements are zero (which I assume is to be ignored). ```go! return &LeafNode{ // depth will be 0, but the commitment calculation // does not need it, and so it won't be free. values: values, stem: stem, commitment: cfg.CommitToPoly(poly[:], NodeWidth-4), c1: c1, c2: c2, }, nil } ``` The rest of the functions follow a similar pattern on creating and updating the node commitment. ## Daily Updates To ensure consistency, I post daily updates (on weekdays) on what I did for EPF. Check out my daily updates this week: [Monday](https://twitter.com/ngweihan_eth/status/1698726060752540089) Tuesday (skipped) [Wednesday](https://twitter.com/ngweihan_eth/status/1699447177259688016) Thursday (skipped) Friday (skipped) ## Next week's Action Items - Complete the Verkle proof component - Complete unit testing for verkle tree modification - Present project during EPF office hours