Skip to content
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
200 changes: 101 additions & 99 deletions .github/workflows/e2e-tests-main-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,23 +439,23 @@ jobs:
follow-up-finalization-check: true
timeout-minutes: 10

run-e2e-authorities-are-staking:
needs: [build-test-docker, build-test-client]
name: Run authorities are staking 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: authorities_are_staking
node-count: 6
reserved-seats: 3
non-reserved-seats: 3
follow-up-finalization-check: false
timeout-minutes: 15
# run-e2e-authorities-are-staking:
# needs: [build-test-docker, build-test-client]
# name: Run authorities are staking 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: authorities_are_staking
# node-count: 6
# reserved-seats: 3
# non-reserved-seats: 3
# follow-up-finalization-check: false
# timeout-minutes: 15

run-e2e-ban-automatic:
needs: [build-test-docker, build-test-client]
Expand Down Expand Up @@ -535,85 +535,87 @@ jobs:
UPGRADE_FINALIZATION_WAIT_SESSIONS: 2
timeout-minutes: 10

run-e2e-failing-version-upgrade:
needs: [build-test-docker, build-test-client]
name: Run basic (failing) version-upgrade 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: doomed_version_upgrade
env:
OVERRIDE_DOCKER_COMPOSE: ./.github/scripts/docker-compose.no_quorum_without_old.override.yml
UPGRADE_VERSION: 1
UPGRADE_SESSION: 3
UPGRADE_FINALIZATION_WAIT_SESSIONS: 2
ONLY_LEGACY: true
timeout-minutes: 10

run-e2e-version-upgrade-catchup:
needs: [build-test-docker, build-cliain-image]
name: Run series of tests where some of the nodes need to do version-upgrade during catch-up
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- nodes: "Node1"
ports: "9934"
ext_status: "finalized"
upgrade_before_disable: "true"

- nodes: "Node1"
ports: "9934"
ext_status: "finalized"
upgrade_before_disable: "false"

- nodes: "Node1:Node2"
ports: "9934:9935"
ext_status: "in-block"
upgrade_before_disable: "true"

- nodes: "Node1:Node2"
ports: "9934:9935"
ext_status: "in-block"
upgrade_before_disable: "false"
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: Download artifact with docker image for cliain
uses: actions/download-artifact@v2
with:
name: cliain-docker

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

- name: Call catchup_test.sh
timeout-minutes: 10
env:
UPGRADE_BLOCK: 31
NODES: ${{ matrix.nodes }}
PORTS: ${{ matrix.ports }}
EXT_STATUS: ${{ matrix.ext_status }}
UPGRADE_BEFORE_DISABLE: ${{ matrix.upgrade_before_disable }}
DOCKER_COMPOSE: docker/docker-compose.bridged.yml
run: |
./scripts/catchup_version_upgrade_test.sh
# The tests below were written under the assumption that nonfinalized blocks are being produced, they need a rewrite before being reenabled.
# TODO(A0-1644): Reenable these tests.
# run-e2e-failing-version-upgrade:
# needs: [build-test-docker, build-test-client]
# name: Run basic (failing) version-upgrade 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: doomed_version_upgrade
# env:
# OVERRIDE_DOCKER_COMPOSE: ./.github/scripts/docker-compose.no_quorum_without_old.override.yml
# UPGRADE_VERSION: 1
# UPGRADE_SESSION: 3
# UPGRADE_FINALIZATION_WAIT_SESSIONS: 2
# ONLY_LEGACY: true
# timeout-minutes: 10

# run-e2e-version-upgrade-catchup:
# needs: [build-test-docker, build-cliain-image]
# name: Run series of tests where some of the nodes need to do version-upgrade during catch-up
# runs-on: ubuntu-20.04
# strategy:
# matrix:
# include:
# - nodes: "Node1"
# ports: "9934"
# ext_status: "finalized"
# upgrade_before_disable: "true"
#
# - nodes: "Node1"
# ports: "9934"
# ext_status: "finalized"
# upgrade_before_disable: "false"
#
# - nodes: "Node1:Node2"
# ports: "9934:9935"
# ext_status: "in-block"
# upgrade_before_disable: "true"
#
# - nodes: "Node1:Node2"
# ports: "9934:9935"
# ext_status: "in-block"
# upgrade_before_disable: "false"
# 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: Download artifact with docker image for cliain
# uses: actions/download-artifact@v2
# with:
# name: cliain-docker
#
# - name: Load cliain docker image
# shell: bash
# run: docker load -i cliain.tar
#
# - name: Call catchup_test.sh
# timeout-minutes: 10
# env:
# UPGRADE_BLOCK: 31
# NODES: ${{ matrix.nodes }}
# PORTS: ${{ matrix.ports }}
# EXT_STATUS: ${{ matrix.ext_status }}
# UPGRADE_BEFORE_DISABLE: ${{ matrix.upgrade_before_disable }}
# DOCKER_COMPOSE: docker/docker-compose.bridged.yml
# run: |
# ./scripts/catchup_version_upgrade_test.sh

