Files
pezkuwi-subxt/substrate/zombienet/0001-basic-warp-sync/README.md
T
Michal Kucharczyk 39cb3b06cd zombienet: warp-sync integration test added (#12675)
* zombienet: warp-sync integration test added

* spelling

* Readme corrected

* dir name updated

* Check second phase of warp sync

* zombienet pipeline enable + naive test network

* zombienet stage added

* paritypr/substrate-debug image added for zombienet testing

* debugs added

* debugs added

* buildah problem fixed

* rollback

* runner tag

* test name corrected

* dir renamed (regex problem)

* common code clean up

* common code clean up

* fix

* warp sync test improvements

* full sha used

as short is too short (https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2051228#L38)

* disable tracing for nodes

* COMMON_USER -> DOCKERIO_USER

* refs reworked

* paritypr/substrate image used

* DOCKERIO -> DOCKER

* generate-ws-db toml cleanup

* improvements

* fix

* raw chain spec used

* zombienet v1.3.18 used

* zombienet: warp sync test enabled

* chain-spec path corrected

* log parsing improved

Checking if log does not container error or verification failed messages

* warp sync test: removed validators

* fix

* review remarks applied

* dir test name changed: 0000_block_building -> 0000-block-building

* transaction finalized test added

* transaction finalized test: error handling improved

* trigger CI job

* trigger CI job

* trigger CI job

* trigger CI job

* Explicitly touch `version.rs` to invalidate the related cache

* zombienet add logs as artifacts

* Revert "Explicitly touch `version.rs` to invalidate the related cache"

This reverts commit 9d00ccfe897a280581156c281961a32665dba6d5.

* file naming changed

Co-authored-by: parity-processbot <>
Co-authored-by: Vladimir Istyufeev <vladimir@parity.io>
Co-authored-by: Javier Viola <javier@parity.io>
2022-12-07 22:44:40 +00:00

3.6 KiB

Test design

The warp-sync test works on predefined database which is stored in the cloud and fetched by the test. alice and bob nodes are spun up using this database snapshot in full node mode.

As warp-sync requires at least 3 peers, the test spawns the charlie full node which uses the same database snapshot.

The dave node executed with --sync warp syncs database with the rest of the network.

How to prepare database

Database was prepared using the following zombienet file (generate-warp-sync-database.toml):

[relaychain]
default_image = "docker.io/parity/substrate:master"
default_command = "substrate"

chain = "gen-db"

chain_spec_path = "chain-spec.json"

  [[relaychain.nodes]]
  name = "alice"
  validator = true

  [[relaychain.nodes]]
  name = "bob"
  validator = true

The zombienet shall be executed with the following command, and run for some period of time to allow for few grandpa eras.

./zombienet-linux spawn --dir ./db-test-gen --provider native generate-warp-sync-database.toml

Once the zombienet is stopped, the database snapshot ({alice,bob}/data/chains/local_testnet/db/ dirs) was created using the following commands:

mkdir -p db-snapshot/{alice,bob}/data/chains/local_testnet/db/  
cp -r db-test-gen/alice/data/chains/local_testnet/db/full db-snapshot/alice/data/chains/local_testnet/db/  
cp -r db-test-gen/bob/data/chains/local_testnet/db/full   db-snapshot/bob/data/chains/local_testnet/db/

The file format should be tar.gz. File shall contain local_testnet folder and its subfolders, e.g.:

$ tar tzf chains.tgz | head
local_testnet/
local_testnet/db/
local_testnet/db/full/
...
local_testnet/db/full/000469.log

Sample command to prepare archive:

tar -C db-snapshot/alice/data/chains/ -czf chains.tgz local_testnet

Also refer to: zombienet#578

The raw chain-spec shall also be saved: db-test-gen/gen-db-raw.json.

Where to upload database

The access to this bucket is required.

Sample public path is: https://storage.googleapis.com/zombienet-db-snaps/substrate/0001-basic-warp-sync/chains-0bb3f0be2ce41b5615b224215bcc8363aa0416a6.tgz.

The database file path should be substrate/XXXX-test-name/file-SHA1SUM.tgz, where SHA1SUM is a sha1sum of the file.

Chain spec

Chain spec was simply built with:

substrate build-spec --chain=local > chain-spec.json

Please note that chain-spec.json committed into repository is raw version produced by zombienet during database snapshot generation. Zombienet applies some modifications to plain versions of chain-spec.

Run the test

Test can be run with the following command:

zombienet-linux test --dir db-snapshot --provider native test-warp-sync.zndsl

NOTE: currently blocked by: zombienet#578

Save some time hack

Substrate can be patched to reduce the grandpa session period.

diff --git a/bin/node/runtime/src/constants.rs b/bin/node/runtime/src/constants.rs
index 23fb13cfb0..89f8646291 100644
--- a/bin/node/runtime/src/constants.rs
+++ b/bin/node/runtime/src/constants.rs
@@ -63,7 +63,7 @@ pub mod time {
 
    // NOTE: Currently it is not possible to change the epoch duration after the chain has started.
    //       Attempting to do so will brick block production.
-   pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
+   pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * MINUTES / 2;
    pub const EPOCH_DURATION_IN_SLOTS: u64 = {
        const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64