Skip to content
Draft
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
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -668,26 +668,26 @@ jobs:
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zebrad-${{ matrix.name }}
path: ./src
path: ./bin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When creating stacked PRs, note the PR you are building on top of in the top comment, so that reviewers know to ignore those commits. (I originally asked to separate this out into a separate PR because it makes review harder, then I realised this was stacked on #47.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will unstack.


- name: Download zainod artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zainod-${{ matrix.name }}
path: ./src
path: ./bin

- name: Download zallet artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zallet-${{ matrix.name }}
path: ./src
path: ./bin

- name: Make artifact executable
if: runner.os != 'Windows'
run: |
chmod +x ${{ format('./src/zebrad{0}', matrix.file_ext) }}
chmod +x ${{ format('./src/zainod{0}', matrix.file_ext) }}
chmod +x ${{ format('./src/zallet{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zebrad{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zainod{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zallet{0}', matrix.file_ext) }}

- name: Run sec-hard test
shell: bash
Expand Down Expand Up @@ -802,26 +802,26 @@ jobs:
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zebrad-${{ matrix.name }}
path: ./src
path: ./bin

- name: Download zainod artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zainod-${{ matrix.name }}
path: ./src
path: ./bin

- name: Download zallet artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: zallet-${{ matrix.name }}
path: ./src
path: ./bin

- name: Make artifact executable
if: runner.os != 'Windows'
run: |
chmod +x ${{ format('./src/zebrad{0}', matrix.file_ext) }}
chmod +x ${{ format('./src/zainod{0}', matrix.file_ext) }}
chmod +x ${{ format('./src/zallet{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zebrad{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zainod{0}', matrix.file_ext) }}
chmod +x ${{ format('./bin/zallet{0}', matrix.file_ext) }}

- name: Get Sprout parameters
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
Expand Down Expand Up @@ -878,7 +878,7 @@ jobs:
sys.exit(1)
EOF
. ./venv/bin/activate
ZEBRAD=$(pwd)/${{ format('src/zebrad{0}', matrix.file_ext) }} ZAINOD=$(pwd)/${{ format('src/zainod{0}', matrix.file_ext) }} ZALLET=$(pwd)/${{ format('src/zallet{0}', matrix.file_ext) }} SRC_DIR=$(pwd) python3 ./subclass.py
ZEBRAD=$(pwd)/${{ format('bin/zebrad{0}', matrix.file_ext) }} ZAINOD=$(pwd)/${{ format('bin/zainod{0}', matrix.file_ext) }} ZALLET=$(pwd)/${{ format('bin/zallet{0}', matrix.file_ext) }} SRC_DIR=$(pwd) python3 ./subclass.py

- uses: ./.github/actions/finish-interop
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
qa/pull-tester/tests_config.py
qa/pull-tester/tests_config.ini
qa/cache/*
src/*
bin/*

poetry.lock
.venv
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ codebase, with the Python test framework (and some of the tests) inherited from
### Running the tests locally

- Clone the repository.
- Build `zebrad`, `zainod`, and `zallet` binaries, and place them in a folder
`./src/` under the repository root.
- Build `zebrad`, `zainod`, and `zallet` binaries, and place them in a directory
`./bin/` under the repository root.

#### With uv (recommended)

Expand Down
1 change: 1 addition & 0 deletions bin/.gitinclude
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This directory is "INTENTIONALLY LEFT BLANK". Its purpose is to hold binaries for users that prefer to keep those references in the working directory. The contents of this directory are not intended to be tracked by git.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.1.0"
requires-python = "==3.11.*"
dependencies = [
"base58",
"grpcio",
"protobuf",
"pyzmq",
"toml",
]
6 changes: 3 additions & 3 deletions qa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pip3 install pyzmq base58 toml
Setup
=====

By default, binaries must exist in the `../src ` folder. All tests require the `zebrad`
By default, binaries must exist in the `../bin` directory. All tests require the `zebrad`
binary; most tests require the `zallet` binary; some tests require the `zainod` binary.

Alternatively, you can set the binary paths with:
Expand Down Expand Up @@ -61,8 +61,8 @@ Possible options, which apply to each individual test run:
-h, --help show this help message and exit
--nocleanup Leave zcashds and test.* datadir on exit or error
--noshutdown Don't stop zcashds after the test execution
--srcdir=SRCDIR Source directory containing zcashd/zcash-cli
(default: ../../src)
--bindir=BINDIR Directory containing zallet/zainod/zebrad
(default: ../../bin)
--tmpdir=TMPDIR Root directory for datadirs
--tracerpc Print out all RPC calls as they are made
--coveragedir=COVERAGEDIR
Expand Down
8 changes: 4 additions & 4 deletions qa/pull-tester/rpc-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ def run_tests(test_handler, test_list, src_dir, build_dir, exeext, jobs=1, enabl

#Set env vars
if "ZEBRAD" not in os.environ:
os.environ["ZEBRAD"] = os.path.join(build_dir, "src", "zebrad" + exeext)
os.environ["ZEBRAD"] = os.path.join(build_dir, "bin", "zebrad" + exeext)
if "ZAINOD" not in os.environ:
os.environ["ZAINOD"] = os.path.join(build_dir, "src", "zainod" + exeext)
os.environ["ZAINOD"] = os.path.join(build_dir, "bin", "zainod" + exeext)
if "ZALLET" not in os.environ:
os.environ["ZALLET"] = os.path.join(build_dir, "src", "zallet" + exeext)
os.environ["ZALLET"] = os.path.join(build_dir, "bin", "zallet" + exeext)

tests_dir = src_dir + '/qa/rpc-tests/'

flags = ["--srcdir={}/src".format(build_dir)] + args
flags = ["--bindir={}/bin".format(build_dir)] + args
flags.append("--cachedir=%s/qa/cache" % build_dir)

if enable_coverage:
Expand Down
8 changes: 7 additions & 1 deletion qa/rpc-tests/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
from test_framework.proto import service_pb2

# Test that we can call the indexer RPCs.
class IndexerTest (BitcoinTestFramework):
Expand All @@ -17,8 +18,13 @@ def __init__(self):
self.num_wallets = 0

def run_test(self):
assert_equal(self.zainos[0].getblockcount(), 100)
assert_equal(self.zainod_json_services[0].getblockcount(), 100)
assert_equal(self.nodes[0].getblockcount(), 100)

# Test gRPC GetLightdInfo
info = self.zainod_grpc_services[0].GetLightdInfo(service_pb2.Empty())
print(info)
assert_equal(info.blockHeight, 100)

if __name__ == '__main__':
IndexerTest ().main ()
Empty file.
130 changes: 130 additions & 0 deletions qa/rpc-tests/test_framework/proto/compact_formats.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Copyright (c) 2019-2021 The Zcash developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

syntax = "proto3";
package cash.z.wallet.sdk.rpc;
option go_package = "lightwalletd/walletrpc";
option swift_prefix = "";

// REMINDER: proto3 fields are all optional. A field that is not present will be set to its zero/false/empty
// value.

// Information about the state of the chain as of a given block.
message ChainMetadata {
uint32 saplingCommitmentTreeSize = 1; // the size of the Sapling note commitment tree as of the end of this block
uint32 orchardCommitmentTreeSize = 2; // the size of the Orchard note commitment tree as of the end of this block
}

// A compact representation of a Zcash block.
//
// CompactBlock is a packaging of ONLY the data from a block that's needed to:
// 1. Detect a payment to your Shielded address
// 2. Detect a spend of your Shielded notes
// 3. Update your witnesses to generate new spend proofs.
// 4. Spend UTXOs associated to t-addresses of your wallet.
//
// Currently, the `header` field should always be unset (empty). In the future,
// the presence or absence of header data may be made dependent on request
// parameters, although it is likely that such flexibility will only be provided via
// newly-added service methods, not via existing APIs.
message CompactBlock {
uint32 protoVersion = 1; // the version of this wire format, for storage
uint64 height = 2; // the height of this block
bytes hash = 3; // if present, the ID (hash) of this block
bytes prevHash = 4; // if present, the ID (hash) of this block's predecessor
uint32 time = 5; // if non-zero, Unix epoch time when the block was mined
bytes header = 6; // if present, full header (as returned by the getblock RPC)
repeated CompactTx vtx = 7; // zero or more compact transactions from this block
ChainMetadata chainMetadata = 8; // information about the state of the chain as of this block
}

// A compact representation of a Zcash transaction.
//
// CompactTx contains the minimum information for a wallet to know if this transaction
// is relevant to it (either pays to it or spends from it) via shielded elements. Additionally,
// it can optionally include the minimum necessary data to detect payments to transparent addresses
// related to your wallet.
message CompactTx {
// The index of the transaction within the block.
uint64 index = 1;

// The id of the transaction as defined in
// [§ 7.1.1 'Transaction Identifiers'](https://zips.z.cash/protocol/protocol.pdf#txnidentifiers)
// This byte array MUST be in protocol order and MUST NOT be reversed
// or hex-encoded; the byte-reversed and hex-encoded representation is
// exclusively a textual representation of a txid.
bytes txid = 2;

// 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.
// If there are no transparent inputs, the fee will be calculable as:
// valueBalanceSapling + valueBalanceOrchard + sum(vPubNew) - sum(vPubOld) - sum(tOut)
uint32 fee = 3;

repeated CompactSaplingSpend spends = 4;
repeated CompactSaplingOutput outputs = 5;
repeated CompactOrchardAction actions = 6;

// `CompactTxIn` values corresponding to the `vin` entries of the full transaction.
//
// Note: the single null-outpoint input for coinbase transactions is omitted. Light
// clients can test `CompactTx.index == 0` to determine whether a `CompactTx`
// represents a coinbase transaction, as the coinbase transaction is always the
// first transaction in any block.
repeated CompactTxIn vin = 7;

// A sequence of transparent outputs being created by the transaction.
repeated TxOut vout = 8;
}

// A compact representation of a transparent transaction input.
message CompactTxIn {
// The id of the transaction that generated the output being spent. This
// byte array must be in protocol order and MUST NOT be reversed or
// hex-encoded.
bytes prevoutTxid = 1;

// The index of the output being spent in the `vout` array of the
// transaction referred to by `prevoutTxid`.
uint32 prevoutIndex = 2;
}

// A transparent output being created by the transaction.
//
// This contains identical data to the `TxOut` type in the transaction itself, and
// thus it is not "compact".
message TxOut {
// The value of the output, in Zatoshis.
uint64 value = 1;

// The script pubkey that must be satisfied in order to spend this output.
bytes scriptPubKey = 2;
}

// A compact representation of a [Sapling Spend](https://zips.z.cash/protocol/protocol.pdf#spendencodingandconsensus).
//
// CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
// protocol specification.
message CompactSaplingSpend {
bytes nf = 1; // Nullifier (see the Zcash protocol specification)
}

// A compact representation of a [Sapling Output](https://zips.z.cash/protocol/protocol.pdf#outputencodingandconsensus).
//
// It encodes the `cmu` field, `ephemeralKey` field, and a 52-byte prefix of the
// `encCiphertext` field of a Sapling Output Description. Total size is 116 bytes.
message CompactSaplingOutput {
bytes cmu = 1; // Note commitment u-coordinate.
bytes ephemeralKey = 2; // Ephemeral public key.
bytes ciphertext = 3; // First 52 bytes of ciphertext.
}

// A compact representation of an [Orchard Action](https://zips.z.cash/protocol/protocol.pdf#actionencodingandconsensus).
message CompactOrchardAction {
bytes nullifier = 1; // [32] The nullifier of the input note
bytes cmx = 2; // [32] The x-coordinate of the note commitment for the output note
bytes ephemeralKey = 3; // [32] An encoding of an ephemeral Pallas public key
bytes ciphertext = 4; // [52] The first 52 bytes of the encCiphertext field
}
51 changes: 51 additions & 0 deletions qa/rpc-tests/test_framework/proto/compact_formats_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions qa/rpc-tests/test_framework/proto/compact_formats_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings


GRPC_GENERATED_VERSION = '1.78.0'
GRPC_VERSION = grpc.__version__
_version_not_supported = False

try:
from grpc._utilities import first_version_is_lower
_version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
except ImportError:
_version_not_supported = True

if _version_not_supported:
raise RuntimeError(
f'The grpc package installed is at version {GRPC_VERSION},'
+ ' but the generated code in compact_formats_pb2_grpc.py depends on'
+ f' grpcio>={GRPC_GENERATED_VERSION}.'
+ f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
+ f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
)
Loading