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

Feature/rust rewarding #750

Merged
merged 79 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
bfc43c8
Calculating gas fees
jstuczyn Aug 9, 2021
6231821
Ability to set custom fees
jstuczyn Aug 9, 2021
0c34c38
Added extra test
jstuczyn Aug 9, 2021
f9489d9
Removed commented code
jstuczyn Aug 9, 2021
abcec68
Moved all msg types to common contract crate
jstuczyn Aug 9, 2021
7dbaab3
Temporarily disabling get_tx method
jstuczyn Aug 10, 2021
f5cad78
Finishing up nymd client API
jstuczyn Aug 10, 2021
ae1d92d
Comment fix
jstuczyn Aug 10, 2021
895a1e3
Remaining fee values
jstuczyn Aug 10, 2021
d70683c
Some cleanup
jstuczyn Aug 10, 2021
849fde0
Removed needless borrow
jstuczyn Aug 10, 2021
1d25c42
Fixed imports in contract tests
jstuczyn Aug 10, 2021
5e8b3e3
Moved error types around
jstuczyn Aug 10, 2021
74a82bf
New ValidatorClient
jstuczyn Aug 11, 2021
ae1e4da
Experiment with new type of defaults
jstuczyn Aug 11, 2021
9ff3d1d
Removed dead module
jstuczyn Aug 11, 2021
9434901
Merge branch 'develop' into feature/nymd-client-integration
jstuczyn Aug 11, 2021
0cecc2b
Merge branch 'develop' into feature/nymd-client-integration
jstuczyn Aug 11, 2021
aa3be40
Dealt with unwrap
jstuczyn Aug 12, 2021
a530514
Migrated mixnode to use new validator client
jstuczyn Aug 12, 2021
ddba2e8
Migrated gateway to use new validator client
jstuczyn Aug 12, 2021
89800fc
Mixnode and gateway adjustments
jstuczyn Aug 12, 2021
b04c7d7
More exported defaults
jstuczyn Aug 12, 2021
fe830f9
Clients using new validator client
jstuczyn Aug 12, 2021
57f8ba4
Fixed mixnode upgrade
jstuczyn Aug 12, 2021
24e1283
Moved default values to a new crate
jstuczyn Aug 12, 2021
16d8abd
Changed behaviour of validator client features
jstuczyn Aug 12, 2021
e1a6f85
Migrated basic functions of validator api
jstuczyn Aug 12, 2021
f027ac8
Updated config + fixed startup
jstuczyn Aug 12, 2021
e5c7bd6
Fixed wasm client build
jstuczyn Aug 12, 2021
e0d0c91
Integration with the explorer api
jstuczyn Aug 13, 2021
a0ec3e8
Merge branch 'develop' into feature/nymd-client-integration
jstuczyn Aug 13, 2021
57d6b5d
Removed tokio dev dependency
jstuczyn Aug 13, 2021
42ad1de
Needless borrow
jstuczyn Aug 13, 2021
bbdede6
Merge branch 'develop' into feature/nymd-client-integration
jstuczyn Aug 13, 2021
e0119eb
Fixex wasm client build
jstuczyn Aug 13, 2021
1ef2469
Fixed tauri client build
jstuczyn Aug 16, 2021
ee38ff3
Needless borrows
jstuczyn Aug 16, 2021
f2e4754
New tables for rewarding
jstuczyn Aug 24, 2021
7f2179b
Updated cosmos-sdk version
jstuczyn Aug 24, 2021
b3858c5
Removed reward-specific node status routes
jstuczyn Aug 24, 2021
a8cf93a
New rewarding-specific config entries
jstuczyn Aug 24, 2021
aaf12ca
Additional network defaults
jstuczyn Aug 24, 2021
f225eed
Initial periodic rewards from validator api
jstuczyn Aug 25, 2021
12ab836
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Aug 25, 2021
fe715d9
Replaced print with log
jstuczyn Aug 25, 2021
175c41e
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Aug 25, 2021
657017a
Filtering nodes with uptime > 0
jstuczyn Aug 26, 2021
9b64642
Additional failure logging statements
jstuczyn Aug 26, 2021
13741da
Fixed operation ordering
jstuczyn Aug 26, 2021
1aea8be
Adjusted next rewarding epoch determination
jstuczyn Aug 26, 2021
b447beb
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Aug 26, 2021
7ebaa33
Modified rewarding behaviour to keep track of rewarding in progress
jstuczyn Aug 26, 2021
17d8e30
Improved error message on config load failure
jstuczyn Aug 26, 2021
87bfc63
Additional log statement
jstuczyn Aug 27, 2021
856d67d
Adjusted rewarding gas limit calculation
jstuczyn Aug 27, 2021
227e85c
Made naming slightly more consistent
jstuczyn Aug 27, 2021
5295867
Fixed incorrect parentheses placement
jstuczyn Aug 27, 2021
8056958
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Aug 27, 2021
b4e521e
Merge branch 'feature/rust-rewarding' of github.com:nymtech/nym into …
jstuczyn Aug 27, 2021
8201965
Fixed fee calculation
jstuczyn Aug 27, 2021
d946743
Cargo fmt
jstuczyn Aug 27, 2021
332578f
Removed failed merge artifacts
jstuczyn Aug 27, 2021
02de282
Introduced comment for any future reward modification
jstuczyn Aug 31, 2021
4640d2e
typos
jstuczyn Aug 31, 2021
30dfdaf
Helper functions for the future
jstuczyn Sep 1, 2021
9e5d889
Making @mfahampshire 's life easier
jstuczyn Sep 1, 2021
318dfce
Redesigned epoch + rewarding skipped epochs (if possible)
jstuczyn Sep 1, 2021
e459005
Removed old merge artifacts
jstuczyn Sep 1, 2021
e0e30ca
Naming consistency
jstuczyn Sep 1, 2021
bcdbbe6
Constraining arguments
jstuczyn Sep 1, 2021
fd76dbc
Removed unnecessary if branch
jstuczyn Sep 1, 2021
96155ca
Ignore monitor check for current epoch
jstuczyn Sep 1, 2021
b1696cf
Additional checks for current epoch data
jstuczyn Sep 2, 2021
118223c
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Sep 20, 2021
fb859db
Monitor threshold check
jstuczyn Sep 24, 2021
c9e98b0
Merge branch 'develop' into feature/rust-rewarding
jstuczyn Sep 24, 2021
1bda018
cargo fmt
jstuczyn Sep 24, 2021
462a83e
Fixed post-merge issues in transactions.rs
jstuczyn Sep 24, 2021
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
24 changes: 23 additions & 1 deletion validator-api/src/network_monitor/monitor/preparer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use nymsphinx::addressing::clients::Recipient;
use nymsphinx::forwarding::packet::MixPacket;
use std::convert::TryInto;
use std::fmt::{self, Display, Formatter};
use std::time::Duration;
use topology::{gateway, mix};

