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

PVF: Add test instructions #2058

Merged
merged 14 commits into from
Nov 28, 2023
56 changes: 56 additions & 0 deletions polkadot/node/core/pvf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# PVF Host

## Running basic tests

The first step is to build the worker binaries:

```sh
SKIP_WASM_BUILD=1 cargo build --bin polkadot-execute-worker --bin polkadot-prepare-worker
mrcnski marked this conversation as resolved.
Show resolved Hide resolved
```

and then to run `cargo test` in the `pvf/` directory.

## Observing Logs

To verify expected behavior it's often useful to observe logs. To avoid too many logs at once, run one test at a time:

1. Add `sp_tracing::try_init_simple();` to the beginning of a test
2. Specify `RUST_LOG=parachain::pvf=trace` before the cargo command.

For example:

```sh
RUST_LOG=parachain::pvf=trace cargo test execute_can_run_serially
```

For more info on how our logs work, check [the docs](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/node/gum/src/lib.rs).

## Running a test-network with zombienet
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Wouldn't this steps be better at the top of this repo ? And if we already have them can we just reference them, since they might change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there is a polkadot/doc/testing.md file. Looks much of this file can go there, and then this file can just reference that like you said.


For major changes it is highly recommended to run a test-network. Zombienet allows you to run a mini test-network locally on your own machine.

First, make sure you have [zombienet](https://github.com/paritytech/zombienet) installed.

Now, all the required binaries must be installed in your $PATH. You must run the following (not `zombienet setup`!) from the `polkadot/` directory in order to test your changes.

```sh
cargo install --path . --locked
```

You will also need to install `undying-collator`. From `polkadot/`, run:

```sh
cargo install --path ./parachain/test-parachains/undying/collator --locked
```

Finally, run the zombienet test from the `polkadot` directory:

```sh
RUST_LOG=parachain::pvf=trace zombienet --provider=native spawn zombienet_tests/functional/0001-parachains-pvf.toml
```

You can pick a validator node like `alice` from the output and view its logs (`tail -f <log_file>`) or metrics. Make sure there is nothing funny in the logs (try `grep WARN <log_file>`).

## Testing on Linux

Much of the PVF functionality, especially related to security, is Linux-only. If you touch anything security-related, make sure to test on Linux! If you're on a Mac, you can either run a VM or you can hire a VPS and use [EternalTerminal](https://github.com/MisterTea/EternalTerminal) to ssh into it. (ET preserves your session across disconnects, and unlike mosh it allows scrollback.)
9 changes: 0 additions & 9 deletions polkadot/node/core/pvf/tests/README.md
mrcnski marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

Loading