Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ func getBlockFromRPC(height int) (*walletrpc.CompactBlock, error) {
t.SetTxID(parser.Reverse(txid))
}
r := block.ToCompact()
r.SaplingCommitmentTreeSize = block1.Trees.Sapling.Size
r.OrchardCommitmentTreeSize = block1.Trees.Orchard.Size
r.ChainMetadata.SaplingCommitmentTreeSize = block1.Trees.Sapling.Size
r.ChainMetadata.OrchardCommitmentTreeSize = block1.Trees.Orchard.Size
return r, nil
}

Expand Down
83 changes: 54 additions & 29 deletions docs/rtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ <h2>Table of Contents</h2>
<a href="#compact_formats.proto">compact_formats.proto</a>
<ul>

<li>
<a href="#cash.z.wallet.sdk.rpc.ChainMetadata"><span class="badge">M</span>ChainMetadata</a>
</li>

<li>
<a href="#cash.z.wallet.sdk.rpc.CompactBlock"><span class="badge">M</span>CompactBlock</a>
</li>
Expand Down Expand Up @@ -358,6 +362,37 @@ <h2 id="compact_formats.proto">compact_formats.proto</h2><a href="#title">Top</a
<p></p>


<h3 id="cash.z.wallet.sdk.rpc.ChainMetadata">ChainMetadata</h3>
<p>ChainMetadata represents information about the state of the chain as of a given block.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>saplingCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>the size of the Sapling note commitment tree as of the end of this block </p></td>
</tr>

<tr>
<td>orchardCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>the size of the Orchard note commitment tree as of the end of this block </p></td>
</tr>

</tbody>
</table>





<h3 id="cash.z.wallet.sdk.rpc.CompactBlock">CompactBlock</h3>
<p>CompactBlock is a packaging of ONLY the data from a block that's needed to:</p><p>1. Detect a payment to your shielded Sapling address</p><p>2. Detect a spend of your shielded Sapling notes</p><p>3. Update your witnesses to generate new Sapling spend proofs.</p>

Expand Down Expand Up @@ -418,17 +453,10 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactBlock">CompactBlock</h3>
</tr>

<tr>
<td>saplingCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>the size of the Sapling note commitment tree as of the end of this block </p></td>
</tr>

<tr>
<td>orchardCommitmentTreeSize</td>
<td><a href="#uint32">uint32</a></td>
<td>chainMetadata</td>
<td><a href="#cash.z.wallet.sdk.rpc.ChainMetadata">ChainMetadata</a></td>
<td></td>
<td><p>the size of the Orchard note commitment tree as of the end of this block </p></td>
<td><p>information about the state of the chain as of this block </p></td>
</tr>

</tbody>
Expand Down Expand Up @@ -473,7 +501,7 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactOrchardAction">CompactOrchardAction</h3>
<td>ciphertext</td>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>[52] The note plaintext component of the encCiphertext field </p></td>
<td><p>[52] The first 52 bytes of the encCiphertext field </p></td>
</tr>

</tbody>
Expand All @@ -484,7 +512,7 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactOrchardAction">CompactOrchardAction</h3>


<h3 id="cash.z.wallet.sdk.rpc.CompactSaplingOutput">CompactSaplingOutput</h3>
<p>output is a Sapling Output Description as described in section 7.4 of the</p><p>Zcash protocol spec. Total size is 948.</p>
<p>output encodes the `cmu` field, `ephemeralKey` field, and a 52-byte prefix of the</p><p>`encCiphertext` field of a Sapling Output Description. These fields are described in</p><p>section 7.4 of the Zcash protocol spec:</p><p>https://zips.z.cash/protocol/protocol.pdf#outputencodingandconsensus</p><p>Total size is 116 bytes.</p>


<table class="field-table">
Expand All @@ -501,7 +529,7 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactSaplingOutput">CompactSaplingOutput</h3>
</tr>

<tr>
<td>epk</td>
<td>ephemeralKey</td>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>ephemeral public key </p></td>
Expand Down Expand Up @@ -559,7 +587,11 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactTx">CompactTx</h3>
<td>index</td>
<td><a href="#uint64">uint64</a></td>
<td></td>
<td><p>the index within the full block </p></td>
<td><p>Index and hash will allow the receiver to call out to chain
explorers or other data structures to retrieve more information
about this transaction.

the index within the full block </p></td>
</tr>

