Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6195976
WIP Add IndexProof
dmitry-timofeev Jan 9, 2020
2751fe5
Make SignedMessage public:
dmitry-timofeev Jan 10, 2020
1912ce4
Finish tests
dmitry-timofeev Jan 10, 2020
b23e0cc
Improve documentation on proofs
dmitry-timofeev Jan 10, 2020
123b951
Implement proof constructors
dmitry-timofeev Jan 10, 2020
13c4ed5
Todo/fixes
dmitry-timofeev Jan 10, 2020
c5d3408
Fix documentation
dmitry-timofeev Jan 10, 2020
d8db838
Reimplement Block#fromMessage
dmitry-timofeev Jan 10, 2020
4260179
Fix checkstyle
dmitry-timofeev Jan 10, 2020
6ed552a
Add jira ref
dmitry-timofeev Jan 10, 2020
eea3ce6
Add changelog entry
dmitry-timofeev Jan 10, 2020
253a45a
Document the exception in case no index proof can be created.
dmitry-timofeev Jan 16, 2020
d47524e
Update to the new native spec
dmitry-timofeev Jan 16, 2020
4a1d3ca
Document the initialization connection
dmitry-timofeev Jan 16, 2020
1fa35e3
Merge remote-tracking branch 'main/master' into add-index-proof-ECR-4011
dmitry-timofeev Jan 16, 2020
0e835cc
Enable the tests depending on the native
dmitry-timofeev Jan 16, 2020
d0c47f6
Fix checkstyle
dmitry-timofeev Jan 16, 2020
edd78a4
Empty to trigger CI
dmitry-timofeev Jan 16, 2020
581bf98
Fix import
dmitry-timofeev Jan 16, 2020
d85adb2
Fix native methods names
dmitry-timofeev Jan 16, 2020
6fa70f3
Merge branch 'master' into add-index-proof-ECR-4011
dmitry-timofeev Jan 16, 2020
0f7aeb6
Extract #getIndexHash in HashableIndex interface [ECR-4064].
dmitry-timofeev Jan 16, 2020
7abe5a5
Add CL entry
dmitry-timofeev Jan 16, 2020
795d9df
s/must affect/affect/
dmitry-timofeev Jan 17, 2020
4020af4
Merge remote-tracking branch 'main/master' into add-hashable-index-EC…
dmitry-timofeev Jan 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exonum-java-binding/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Transaction index in block type changed from `long` to `int`. (#1348)
- Extracted artifact version to the separate field from the artifact name.
Artifact name format is `groupId/artifactId` now.
PluginId format is `runtimeId:artifactName:artifactVersion` now. (#1349)
PluginId format is `runtimeId:artifactName:artifactVersion` now. (#1349)
- Extracted `#getIndexHash` into `HashableIndex` interface. (#1366)

### Removed
- Classes supporting no longer used tree-like list proof representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
package com.exonum.binding.core.service;

import com.exonum.binding.core.blockchain.Block;
import com.exonum.binding.core.storage.indices.ProofEntryIndexProxy;
import com.exonum.binding.core.storage.indices.ProofListIndexProxy;
import com.exonum.binding.core.storage.indices.ProofMapIndexProxy;

/**
* A schema of the collections (a.k.a. indices) of a service.
Expand All @@ -38,9 +35,7 @@
* the framework will not be able to verify that its transactions cause the same
* results on different nodes.
*
* @see ProofListIndexProxy#getIndexHash()
* @see ProofMapIndexProxy#getIndexHash()
* @see ProofEntryIndexProxy#getIndexHash()
* @see com.exonum.binding.core.storage.indices.HashableIndex
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other links are index-specific.

* @see com.exonum.binding.core.blockchain.Blockchain
*/
public interface Schema {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020 The Exonum Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.exonum.binding.core.storage.indices;

import com.exonum.binding.common.hash.HashCode;

/**
* A hashable index provides a cryptographic hash which represents the complete state of this index.
*
* <p>Hashable indexes enable efficient verification of their contents. Two indexes contain
* the same values if their index hashes are equal. This property is used in the consensus
* algorithm to compare the database state on different nodes.
*
* <p>Index hashes are also used in verifiable index views. Such views contain a subset
* of index elements and a proof that jointly allow to restore the index hash. The computed
* index hash allows to verify that the elements come from an index with a certain state.
*
* <p>Hashable indexes may participate in
* <a href="https://docs.rs/exonum-merkledb/0.13.0-rc.2/exonum_merkledb/#state-aggregation">state hash aggregation</a>.
*
* @see <a href="https://docs.rs/exonum-merkledb/0.13.0-rc.2/exonum_merkledb/trait.ObjectHash.html">ObjectHash trait</a>
*/
public interface HashableIndex extends StorageIndex {

/**
* Returns the index hash which represents the complete state of this index.
* Any modifications to the stored entries affect the index hash.
*
* <p>How index hash is computed depends on the index data structure implementation.
*/
HashCode getIndexHash();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*
* @see View
*/
public final class ProofEntryIndexProxy<T> extends AbstractIndexProxy {
public final class ProofEntryIndexProxy<T> extends AbstractIndexProxy implements HashableIndex {

static {
LibraryLoader.load();
Expand Down Expand Up @@ -178,8 +178,9 @@ public T get() {
* <p>The entry index hash is computed as SHA-256 of the entry binary representation, or
* a hash of zeroes if the entry is not set.
*
* @throws IllegalStateException if this list is not valid
* @throws IllegalStateException if the proxy is invalid
*/
@Override
public HashCode getIndexHash() {
return HashCode.fromBytes(nativeGetIndexHash(getNativeHandle()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* @see View
*/
public final class ProofListIndexProxy<E> extends AbstractListIndexProxy<E>
implements ListIndex<E> {
implements ListIndex<E>, HashableIndex {

static {
LibraryLoader.load();
Expand Down Expand Up @@ -212,12 +212,7 @@ private static ListProof parseProof(byte[] proofMessage) {
}
}

/**
* Returns the index hash which represents the complete state of this list.
* Any modifications to the stored entries affect the index hash.
*
* @throws IllegalStateException if this list is not valid
*/
@Override
public HashCode getIndexHash() {
return HashCode.fromBytes(nativeGetIndexHash(getNativeHandle()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
* @param <V> the type of values in this map
* @see View
*/
public final class ProofMapIndexProxy<K, V> extends AbstractIndexProxy implements MapIndex<K, V> {
public final class ProofMapIndexProxy<K, V> extends AbstractIndexProxy implements MapIndex<K, V>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we make the index factories and add the interfaces for each index type, those interfaces could extend HashableIndex, instead of implementation classes.

HashableIndex {

private final Serializer<K> keySerializer;
private final CheckingSerializerDecorator<V> valueSerializer;
Expand Down Expand Up @@ -381,12 +382,7 @@ private static MapProof decodeProofMessage(byte[] proofMessage) {
}
}

/**
* Returns the index hash which represents the complete state of this map.
* Any modifications to the stored entries affect the index hash.
*
* @throws IllegalStateException if this map is not valid
*/
@Override
public HashCode getIndexHash() {
return HashCode.fromBytes(nativeGetIndexHash(getNativeHandle()));
}
Expand Down