-
Notifications
You must be signed in to change notification settings - Fork 66
Problem (CRO-594): block results and "fast sync" are not verified in client #651
Conversation
bors try |
tryBuild failed |
Codecov Report
@@ Coverage Diff @@
## master #651 +/- ##
==========================================
- Coverage 70.89% 70.16% -0.73%
==========================================
Files 133 133
Lines 16197 16384 +187
==========================================
+ Hits 11483 11496 +13
- Misses 4714 4888 +174
|
Give up on debugging of the compile error of |
bors retry |
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.
looks good -- client libraries depending on abci is a bit of an overkill / extra coupling.
It seems for the lite verification, the client doesn't need the whole node state, but only the top level "app state" / the inputs to computing app hash (staked state merkle trie root hash, rewards pool state, network parameters).
Perhaps extracting this needed information to a struct, e.g. something like:
pub struct ChainState {
last_account_root_hash: H256,
rewards_pool: RewardsPool,
network_params: NetworkParameters,
}
that would be in chain-core (it'll just need feature guards for serde),
and have this around:
- ChainNodeState could have a field say
last_top_level_state: ChainState
instead of individual components - compute_app_hash could take
&ChainState
as argument instead of those components - it could be stored for that historical querying and returned to client
any thoughts?
tryBuild failed |
if abci and client needs same data, consider separate to another lower level. |
chain-abci/src/app/app_init.rs
Outdated
let encoded_height = i64::encode_var_vec(0); | ||
inittx.put(COL_APP_HASHS, &encoded_height, &genesis_state.last_apphash); | ||
if write_history_states { | ||
inittx.put(COL_APP_STATES, &encoded_height, &encoded); |
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.
histroy states implies that vector
how about previos state?
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's stored as key value map: height -> state
let encoded_state = new_state.encode(); | ||
inittx.put(COL_NODE_INFO, LAST_STATE_KEY, &encoded_state); | ||
let encoded_height = i64::encode_var_vec(new_state.last_block_height); | ||
inittx.put(COL_APP_HASHS, &encoded_height, &new_state.last_apphash); |
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.
COL_APP_HASH?
because it's single
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's actually a map of height -> app_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.
lgtm
but do some tidy up and naming
I'll try this. we would have to hard code key length of |
Yeah, chain-core is a good place for this, it's just chain-core are more strict because of the no_std thing,. |
|
@@ -48,7 +48,7 @@ services: | |||
- ${TENDERMINT_ZEROFEE_RPC_PORT:-16657}:26657 | |||
chain-abci-zerofee: | |||
image: "${CHAIN_DOCKER_IMAGE:-integration-tests-chain}" | |||
command: "/usr/bin/chain-abci --host=0.0.0.0 --port=26658 --chain_id=${CHAIN_ID} --genesis_app_hash=${ZEROFEE_APP_HASH} --enclave_server=tcp://chain-tx-enclave-zerofee:25933 --data=/.storage" | |||
command: "/usr/bin/chain-abci --host=0.0.0.0 --port=26658 --chain_id=${CHAIN_ID} --genesis_app_hash=${ZEROFEE_APP_HASH} --enclave_server=tcp://chain-tx-enclave-zerofee:25933 --tx_query=tcp://chain-tx-enclave-zerofee:25933 --data=/.storage" |
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.
tx-query address != enclave server
just a note to myself, as this will then need to be fixed in #637
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.
lgtm
bors r+ |
651: Problem (CRO-594): block results and "fast sync" are not verified in client r=tomtau a=yihuang Solution: - Store history hashes to `COL_APP_HASHS`, history state to `COL_APP_STATES` - Add `query_state_batch` to rpc client, and verify block results with it. - Make fast-forward syncing optional - Improve `BlockGenerator` to pass manual synchronizer test `BlockGenerator` not support mocking transaction data yet, maybe save it for another PR. Co-authored-by: yihuang <yi.codeplayer@gmail.com>
Build failed |
bors retry |
Merge conflict (retrying...) |
Merge conflict |
…client Solution: - Store history hashes to `COL_APP_HASHS`, history state to `COL_APP_STATES` - Add `query_state_batch` to rpc client, and verify block results with it. - Make fast-forward syncing optional - Improve BlockGenerator to pass manual synchronizer test
Rebased. |
bors r+ |
651: Problem (CRO-594): block results and "fast sync" are not verified in client r=tomtau a=yihuang Solution: - Store history hashes to `COL_APP_HASHS`, history state to `COL_APP_STATES` - Add `query_state_batch` to rpc client, and verify block results with it. - Make fast-forward syncing optional - Improve `BlockGenerator` to pass manual synchronizer test `BlockGenerator` not support mocking transaction data yet, maybe save it for another PR. Co-authored-by: yihuang <yi.codeplayer@gmail.com>
2484: Bump cbindgen from 0.16.0 to 0.17.0 r=tomtau a=dependabot-preview[bot] Bumps [cbindgen](https://github.com/eqrion/cbindgen) from 0.16.0 to 0.17.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/releases">cbindgen's releases</a>.</em></p> <blockquote> <h2>v0.17.0</h2> <ul> <li>Add with_parse_extra_bindings to builder. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/645">#645</a>)</li> <li>Support NonZero and fix incorrect simplification of Option<!-- raw HTML omitted --> into ptr. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/647">#647</a>)</li> <li>Deal with name conflicts correctly in declaration type resolution. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/651">#651</a>)</li> <li>Support pointers to ZSTs. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/656">#656</a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/blob/master/CHANGES">cbindgen's changelog</a>.</em></p> <blockquote> <h2>0.17.0</h2> <pre><code> * Add with_parse_extra_bindings to builder. ([#645](mozilla/cbindgen#645)) * Support NonZero and fix incorrect simplification of Option<ptr> into ptr. ([#647](mozilla/cbindgen#647)) * Deal with name conflicts correctly in declaration type resolution. ([#651](mozilla/cbindgen#651)) * Support pointers to ZSTs. ([#656](mozilla/cbindgen#656)) </code></pre> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/eqrion/cbindgen/commit/8236c8267936ae66785cd236c9c119c2f5b95b57"><code>8236c82</code></a> v0.17.0</li> <li><a href="https://github.com/eqrion/cbindgen/commit/3d41d33ffe1b1f811a5e3e3a8a077b8ec7464150"><code>3d41d33</code></a> config: Deal with clippy lints -.-.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/c5c301b08a6a604d15e4ac6f18cb4ad5a916b4f1"><code>c5c301b</code></a> ir: Support pointers to zsts.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/d3cd22bc6f07ccb595b8b82c8765f9023f2ffcc1"><code>d3cd22b</code></a> doc: Document the <code>documentation</code> config entry.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/d0d287f9f32f4b64017250c0054e2637befa1075"><code>d0d287f</code></a> parser: Deal with a new clippy warning.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/750745831af8755790a42f199b7733b37a3d9e0d"><code>7507458</code></a> ir: Deal with name conflicts correctly in declaration type resolution.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/c47ee1516be72f4278b2c5e6b64a1e1edad13faf"><code>c47ee15</code></a> ir: Handle NonZero and simplify Option<NonZero> like we simplify Option<NonNu...</li> <li><a href="https://github.com/eqrion/cbindgen/commit/f922f68531fa44708af7779ffbb4b118d6e189ae"><code>f922f68</code></a> ir: Avoid generating bogus pointer arguments.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/4ba7d1f0833b2c09b1c77a3012460c937b414f52"><code>4ba7d1f</code></a> ir: Make simplify_standard_types less clone-happy.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/2e1be241671a356516cf8c910ba40c014c7b3144"><code>2e1be24</code></a> ir: Give integers a more structured representation.</li> <li>Additional commits viewable in <a href="https://github.com/eqrion/cbindgen/compare/v0.16.0...v0.17.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=cbindgen&package-manager=cargo&previous-version=0.16.0&new-version=0.17.0)](https://dependabot.com/compatibility-score/?dependency-name=cbindgen&package-manager=cargo&previous-version=0.16.0&new-version=0.17.0) 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: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2484: Bump cbindgen from 0.16.0 to 0.17.0 r=tomtau a=dependabot-preview[bot] Bumps [cbindgen](https://github.com/eqrion/cbindgen) from 0.16.0 to 0.17.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/releases">cbindgen's releases</a>.</em></p> <blockquote> <h2>v0.17.0</h2> <ul> <li>Add with_parse_extra_bindings to builder. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/645">#645</a>)</li> <li>Support NonZero and fix incorrect simplification of Option<!-- raw HTML omitted --> into ptr. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/647">#647</a>)</li> <li>Deal with name conflicts correctly in declaration type resolution. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/651">#651</a>)</li> <li>Support pointers to ZSTs. (<a href="https://github-redirect.dependabot.com/eqrion/cbindgen/issues/656">#656</a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/eqrion/cbindgen/blob/master/CHANGES">cbindgen's changelog</a>.</em></p> <blockquote> <h2>0.17.0</h2> <pre><code> * Add with_parse_extra_bindings to builder. ([#645](mozilla/cbindgen#645)) * Support NonZero and fix incorrect simplification of Option<ptr> into ptr. ([#647](mozilla/cbindgen#647)) * Deal with name conflicts correctly in declaration type resolution. ([#651](mozilla/cbindgen#651)) * Support pointers to ZSTs. ([#656](mozilla/cbindgen#656)) </code></pre> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/eqrion/cbindgen/commit/8236c8267936ae66785cd236c9c119c2f5b95b57"><code>8236c82</code></a> v0.17.0</li> <li><a href="https://github.com/eqrion/cbindgen/commit/3d41d33ffe1b1f811a5e3e3a8a077b8ec7464150"><code>3d41d33</code></a> config: Deal with clippy lints -.-.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/c5c301b08a6a604d15e4ac6f18cb4ad5a916b4f1"><code>c5c301b</code></a> ir: Support pointers to zsts.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/d3cd22bc6f07ccb595b8b82c8765f9023f2ffcc1"><code>d3cd22b</code></a> doc: Document the <code>documentation</code> config entry.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/d0d287f9f32f4b64017250c0054e2637befa1075"><code>d0d287f</code></a> parser: Deal with a new clippy warning.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/750745831af8755790a42f199b7733b37a3d9e0d"><code>7507458</code></a> ir: Deal with name conflicts correctly in declaration type resolution.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/c47ee1516be72f4278b2c5e6b64a1e1edad13faf"><code>c47ee15</code></a> ir: Handle NonZero and simplify Option<NonZero> like we simplify Option<NonNu...</li> <li><a href="https://github.com/eqrion/cbindgen/commit/f922f68531fa44708af7779ffbb4b118d6e189ae"><code>f922f68</code></a> ir: Avoid generating bogus pointer arguments.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/4ba7d1f0833b2c09b1c77a3012460c937b414f52"><code>4ba7d1f</code></a> ir: Make simplify_standard_types less clone-happy.</li> <li><a href="https://github.com/eqrion/cbindgen/commit/2e1be241671a356516cf8c910ba40c014c7b3144"><code>2e1be24</code></a> ir: Give integers a more structured representation.</li> <li>Additional commits viewable in <a href="https://github.com/eqrion/cbindgen/compare/v0.16.0...v0.17.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=cbindgen&package-manager=cargo&previous-version=0.16.0&new-version=0.17.0)](https://dependabot.com/compatibility-score/?dependency-name=cbindgen&package-manager=cargo&previous-version=0.16.0&new-version=0.17.0) 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: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Solution:
COL_APP_HASHS
, history state toCOL_APP_STATES
query_state_batch
to rpc client, and verify block results with it.BlockGenerator
to pass manual synchronizer testBlockGenerator
not support mocking transaction data yet, maybe save it for another PR.