<tr>
Expand All @@ -576,22 +608,22 @@ <h3 id="cash.z.wallet.sdk.rpc.CompactTx">CompactTx</h3>
<td><p>The transaction fee: present if server can provide. In the case of a
stateless server and a transaction with transparent inputs, this will be
unset because the calculation requires reference to prior transactions.
in a pure-Sapling context, the fee will be calculable as:
valueBalance &#43; (sum(vPubNew) - sum(vPubOld) - sum(tOut)) </p></td>
If there are no transparent inputs, the fee will be calculable as:
valueBalanceSapling &#43; valueBalanceOrchard &#43; sum(vPubNew) - sum(vPubOld) - sum(tOut) </p></td>
</tr>

<tr>
<td>spends</td>
<td><a href="#cash.z.wallet.sdk.rpc.CompactSaplingSpend">CompactSaplingSpend</a></td>
<td>repeated</td>
<td><p>inputs </p></td>
<td><p> </p></td>
</tr>

<tr>
<td>outputs</td>
<td><a href="#cash.z.wallet.sdk.rpc.CompactSaplingOutput">CompactSaplingOutput</a></td>
<td>repeated</td>
<td><p>outputs </p></td>
<td><p> </p></td>
</tr>

<tr>
Expand Down Expand Up @@ -1308,8 +1340,8 @@ <h3 id="cash.z.wallet.sdk.rpc.GetSubtreeRootsArg">GetSubtreeRootsArg</h3>
</tr>

<tr>
<td>limit</td>
<td><a href="#uint64">uint64</a></td>
<td>maxEntries</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>Maximum number of entries to return, or 0 for all entries. </p></td>
</tr>
Expand Down Expand Up @@ -1539,13 +1571,6 @@ <h3 id="cash.z.wallet.sdk.rpc.SubtreeRoot">SubtreeRoot</h3>
</thead>
<tbody>

<tr>
<td>index</td>
<td><a href="#uint32">uint32</a></td>
<td></td>
<td><p>The index of the subtree. Each subtree containx 2^16 leaves. </p></td>
</tr>

<tr>
<td>rootHash</td>
<td><a href="#bytes">bytes</a></td>
Expand Down Expand Up @@ -1713,13 +1738,13 @@ <h3 id="cash.z.wallet.sdk.rpc.ShieldedProtocol">ShieldedProtocol</h3>
<tbody>

<tr>
<td>SAPLING</td>
<td>sapling</td>
<td>0</td>
<td><p></p></td>
</tr>

<tr>
<td>ORCHARD</td>
<td>orchard</td>
<td>1</td>
<td><p></p></td>
</tr>
Expand Down
8 changes: 4 additions & 4 deletions frontend/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func (s *lwdStreamer) GetBlockNullifiers(ctx context.Context, id *walletrpc.Bloc
tx.Outputs = nil
}
// these are not needed (we prefer to save bandwidth)
cBlock.SaplingCommitmentTreeSize = 0
cBlock.OrchardCommitmentTreeSize = 0
cBlock.ChainMetadata.SaplingCommitmentTreeSize = 0
cBlock.ChainMetadata.OrchardCommitmentTreeSize = 0
return cBlock, err
}

Expand Down Expand Up @@ -228,8 +228,8 @@ func (s *lwdStreamer) GetBlockRangeNullifiers(span *walletrpc.BlockRange, resp w
tx.Outputs = nil
}
// these are not needed (we prefer to save bandwidth)
cBlock.SaplingCommitmentTreeSize = 0
cBlock.OrchardCommitmentTreeSize = 0
cBlock.ChainMetadata.SaplingCommitmentTreeSize = 0
cBlock.ChainMetadata.OrchardCommitmentTreeSize = 0
if err := resp.Send(cBlock); err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions parser/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ func (b *Block) GetPrevHash() []byte {
func (b *Block) ToCompact() *walletrpc.CompactBlock {
compactBlock := &walletrpc.CompactBlock{
//TODO ProtoVersion: 1,
Height: uint64(b.GetHeight()),
PrevHash: b.hdr.HashPrevBlock,
Hash: b.GetEncodableHash(),
Time: b.hdr.Time,
Height: uint64(b.GetHeight()),
PrevHash: b.hdr.HashPrevBlock,
Hash: b.GetEncodableHash(),
Time: b.hdr.Time,
ChainMetadata: &walletrpc.ChainMetadata{},
}

// Only Sapling transactions have a meaningful compact encoding
Expand Down
6 changes: 3 additions & 3 deletions parser/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ func (p *output) ParseFromSlice(data []byte, version uint32) ([]byte, error) {

func (p *output) ToCompact() *walletrpc.CompactSaplingOutput {
return &walletrpc.CompactSaplingOutput{
Cmu: p.cmu,
Epk: p.ephemeralKey,
Ciphertext: p.encCiphertext[:52],
Cmu: p.cmu,
EphemeralKey: p.ephemeralKey,
Ciphertext: p.encCiphertext[:52],
}
}

Expand Down
Loading