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

synthetic-network for nightly-pipeline #804

Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e8ae567
as_ref in aleph-client for Connection types
fixxxedpoint Dec 15, 2022
528f9aa
rust API for synthetic-network's json API
fixxxedpoint Dec 14, 2022
5a98f81
refactored synthetic-link
fixxxedpoint Dec 15, 2022
9d20ad0
new e2e-tests: high out-latency
fixxxedpoint Dec 15, 2022
2bf7a6e
refactored synthetic-network bash scripts
fixxxedpoint Dec 15, 2022
8a259e0
added git submodule for synthetic-network
fixxxedpoint Dec 15, 2022
0093386
added nightly e2e test for synthetic-network
fixxxedpoint Dec 15, 2022
32eb26d
refactored synthetic-link library
fixxxedpoint Dec 15, 2022
fc1a3f0
added load_config for synthetic-network e2e test
fixxxedpoint Dec 15, 2022
64234ae
more refactoring of synthetic-link
fixxxedpoint Dec 15, 2022
75434a5
missing synthetic-link in Cargo.toml
fixxxedpoint Dec 16, 2022
415faf0
e2e-tests/config.rs cleaned
fixxxedpoint Dec 16, 2022
1ac0792
Into -> From in synthetic-link
fixxxedpoint Dec 16, 2022
55f6f14
slightly cleaned code for synthetic-network
fixxxedpoint Dec 16, 2022
26d1e53
added RUST_SRC_PATH in shell.nix for better support for IDEs
fixxxedpoint Dec 16, 2022
08269ca
slightly cleaned synthetic-link
fixxxedpoint Dec 17, 2022
59461bb
refactored synthetic-link: more types for ranged parameters
fixxxedpoint Dec 17, 2022
7bccc5d
refactored synthetic-link lib
fixxxedpoint Dec 18, 2022
5eaaaf3
added code-docs to synthetic-link
fixxxedpoint Dec 18, 2022
86b0399
using try_from for PortRange in synthetic-lib for input validation
fixxxedpoint Dec 19, 2022
0282568
Merge remote-tracking branch 'origin/main' into network_tests.synthet…
fixxxedpoint Dec 30, 2022
95a7c33
Merge remote-tracking branch 'origin/main' into network_tests.synthet…
fixxxedpoint Jan 2, 2023
31c8cf5
missing deps after merge for synthetic-network
fixxxedpoint Jan 2, 2023
10739fc
Merge remote-tracking branch 'origin/main' into network_tests.synthet…
fixxxedpoint Jan 3, 2023
8eb1410
REVERT ME testing nightly pipeline
fixxxedpoint Jan 3, 2023
98499c2
fix after merge
fixxxedpoint Jan 3, 2023
b991f75
say no to install-protoc in github pipelines
fixxxedpoint Jan 3, 2023
b2a6a9d
Revert "say no to install-protoc in github pipelines"
fixxxedpoint Jan 3, 2023
a0f76fb
GITHUB_TOKEN for "Install Protoc" action
fixxxedpoint Jan 3, 2023
01d7b68
reverted changed file permissions
fixxxedpoint Jan 3, 2023
61e2f79
reverted rust-toolchain file
fixxxedpoint Jan 3, 2023
ca97e85
typo in description for PortRange
fixxxedpoint Jan 3, 2023
03aa36e
e2e-tests: config.validator_names() uses validators_count
fixxxedpoint Jan 3, 2023
d879c86
e2e-tests: added description for the `latency` tests
fixxxedpoint Jan 3, 2023
9a8e405
shell.nix: added description for new ENV var RUST_SRC_PATH - it's for…
fixxxedpoint Jan 3, 2023
f4a646b
BACKUP: e2e-tests/config.rs with iterators
fixxxedpoint Jan 4, 2023
36287c9
new verion of the synthetic-network e2e-test that supports non-docker…
fixxxedpoint Jan 4, 2023
a899970
Merge remote-tracking branch 'origin/main' into network_tests.synthet…
fixxxedpoint Jan 4, 2023
fbd4c4d
fix for e2e-test `no_quorum_without_high_latency` - missing call for …
fixxxedpoint Jan 4, 2023
4c0a55a
extended README.md for the synthetic-network: how to run e2e-tests wi…
fixxxedpoint Jan 4, 2023
93eeb03
renamed e2e-tests for high-out-latency with synthetic-network
fixxxedpoint Jan 4, 2023
656af60
renamed one of the e2e-tests pipelines in nightly for high-latency (s…
fixxxedpoint Jan 4, 2023
f79bdb0
Revert "REVERT ME testing nightly pipeline"
fixxxedpoint Jan 4, 2023
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
16 changes: 14 additions & 2 deletions .github/actions/run-e2e-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ inputs:
follow-up-finalization-check:
description: 'Whether to run a follow-up finalization check.'
required: false
image-path:
description: 'Custom path to docker image for aleph-node'
required: false
default: aleph-test-docker
node-image:
description: 'Custom name of aleph-node image'
required: false
default: aleph-node:latest
compose-file:
description: 'Custom docker-compose configuration'
required: false
default: ''

runs:
using: 'composite'
Expand All @@ -34,15 +46,15 @@ runs:
- name: Download artifact with docker image
uses: actions/download-artifact@v2
with:
name: aleph-test-docker
name: ${{ inputs.image-path }}

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Run consensus party
shell: bash
run: ./.github/scripts/run_consensus.sh -m ${{ inputs.min-validator-count }} -n ${{ inputs.node-count }}
run: NODE_IMAGE=${{ inputs.node-image }} DOCKER_COMPOSE=${{ inputs.compose-file }} ./.github/scripts/run_consensus.sh -m ${{ inputs.min-validator-count }} -n ${{ inputs.node-count }}

- name: Sleep
shell: bash
Expand Down
3 changes: 2 additions & 1 deletion .github/scripts/run_consensus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ NODE_COUNT=5
MIN_VALIDATOR_COUNT=4
DOCKER_COMPOSE=${DOCKER_COMPOSE:-"docker/docker-compose.yml"}
OVERRIDE_DOCKER_COMPOSE=${OVERRIDE_DOCKER_COMPOSE:-""}
NODE_IMAGE=${NODE_IMAGE:-aleph-node:latest}

# default minimum validator count
MIN_VALIDATOR_COUNT=4

export NODE_IMAGE=aleph-node:latest
export NODE_IMAGE

mkdir -p docker/data/

Expand Down
71 changes: 69 additions & 2 deletions .github/workflows/nightly-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ jobs:
if-no-files-found: error
retention-days: 7

build-synthetic-network-docker:
needs: [build-test-docker]
name: Build docker image with the test node artifact and support for synthetic-network
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Download artifact with docker image for aleph-node
uses: actions/download-artifact@v2
with:
name: aleph-test-docker

- name: Load node docker image
shell: bash
run: docker load -i aleph-node.tar

- name: Build test docker image
id: build-image
run: |
scripts/synthetic-network/build_synthetic-network.sh
docker save -o aleph-node.tar aleph-node:syntheticnet

- name: Upload test docker image
uses: actions/upload-artifact@v2
with:
name: aleph-test-synthetic-docker
path: aleph-node.tar
if-no-files-found: error
retention-days: 7

check-determinism:
needs: [build-new-node]
name: Verify runtime build determinism
Expand All @@ -59,7 +90,7 @@ jobs:
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.6.1'
version: '3.6.1'

- name: Install WASM target
run: rustup target add wasm32-unknown-unknown
Expand Down Expand Up @@ -96,7 +127,7 @@ jobs:
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: '3.6.1'
version: '3.6.1'

- name: Restore cache
uses: ./.github/actions/restore-cache
Expand Down Expand Up @@ -140,9 +171,45 @@ jobs:
randomized: true
timeout-minutes: 60

run-e2e-high-out-latency:
needs: [build-synthetic-network-docker, build-test-client]
name: Run high out-latency test
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Run e2e test
uses: ./.github/actions/run-e2e-test
with:
test-case: high_out_latency
image-path: aleph-test-synthetic-docker
node-image: aleph-node:syntheticnet
compose-file: docker/docker-compose.synthetic-network.yml
timeout-minutes: 30

no_quorum_without_high_out_latency:
needs: [build-synthetic-network-docker, build-test-client]
name: Run high out-latency for every quorum
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Run e2e test
uses: ./.github/actions/run-e2e-test
with:
test-case: no_quorum_without_high_out_latency
image-path: aleph-test-synthetic-docker
node-image: aleph-node:syntheticnet
compose-file: docker/docker-compose.synthetic-network.yml
timeout-minutes: 15

check-e2e-test-suite-completion:
needs: [
run-e2e-authorities-are-staking,
run-e2e-high-out-latency,
no_quorum_without_high_out_latency,
]
name: Check e2e test suite completion
runs-on: ubuntu-20.04
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "scripts/synthetic-network/vendor/synthetic-network"]
path = scripts/synthetic-network/vendor/synthetic-network
url = https://github.com/daily-co/synthetic-network.git
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exclude = [
"fork-off",
"benches/payout-stakers",
"bin/cliain",
"scripts/synthetic-network/synthetic-link",
]

