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

[dot/state] implement state_subscribeStorage #1290

Merged
merged 27 commits into from
Jan 12, 2021
Merged

Conversation

edwardmack
Copy link
Member

Changes

  • Implement/fix state_subscribeStorage RPC websocket function.

Tests

Make websocket call:

{
    "jsonrpc": "2.0",
    "method": "state_subscribeStorage",
    "params": [["0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850" , "0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96"]],
    "id": 1
}

and enjoy the results.

Checklist

  • I have read CODE_OF_CONDUCT and CONTRIBUTING
  • I have provided as much information as possible and necessary
  • I have reviewed my own pull request before requesting a review
  • All integration tests and required coverage checks are passing

Issues

Copy link
Contributor

@anthdm anthdm left a comment

Choose a reason for hiding this comment

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

LGTM, nice example btw

@edwardmack edwardmack merged commit b1e844b into development Jan 12, 2021
@edwardmack edwardmack deleted the ed/db_subscribe branch January 12, 2021 20:09
github-actions bot pushed a commit that referenced this pull request Jan 12, 2021
Edward Mack: [dot/state] implement state_subscribeStorage (#1290)

* added system accounts to gensis configs

Added test for encoding balances genesis parameters.

* add to full account object to raw genesis

* fix tests

* enable rpc module by defualt

* update gssmr genesis to use palletBalances key

* update genesis-raw

* use subscribe for db listener

* testing db storage subscribe

* lint

* add test for db subscribe

* add Example db.Subscribe code

* update go.mod to use updated chaindb

* implement subscribe storage, move filters

* remove unused code

* lint

* remove redundant test

* modify tests to increase coverage
Comment on lines +177 to +188
ent := s.tries[root].Entries()
for k, v := range ent {
if k != ":code" {
// todo, currently we're ignoring :code since this is a lot of data
kv := &KeyValue{
Key: common.MustHexToBytes(fmt.Sprintf("0x%x", k)),
Value: v,
}
subRes.Changes = append(subRes.Changes, *kv)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

this seems to send all the entries in the trie, not just the ones that are changed? am I mistaken?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I wasn't sure about this, however when I was testing with Substrate node, using key 0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850 (System EventCount) I saw that it was responding with a value every block, even though the value remained the same (1). So I figured that I should replicate the same behavior.

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