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

Merkle proofs for receipts #1216

Merged
merged 2 commits into from
Aug 28, 2019
Merged

Merkle proofs for receipts #1216

merged 2 commits into from
Aug 28, 2019

Conversation

Kouprin
Copy link
Member

@Kouprin Kouprin commented Aug 26, 2019

The problem is to make sure that received receipts are trusty.

The common idea is to deliver a pair of (receipts, receipts_proof)
where receipts_proof is a Merkle proof of the receipts are received.

While chunk is producing, we calculate Merkle proof root and put it
into chunk header (check ClientActor::receipts_proof for more details).

Then we should check proofs in two cases:

  1. Anyone who cares about shard and applying chunks completely
    must compare Merkle root with proof which is stored into chunk header.
  2. Sending ChunkOnePart, we must calculate proofs for each subset of
    receipts related to some shard, as many as num_shards we have.
    Receiving ChunkOnePart, we must check that all proofs are given and
    all proofs guarantee that each subset contains in chunk receipts.

TEST PLAN

  • sanity tests in chain and client folders
  • cargo test --all-features --package near-client --test cross_shard_tx tests::test_cross_shard_tx -- --exact --nocapture
    (10 iterations)
  • cargo test --all-features --package near --test run_nodes run_nodes_2 -- --exact --nocapture
  • cargo test --package near --test stake_nodes test_validator_join -- --exact --nocapture

LOGIC REVIEWER

Alex Skidanov

The problem is to make sure that received receipts are trusty.

The common idea is to deliver a pair of (receipts, receipts_proof)
where receipts_proof is a Merkle proof of the receipts are received.

While chunk is producing, we calculate Merkle proof root and put it
into chunk header (check ClientActor::receipts_proof for more details).

Then we should check proofs in two cases:
1. Anyone who cares about shard and applying chunks completely
must compare Merkle root with proof which is stored into chunk header.
2. Sending ChunkOnePart, we must calculate proofs for each subset of
receipts related to some shard, as many as num_shards we have.
Receiving ChunkOnePart, we must check that all proofs are given and
all proofs guarantee that each subset contains in chunk receipts.

TEST PLAN
===
- sanity tests in chain and client folders
- cargo test --all-features --package near-client --test cross_shard_tx tests::test_cross_shard_tx -- --exact --nocapture
(10 iterations)
- cargo test --all-features --package near --test run_nodes run_nodes_2 -- --exact --nocapture
- cargo test --package near --test stake_nodes test_validator_join -- --exact --nocapture

LOGIC REVIEWER
===
Alex Skidanov
@Kouprin Kouprin requested a review from ilblackdragon as a code owner August 26, 2019 17:18
@Kouprin Kouprin requested review from SkidanovAlex and ilblackdragon and removed request for ilblackdragon August 27, 2019 07:17
chain/chain/src/chain.rs Outdated Show resolved Hide resolved
chain/chain/src/chain.rs Outdated Show resolved Hide resolved
chain/chunks/src/lib.rs Outdated Show resolved Hide resolved
chain/client/src/client.rs Outdated Show resolved Hide resolved
chain/client/src/client.rs Outdated Show resolved Hide resolved
@SkidanovAlex SkidanovAlex merged commit e2b0c4a into chunks Aug 28, 2019
@Kouprin Kouprin deleted the kpr_receipts_proofs_v4 branch August 29, 2019 11:18
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.

2 participants