Commit Graph

26 Commits

Author SHA1 Message Date
teor d9add4a01f
change(cd): Deploy testnet instances for every main branch push and release (#6842) 2023-06-08 15:44:30 +10:00
Marek 5421447804
Listen on `0.0.0.0` instead of `127.0.0.1` (#6755)
Binding `127.0.0.1` means that Zebra will accept inbound connections
coming only from the loopback network interface. This is desirable as
long as Zebra runs on a native machine.

When Zebra runs inside a Docker container, incoming connections coming
from the host machine don't come from the container's loopback
interface. In order to be able to connect to Zebra from the host
machine, we can listen on `0.0.0.0` so Zebra accepts inbound connections
coming from any interface. Users then can limit inbound connection to
the loopback of their host by

```bash
docker run -p 127.0.0.1:8232:8232 zfnd/zebra:1.0.0-rc.8
```
2023-05-24 16:56:22 +00:00
teor 1461c912f9
change(ci): Generate mainnet checkpoints in CI (#6550)
* Add extra test type modes to support zebra-checkpoints

* Add Mainnet and Testnet zebra-checkpoints test harnesses

* Add zebra-checkpoints to test docker images

* Add zebra-checkpoints test entrypoints

* Add Mainnet CI workflow for zebra-checkpoints

* Enable zebra-checkpoints feature in the test image

* Use the same features for (almost) all the docker tests

* Make workflow features match Docker features

* Add a feature note

* Add a zebra-checkpoints test feature to zebrad

* Remove the "no cached state" testnet code

* Log a startup message to standard error when launching zebra-checkpoints

* Rename tests to avoid partial name conflicts

* Fix log formatting

* Add sentry feature to experimental docker image build

* Explain what ENTRYPOINT_FEATURES is used for

* Use the correct zebra-checkpoints path

* Silence zebrad logs while generating checkpoints

* Fix zebra-checkpoints log handling

* Re-enable waiting for zebrad to fully sync

* Add documentation for how to run these tests individually

* Start generating checkpoints from the last compiled-in checkpoint

* Fix clippy lints

* Revert changes to TestType

* Wait for all the checkpoints before finishing

* Add more stderr debugging to zebra-checkpoints

* Fix an outdated module comment

* Add a workaround for zebra-checkpoints launch/run issues

* Use temp dir and log what it is

* Log extra metadata about the zebra-checkpoints binary

* Add note about unstable feature -Z bindeps

* Temporarily make the test run faster and with debug info

* Log the original test command name when showing stdout and stderr

* Try zebra-checkpoints in the system path first, then the cargo path

* Fix slow thread close bug in dual process test harness

* If the logs are shown, don't say they are hidden

* Run `zebra-checkpoints --help` to work out what's going on in CI

* Build `zebra-utils` binaries for `zebrad` integration tests

* Revert temporary debugging changes

* Revert changes that were moved to another PR
2023-04-27 04:39:43 +00:00
Arya 671420bd84
feat(release): create Docker hub binary with mining enabled on release (#6228)
* Duplicates Dockerfile

* updates mining-testnet Dockerfile with getblocktemplate-rpcs feature, Testnet by default, and an RPC port

* renames mining-testnet.Dockerfile and adds workflow for publishing images on release

* replaces space-seperated features with commas

* Adds .experimental tag suffix, removes new dockerfile, makes lightwalletd tests conditional

* updates build-args to pass on features directly

* adds "lightwalletd-grpc-tests" as default test_features in build-docker-image

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* adds tag suffix to cache keys

---------

Co-authored-by: teor <teor@riseup.net>
2023-03-24 07:10:40 +00:00
Gustavo Valverde 85bcbbdf16
ci: add a test to check that the Docker image config works (#5968)
* ci: add a test to validate Zebra's config file and path

* fix: use `ZEBRA_CONF_PATH` as single variable locating the conf

* fix: do not remove the containers

* fix: use extended regex

* fix: use different steps to validate the conf tests

* fix: do not specify a default CMD for running Docker in test builds

* fix: use actual starting commands for entrypoint

* fix: do not add cargo twice if cargo is in $1

* fix: allow to run `zebrad` in the `tests` stage of Dockerfile

* fix: new entrypoint does not allow an empty CMD

* fix: do not duplicate the `zebrad` command

* fix: segregate configuration jobs

* refactor(entrypoint): handle better parameters conditions

* fix: make `zebrad` an executable command in `tests` stage

* Show the commands that are being executed in the new docker test

* Show full logs without tee or grep

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

* fix: use the actual path inside docker

* fix: use `grep` with exit code

If the container is logging to stderr, piping works only for stdout, so we're adding `2>&1`

* fix: use `grep -q` to get an exit code

* fix: fail if any error is detected

* fix: fail if this test takes more than 5 minutes

* fix: update patch workflows

* feat: test Dockerfile `runtime` config

* fix: depend on the configuration test to continue

Co-authored-by: teor <teor@riseup.net>
2023-01-23 06:41:59 +00:00
Gustavo Valverde bbbd56d7ce
fix(build): restore Rust stable in builds and beta for CI (#5515)
* Revert "fix(ci): Build zebrad with Rust 1.63 to avoid Zcash parameter download hangs (#5251)"

This reverts commit 9cb6c559f4.

* Revert "Require Rust 1.63 in the README (#5359)"

This reverts commit ee0edef857.

* Revert "Revert "ci(build): re-enable Rust beta tests in ubuntu (#5024)" (#5090)"

This reverts commit 579d6be4e9.
2022-11-01 10:51:29 +10:00
teor 469c471d92
Use correct TOML syntax in Docker zebrad.toml (#5320) 2022-10-04 02:51:43 +00:00
teor f71bb74951
fix(docker): Make default command work in docker images, disable optional listener ports (#5313)
* Disable optional listener ports so the default config is secure

* Fix Zebra config file path in Dockerfile
2022-10-03 17:50:27 +00:00
teor 9cb6c559f4
fix(ci): Build zebrad with Rust 1.63 to avoid Zcash parameter download hangs (#5251)
* Try running coverage with Rust 1.63

* Run GitHub Actions tests with Rust 1.63

* Change from stable to 1.63 in the patch file

* Use Rust 1.63 to download Zcash parameters

* Use Rust 1.63 to build Docker zebrad images

* Make Rust 1.63 a supported platform, and make stable temporarily unsupported
2022-09-26 12:37:23 +00:00
Gustavo Valverde 726f732640
fix(build): a path must exist before creating a file in it (#5177)
* fix(build): a path must exist before creating a file in it

Other directories in the Dockerfile were automatically created with the `WORKDIR` and  `COPY` commands. In this case it has to be explicitly created

* fix(build): use a variable for the conf path and another for the file

Add some pending actions to consider, for a better user experience.

* fix(runtime): run with the correct path
2022-09-15 22:26:32 +00:00
Gustavo Valverde e48e8e5572
chore(build): allow a custom `zebrad` config file path (#5163)
* chore(build): allow a custom `zebrad` config file path

Previous behavior:
The zebrad config file was hardcoded into the Dockerfile, allowing to
change specific values, but not the config file as a whole

Expected behavior:
Allow the user to specify the config file themselves, for example with
the nginx image you can pass -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro

Solution:
Use and ARG, with a default value, to allow the user to change the location
of the zebrad configuration file. This also sets the location under /etc,
honoring The Filesystem Hierarchy Standard (FHS) for linux

* Apply suggestions from code review

Co-authored-by: teor <teor@riseup.net>

Co-authored-by: teor <teor@riseup.net>
2022-09-15 09:05:24 +00:00
teor f804ff6238
fix(docker): Copy lightwalletd from the correct path during Docker builds (#4886)
* Copy lightwalletd from the updated Docker path

* Try the build path instead

* Fix the build stage entrypoint path
2022-08-04 06:29:49 +00:00
Gustavo Valverde 6ff0a42318
refactor(build): use FHS for deployments and artifacts (#4786)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-08-03 23:43:32 +00:00
teor 29e73b3f3e
breaking(diagnostics): make zebrad diagnostics into optional compile-time features (#4539)
* Disable the flamegraph feature by default at compile time

* Disable the journald feature by default at compile time

* Also disable inferno dependency, and rearrange features

* Disable the prometheus feature by default at compile time

* Disable the tracing filter reload feature by default at compile time

* Disable tests when corresponding features are disabled

* Add compile-time tracing features to user docs

* Add compile-time features to the metrics user docs

* Document diagnostics as part of the start command tasks and services

* breaking(diagnostics): rename "enable-sentry" feature to "sentry" (#4623)

* Also skip conflict tests when those ports are disabled

* breaking(diagnostics): rename "enable-sentry" feature to "sentry"

This is mostly:
```sh
fastmod enable-sentry sentry
```

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-16 19:56:40 +00:00
Dimitris Apostolou 59ae77d04b
Fix typos (#4397) 2022-05-16 05:33:08 +00:00
teor f789f8aaa7
fix(ci): make test selection and logging consistent (#4375)
* fix(ci): sentry is not longer being activated in test builds

This removes sentry from all the test execution, as some tests might fail as sentry wasn't initially built, or it might take more time to build as it will have to build with sentry.

* fix(build): workaround the failed to fetch oauth token error

* Drop sentry dependencies when enable-sentry feature is disabled

* Make lightwalletd gRPC tests depend on a new lightwalletd-grpc-tests feature

* fix(ci): remove enable-sentry feature from tests

* Add lightwalletd-grpc-tests feature for functionality or efficiency

And document where it is just used to stop re-compilations.

* Remove redundant `cmake` and `protobuf-compiler` dependencies

* Document Zebra's optional production and test feature flags

* Minimise dependencies in zcash-params/Dockerfile

* Minimise dependencies in docker/Dockerfile

* Add a workflow TODO

* Catch more errors in entrypoint.sh

Also makes entrypoint.sh compatible with more distributions

* Remove unnecessary quoting in entrypoint.sh

* Use exactly the same arguments to call CI tests

* Remove a redundant CI build

* Rename Cargo.lock check job

Co-authored-by: Gustavo Valverde <gustavo@iterativo.do>
2022-05-11 23:41:33 +00:00
teor f7a3a0f6bc
fix(build): put gRPC tests behind an optional feature flag to fix production build issues (#4369)
* fix(ci): sentry is not longer being activated in test builds

This removes sentry from all the test execution, as some tests might fail as sentry wasn't initially built, or it might take more time to build as it will have to build with sentry.

* fix(build): workaround the failed to fetch oauth token error

* Drop sentry dependencies when enable-sentry feature is disabled

* Make lightwalletd gRPC tests depend on a new lightwalletd-grpc-tests feature

* fix(ci): remove enable-sentry feature from tests

* Add lightwalletd-grpc-tests feature for functionality or efficiency

And document where it is just used to stop re-compilations.

* Remove redundant `cmake` and `protobuf-compiler` dependencies

* Document Zebra's optional production and test feature flags

* Minimise dependencies in zcash-params/Dockerfile

* Minimise dependencies in docker/Dockerfile

* Add a workflow TODO

Co-authored-by: Gustavo Valverde <gustavo@iterativo.do>
2022-05-11 14:06:58 +00:00
Gustavo Valverde 93e158936e
refactor(build): deprecate gcr.io as a registry and build faster (#4298)
* refactor(build): use better stage naming and document it

* refactort(build): use multiple cache sources

* docs(build): add a comment for cache

* fix(build): remove gcr.io as it does not supports OCI images
2022-05-10 17:00:09 -04:00
Gustavo Valverde a23420be88
feat(ci): add `fully_synced_rpc_test` test to CI (#4223)
* feat(ci): add lightwalletd RPC call test

Co-authored-by: teor <teor@riseup.net>
2022-05-05 05:27:07 -04:00
Janito Vaqueiro Ferreira Filho 5a94a09292
add(test): Integration test to send transactions using lightwalletd (#4068)
* Export the `zebra_state::Config::db_path` method

Make it easier for tests to discover the sub-directory used to store
the chain state data.

* Generate code for interfacing with lightwalletd

Use the `tonic-build` crate to generate Rust code for communicating with
lightwalletd using gRPC.

The `*.proto` files were obtained from the Zcash lightwalletd
repository.

* Use `block::Height` instead of `Height`

Import the `block` instead to make it slightly clearer.

* Add helper function to remove a file if it exists

Try to remove it and ignore an error if it says that the file doesn't
exist. This will be used later to remove the lock file from a copied
chain state directory.

* Add helper function to copy chain state dirs

Copy an existing chain state directory into a new temporary directory.

* Add a `BoxStateService` type alias

Make it easier to write and read a boxed version of a state service.

* Add a helper function to start the state service

Make it easier to specify the state service to use an existing state
cache directory.

* Import `eyre!` macro at the module level

Allow it to be used in different places without having to repeat the
imports.

* Add `load_tip_height_from_state_directory` helper

A function to discover the current chain tip height stored in a state
cache.

* Add helper function to prepare partial sync. state

Loads a partially synchronized cached state directory into a temporary
directory that can be used by a zebrad instance, and also returns the
chain tip block height of that state.

* Add `perform_full_sync_starting_from` helper

Runs a zebrad with an existing partially synchronized state, and
finishes synchronizing it to the network chain tip.

* Add function to load transactions from a block

Use a provided state service to load all transactions from a block at a
specified height.

The state service is a generic type parameter, because
`zebra_state::service::ReadStateService` is not exported publicly. Using
a generic type parameter also allows the service to be wrapped in layers
if needed in the future.

* Add `load_transactions_from_block_after` helper

A function to load transactions from a block stored in a cached state
directory. The cached state must be synchronized to a chain tip higher
than the requested height.

* Add helper function to load some test transactions

Given a partially synchronized chain state, it will extend that chain by
performing a full synchronization, and obtain some transactions from one
of the newly added blocks.

* Update `spawn_zebrad_for_rpc_without_initial_peers`

Wait until the mempool is activated.

* Add method to start lightwalletd with RPC server

Returns the lightwalletd instance and the port that it's listening for
RPC connections.

The instance can reuse an existing cached lightwalletd state if the
`LIGHTWALLETD_DATA_DIR` environment variable is set.

* Add a `LightwalletdRpcClient` type alias

To make it easier to identify the type generated from the Protobuf
files.

* Add helper function to connect to lightwalletd

Prepare an RPC client to send requests to a lightwalletd instance.

* Add a `prepare_send_transaction_request` helper

Creates a request message for lightwalletd to send a transaction.

* Add test to send transactions using lightwalletd

Obtain some valid transactions from future blocks and try to send them
to a lightwalletd instance connected to a zebrad instance that hasn't
seen those transactions yet. The transactions should be successfully
queued in Zebra's mempool.

* Make `zebra_directory` parameter generic

Allow using a `TempDir` or a `PathBuf`.

* Move lightwalletd protobuf files

Place them closer to the module directory, so that it's clearer that
they specify the RPC protocol for lightwalletd, and not Zebra itself.

* Don't use coinbase transactions in the test

Coinbase transactions are rejected by the mempool.

* Don't remove state lock file

It is removed automatically by Zebra when it shuts down, so if it exists
it should be reported as a bug.

* Force mempool to be enabled in Zebrad instance

Speed up the initialization of the Zebrad instance used for lightwalletd
to connect to.

* Refactor to create `LIGHTWALLETD_DATA_DIR_VAR`

Document how the environment variable can be used to speed up the test.

* Check for process errors in spawned Zebra instance

Enable checking for known process failure messages.

* Add `FINISH_PARTIAL_SYNC_TIMEOUT` constant

Document why it exists and how the choice of the value affects the test.

* Add `LIGHTWALLETD_TEST_TIMEOUT` constant

And use it for the Zebrad and the Lightwalletd instances used in the
send transaction integration test.

* Check `lightwalletd` process for errors

Enable checking the lightwalletd process for known failure messages.

* Update `tonic` and `prost` dependencies

Use the latest version and fix CI failures because `rustfmt` isn't
installed in the build environment.

* Create `send_transaction_test` module

Move the send transaction using lightwalletd test and its helper
functions into a new module.

* Move `LIGHTWALLETD_TEST_TIMEOUT` constant

Place it in the parent `lightwalletd` module.

* Move gRPC helper functions and types to `rpc` mod.

Make them more accessible so that they can be used by other tests.

* Create a `cached_state` module

Move the test utility functions related to using a cached Zebra state
into the module.

* Move `perform_full_sync_starting_from` to `sync`

Keep to closer to the synchronization utility functions.

* Move Zebra cached state path variable constant

Place it in the `cached_state` module.

* Skip test if `ZEBRA_TEST_LIGHTWALLETD` is not set

Make it part of the set of tests ignored as a whole if no lightwalletd
tests should be executed.

* Move `spawn_zebrad_for_rpc_without_initial_peers`

Place it in the `launch` sub-module.

* Rename `rpc` module into `wallet_grpc`

Avoid any potential misunderstandings when the name is seen out of
context.

* Allow duplicate `heck` dependency

At least until `structopt` is updated or `zebra-utils` is updated to use
`clap` 3.

* Fix a deny.toml typo

* fix(build): CMake is required by `prost` crate

Co-authored-by: teor <teor@riseup.net>
Co-authored-by: Gustavo Valverde <gustavo@iterativo.do>
2022-04-27 23:06:11 +00:00
teor 2423f591b0
change(rust): Use link-time optimisation in release builds (#4184)
* Move Rust optimisations to Cargo.toml

Previously they were in the Dockerfile,
so they only applied to those builds.

* Use link-time optimisation in release builds

* Retry after log ssh failures in full sync test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-27 02:51:26 +00:00
Gustavo Valverde 3923c3de9e
imp(test): turn on full backtraces and disable frame filtering (#3763)
* imp(test): turn on full backtraces and disable frame filtering

* imp(verbosity): add RUST_LIB_BACKTRACE

We also need `RUST_LIB_BACKTRACE` as stated in:
https://docs.rs/color-eyre/latest/color_eyre/#multiple-report-format-verbosity-levels
https://doc.rust-lang.org/std/backtrace/index.html#environment-variables

Co-authored-by: teor <teor@riseup.net>

* fix(verbosity): add missing instances for RUST_BACKTRACE, RUST_LIB_BACKTRACE and COLORBT_SHOW_HIDDEN

Co-authored-by: teor <teor@riseup.net>
2022-03-08 15:09:41 +00:00
Conrado Gouvea 2f6a48bed8
fix(tests): use TEST_FAKE_ACTIVATION_HEIGHTS at runtime and fix tests (#3749)
* fix: check TEST_FAKE_ACTIVATION_HEIGHTS at runtime

* fix(tests): add TEST_FAKE_ACTIVATION_HEIGHTS variable

This variable ensures the test is activated in the `test-fake-activation-heights` step

* fix(docker): do not run specific tests by default in entrypoint.sh

* fix(test): remove extra TEST_FULL_SYNC argument

* imp(timeout): wait for an average build time

Co-authored-by: Gustavo Valverde <gustavo@iterativo.do>
2022-03-05 13:32:46 -04:00
Gustavo Valverde c176e2a423
feat(build): add arm64 support with cross-compilation (#3678)
* add(actions): lightwalletd continous integrations

* refactor(actions): build lightwalletd and reuse it in zebra

- Download lightwalletd source code
- Create a new Dockerfile for lightwalletd
- Use lightwalletd binary in Zebra's image
- Create a specific step to build/update lightwalletd
- Add lightwalletd integration test to the test suite
- Remove lightwalletd.yml, as it was harder to control

* refactor(docker): organize Dockerfiles and remove unused

Fixes: #3344

* feat(build): add arrm64 support

* fix(build): do not install google-compute-engine in arm64

This package is not available for this platform

* fix(build): do not build arm64 for tests

* fix(condition): indent for better visibility

* fix(condition): wrong use of operators
2022-03-03 00:39:41 +00:00
Gustavo Valverde db966f27fa
feat(actions)!: add full sync test (#3582)
* add(tests): full sync test

* fix(test): add build

* fix(deploy): escape double dashes '--' correctly

* fix(test): remove unexpected --no-capture arg

error: Found argument '--nocapture' which wasn't expected, or isn't valid in this context

* refactor(docker): use default executable as entrypoint

* refactor(startup): add a custom entrypoint

* fix(test): add missing TEST_FULL_SYNC variable

* test(timeout): use the biggest machine

* fix

* fix(deploy): use latest successful image

* typo

* refactor(docker): generate config file at startup

* revert(build): changes were made to docker

* fix(docker): send variables correctly to the entrypoint

* test different conf file approach

* fix(env): add RUN_TEST env variable

* ref: use previous approach

* fix(color): use environment variable

* fix(resources): use our normal machine size

* fix(ci): double CPU and RAM for full sync test

* fix(test): check for zebrad test output in the correct order

The mempool is only activated once, so we must check for that log first.
After mempool activation, the stop regex is logged at least once.
(It might be logged before as well, but we can't rely on that.)

When checking that the mempool didn't activate,
wait for the `zebrad` command to exit,
then check the entire log.

* fix(ci): run full sync test with full compiler optimisations

* fix(tests): reintroduce tests and run full sync on approval

* fix(tests): reduce the changelog

Co-authored-by: teor <teor@riseup.net>
2022-03-02 14:15:24 +00:00
Gustavo Valverde a0c451223f
feat(lightwalletd): add build and CI pipeline (#3657)
* add(actions): lightwalletd continous integrations

* refactor(actions): build lightwalletd and reuse it in zebra

- Download lightwalletd source code
- Create a new Dockerfile for lightwalletd
- Use lightwalletd binary in Zebra's image
- Create a specific step to build/update lightwalletd
- Add lightwalletd integration test to the test suite
- Remove lightwalletd.yml, as it was harder to control

* fix(build): remove extra port being exposed

* fix(lightwalletd): test should be after `--` in cargo test

* revert(lint): do not lint external code as it can be confusing

* fix(test): lightwalletd_integration test is not ignored

* docs(docker): clarify the addition of unused args

* refactor(docker): organize Dockerfiles and remove unused

Fixes: #3344

* fix(actions): activate workflows on correct path changes

* test

* revert previous commit

* feat(build): add arm64 support with cross-compilation (#3659)

* feat(build): add arrm64 support

* fix(build): do not install google-compute-engine in arm64

This package is not available for this platform

* fix(build): do not build arm64 for tests

* fix(changes): reduce changelog

* Revert "feat(build): add arm64 support with cross-compilation (#3659)"

This reverts commit 291e00c405.
2022-03-02 09:00:55 +00:00