-
Notifications
You must be signed in to change notification settings - Fork 205
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
refactor dataTrieTracker #4491
refactor dataTrieTracker #4491
Conversation
…refactor # Conflicts: # common/interface.go # go.mod # go.sum
common/interface.go
Outdated
@@ -50,6 +50,13 @@ type KeyBuilder interface { | |||
Clone() KeyBuilder | |||
} | |||
|
|||
// DataTrie is an interface that declares the methods used for dataTries | |||
type DataTrie interface { |
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.
DataTrieHandler ?
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.
Done.
@@ -187,16 +188,21 @@ func NewJournalEntryDataTrieUpdates(trieUpdates map[string][]byte, account baseA | |||
|
|||
// Revert applies undo operation | |||
func (jedtu *journalEntryDataTrieUpdates) Revert() (vmcommon.AccountHandler, error) { | |||
trie, ok := jedtu.account.DataTrie().(common.Trie) |
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.
why does the account.DataTrie() method returns a subset of the Trie interface but we have the code swarming with casts like this?
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.
There are only 2 casts in productive code (the rest are in tests). The idea behind this was to not give access directly to the trie (although this is possible through casting).
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.
ok, as agreed, we will keep this as it is
state/trackableDataTrie.go
Outdated
if check.IfNil(tdaw.tr) { | ||
newDataTrie, err := mainTrie.Recreate(make([]byte, 0)) | ||
if err != nil { | ||
return map[string][]byte{}, err |
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.
please return nil, err
here to keep the consistency across the project
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.
Done.
} | ||
|
||
tdaw.dirtyData = make(map[string][]byte) | ||
return oldValues, nil |
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.
we return the old data for jurnalizing purposes, I guess. Can you please check where do we use this?
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.
Yes, this is used only for journalizing. (accountsDB -> saveDataTrie())
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.
ok, will remain as it is
tr: tr, | ||
dirtyData: make(map[string][]byte), | ||
identifier: identifier, | ||
} | ||
} | ||
|
||
// ClearDataCaches empties the dirtyData map and original map | ||
func (tdaw *TrackableDataTrie) ClearDataCaches() { |
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.
this doesn't need to be called anymore due to this refactoring
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.
Correct. It is called inside SaveDirtyData(), but we don't need a method for this.
go.mod
Outdated
@@ -7,8 +7,8 @@ require ( | |||
github.com/ElrondNetwork/arwen-wasm-vm/v1_3 v1.3.42-0.20220729115131-85ecca868e90 | |||
github.com/ElrondNetwork/arwen-wasm-vm/v1_4 v1.4.59-0.20220729115431-a6c93119bdda | |||
github.com/ElrondNetwork/covalent-indexer-go v1.0.6 | |||
github.com/ElrondNetwork/elastic-indexer-go v1.2.41 | |||
github.com/ElrondNetwork/elrond-go-core v1.1.19 | |||
github.com/ElrondNetwork/elastic-indexer-go v1.2.42-0.20220921110140-860b4b8c7fc3 |
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.
do not forget about proper releases
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.
Will do.
|
||
if check.IfNil(adb.dataTries.Get(accountHandler.AddressBytes())) { | ||
adb.dataTries.Put(accountHandler.AddressBytes(), accountHandler.DataTrie()) | ||
trie, ok := accountHandler.DataTrie().(common.Trie) |
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.
another cast
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.
will remain as it is
…refactor # Conflicts: # factory/consensus/consensusComponents_test.go # factory/state/stateComponentsHandler_test.go # go.mod
@@ -1172,7 +1172,7 @@ func (n *Node) getAccountRootHashAndVal(address []byte, accBytes []byte, key []b | |||
return nil, nil, fmt.Errorf("empty dataTrie rootHash") | |||
} | |||
|
|||
retrievedVal, err := userAccount.RetrieveValueFromDataTrieTracker(key) | |||
retrievedVal, err := userAccount.RetrieveValue(key) |
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.
when system-testing this branch, please make sure you test the /address/erd1.../esdt
endpoint. it should validate that the affected functionalities (save key value, retrieve value) work the same
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.
It works as expected.
Codecov ReportBase: 71.18% // Head: 71.16% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## rc/v1.4.0 #4491 +/- ##
=============================================
- Coverage 71.18% 71.16% -0.02%
=============================================
Files 662 662
Lines 85839 85842 +3
=============================================
- Hits 61106 61092 -14
- Misses 20242 20249 +7
- Partials 4491 4501 +10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
System test passed.
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.
Just the proper release comment remains
…refactor # Conflicts: # go.mod
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.
System test passed.
Description of the reasoning behind the pull request (what feature was missing / how the problem was manifesting itself / what was the motive behind the refactoring)
Proposed Changes
Testing procedure