Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow analysis #418

Merged
merged 10 commits into from
Jul 29, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/checkout@v3

- name: Symlink lightwalletd and zcash binaries
run: ln -s /usr/bin/lightwalletd /usr/bin/zcashd /usr/bin/zcash-cli ./regtest/bin/
run: ln -s /usr/bin/lightwalletd /usr/bin/zcashd /usr/bin/zcash-cli ./zingocli/regtest/bin/

- name: Symlink zcash parameters
run: ln -s /root/.zcash-params /github/home
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
regtest/data/zcashd/regtest/
regtest/data/lightwalletd/
regtest/data/zingo/
zingocli/regtest/data/zcashd/regtest/
zingocli/regtest/data/lightwalletd/
zingocli/regtest/data/zingo/
zingocli/regtest/zingo-wallet.dat
zingocli/regtest/bin
target
zingolib/target
zingocli/target
Expand Down
14 changes: 7 additions & 7 deletions regtest/README.md → zingo-testutils/regtest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ WARNING Experimental!
The CLI can work in regtest mode, by locally running a `zcashd` and `lightwalletd`.
This is now working with a simple `zingo-cli` invocation flag, with a little user setup.

There are pre-made directories in this repo to support ready use of regtest mode. These are found in the `$G/regtest/` subdirectory.
There are pre-made directories in this repo to support ready use of regtest mode. These are found in the `$G/zingocli/regtest/` subdirectory.

There are default config files for these binaries already in place in `$G/regtest/conf/` which can also be edited.
There are default config files for these binaries already in place in `$G/zingocli/regtest/conf/` which can also be edited.

Because regtest mode has no ability to cope with an initial `zcashd` state without any blocks,
we have included files to produce an initial block height of one, with no variation between runs.
These files are copied from a 'passive' directory (`$G/regtest/data/regtestvectors/`)
These files are copied from a 'passive' directory (`$G/zingocli/regtest/data/regtestvectors/`)
into a newly cleared 'active' data directory at the beginning of each time regtest mode is run.
This means, by default, any blocks added while zcashd is running are not retained for subsequent runs.

The default config includes all network upgrades set to block height 1, therefore all network upgrades are active by default in regtest mode.

# Usage example:
You must copy your compiled `zcashd`, `zcash-cli` and `lightwalletd` binaries to `$G/regtest/bin/` or set up symlinks, etc. `zcash-cli` is also needed if you wish
You must copy your compiled `zcashd`, `zcash-cli` and `lightwalletd` binaries to `$G/zingocli/regtest/bin/` or set up symlinks, etc. `zcash-cli` is also needed if you wish
to interact with your `zcashd` instance while it is running.

From your `$G/` directory, you can run:
Expand Down Expand Up @@ -48,7 +48,7 @@ at which point the interactive cli application should work with your regtest net

Once regtest mode is running, you can manipulate the simulated chain with `zcash-cli`.

For example, in still another terminal instance in the `$G/regtest/bin/` directory, you can run
For example, in still another terminal instance in the `$G/zingocli/regtest/bin/` directory, you can run
`./zcash-cli -regtest -rpcuser=xxxxxx -rpcpassword=xxxxxx generate 11` to generate 11 blocks.
Please note that by adding more than 100 blocks it is difficult or impossible to rewind the chain. The config means that after the first block all network upgrades should be in place.
Other `zcash-cli` commands should work similarly.
Expand All @@ -59,7 +59,7 @@ Invocation currently only works when being launched within a `zingolib` repo's w
Have fun!

# Tree Diagrams
In `$G/`, running `tree ./regtest`
In `$G/zingocli`, running `tree ./regtest`
after moving binaries and running:
./regtest/
├── bin
Expand Down Expand Up @@ -150,4 +150,4 @@ after moving binaries and running:
└── README.md

# Working Commits
Tested with `zcash` commit `d6d209`, `lightwalletd` commit `f53511c`, and `zingolib` commit `c414fc` or better.
Tested with `zcash` commit `d6d209`, `lightwalletd` commit `f53511c`, and `zingolib` commit `89fbe118f8305051d5f1d1d95903ba3ccaec586b` or better.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions zingo-testutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ pub fn get_wallet_nym(nym: &str) -> Result<(String, PathBuf, PathBuf), String> {
match nym {
"sap_only" | "orch_only" | "orch_and_sapl" | "tadd_only" => {
let one_sapling_wallet = format!(
"{}/zingocli/tests/data/wallets/v26/202302_release/regtest/{nym}/zingo-wallet.dat",
regtest::get_cargo_manifest_dir_parent().to_string_lossy()
"{}/tests/data/wallets/v26/202302_release/regtest/{nym}/zingo-wallet.dat",
regtest::get_cargo_manifest_dir().to_string_lossy()
);
let wallet_path = Path::new(&one_sapling_wallet);
let wallet_dir = wallet_path.parent().unwrap();
Expand Down Expand Up @@ -388,6 +388,9 @@ pub mod scenarios {
pub fn new_load_1153_saplingcb_regtest_chain() -> Self {
let mut sb = ScenarioBuilder::build_scenario(None, None);
let source = get_regtest_dir().join("data/chain_cache/blocks_1153/zcashd/regtest");
if !source.exists() {
panic!("Data cache is missing!");
}
let destination = &sb.regtest_manager.zcashd_data_dir;

std::process::Command::new("cp")
Expand Down
7 changes: 2 additions & 5 deletions zingo-testutils/src/regtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ use std::io::Read;
/// Simple helper to succinctly reference the project root dir.
use std::path::PathBuf;
use std::process::Child;
pub fn get_cargo_manifest_dir_parent() -> PathBuf {
pub fn get_cargo_manifest_dir() -> PathBuf {
PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("To be inside a manifested space."))
.parent()
.unwrap()
.to_path_buf()
}

pub fn get_regtest_dir() -> PathBuf {
get_cargo_manifest_dir_parent().join("regtest")
get_cargo_manifest_dir().join("regtest")
}

/// To manage the state associated a "regtest" run this type:
Expand Down
Empty file.
Loading