Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
chore(mpt-witness-generator): bit of proofreading (#1730)
Browse files Browse the repository at this point in the history
Find few typos while studying the code, in comments. Hope I can be of
any help, even if tiny.
Have a nice weekend.
  • Loading branch information
Ursulafe authored Jan 16, 2024
1 parent df265ae commit 4dc76eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mpt-witness-generator/oracle/preimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion mpt-witness-generator/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions mpt-witness-generator/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions mpt-witness-generator/witness/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4dc76eb

Please sign in to comment.