Skip to content

Commit dad0cdc

Browse files
authored
Merge pull request #2 from AloeareV/even_morchard
Even morchard
2 parents 4a1379d + f34d7b8 commit dad0cdc

22 files changed

+479
-239
lines changed

Cargo.lock

Lines changed: 25 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ members = [
66
]
77

88
[profile.release]
9-
debug = false
9+
debug = false
10+
11+
[patch.crates-io]
12+
zcash_note_encryption = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542" }
13+
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542" }
14+
orchard = { git = "https://github.com/zcash/orchard", rev = "597f37a869d2d03bb40b8b8108b88fba984b0842" }

config/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["transparent-inputs", "test-dependencies"] }
10-
zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
9+
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542", features = ["transparent-inputs", "test-dependencies"] }
10+
zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542"}

lib/Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ jubjub = "0.9.0"
4949
bls12_381 = "0.7"
5050
group = "0.12"
5151
rust-embed = { version = "6.3.0", features = ["debug-embed"] }
52-
orchard = "0.1.0"
52+
orchard = "0.2.0"
5353
subtle = "2.4.1"
54-
zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
55-
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["transparent-inputs", "test-dependencies"] }
56-
zcash_client_backend = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
57-
zcash_proofs = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["multicore"]}
58-
zcash_encoding = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76"}
59-
zcash_note_encryption = { git = "https://github.com/zcash/librustzcash", rev = "73d9395c9d3c5fa81fc7becd363a2c1a51772a76", features = ["pre-zip-212"]}
54+
zcash_address = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542"}
55+
zcash_primitives = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542", features = ["transparent-inputs", "test-dependencies"] }
56+
zcash_client_backend = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542"}
57+
zcash_proofs = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542", features = ["multicore"]}
58+
zcash_encoding = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542"}
59+
zcash_note_encryption = { git = "https://github.com/zcash/librustzcash", rev = "8ad60a0fc020ac0338615fd9f242e6eff7b66542", features = ["pre-zip-212"]}
6060
zingoconfig = { path = "../config" }
6161

6262
[dev-dependencies]

lib/proto/compact_formats.proto

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,30 @@ message CompactTx {
3737
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
3838
uint32 fee = 3;
3939

40-
repeated CompactSpend spends = 4; // inputs
41-
repeated CompactOutput outputs = 5; // outputs
40+
repeated CompactSaplingSpend spends = 4; // inputs
41+
repeated CompactSaplingOutput outputs = 5; // outputs
42+
repeated CompactOrchardAction actions = 6;
4243
}
4344

