You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, there is a strange situation when I add boolean data in cryptocurrency.proto under cryptocurrency-advance (diff below). After adding this field, the exonum.MapProof cannot get the correct Merkle root from the javascript client.
Could someone help to check whether it is an issue?
diff --git a/examples/cryptocurrency-advanced/backend/src/api.rs b/examples/cryptocurrency-advanced/backend/src/api.rs
index 8006eb7..c01cb1f 100644
--- a/examples/cryptocurrency-advanced/backend/src/api.rs
+++ b/examples/cryptocurrency-advanced/backend/src/api.rs
@@ -81,6 +81,13 @@ impl PublicApi {
let to_table: MapProof<Hash, Hash> =
general_schema.get_proof_to_service_table(CRYPTOCURRENCY_SERVICE_ID, 0);
+ let to_wallet =
+ currency_schema.wallets().get_proof(query.pub_key).check().unwrap();
+
+ println!("show entries {:?}", to_wallet.entries().collect::<Vec<_>>());
+ println!("show missing_keys {:?}", to_wallet.missing_keys().collect::<Vec<_>>());
+ println!("show merkle root {:?}", to_wallet.merkle_root());
+
let to_wallet: MapProof<PublicKey, Wallet> =
currency_schema.wallets().get_proof(query.pub_key);
diff --git a/examples/cryptocurrency-advanced/backend/src/proto/cryptocurrency.proto b/examples/cryptocurrency-advanced/backend/src/proto/cryptocurrency.proto
index 04252b0..7435e59 100644
--- a/examples/cryptocurrency-advanced/backend/src/proto/cryptocurrency.proto
+++ b/examples/cryptocurrency-advanced/backend/src/proto/cryptocurrency.proto
@@ -54,4 +54,6 @@ message Wallet {
uint64 history_len = 4;
// `Hash` of the transactions history.
exonum.Hash history_hash = 5;
+ // test
+ bool test_fail = 6;
}
diff --git a/examples/cryptocurrency-advanced/backend/src/wallet.rs b/examples/cryptocurrency-advanced/backend/src/wallet.rs
index 5a33dea..d4ed040 100644
--- a/examples/cryptocurrency-advanced/backend/src/wallet.rs
+++ b/examples/cryptocurrency-advanced/backend/src/wallet.rs
@@ -32,6 +32,8 @@ pub struct Wallet {
pub history_len: u64,
/// `Hash` of the transactions history.
pub history_hash: Hash,
+ /// test
+ pub test_fail: bool,
}
impl Wallet {
@@ -49,6 +51,7 @@ impl Wallet {
balance,
history_len,
history_hash,
+ test_fail: false,
}
}
/// Returns a copy of this wallet with updated balance.
diff --git a/examples/cryptocurrency-advanced/frontend/src/plugins/blockchain.js b/examples/cryptocurrency-advanced/frontend/src/plugins/blockchain.js
index 8b084a0..f654c22 100644
--- a/examples/cryptocurrency-advanced/frontend/src/plugins/blockchain.js
+++ b/examples/cryptocurrency-advanced/frontend/src/plugins/blockchain.js
@@ -116,9 +116,12 @@ module.exports = {
return Exonum.verifyBlock(data.block_proof, validators).then(() => {
// verify table timestamps in the root tree
const tableRootHash = Exonum.verifyTable(data.wallet_proof.to_table, data.block_proof.block.state_hash, SERVICE_ID, TABLE_INDEX)
-
+ console.log('tableRootHash: ' + tableRootHash)
// find wallet in the tree of all wallets
const walletProof = new Exonum.MapProof(data.wallet_proof.to_wallet, Exonum.PublicKey, Wallet)
+ console.log(walletProof.entries)
+ console.log(walletProof.missingKeys)
+ console.log('walletProof merkleRoot: ' + walletProof.merkleRoot)
if (walletProof.merkleRoot !== tableRootHash) {
throw new Error('Wallet proof is corrupted')
}
The results are below. From the backend side:
show entries [(PublicKey(cf0c5b2c...), Wallet { pub_key: PublicKey(cf0c5b2c...), name: "ababa", balance: 100, history_len: 1, history_hash: Hash(416e9a05...), test_fail: false })]
show missing_keys []
show merkle root Hash(b6cb148d...)
From the frontend side:
You can see the result of merkleRoot is different from "b6cb148d..." (backend result and tableRootHash in the frontend side) and "336bb671...". (walletProof merkleRoot in the frontend side).
The text was updated successfully, but these errors were encountered:
platform: Ubuntu 18.04
rust: rustc 1.38.0-nightly (78ca1bda3 2019-07-08)
exonum: 0.11-master
exonum-client: 0.16.4
Hi, there is a strange situation when I add boolean data in cryptocurrency.proto under cryptocurrency-advance (diff below). After adding this field, the exonum.MapProof cannot get the correct Merkle root from the javascript client.
Could someone help to check whether it is an issue?
The results are below.
From the backend side:
From the frontend side:
You can see the result of merkleRoot is different from "b6cb148d..." (backend result and tableRootHash in the frontend side) and "336bb671...". (walletProof merkleRoot in the frontend side).
The text was updated successfully, but these errors were encountered: