Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
as_ref in aleph-client for Connection types
  • Loading branch information
fixxxedpoint committed Dec 16, 2022
commit e8ae567b7cc232c6f44c5676b9752153f8b8b435
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