44-
// CompactSpend is a Sapling Spend Description as described in 7.3 of the Zcash
45+
// CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
4546
// protocol specification.
46-
message CompactSpend {
47+
message CompactSaplingSpend {
4748
bytes nf = 1; // nullifier (see the Zcash protocol specification)
4849
}
4950

5051
// output is a Sapling Output Description as described in section 7.4 of the
5152
// Zcash protocol spec. Total size is 948.
52-
message CompactOutput {
53+
message CompactSaplingOutput {
5354
bytes cmu = 1; // note commitment u-coordinate
5455
bytes epk = 2; // ephemeral public key
55-
bytes ciphertext = 3; // ciphertext and zkproof
56+
bytes ciphertext = 3; // first 52 bytes of ciphertext
57+
}
58+
59+
// https://github.com/zcash/zips/blob/main/zip-0225.rst#orchard-action-description-orchardaction
60+
// (but not all fields are needed)
61+
message CompactOrchardAction {
62+
bytes nullifier = 1; // [32] The nullifier of the input note
63+
bytes cmx = 2; // [32] The x-coordinate of the note commitment for the output note
64+
bytes ephemeralKey = 3; // [32] An encoding of an ephemeral Pallas public key
65+
bytes ciphertext = 4; // [52] The note plaintext component of the encCiphertext field
5666
}

lib/proto/service.proto

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ message TxFilter {
3232
}
3333

3434
// RawTransaction contains the complete transaction data. It also optionally includes
35-
// the block height in which the transaction was included.
35+
// the block height in which the transaction was included, or, when returned
36+
// by GetMempoolStream(), the latest block height.
3637
message RawTransaction {
3738
bytes data = 1; // exact data returned by Zcash 'getrawtransaction'
3839
uint64 height = 2; // height that the transaction was mined (or -1)
@@ -109,11 +110,12 @@ message Exclude {
109110

110111
// The TreeState is derived from the Zcash z_gettreestate rpc.
111112
message TreeState {
112-
string network = 1; // "main" or "test"
113-
uint64 height = 2;
114-
string hash = 3; // block id
115-
uint32 time = 4; // Unix epoch time when the block was mined
116-
string tree = 5; // sapling commitment tree state
113+
string network = 1; // "main" or "test"
114+
uint64 height = 2; // block height
115+
string hash = 3; // block id
116+
uint32 time = 4; // Unix epoch time when the block was mined
117+
string saplingTree = 5; // sapling commitment tree state
118+
string orchardTree = 6; // orchard commitment tree state
117119
}
118120

119121
// Results are sorted by height, which makes it easy to issue another
@@ -176,9 +178,6 @@ service CompactTxStreamer {
176178
// Return the txids corresponding to the given t-address within the given block range
177179
rpc GetTaddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
178180

179-
// Legacy API that is used as a fallback for t-Address support, if the server is running the old version (lwdv2)
180-
rpc GetAddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
181-
182181
rpc GetTaddressBalance(AddressList) returns (Balance) {}
183182
rpc GetTaddressBalanceStream(stream Address) returns (Balance) {}
184183

@@ -193,6 +192,8 @@ service CompactTxStreamer {
193192
// in the exclude list that don't exist in the mempool are ignored.
194193
rpc GetMempoolTx(Exclude) returns (stream CompactTx) {}
195194

195+
// Return a stream of current Mempool transactions. This will keep the output stream open while
196+
// there are mempool transactions. It will close the returned stream when a new block is mined.
196197
rpc GetMempoolStream(Empty) returns (stream RawTransaction) {}
197198

198199
// GetTreeState returns the note commitment tree state corresponding to the given block.

lib/src/blaze/block_witness_data.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl BlockAndWitnessData {
165165
let mut tree_state = TreeState::default();
166166
tree_state.height = h;
167167
tree_state.hash = hash.to_string();
168-
tree_state.tree = tree.to_string();
168+
tree_state.sapling_tree = tree.to_string();
169169

170170
tree_state
171171
}),
@@ -220,7 +220,8 @@ impl BlockAndWitnessData {
220220
return true;
221221
}
222222
let mut tree =
223-
CommitmentTree::<Node>::read(&hex::decode(ct.tree).unwrap()[..]).unwrap();
223+
CommitmentTree::<Node>::read(&hex::decode(ct.sapling_tree).unwrap()[..])
224+
.unwrap();
224225

225226
{
226227
let blocks = blocks.read().await;
@@ -249,7 +250,7 @@ impl BlockAndWitnessData {
249250
tree.write(&mut buf).unwrap();
250251

251252
// Return if verified
252-
hex::encode(buf) == vt.tree
253+
hex::encode(buf) == vt.sapling_tree
253254
})
254255
})
255256
.collect();
@@ -472,7 +473,7 @@ impl BlockAndWitnessData {
472473
CommitmentTree::empty()
473474
} else {
474475
let tree_state = GrpcConnector::get_sapling_tree(uri, prev_height).await?;
475-
let sapling_tree = hex::decode(&tree_state.tree).unwrap();
476+
let sapling_tree = hex::decode(&tree_state.sapling_tree).unwrap();
476477
self.verification_list.write().await.push(tree_state);
477478
CommitmentTree::read(&sapling_tree[..]).map_err(|e| format!("{}", e))?
478479
};

0 commit comments

Comments
 (0)