// declared type aliases for easier code reasoning
Expand Down Expand Up @@ -167,10 +168,31 @@ impl PacketPreparer {
}

pub(crate) async fn wait_for_validator_cache_initial_values(&self) {
// wait for the cache to get initialised
self.validator_cache.wait_for_initial_values().await;

// now wait for our "good" topology to be online
info!("Waiting for 'good' topology to be online");
let initialisation_backoff = Duration::from_secs(30);
loop {
let gateways = self.validator_cache.gateways().await;
let mixnodes = self.validator_cache.mixnodes().await;
if self
.tested_network
.is_online(&mixnodes.into_inner(), &gateways.into_inner())
{
break;
} else {
info!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

30 seconds seems like quite a long time, maybe this should be a warning instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only happening at startup and I'd even argue that perhaps 30s is too short. This is basically to help to solve our chicken and the egg problem of network monitor requiring "good" topology to be online to run and mixnodes/gateways requiring the validator-api to be online in order to start themselves. With this delay we can start the basic validator-api functionality (without monitoring), while we wait for mixnodes/gateways to become online. After that happens the monitor will start

"Our 'good' topology is still not offline. Going to check again in {:?}",
initialisation_backoff
);
tokio::time::sleep(initialisation_backoff).await;
}
}
}

async fn get_network_nodes(&mut self) -> (Vec<MixNodeBond>, Vec<GatewayBond>) {
async fn get_network_nodes(&self) -> (Vec<MixNodeBond>, Vec<GatewayBond>) {
info!(target: "Monitor", "Obtaining network topology...");

let mixnodes = self.validator_cache.mixnodes().await.into_inner();
Expand Down
37 changes: 37 additions & 0 deletions validator-api/src/network_monitor/tested_network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::network_monitor::test_packet::IpVersion;
use mixnet_contract::{GatewayBond, MixNodeBond};
use topology::{gateway, mix, NymTopology};

pub(crate) mod good_topology;
Expand Down Expand Up @@ -68,4 +69,40 @@ impl TestedNetwork {
pub(crate) fn v6_topology(&self) -> &NymTopology {
&self.good_v6_topology
}

/// Given slices of bonded mixnodes and gateways, checks whether all 'good' nodes are present
/// in the lists.
///
/// # Arguments
///
/// * `bonded_mixnodes`: slice of currently bonded mixnodes
/// * `bonded_gateways`: slice of currently bonded gateways
pub(crate) fn is_online(
&self,
bonded_mixnodes: &[MixNodeBond],
bonded_gateways: &[GatewayBond],
) -> bool {
// while technically this is not the most optimal way of checking all nodes as we have to
// go through entire slice multiple times, we only do it every 30s before monitor startup
// so it's not really that bad
for layer_mixes in self.good_v4_topology.mixes().values() {
for mix in layer_mixes {
if !bonded_mixnodes.iter().any(|bonded| {
bonded.mix_node.identity_key == mix.identity_key.to_base58_string()
}) {
return false;
}
}
}

for gateway in self.good_v4_topology.gateways() {
if !bonded_gateways.iter().any(|bonded| {
bonded.gateway.identity_key == gateway.identity_key.to_base58_string()
}) {
return false;
}
}

true
}
}