Skip to content

Commit f82550c

Browse files
A0-1502: Finality version e2e test (#717)
* Setting up AlephBFT version * Changed handling to map from session to version * Changed logic to handle serving last set AlephBFT version * Changed logic to handle setting of version in future only * Reworked storage and accessors to only store one version plus session to change it * Treat version change as a delimiting flag * Loose coupling between pallet_aleph and pallet_session to access current session index * Fixed trait implementation for mock * Added comment to trait * Replaced panics with Results in AlephBFT version handling * Changed logic to work with numbered versions * Changed behavior on session start and end * Fixed version change update * Linked SessionManager in runtime * Mock impl * Reworked SessionManage link * Linter * Removed pallet_elections from mock * Removed event * linter * Linter * Reworked AlephBFT version history updates * Reworked storage to use value instead of map * Added unit test * Added version change unscheduling and next session version * Removed explicit version unscheduling; added version default * Extended docs for pallet aleph * Moved default AlephBFT version to const * Renamed helper function * Fixed test * Changed naming * Bumped spec version * Bumped transaction version * Finality version RPC and e2e test, first stab * Added GenesisBuild to pallet_aleph * Added finality version e2e test * Reworked test logic * Removed unused imports * Dependency version fixes; prep work for test logic change * Post factum checks * Changed checks; changed finality version update session * Added test description * aleph-client and aleph-e2e-client version bumps * spec_version and transaction_version bumps * Changed comment about error code * Added doc comment * Cargo.lock * Bumped runtime version * Disabled runtime upgrade check in CI * Revert "Disabled runtime upgrade check in CI" This reverts commit e4cc57b. * Disabled runtime upgrade check without removing it * Post-merge cleanup * Back to storage; handle connection refactor * Codegen * Bumped aleph-client version * Back to rpc call; prelims * Rpc interface * Rpc * Link with node * Rpc request; cleanup * Partial fix * Fixed RPC params * Versioning * Linter * Default version fix * E2e test version bump * Interface reorg * Linter * Connection fixes; pipelines * Linter * Finality version set in chain spec * Subxt codegen * E2e test fix * Runtime metadata for aleph-client * Hide doc warnings * Removed hide docs * Actually check the version change * Subxt metadata * Linter cleanup * Const reorg * Current finality version calculated based on the legacy one
1 parent c3a93ab commit f82550c

File tree

26 files changed

+421
-192
lines changed

26 files changed

+421
-192
lines changed

.github/workflows/e2e-tests-main-devnet.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -466,23 +466,23 @@ jobs:
466466
follow-up-finalization-check: true
467467
timeout-minutes: 10
468468

469-
# run-e2e-authorities-are-staking:
470-
# needs: [build-test-docker, build-test-client]
471-
# name: Run authorities are staking test
472-
# runs-on: ubuntu-20.04
473-
# steps:
474-
# - name: Checkout source code
475-
# uses: actions/checkout@v2
476-
#
477-
# - name: Run e2e test
478-
# uses: ./.github/actions/run-e2e-test
479-
# with:
480-
# test-case: authorities_are_staking
481-
# node-count: 6
482-
# reserved-seats: 3
483-
# non-reserved-seats: 3
484-
# follow-up-finalization-check: false
485-
# timeout-minutes: 15
469+
run-e2e-authorities-are-staking:
470+
needs: [build-test-docker, build-test-client]
471+
name: Run authorities are staking test
472+
runs-on: ubuntu-20.04
473+
steps:
474+
- name: Checkout source code
475+
uses: actions/checkout@v2
476+
477+
- name: Run e2e test
478+
uses: ./.github/actions/run-e2e-test
479+
with:
480+
test-case: authorities_are_staking
481+
node-count: 6
482+
reserved-seats: 3
483+
non-reserved-seats: 3
484+
follow-up-finalization-check: true
485+
timeout-minutes: 15
486486

487487
run-e2e-ban-automatic:
488488
needs: [build-test-docker, build-test-client]
@@ -570,7 +570,7 @@ jobs:
570570
- name: Run e2e test
571571
uses: ./.github/actions/run-e2e-test
572572
with:
573-
test-case: version_upgrade::schedule_version_change
573+
test-case: finality_version::schedule_version_change
574574
env:
575575
UPGRADE_VERSION: 1
576576
UPGRADE_SESSION: 3
@@ -683,6 +683,21 @@ jobs:
683683
# run: |
684684
# ./scripts/catchup_version_upgrade_test.sh
685685

686+
run-e2e-finality-version-change:
687+
needs: [build-test-docker, build-test-client]
688+
name: Run finality version change test
689+
runs-on: ubuntu-20.04
690+
steps:
691+
- name: Checkout source code
692+
uses: actions/checkout@v2
693+
694+
- name: Run e2e test
695+
uses: ./.github/actions/run-e2e-test
696+
with:
697+
test-case: finality_version::finality_version_change
698+
follow-up-finalization-check: true
699+
timeout-minutes: 10
700+
686701
check-e2e-test-suite-completion:
687702
needs: [
688703
run-e2e-finalization-test,
@@ -702,7 +717,7 @@ jobs:
702717
run-e2e-rewards-stake-change,
703718
run-e2e-rewards-change-stake-force-new-era,
704719
run-e2e-rewards-points-basic,
705-
# run-e2e-authorities-are-staking,
720+
run-e2e-authorities-are-staking,
706721
run-e2e-ban-automatic,
707722
run-e2e-ban-manual,
708723
run-e2e-ban-counter-clearing,
@@ -712,6 +727,7 @@ jobs:
712727
run-e2e-adder-contract-test,
713728
# run-e2e-failing-version-upgrade,
714729
# run-e2e-version-upgrade-catchup,
730+
run-e2e-finality-version-change,
715731
]
716732
name: Check e2e test suite completion
717733
runs-on: ubuntu-20.04

.github/workflows/nightly-pipeline.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ jobs:
158158
if-no-files-found: error
159159
retention-days: 7
160160

161-
run-e2e-authorities-are-staking:
162-
needs: [build-test-docker, build-test-client]
163-
name: Run authorities are staking test
164-
runs-on: ubuntu-20.04
165-
steps:
166-
- name: Checkout source code
167-
uses: actions/checkout@v2
168-
169-
- name: Run e2e test
170-
uses: ./.github/actions/run-e2e-test
171-
with:
172-
test-case: authorities_are_staking
173-
node-count: 6
174-
follow-up-finalization-check: true
175-
timeout-minutes: 60
176-
177161
run-e2e-high-out-latency:
178162
needs: [build-synthetic-network-docker, build-test-client]
179163
name: Run high out-latency test
@@ -210,7 +194,6 @@ jobs:
210194

211195
check-e2e-test-suite-completion:
212196
needs: [
213-
run-e2e-authorities-are-staking,
214197
run-e2e-high-out-latency,
215198
run-e2e-no-quorum-without-high-out-latency,
216199
]

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aleph-client/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aleph-client/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "aleph_client"
3-
version = "2.12.0"
3+
# TODO bump major version when API stablize
4+
version = "2.13.0"
45
edition = "2021"
56
license = "Apache 2.0"
67

aleph-client/src/aleph_zero.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6353,9 +6353,10 @@ pub mod api {
63536353
"NextAuthorities",
63546354
vec![],
63556355
[
6356-
241u8, 145u8, 255u8, 235u8, 191u8, 220u8, 57u8, 89u8, 8u8, 134u8, 72u8,
6357-
193u8, 247u8, 37u8, 54u8, 201u8, 136u8, 32u8, 11u8, 199u8, 134u8,
6358-
207u8, 154u8, 107u8, 71u8, 121u8, 245u8, 153u8, 9u8, 33u8, 70u8, 3u8,
6356+
223u8, 196u8, 18u8, 234u8, 75u8, 169u8, 31u8, 25u8, 180u8, 189u8, 78u8,
6357+
192u8, 179u8, 27u8, 218u8, 254u8, 245u8, 211u8, 86u8, 33u8, 113u8,
6358+
114u8, 214u8, 133u8, 240u8, 211u8, 232u8, 163u8, 123u8, 98u8, 114u8,
6359+
26u8,
63596360
],
63606361
)
63616362
}
@@ -6430,9 +6431,10 @@ pub mod api {
64306431
"FinalityVersion",
64316432
vec![],
64326433
[
6433-
99u8, 158u8, 103u8, 180u8, 128u8, 32u8, 84u8, 110u8, 229u8, 2u8, 3u8,
6434-
114u8, 95u8, 125u8, 230u8, 210u8, 56u8, 85u8, 38u8, 136u8, 49u8, 206u8,
6435-
6u8, 136u8, 193u8, 164u8, 251u8, 60u8, 125u8, 91u8, 205u8, 144u8,
6434+
134u8, 19u8, 94u8, 247u8, 125u8, 18u8, 148u8, 160u8, 167u8, 235u8,
6435+
174u8, 4u8, 107u8, 69u8, 55u8, 187u8, 249u8, 13u8, 129u8, 99u8, 116u8,
6436+
158u8, 38u8, 29u8, 239u8, 112u8, 150u8, 92u8, 151u8, 197u8, 223u8,
6437+
30u8,
64366438
],
64376439
)
64386440
}
@@ -19553,9 +19555,9 @@ pub mod api {
1955319555
let runtime_metadata_hash = client.metadata().metadata_hash(&PALLETS);
1955419556
if runtime_metadata_hash
1955519557
!= [
19556-
51u8, 153u8, 218u8, 203u8, 158u8, 62u8, 141u8, 96u8, 177u8, 177u8, 12u8, 204u8,
19557-
220u8, 53u8, 42u8, 155u8, 22u8, 96u8, 238u8, 212u8, 98u8, 225u8, 39u8, 241u8, 52u8,
19558-
28u8, 166u8, 99u8, 14u8, 192u8, 65u8, 67u8,
19558+
129u8, 53u8, 4u8, 85u8, 248u8, 69u8, 122u8, 6u8, 68u8, 150u8, 173u8, 133u8, 118u8,
19559+
19u8, 96u8, 223u8, 153u8, 160u8, 226u8, 156u8, 47u8, 53u8, 206u8, 110u8, 204u8,
19560+
37u8, 67u8, 45u8, 176u8, 126u8, 21u8, 133u8,
1955919561
]
1956019562
{
1956119563
Err(::subxt::error::MetadataError::IncompatibleMetadata)

aleph-client/src/pallets/aleph.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use codec::Encode;
2-
use primitives::{BlockNumber, SessionIndex};
2+
use primitives::{BlockNumber, SessionIndex, Version};
33
use subxt::rpc_params;
44

55
use crate::{
6+
api,
67
api::runtime_types::{
78
pallet_aleph::pallet::Call::set_emergency_finalizer, primitives::app::Public,
89
sp_core::ed25519::Public as EdPublic,
@@ -15,6 +16,15 @@ use crate::{
1516
};
1617

1718
// TODO replace docs with link to pallet aleph docs, once they are published
19+
/// Pallet aleph API which does not require sudo.
20+
#[async_trait::async_trait]
21+
pub trait AlephApi {
22+
/// Gets the current finality version.
23+
async fn finality_version(&self, at: Option<BlockHash>) -> Version;
24+
/// Gets the finality version for the next session.
25+
async fn next_session_finality_version(&self, at: Option<BlockHash>) -> Version;
26+
}
27+
1828
/// Pallet aleph API that requires sudo.
1929
#[async_trait::async_trait]
2030
pub trait AlephSudoApi {
@@ -57,6 +67,23 @@ pub trait AlephRpc {
5767
) -> anyhow::Result<()>;
5868
}
5969

70+
#[async_trait::async_trait]
71+
impl<C: ConnectionApi> AlephApi for C {
72+
async fn finality_version(&self, at: Option<BlockHash>) -> Version {
73+
let addrs = api::storage().aleph().finality_version();
74+
75+
self.get_storage_entry(&addrs, at).await
76+
}
77+
78+
async fn next_session_finality_version(&self, hash: Option<BlockHash>) -> Version {
79+
let method = "state_call";
80+
let api_method = "AlephSessionApi_next_session_finality_version";
81+
let params = rpc_params![api_method, "0x", hash];
82+
83+
self.rpc_call(method.to_string(), params).await.unwrap()
84+
}
85+
}
86+
6087
#[async_trait::async_trait]
6188
impl AlephSudoApi for RootConnection {
6289
async fn set_emergency_finalizer(

benches/payout-stakers/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/cliain/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/src/chain_spec.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
use std::{collections::HashSet, str::FromStr};
1+
use std::{collections::HashSet, str::FromStr, string::ToString};
22

33
use aleph_primitives::{
44
staking::{MIN_NOMINATOR_BOND, MIN_VALIDATOR_BOND},
5-
AuthorityId as AlephId, ADDRESSES_ENCODING, TOKEN, TOKEN_DECIMALS,
5+
AuthorityId as AlephId, Version as FinalityVersion, ADDRESSES_ENCODING,
6+
LEGACY_FINALITY_VERSION, TOKEN, TOKEN_DECIMALS,
67
};
78
use aleph_runtime::{
8-
AccountId, AuraConfig, BalancesConfig, ElectionsConfig, GenesisConfig, Perbill, SessionConfig,
9-
SessionKeys, StakingConfig, SudoConfig, SystemConfig, VestingConfig, WASM_BINARY,
9+
AccountId, AlephConfig, AuraConfig, BalancesConfig, ElectionsConfig, GenesisConfig, Perbill,
10+
SessionConfig, SessionKeys, StakingConfig, SudoConfig, SystemConfig, VestingConfig,
11+
WASM_BINARY,
1012
};
1113
use libp2p::PeerId;
1214
use pallet_staking::{Forcing, StakerStatus};
@@ -136,6 +138,10 @@ pub struct ChainParams {
136138
/// Minimum number of stakers before chain enters emergency state.
137139
#[arg(long, default_value = "4")]
138140
min_validator_count: u32,
141+
142+
/// Finality version at chain inception.
143+
#[arg(long, default_value = LEGACY_FINALITY_VERSION.to_string())]
144+
finality_version: FinalityVersion,
139145
}
140146

141147
impl ChainParams {
@@ -170,6 +176,10 @@ impl ChainParams {
170176
pub fn min_validator_count(&self) -> u32 {
171177
self.min_validator_count
172178
}
179+
180+
pub fn finality_version(&self) -> FinalityVersion {
181+
self.finality_version
182+
}
173183
}
174184

175185
fn system_properties(token_symbol: String) -> serde_json::map::Map<String, Value> {
@@ -218,6 +228,7 @@ fn generate_chain_spec_config(
218228
let sudo_account = chain_params.sudo_account_id();
219229
let faucet_account = chain_params.faucet_account_id();
220230
let min_validator_count = chain_params.min_validator_count();
231+
let finality_version = chain_params.finality_version();
221232

222233
Ok(ChainSpec::from_genesis(
223234
// Name
@@ -233,6 +244,7 @@ fn generate_chain_spec_config(
233244
faucet_account.clone(), // Pre-funded faucet account
234245
controller_accounts.clone(), // Controller accounts for staking.
235246
min_validator_count,
247+
finality_version,
236248
)
237249
},
238250
// Bootnodes
@@ -335,6 +347,7 @@ fn generate_genesis_config(
335347
faucet_account: Option<AccountId>,
336348
controller_accounts: Vec<AccountId>,
337349
min_validator_count: u32,
350+
finality_version: FinalityVersion,
338351
) -> GenesisConfig {
339352
let special_accounts = match faucet_account {
340353
Some(faucet_id) => vec![sudo_account.clone(), faucet_id],
@@ -398,6 +411,10 @@ fn generate_genesis_config(
398411
min_nominator_bond: MIN_NOMINATOR_BOND,
399412
..Default::default()
400413
},
414+
aleph: AlephConfig {
415+
finality_version,
416+
..Default::default()
417+
},
401418
treasury: Default::default(),
402419
vesting: VestingConfig { vesting: vec![] },
403420
nomination_pools: Default::default(),

0 commit comments

Comments
 (0)