-
Notifications
You must be signed in to change notification settings - Fork 290
feat: global state root 🔥 #667
feat: global state root 🔥 #667
Conversation
Does computing it in a single go produces the exact same result that tax by tx? I can't think of any drawbacks and see a lot of pros as it allows us to skip storing all the intermediate states. |
Ideally (in a few months) this should be computed outside of the runtime, and maybe for block b-1. So I would advise for the solution that is as decoupled as possible from substrate logic. |
You can disable the scale max length constraint. Either for one single storage or for the whole pallet. It should not cause any trouble, especially if we kill the storage at the end of the block execution |
I mean remember what we we did originally to compute the storage we read everything from storage at each block and that was slowing down a lot. What do we need here to compute tu global state root ?
Having an iterative process sounds more performant than this as reads are O(log n) without cache |
The problem was we were reading everything every tx. Now we read only what we need, but at each tx. If we do this at the end in onfinalize rather than along the execution, it will be exactly the same amount of computing. Won't it ? |
Following some discussion with @tdelabro and Mikro from Equilibrium who wrote the initial MPT implementation, I decided to replace Second thing, I had to do a PR to scale-info repo in order to add a With these two things in place the trees are now persisted through time and we can update them iteratively, this sounds like the best approach until we adopt a client-first approach in the next few months. |
b132228
to
71b22bf
Compare
71b22bf
to
851db0d
Compare
crates/primitives/starknet/src/execution/contract_class_wrapper.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Pull Request type
Please add the labels corresponding to the type of changes your PR introduces:
X Feature
What is the current behavior?
Resolves: #166
What is the new behavior?
SCALE
encoding for theStateCommitmentTree
structureState
struct in runtime which contains the twoStateCommitmentTree
: classes/contracts trees.scale-info
,scale-coded
andbitvec
BlockifierStateAdapter
such that it updates the state trees accordingly.IntermediateStateRoot
to compute the global state root from the intermediate trees.Does this introduce a breaking change?
Yes
Other information
SCALE
encodeRefCell
? Does it even make sense or should we replace byBox
?BitVec
has noMaxEncodedLen
which makes sense but prevents from storing it within the runtime, so we can either create someBoundedBitVec
wrapper or switch toBoundedVec<bool>
for instance.