check-e2e-test-suite-completion:
needs: [
Expand All @@ -634,14 +636,14 @@ jobs:
run-e2e-rewards-stake-change,
run-e2e-rewards-change-stake-force-new-era,
run-e2e-rewards-points-basic,
run-e2e-authorities-are-staking,
# run-e2e-authorities-are-staking,
run-e2e-ban-automatic,
run-e2e-ban-manual,
run-e2e-ban-counter-clearing,
run-e2e-ban-threshold,
run-e2e-version-upgrade,
run-e2e-failing-version-upgrade,
run-e2e-version-upgrade-catchup,
# run-e2e-failing-version-upgrade,
# run-e2e-version-upgrade-catchup,
]
name: Check e2e test suite completion
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bin/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ sc-network = { git = "https://github.com/Cardinal-Cryptography/substrate.git", b
sc-transaction-pool = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sp-transaction-pool = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sc-transaction-pool-api = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sp-arithmetic = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sc-consensus-slots = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sc-consensus-aura = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sp-consensus-aura = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
sp-consensus = { git = "https://github.com/Cardinal-Cryptography/substrate.git", branch = "aleph-v0.9.30" }
Expand Down
14 changes: 14 additions & 0 deletions bin/node/src/aleph_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use aleph_primitives::DEFAULT_UNIT_CREATION_DELAY;
use clap::{ArgGroup, Parser};
use finality_aleph::UnitCreationDelay;
use log::warn;

#[derive(Debug, Parser, Clone)]
#[clap(group(ArgGroup::new("backup")))]
Expand Down Expand Up @@ -33,6 +34,12 @@ pub struct AlephCli {
/// with `--no-backup`, but note that that limits crash recoverability.
#[clap(long, value_name = "PATH", group = "backup")]
backup_path: Option<PathBuf>,

/// The maximum number of nonfinalized blocks, after which block production should be locally
/// stopped. DO NOT CHANGE THIS, PRODUCING MORE OR FEWER BLOCKS MIGHT BE CONSIDERED MALICIOUS
/// BEHAVIOUR AND PUNISHED ACCORDINGLY!
#[clap(long, default_value_t = 20)]
max_nonfinalized_blocks: u32,
}

impl AlephCli {
Expand All @@ -55,4 +62,11 @@ impl AlephCli {
pub fn no_backup(&self) -> bool {
self.no_backup
}

pub fn max_nonfinalized_blocks(&self) -> u32 {
if self.max_nonfinalized_blocks != 20 {
warn!("Running block production with a value of max-nonfinalized-blocks {}, which is not the default of 20. THIS MIGHT BE CONSIDERED MALICIOUS BEHAVIOUR AND RESULT IN PENALTIES!", self.max_nonfinalized_blocks);
}
self.max_nonfinalized_blocks
}
}
30 changes: 28 additions & 2 deletions bin/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ use futures::channel::mpsc;
use log::warn;
use sc_client_api::{Backend, HeaderBackend};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_slots::BackoffAuthoringBlocksStrategy;
use sc_network::NetworkService;
use sc_service::{
error::Error as ServiceError, Configuration, KeystoreContainer, NetworkStarter, RpcHandlers,
TFullClient, TaskManager,
};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_api::ProvideRuntimeApi;
use sp_arithmetic::traits::BaseArithmetic;
use sp_blockchain::Backend as _;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
use sp_consensus_aura::{sr25519::AuthorityPair as AuraPair, Slot};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT, Zero},
Expand All @@ -35,6 +37,30 @@ type FullClient = sc_service::TFullClient<Block, RuntimeApi, AlephExecutor>;
type FullBackend = sc_service::TFullBackend<Block>;
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;

struct LimitNonfinalized(u32);

impl<N: BaseArithmetic> BackoffAuthoringBlocksStrategy<N> for LimitNonfinalized {
fn should_backoff(
&self,
chain_head_number: N,
_chain_head_slot: Slot,
finalized_number: N,
_slow_now: Slot,
_logging_target: &str,
) -> bool {
let nonfinalized_blocks: u32 = chain_head_number
.saturating_sub(finalized_number)
.unique_saturated_into();
match nonfinalized_blocks >= self.0 {
true => {
warn!("We have {} nonfinalized blocks, with the limit being {}, delaying block production.", nonfinalized_blocks, self.0);
true
}
false => false,
}
}
}

fn backup_path(aleph_config: &AlephCli, base_path: &Path) -> Option<PathBuf> {
if aleph_config.no_backup() {
return None;
Expand Down Expand Up @@ -279,7 +305,7 @@ pub fn new_authority(
);

let force_authoring = config.force_authoring;
let backoff_authoring_blocks: Option<()> = None;
let backoff_authoring_blocks = Some(LimitNonfinalized(aleph_config.max_nonfinalized_blocks()));
let prometheus_registry = config.prometheus_registry().cloned();

let (_rpc_handlers, network, network_starter) = setup(
Expand Down