Skip to content
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

Use prefix comparison for account selective statediffing #247

Conversation

prathamesh0
Copy link
Collaborator

Part of #29

  • Include intermediate nodes when having watched addresses
  • Check (intermediate | leaf) node paths as prefix to paths of watched addresses to filter out unwanted nodes

@prathamesh0 prathamesh0 force-pushed the pm-account-selective-statediffing branch from 4110c75 to 3fac5fa Compare June 23, 2022 06:51
@prathamesh0 prathamesh0 changed the base branch from v1.10.18-statediff-v4 to v1.10.19-statediff-v4 June 23, 2022 06:51
@prathamesh0 prathamesh0 force-pushed the pm-account-selective-statediffing branch from 3fac5fa to 365369d Compare June 23, 2022 06:55
@prathamesh0 prathamesh0 force-pushed the pm-account-selective-statediffing branch from 365369d to 0438809 Compare June 27, 2022 09:35
@prathamesh0 prathamesh0 changed the title [WIP] Use prefix comparison for account selective statediffing Use prefix comparison for account selective statediffing Jun 27, 2022
Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM! I reviewed the difference iterator a bit and it appears it would be a bit tricky to get it to respect the "descend" flag. Pruning away subtries is much less pertinent for a difference trie than it is when doing a complete trie snapshot but I think it is worth investigating further as a separate issue.

@@ -322,33 +328,44 @@ func (sdb *StateDiffBuilder) createdAndUpdatedState(a, b trie.NodeIterator, watc
}
partialPath := trie.CompactToHex(nodeElements[0].([]byte))
valueNodePath := append(node.Path, partialPath...)

// ignore leaf node if it is not a watched address
if !isWatchedAddress(watchedAddressesLeafPaths, valueNodePath) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the path check on 309 already exclude this possibility?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is required since there is an edge case where before a watched contract is deployed, there might be some other account deployed on its path.
Eg. Let's say a leaf node of contract B to be watched has path 0309 when it is deployed at block number 20. Another contract A, which was deployed at block number 15, had leaf node at path 03. If we start statediffing at block number 10 with contract B as the only watched contract, it will index unncessary diff for contract A at block number 15 which just happens to be on the prospective path to contract B.

@ashwinphatak ashwinphatak merged commit bf4bba2 into cerc-io:v1.10.19-statediff-v4 Jun 28, 2022
@ashwinphatak ashwinphatak deleted the pm-account-selective-statediffing branch June 28, 2022 05:04
@prathamesh0
Copy link
Collaborator Author

This LGTM! I reviewed the difference iterator a bit and it appears it would be a bit tricky to get it to respect the "descend" flag. Pruning away subtries is much less pertinent for a difference trie than it is when doing a complete trie snapshot but I think it is worth investigating further as a separate issue.

Created #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants