From 4dc76ebd2c1776abb15ee5bc8064bd13b000f78c Mon Sep 17 00:00:00 2001 From: Ursulafe <152976968+Ursulafe@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:00:52 +0100 Subject: [PATCH] chore(mpt-witness-generator): bit of proofreading (#1730) Find few typos while studying the code, in comments. Hope I can be of any help, even if tiny. Have a nice weekend. --- mpt-witness-generator/oracle/preimage.go | 2 +- mpt-witness-generator/state/state_object.go | 2 +- mpt-witness-generator/state/statedb.go | 12 ++++++------ mpt-witness-generator/witness/branch.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mpt-witness-generator/oracle/preimage.go b/mpt-witness-generator/oracle/preimage.go index 65733a340e..2132f950bf 100644 --- a/mpt-witness-generator/oracle/preimage.go +++ b/mpt-witness-generator/oracle/preimage.go @@ -23,7 +23,7 @@ func Preimage(hash common.Hash) ([]byte, error) { return val, nil } -// TODO: Maybe we will want to have a seperate preimages for next block's preimages? +// TODO: Maybe we will want to have a separate preimages for next block's preimages? func Preimages() map[common.Hash][]byte { return preimages } diff --git a/mpt-witness-generator/state/state_object.go b/mpt-witness-generator/state/state_object.go index d47fd466d1..68630d1cbc 100644 --- a/mpt-witness-generator/state/state_object.go +++ b/mpt-witness-generator/state/state_object.go @@ -357,7 +357,7 @@ func (s *stateObject) updateTrie(db Database) Trie { var v []byte if (value == common.Hash{}) { //fmt.Println("delete", s.address, key) - // Get absense proof of key in case the deletion needs the sister node. + // Get absence proof of key in case the deletion needs the sister node. // Note: commented for now because of `ExtNodeDeleted` oracle.PrefetchStorage(big.NewInt(db.BlockNumber.Int64()+1), s.address, key, trie.GenPossibleShortNodePreimage) diff --git a/mpt-witness-generator/state/statedb.go b/mpt-witness-generator/state/statedb.go index de527de2c3..99f38b2e4f 100644 --- a/mpt-witness-generator/state/statedb.go +++ b/mpt-witness-generator/state/statedb.go @@ -554,7 +554,7 @@ func (s *StateDB) deleteStateObject(obj *stateObject) { } // Delete the account from the trie addr := obj.Address() - // Get absense proof of account in case the deletion needs the sister node. + // Get absence proof of account in case the deletion needs the sister node. oracle.PrefetchAccount(big.NewInt(s.Db.BlockNumber.Int64()+1), addr, trie.GenPossibleShortNodePreimage) if err := s.trie.TryDelete(addr[:]); err != nil { s.setError(fmt.Errorf("deleteStateObject (%x) error: %v", addr[:], err)) @@ -893,11 +893,11 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) { // If state snapshotting is active, also mark the destruction there. // Note, we can't do this only at the end of a block because multiple // transactions within the same block might self destruct and then - // ressurrect an account; but the snapshotter needs both events. + // resurrect an account; but the snapshotter needs both events. if s.snap != nil { s.snapDestructs[obj.addrHash] = struct{}{} // We need to maintain account deletions explicitly (will remain set indefinitely) - delete(s.snapAccounts, obj.addrHash) // Clear out any previously updated account data (may be recreated via a ressurrect) - delete(s.snapStorage, obj.addrHash) // Clear out any previously updated storage data (may be recreated via a ressurrect) + delete(s.snapAccounts, obj.addrHash) // Clear out any previously updated account data (may be recreated via a resurrect) + delete(s.snapStorage, obj.addrHash) // Clear out any previously updated storage data (may be recreated via a resurrect) } } else { obj.finalise(true) // Prefetch slots in the background @@ -991,7 +991,7 @@ func (s *StateDB) clearJournalAndRefund() { s.journal = newJournal() s.refund = 0 } - s.validRevisions = s.validRevisions[:0] // Snapshots can be created without journal entires + s.validRevisions = s.validRevisions[:0] // Snapshots can be created without journal entries } // Commit writes the state to the underlying in-memory trie database. @@ -1040,7 +1040,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) { } }*/ - // Write the account trie changes, measuing the amount of wasted time + // Write the account trie changes, measuring the amount of wasted time var start time.Time if metrics.EnabledExpensive { start = time.Now() diff --git a/mpt-witness-generator/witness/branch.go b/mpt-witness-generator/witness/branch.go index 48a751ea63..d6deda4abd 100644 --- a/mpt-witness-generator/witness/branch.go +++ b/mpt-witness-generator/witness/branch.go @@ -248,14 +248,14 @@ func addBranchAndPlaceholder(proof1, proof2, Now we want to add a leaf at position n1 n2 n3 n4 n5 m1 where m1 != n6. The adding algorithm walks through the trie, but it bumps into an extension node where it should put this leaf. So a new extension node is added at position n1 n2 n3 n4 which only - has one nibble: n5. So at n1 n2 n3 n4 n5 we have a branch now. In this brach, at position m we + has one nibble: n5. So at n1 n2 n3 n4 n5 we have a branch now. In this branch, at position m we have a leaf, while at position n6 we have another extension node with one extension nibble: n7. At this position (n7) we have the branch from the original extension node. When an extension node is inserted because of the added key, C proof will contain this new extension node and the underlying branch. However, S proof will stop at the old extension node. This old extension node is not part of the C proof, but we need to ensure that it is in the C trie. - We need to take into accout that in the C trie the old extension node has a shortened extension. + We need to take into account that in the C trie the old extension node has a shortened extension. The problem is where to store the old extension node. Note that in the above code the new extension node and the underlying branch rows are prepared. For example, when len2 > len1 we