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

Problem (WIP #1313): light client doesn't verify the fetched staking state #1466

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Apr 22, 2020

Solution:

This feature(query historical staked state) is also needed to make the reward integration tests more stable.
Added a new abci_query path "staking" which is like "account", but it returns JSON directly, also support the new features (historical query, proof), the next step will be update the "staking_state" API in client-rpc and client-cli to use the new one.

@codecov
Copy link

codecov bot commented Apr 22, 2020

Codecov Report

Merging #1466 into master will increase coverage by 0.06%.
The diff coverage is 76.74%.

@@            Coverage Diff             @@
##           master    #1466      +/-   ##
==========================================
+ Coverage   64.45%   64.51%   +0.06%     
==========================================
  Files         160      160              
  Lines       21632    21673      +41     
==========================================
+ Hits        13942    13983      +41     
  Misses       7690     7690              
Impacted Files Coverage Δ
chain-storage/src/lib.rs 53.39% <0.00%> (-1.61%) ⬇️
chain-storage/src/api.rs 86.59% <50.00%> (-3.29%) ⬇️
chain-abci/src/app/query.rs 64.00% <81.25%> (+2.05%) ⬆️
chain-abci/src/app/app_init.rs 77.87% <100.00%> (+0.29%) ⬆️
chain-abci/tests/abci_app.rs 94.82% <100.00%> (+0.08%) ⬆️
chain-core/src/state/account.rs 85.89% <0.00%> (+0.42%) ⬆️
chain-core/src/state/account/address.rs 88.63% <0.00%> (+20.45%) ⬆️

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

is the new column really required / does this need a breaking change? this is only for querying and if one provides the tx-query flag, it should be storing historical app states and each app state contains the staking version?

CHANGELOG.md Outdated Show resolved Hide resolved
@yihuang
Copy link
Collaborator Author

yihuang commented Apr 22, 2020

is the new column really required / does this need a breaking change? this is only for querying and if one provides the tx-query flag, it should be storing historical app states and each app state contains the staking version?

The current historical app states only stores ChainState, staking_version is not in that, so an alternative solution is to put staking_version into the ChainState, or store historical ChainNodeState, I'm not sure.

@tomtau
Copy link
Contributor

tomtau commented Apr 22, 2020

is the new column really required / does this need a breaking change? this is only for querying and if one provides the tx-query flag, it should be storing historical app states and each app state contains the staking version?

The current historical app states only stores ChainState, staking_version is not in that, so an alternative solution is to put staking_version into the ChainState, or store historical ChainNodeState, I'm not sure.

all the options are breaking -- a new column is probably the simplest.
I guess it's not possible to retroactively create this column, so the easiest migration will be to sync from scratch?

@yihuang
Copy link
Collaborator Author

yihuang commented Apr 22, 2020

all the options are breaking -- a new column is probably the simplest.
I guess it's not possible to retroactively create this column, so the easiest migration will be to sync from scratch?

Yes, the information was not there.

@yihuang yihuang force-pushed the history_staking branch 2 times, most recently from bf98406 to 470d7ab Compare April 22, 2020 13:03
@yihuang yihuang requested a review from tomtau April 22, 2020 13:09
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

I guess the column is the simplest breaking change -- just one thing is whether this could function without historical states?
Also I wouldn't mark this as "fix #1313", as client wasn't updated to verify fetched staking states in this PR?

chain-storage/src/api.rs Show resolved Hide resolved
@yihuang
Copy link
Collaborator Author

yihuang commented Apr 23, 2020

I guess the column is the simplest breaking change -- just one thing is whether this could function without historical states?

#1466 (comment)

Also I wouldn't mark this as "fix #1313", as client wasn't updated to verify fetched staking states in this PR?

Yes, I'll remove the "fix".

…d staking state

Solution:
- Support query merkle inclusion proof
- Also support query historical staking state
- Query json encoded staking from abci_query directly crypto-com#1464
@yihuang yihuang changed the title Problem (Fix #1313): light client doesn't verify the fetched staking state Problem (WIP #1313): light client doesn't verify the fetched staking state Apr 23, 2020
@tomtau
Copy link
Contributor

tomtau commented Apr 23, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 23, 2020

Build succeeded:

@bors bors bot merged commit 0c9738f into crypto-com:master Apr 23, 2020
bors bot added a commit that referenced this pull request Apr 29, 2020
1467: Problem (Fix #1040): No reward distribution integration tests r=tomtau a=yihuang

    Solution:
    - Add a dedicated reward integration test
      Check:
      - monetary expansion formula, tau decaying
      - no reward for jailed node
      - slashing is added to reward pool

Based on #1466, rebase after that is merged.

1504: Bump serde_json from 1.0.51 to 1.0.52 r=tomtau a=dependabot-preview[bot]

Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.51 to 1.0.52.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/serde-rs/json/commit/9354bec7ddf0733bae7666e64f0078d9d5f029d9"><code>9354bec</code></a> Release 1.0.52</li>
<li><a href="https://github.com/serde-rs/json/commit/23c00cbd57bbe5b4975731e223ab51f3680b4b93"><code>23c00cb</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/serde-rs/json/issues/658">#658</a> from jplatte/to_raw_value</li>
<li><a href="https://github.com/serde-rs/json/commit/169a895ef600b7c92eb135dff13c75a6108f3e58"><code>169a895</code></a> Add value::to_raw_value</li>
<li><a href="https://github.com/serde-rs/json/commit/cb1782104a90f599a67b7c555b97d701f9875fe8"><code>cb17821</code></a> Run clippy on latest nightly that has clippy</li>
<li><a href="https://github.com/serde-rs/json/commit/0fb61479e7026683dd32fb8dfa0eb88e35693cd2"><code>0fb6147</code></a> Mark StreamDeserializer's error codepaths as cold</li>
<li>See full diff in <a href="https://github.com/serde-rs/json/compare/v1.0.51...v1.0.52">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=serde_json&package-manager=cargo&previous-version=1.0.51&new-version=1.0.52)](https://dependabot.com/compatibility-score/?dependency-name=serde_json&package-manager=cargo&previous-version=1.0.51&new-version=1.0.52)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)



</details>

Co-authored-by: yihuang <huang@crypto.com>
Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants