-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add block and index proofs [ECR-4011] #1355
Conversation
Make SignedMessage public and prevent redundant message serialization in #parseFrom.
Also, remove bad/redundant anchors.
Prevent redundant deserialization.
[skip ci]
* | ||
* Link here with <a href="<relative path>/Blockchain.html#proofs">Blockchain Proofs</a>. | ||
* See also: https://stackoverflow.com/a/27522316/ --> | ||
* <h2 id="proofs">Proofs</h2> |
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.
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.
The documentation here looks good 👍
[skip ci]
todo: Shall we allow creating proofs for invalid (e.g., impossible) index names or throw | ||
an exception? | ||
|
||
todo: If index proofs for "uninitialized" indexes are forbidden, document that. |
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.
The native will throw an exception, so I think we should document it.
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.
Why doesn't it return a proof of absence (no such index)? Especially as an index is not "initialized" unless (?) something is recorded in it? Doesn't that place extra burden on the service developers to "initialize" an index? Shall they now write an extra "initialize" method in a schema of each service (and we — document that)?
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.
Actually, I don't know. I read sources of proof_for_index
method - it looks like explicit check for existence of the index can be removed, and the method will return proof of absence. @slowli am I right?
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.
Yes, if the check of existence is removed, proof_for_index
may return proof of absence for a non-existing index. The reason the method is implemented as is currently is that returning proof for a non-existing index doesn't make sense in a typical use case (returning the index proof + proof for data within the index, such as proof for a wallet in the cryptocurrency service).
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.
Thanks! Would you clarify please, if one first requests a proof from an empty index (= no wallets), will it become "initialized"? Will one be able to provide then a proof that the index remains empty?
* @param height the height of the block | ||
*/ | ||
static BlockProof createBlockProof( | ||
/* todo: here snapshot is not strictly required — but shall we allow Forks (see the ticket) */ |
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.
Actually I couldn't find any use case for block proofs in execution context (where fork is available), so I propose to keep such restriction for now.
* | ||
* <p>If an index does not exist in the database, then the MapProof will prove its absence. | ||
* | ||
* @see <a href="../Blockchain.html#service-data-proof">Service Data Proofs</a> |
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.
IDEA's quick documentation correctly opens the referenced javadoc, but doesn't recognize anchors. I think it's not the issue for changing links, just fyi
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.
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.
Don't anchors work anywhere, even in Blockchain#callerrors?
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.
* @see com.exonum.binding.core.blockchain.Block | ||
*/ | ||
@AutoValue | ||
public abstract class BlockProof { |
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.
what is the reason to have this wrapper? Could we use Proofs.BlockProof
directly (and index proof as well)?
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.
The main reason is to have some flexibility to add operations if we release 1.0 without proof verifications. With a wrapper we can add extra operations on top of the proof data if they are needed (e.g., verification).
A side benefit — better documentation, but it can be achieved by other means.
We briefly discussed Optional vs Exception in case of uninitialized indexes in |
exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/Schema.java
Outdated
Show resolved
Hide resolved
* entire blockchain state and is recorded as such in {@linkplain Block#getStateHash() blocks} | ||
* and Precommit messages. | ||
* | ||
* <p>Exonum starts aggregating a service collection state hash once it is <em>initialized</em>: |
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.
* <p>Exonum starts aggregating a service collection state hash once it is <em>initialized</em>: | |
* <p>Exonum starts aggregating a service collections state hash once it is <em>initialized</em>: |
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.
The sentence says when Exonum starts aggregating one (any, a single) collection.
[skip ci]
Overview
Added block and index proofs support. They shall be created through Blockchain.
Documented the various proof types: what they prove, what comprises them, how to create them. Added an example for a commonly used proof type.
Also:
See: ECR-4011
Definition of Done