forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SMT: Ideds about SMT Implementation Optimization #49
Comments
agree. A lot of tech debt in tree codes. We should revisit these sub-optimal codes later. |
silathdiir
pushed a commit
that referenced
this issue
Jun 14, 2023
* ethdb: use pebble Co-authored-by: Gary Rong <[email protected]> foo update * apply suggested changes * flags: go format node: fix ddir lookup mistake accounts/abi/bind: fix go.mod replacement for generated binding deps: update pebble + with fix 32-bit build * ethdb/pebble: respect max memtable size * core/rawdb, ethdb: enable pebble on non-32bit platforms only * core/rawdb: fix build tags, fix some review concerns * core/rawdb: refactor methods for database opening * core/rawdb: remove erroneous build tag * cmd/geth: fix the flag default handling + testcase * cmd/geth: improve testing regarding custom backends * ethdb/pebble, deps: update pebble dependency * core/rawdb: replace method with Open * ethdb/pebble: several updates for pebble (#49) * ethdb/pebble: fix size count in batch * ethdb/pebble: disable seek compaction * ethdb/pebble: more fixes * ethdb, core, cmd: polish and fixes (#50) * cmd/utils, core/rawdb, ethdb/pebble: address some review concerns * Update flags.go * ethdb/pebble: minor refactors * ethdb/pebble: avoid copy on batch replay * ethdb: fix compilation flaw * cmd: fix test fail due to mismatching error message * cmd/geth, node: rename backingdb to db.engine --------- Co-authored-by: Jared Wasinger <[email protected]> Co-authored-by: rjl493456442 <[email protected]> Co-authored-by: Péter Szilágyi <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi friends, I have a small question about the SMT codebase.
Since the logic of
mt.updateWord
andmt.updateVarWord
functions are basically the same, I will takemt.updateWord
as an example.To my understanding, in the tree update process, the function call chains when facing a new node are as follows:
mt.updateWord
and then callmt.Update
.proof, err := mt.Update(k, v, kPreimage, vPreimage[:])
mt.Update
function, we first go through the MT by themt.GetNode
function.n, err := mt.GetNode(nextKey)
mt.updateWord
function, then call MT. Add function to add a new node to the MT.mt.Add
function, we call themt.addLeaf
function to add the lead node.newNodeLeaf := NewNodeLeaf(kHash, vHash, kPreimage, vPreimage)
However, we can see that there are two parts that should be duplicated in the current codebase.
We can observe that the
mt.Update
andmt.Add
have the same agruments when we callMT.updateWord
function.Hence, the values of kHash, vHash, and path should be the same both in
Update
andAdd
.mt.Update
function, but we go through the MT in themt.addLeaf
again.I think the
mt.GetNode
function called in bothmt.Update
andmt.addLeaf
is costly, since it will callmt.db.Get (key [:])
, which is currently called leveldb every time it is invoked.I have some simple ideas:
mt.Update
function.After finishing all the main workflow functions, we may need to think about how to reduce the potential number of levelDB calls, since the disk I/O is costly.
Please let me know if I have misunderstood anything.
The text was updated successfully, but these errors were encountered: