Zcash Shielded Asset Swaps and Transaction Acceptance

Dear Zcash Community,

We have some exciting implementation updates to share with you! We demonstrated the end-to-end functionality of ZSAs including Swaps on a ZecHub community call last week - you can have a look at the recording here.

Updates across the development stack to create this implementation of the Swaps + ZSA functionality can be seen in the following pull requests to the various repositories:

Repository Pull Request Swaps working branch
orchard PR#116 zsa_swap
librustzcash PR#99 zsa-swap
zebra PR#96 zsa-swap-multiple-ag
zcash_tx_tool PR#23 zsa-swap

Running Locally

It is possible to test the functionality locally via the steps described in the README of the zcash_tx_tool repository. The most relevant section is reproduced below:

Prerequisites

  • Docker: Install Docker

  • Rust & Cargo: Install Rust and Cargo

  • Diesel CLI: Installed via Cargo.

  • Linux Dev tools:

    sudo apt update
    
    sudo apt install pkg-config libssl-dev libsqlite3-dev
    

Getting Started

1. Build and Run the Zebra Docker Image

Open a terminal and execute the following commands:

# Clone the zebra repository with the ZSA swaps branch
git clone -b zsa-swap-multiple-ag --single-branch https://github.com/QED-it/zebra.git

# Navigate to the testnet deployment directory
cd zebra

# Build the Zebra Docker image
docker build -f testnet-single-node-deploy/dockerfile -t qedit/zebra-regtest-txv6 .

# Run the Zebra Docker container
docker run -p 18232:18232 qedit/zebra-regtest-txv6

For more details on how the Docker image is created and synchronized, refer to the Dockerfile in the zebra repository.

2. Set Up and Run the Zcash tx-tool

In a separate terminal window, perform the following steps:

One-Time Setup

Install Diesel CLI and set up the database and get Zcash Params for Sapling:

# Install Diesel CLI with SQLite support
cargo install diesel_cli --no-default-features --features sqlite

# Set up the database
diesel setup

# Get Zcash Params for Sapling (if needed)
./zcutil/fetch-params.sh

Build and Run a Test Scenario

There are multiple test scenarios provided in the repository, viz.

Build and run the test case of your choice using the Zcash Transaction Tool, by replacing <test-case> in the command below with either of the test scenarios listed above:

# Build and run with ZSA feature enabled
cargo run --release --package zcash_tx_tool --bin zcash_tx_tool <test-case>

For example, to run the test-orchard-zsa scenario, use:

cargo run --release --package zcash_tx_tool --bin zcash_tx_tool test-orchard-zsa

Note: To re-run the test scenario (or to run a different scenario), reset the Zebra node by stopping and restarting the Zebra Docker container.

Connecting to the public testnet

A dedicated AWS node has been set up to run the version of the Zebra node that has been updated for swaps. The URL to connect to this node, and detailed and updated instructions for connecting and running your test scenarios can be found on this Wiki link. We also provide these details here:

To connect to the Swaps node, the URL is https://dev.zebra-swaps.zsa-test.net/

Environment Variables

Start by setting the following environment variables:

# For the ZSA Swaps testnet
export ZCASH_NODE_ADDRESS=dev.zebra-swaps.zsa-test.net
export ZCASH_NODE_PORT=443
export ZCASH_NODE_PROTOCOL=https

Clone the zsa-swaps branch of the transaction tool:

# Clone the zcash_tx_tool repository with the ZSA swaps branch
git clone -b zsa-swap --single-branch https://github.com/QED-it/zcash_tx_tool.git

Then run the desired test scenario:

# Build and run with ZSA feature enabled
cargo run --release --package zcash_tx_tool --bin zcash_tx_tool <test-case>

where <test-case> can be replaced with any of the scenarios already constructed (eg test-asset-swaps), or your own test scenario if you choose to construct your own.

This will automatically connect to the ECS node and run the scenario on it after syncing with the existing blocks.


This corresponds to milestones #1 and #2 of our User Control for ZSAs grant. We look forward to you testing out these tools and letting us know what you think!

Best,

The QEDIT Team.

3 Likes