-
Notifications
You must be signed in to change notification settings - Fork 220
refactor(trie2): use more descriptive felt.Hash type instead of felt.Felt
#3316
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3316 +/- ##
==========================================
- Coverage 76.20% 76.16% -0.05%
==========================================
Files 346 346
Lines 32690 32738 +48
==========================================
+ Hits 24912 24935 +23
- Misses 5987 6009 +22
- Partials 1791 1794 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9210f6f to
090e07a
Compare
ad10776 to
6bee396
Compare
6a421db to
886e905
Compare
886e905 to
96d28a1
Compare
| stateCommitment := felt.NewFromUint64[felt.Felt](1000) | ||
| classRootHash := felt.NewFromUint64[felt.Felt](2000) | ||
| contractRootHash := felt.NewFromUint64[felt.Felt](3000) | ||
| stateCommitment := felt.NewFromUint64[felt.Hash](uint64(1000)) |
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.
nitpick -> This uint64(...) seems redundant?
| classNodes map[felt.Hash]map[trieutils.Path]trienode.TrieNode | ||
| contractNodes map[felt.Hash]map[trieutils.Path]trienode.TrieNode | ||
| contractStorageNodes map[felt.Hash]map[felt.Address]map[trieutils.Path]trienode.TrieNode |
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.
felt.Hash is the most general type, but I think it is being miss-used.
felt.Hash means that there is not a good type to define it and it makes sense to be a general type, for example the return type of hashing function.
On the other hand, here we know the semantic meaning each hash has here, so we should use the appropriate types.
As far as I understand, it should be:
classNodeskeys should be of typefelt.ClassHashcontractNodesshould be of typefelt.Addresssince it is a contract addresscontractStorageNodesshould be of typefelt.Addresstofelt.StorageAddress(orfelt.StorageSlot). <- The latter types are to be defined
| // Tracks all unique and latest nodes in the layer tree | ||
| classPaths map[trieutils.Path]trienode.TrieNode | ||
| contractPaths map[trieutils.Path]trienode.TrieNode | ||
| contractStoragePaths map[felt.Address]map[trieutils.Path]trienode.TrieNode |
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.
Is this Address referencing StorageAddress, if that's the case, then it is being miss-used.
Address strictly refers to a Starknet contract address – this has been discussed both in dailies and slack.
|
|
||
| stateComm := id.StateComm() | ||
| if stateComm.IsZero() { | ||
| if (*felt.Felt)(&stateComm).IsZero() { |
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.
let's avoid the use of this casting
|
|
||
| stateComm := id.StateComm() | ||
| if stateComm.IsZero() { | ||
| if (*felt.Felt)(&stateComm).IsZero() { |
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.
Here as well please
| func (t *layerTracker) trackLayer(root, parent *felt.Felt) { | ||
| if root.Equal(parent) { | ||
| func (t *layerTracker) trackLayer(root, parent *felt.Hash) { | ||
| if (*felt.Felt)(root).Equal((*felt.Felt)(parent)) { |
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.
Avoid this second conversion
|
|
||
| // Child to parent layer relationship | ||
| childToParent map[felt.Felt]felt.Felt | ||
| childToParent map[felt.Hash]felt.Hash |
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.
Similar coment to the previous ones, what would be the right hash here?
This PR addresses #3282 (comment), and uses more descriptive
felt.Hashtype for owner fields in alltriedbandtrie2packages