From f945e6531735c3ae7320ae6f9d8cc521e997b263 Mon Sep 17 00:00:00 2001 From: Shreyan Gupta Date: Thu, 14 Nov 2024 18:15:33 +0530 Subject: [PATCH] reference impl --- neps/assets/nep-0568/NEP-HybridMemTrie.png | Bin 0 -> 20318 bytes neps/nep-0568.md | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 neps/assets/nep-0568/NEP-HybridMemTrie.png diff --git a/neps/assets/nep-0568/NEP-HybridMemTrie.png b/neps/assets/nep-0568/NEP-HybridMemTrie.png new file mode 100644 index 0000000000000000000000000000000000000000..c18836f816ae862a39277a0e8ad8914022a5734b GIT binary patch literal 20318 zcmb@uby$>J+c%7fgn%H@AOa%Y(u{%%3@IQfB?2NP-3&@8odZaTFoXz5cS{aAAf3`V z3^l|seAnpS-h1EgbA0b{Jm2?+{Nc>3YprX=d7i&mAJkRluM^S|;^E<4S5$bUfrobi z3;Ywib`|)anwjV@JUlfv#YYdd+>N$U@e^;hO#~)~`F%*yE4gz|PmoJou}>V_CvHi0 z`SPO&S`Qr6qr=|Eu-#iu;m^q*eKQ1EK#%67*?E4kG>r~i8<$4zrC8Q}@$~dOoE+Dz z<_RT}y~Z5yfBU2GLLv6i~} z#hon7(Y|3;YsFnL;&2sVUtmBV?)30$51D0CfjEL z=3XsJuEUw01&`8ZlDkCZHnQX*p&hL(Y8mI@C4XF)ME~#JeSqGzrN3QGXr8ddzO`RM zp~s2Glqgb9b|?V-nibe5iNYA5Y~=_-C%$o$@tW@h?tRw#4lRk+w5xWjFsd2OqMZ zfJO|!I$XSKLfNshuwC#9L2pYp3k|4`sVX;ChF81dlNa$qqf-3*k?D_?MmFnPNsW*) zRZ`!oP=g?}qjJ4s`h=&h>3oI*BFoJdE&aMOpF6cZcveaHzg}lHlp*~qa7Y05v?YT4g zgektA@$y5N89m&tq8F4iq&P0u*NHpKqzj%l`0oKi2d<}!^xJBbKD)9eQC(f8o*e87paHV$T7016;?-hW=&eSN>zkJb ze4Qz1O0y%04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K+Zm4a=T)??Hm%z;zZtltVAGrLUFIPgA$~yPU0Ap5*uUw`#ti+X zQ~o8z8vV9U`V+0YoBRI4iKQohBt9@Wc{l8l+Fr|J{Bm30#4)9Vj!U|Dwg1}Qa;Ny{ zrN^C*o1gmeQO>{m)P<}2-CxG}%K@{mkf;IY`}EU!j`|zkM1HE@{-!W1{mt)wiT|?G zYGY^UeY(F{PqKdc1;cxnZ_B>(kuU+Sy2?FW_jXRet?WMxKVOK>$hkRL{33J1cV?jB z-4Wkx-*0(y^Z$>W9eP@z62jxk$+VltT2)IUE`@3DiI9e@=QpYAmwa<>P34UIyB7=( zu-KfrGC%F+`uB-9*WTw^m>hiXdezH>o7b6UNcI;>V5yPUG`Hod82=G)=Eex~(;Ma;(EFCE)e;=f=?>h~;*Cjn9`zbr`gH#qYKoc>8K er#wo2)(hz8208k?oeexUkHOQ`&t;ucLK6Ta>Th!Z literal 0 HcmV?d00001 diff --git a/neps/nep-0568.md b/neps/nep-0568.md index ebe02d9eb..9018649dd 100644 --- a/neps/nep-0568.md +++ b/neps/nep-0568.md @@ -193,6 +193,24 @@ The section should return to the examples given in the previous section, and exp ``` ### State Storage - MemTrie +The current implementation of MemTrie uses a pool of memory (`STArena`) to allocate and deallocate nodes and internal pointers in this pool to reference child nodes. MemTries, unlike the State representation of Trie, do not work with the hash of the nodes but internal memory pointers directly. Additionally, MemTries are not thread safe and one MemTrie exists per shard. + +As described in [MemTrie](#state-storage---memtrie) section above, we need an efficient way to split the MemTrie into two child MemTries within a span of 1 block. What makes this challenging is that the current implementation of MemTrie is not thread safe and can not be shared across two shards. + +The naive way to create two MemTries for the child shards would be to iterate through all the entries of the parent MemTrie and fill in these values into the child MemTries. This however is prohibitively time consuming. + +The solution to this problem was to introduce the concept of Frozen MemTrie (with a `FrozenArena`) which is a cloneable, read-only, thread-safe snapshot of a MemTrie. We can call the `freeze` method on an existing MemTrie that converts it into a Frozen MemTrie. Note that this process consumes the original MemTrie and we can no longer allocate and deallocate nodes to it. + +Along with `FrozenArena`, we also introduce a `HybridArena` which is effectively a base made of `FrozenArena` with a top layer of `STArena` where we support allocating and deallocating new nodes into the MemTrie. Newly allocated nodes can reference/point to nodes in the `FrozenArena`. We use this Hybrid MemTrie as a temporary MemTrie while the flat storage is being constructed in the background. + +During a resharding event, at the boundary of the epoch, when we need to split the parent shard into the two child shards, we do the following steps: +1. Freeze the parent MemTrie arena to create a read-only frozen arena that represents a snapshot of the state as of the time of freezing, i.e. after postprocessing last block of epoch. Note that we no longer require the parent MemTrie in runtime going forward. +2. We cheaply clone the Frozen MemTrie for both the child MemTries to use. Note that this doesn't clone the parent arena memory, but just increases the refcount. +3. We then create a new MemTrie with HybridArena for each of the children. The base of the MemTrie is the read-only FrozenArena while all new node allocations happens on a dedicated STArena memory pool for each child MemTrie. This is the temporary MemTrie that we use while Flat Storage is being built in the background. +4. Once the Flat Storage is constructed in the post processing step of resharding, we use that to load a new MemTrie and discard the Hybrid MemTrie. + +![Hybrid MemTrie diagram](assets/nep-0568/NEP-HybridMemTrie.png) + ### State Storage - State mapping To enable efficient shard state management during resharding, Resharding V3 uses the `DBCol::ShardUIdMapping` column.