[profile.release]
Expand Down
14 changes: 13 additions & 1 deletion aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{thread::sleep, time::Duration};
use std::{convert::AsRef, thread::sleep, time::Duration};

use anyhow::anyhow;
use codec::Decode;
Expand Down Expand Up @@ -58,6 +58,12 @@ impl SudoCall for RootConnection {
}
}

impl AsRef<Connection> for Connection {
fn as_ref(&self) -> &Connection {
self
}
}

impl Connection {
const DEFAULT_RETRIES: u32 = 10;
const RETRY_WAIT_SECS: u64 = 1;
Expand Down Expand Up @@ -161,6 +167,12 @@ impl SignedConnection {
}
}

impl AsRef<Connection> for SignedConnection {
fn as_ref(&self) -> &Connection {
&self.connection
}
}

impl RootConnection {
pub async fn new(address: String, root: KeyPair) -> anyhow::Result<Self> {
RootConnection::try_from_connection(Connection::new(address).await, root).await
Expand Down
9 changes: 5 additions & 4 deletions aleph-client/src/pallets/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,30 @@ pub trait SessionUserApi {
}

#[async_trait::async_trait]
impl SessionApi for Connection {
impl<C: AsRef<Connection> + Sync + ?Sized> SessionApi for C {
async fn get_next_session_keys(
&self,
account: AccountId,
at: Option<BlockHash>,
) -> Option<SessionKeys> {
let addrs = api::storage().session().next_keys(account);

self.get_storage_entry_maybe(&addrs, at).await
self.as_ref().get_storage_entry_maybe(&addrs, at).await
}

async fn get_session(&self, at: Option<BlockHash>) -> SessionIndex {
let addrs = api::storage().session().current_index();

self.get_storage_entry_maybe(&addrs, at)
self.as_ref()
.get_storage_entry_maybe(&addrs, at)
.await
.unwrap_or_default()
}

async fn get_validators(&self, at: Option<BlockHash>) -> Vec<AccountId> {
let addrs = api::storage().session().validators();

self.get_storage_entry(&addrs, at).await
self.as_ref().get_storage_entry(&addrs, at).await
}
}

Expand Down
36 changes: 30 additions & 6 deletions aleph-client/src/waiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,23 @@ pub trait WaitingExt {
}

#[async_trait::async_trait]
impl AlephWaiting for Connection {
impl<C: AsRef<Connection> + Sync> AlephWaiting for C {
async fn wait_for_block<P: Fn(u32) -> bool + Send>(&self, predicate: P, status: BlockStatus) {
let mut block_sub = match status {
BlockStatus::Best => self.client.blocks().subscribe_best().await.unwrap(),
BlockStatus::Finalized => self.client.blocks().subscribe_finalized().await.unwrap(),
BlockStatus::Best => self
.as_ref()
.client
.blocks()
.subscribe_best()
.await
.unwrap(),
BlockStatus::Finalized => self
.as_ref()
.client
.blocks()
.subscribe_finalized()
.await
.unwrap(),
};

while let Some(Ok(block)) = block_sub.next().await {
Expand All @@ -54,8 +66,20 @@ impl AlephWaiting for Connection {
status: BlockStatus,
) -> T {
let mut block_sub = match status {
BlockStatus::Best => self.client.blocks().subscribe_best().await.unwrap(),
BlockStatus::Finalized => self.client.blocks().subscribe_finalized().await.unwrap(),
BlockStatus::Best => self
.as_ref()
.client
.blocks()
.subscribe_best()
.await
.unwrap(),
BlockStatus::Finalized => self
.as_ref()
.client
.blocks()
.subscribe_finalized()
.await
.unwrap(),
};

info!(target: "aleph-client", "waiting for event {}.{}", T::PALLET, T::EVENT);
Expand All @@ -81,7 +105,7 @@ impl AlephWaiting for Connection {

async fn wait_for_era(&self, era: EraIndex, status: BlockStatus) {
let addrs = aleph_zero::api::constants().staking().sessions_per_era();
let sessions_per_era = self.client.constants().at(&addrs).unwrap();
let sessions_per_era = self.as_ref().client.constants().at(&addrs).unwrap();
let first_session_in_era = era * sessions_per_era;

self.wait_for_session(first_session_in_era, status).await;
Expand Down
Loading