Feature/rust rewarding (#750)
* Calculating gas fees * Ability to set custom fees * Added extra test * Removed commented code * Moved all msg types to common contract crate * Temporarily disabling get_tx method * Finishing up nymd client API * Comment fix * Remaining fee values * Some cleanup * Removed needless borrow * Fixed imports in contract tests * Moved error types around * New ValidatorClient * Experiment with new type of defaults * Removed dead module * Dealt with unwrap * Migrated mixnode to use new validator client * Migrated gateway to use new validator client * Mixnode and gateway adjustments * More exported defaults * Clients using new validator client * Fixed mixnode upgrade * Moved default values to a new crate * Changed behaviour of validator client features * Migrated basic functions of validator api * Updated config + fixed startup * Fixed wasm client build * Integration with the explorer api * Removed tokio dev dependency * Needless borrow * Fixex wasm client build * Fixed tauri client build * Needless borrows * New tables for rewarding * Updated cosmos-sdk version * Removed reward-specific node status routes * New rewarding-specific config entries * Additional network defaults * Initial periodic rewards from validator api * Replaced print with log * Filtering nodes with uptime > 0 * Additional failure logging statements * Fixed operation ordering * Adjusted next rewarding epoch determination * Modified rewarding behaviour to keep track of rewarding in progress * Improved error message on config load failure * Additional log statement * Adjusted rewarding gas limit calculation * Made naming slightly more consistent * Fixed incorrect parentheses placement * Fixed fee calculation * Cargo fmt * Removed failed merge artifacts * Introduced comment for any future reward modification * typos * Helper functions for the future * Making @mfahampshire 's life easier * Redesigned epoch + rewarding skipped epochs (if possible) * Removed old merge artifacts * Naming consistency * Constraining arguments * Removed unnecessary if branch * Ignore monitor check for current epoch * Additional checks for current epoch data * Monitor threshold check * cargo fmt * Fixed post-merge issues in transactions.rs
This commit is contained in:
committed by
GitHub
parent
5dfaff6296
commit
020cad897d
@@ -26,9 +26,6 @@ pub(crate) fn stage(database_path: PathBuf) -> AdHoc {
|
||||
routes::gateway_report,
|
||||
routes::mixnode_uptime_history,
|
||||
routes::gateway_uptime_history,
|
||||
routes::mixnodes_full_report,
|
||||
routes::gateways_full_report,
|
||||
routes::rewarding_chores,
|
||||
],
|
||||
)
|
||||
})
|
||||
|
||||
@@ -7,17 +7,17 @@ use rocket::http::{ContentType, Status};
|
||||
use rocket::response::{self, Responder, Response};
|
||||
use rocket::Request;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::io::Cursor;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
// todo: put into some error enum
|
||||
#[derive(Debug)]
|
||||
pub struct InvalidUptime;
|
||||
|
||||
// value in range 0-100
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
|
||||
pub struct Uptime(u8);
|
||||
|
||||
impl Uptime {
|
||||
@@ -76,17 +76,17 @@ impl TryFrom<i64> for Uptime {
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct MixnodeStatusReport {
|
||||
identity: String,
|
||||
owner: String,
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
|
||||
most_recent_ipv4: bool,
|
||||
most_recent_ipv6: bool,
|
||||
pub(crate) most_recent_ipv4: bool,
|
||||
pub(crate) most_recent_ipv6: bool,
|
||||
|
||||
last_hour_ipv4: Uptime,
|
||||
last_hour_ipv6: Uptime,
|
||||
pub(crate) last_hour_ipv4: Uptime,
|
||||
pub(crate) last_hour_ipv6: Uptime,
|
||||
|
||||
last_day_ipv4: Uptime,
|
||||
last_day_ipv6: Uptime,
|
||||
pub(crate) last_day_ipv4: Uptime,
|
||||
pub(crate) last_day_ipv6: Uptime,
|
||||
}
|
||||
|
||||
impl MixnodeStatusReport {
|
||||
@@ -122,17 +122,17 @@ impl MixnodeStatusReport {
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct GatewayStatusReport {
|
||||
identity: String,
|
||||
owner: String,
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
|
||||
most_recent_ipv4: bool,
|
||||
most_recent_ipv6: bool,
|
||||
pub(crate) most_recent_ipv4: bool,
|
||||
pub(crate) most_recent_ipv6: bool,
|
||||
|
||||
last_hour_ipv4: Uptime,
|
||||
last_hour_ipv6: Uptime,
|
||||
pub(crate) last_hour_ipv4: Uptime,
|
||||
pub(crate) last_hour_ipv6: Uptime,
|
||||
|
||||
last_day_ipv4: Uptime,
|
||||
last_day_ipv6: Uptime,
|
||||
pub(crate) last_day_ipv4: Uptime,
|
||||
pub(crate) last_day_ipv6: Uptime,
|
||||
}
|
||||
|
||||
impl GatewayStatusReport {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::node_status_api::local_guard::LocalRequest;
|
||||
use crate::node_status_api::models::{
|
||||
ErrorResponse, GatewayStatusReport, GatewayUptimeHistory, MixnodeStatusReport,
|
||||
MixnodeUptimeHistory,
|
||||
@@ -11,22 +10,6 @@ use rocket::http::Status;
|
||||
use rocket::serde::json::Json;
|
||||
use rocket::State;
|
||||
|
||||
#[get("/daily-chores")]
|
||||
pub(crate) async fn rewarding_chores(
|
||||
_local_request: LocalRequest,
|
||||
storage: &State<NodeStatusStorage>,
|
||||
) -> Result<&'static str, ErrorResponse> {
|
||||
if storage
|
||||
.daily_chores()
|
||||
.await
|
||||
.map_err(|err| ErrorResponse::new(err, Status::InternalServerError))?
|
||||
{
|
||||
Ok("Updated historical uptimes and purged old reports.")
|
||||
} else {
|
||||
Ok("The historical uptimes were already updated at some point today - nothing was done now.")
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/mixnode/<pubkey>/report")]
|
||||
pub(crate) async fn mixnode_report(
|
||||
storage: &State<NodeStatusStorage>,
|
||||
@@ -74,25 +57,3 @@ pub(crate) async fn gateway_uptime_history(
|
||||
.map(Json)
|
||||
.map_err(|err| ErrorResponse::new(err, Status::NotFound))
|
||||
}
|
||||
|
||||
#[get("/mixnodes/all/report")]
|
||||
pub(crate) async fn mixnodes_full_report(
|
||||
storage: &State<NodeStatusStorage>,
|
||||
) -> Result<Json<Vec<MixnodeStatusReport>>, ErrorResponse> {
|
||||
storage
|
||||
.get_all_mixnode_reports()
|
||||
.await
|
||||
.map(Json)
|
||||
.map_err(|err| ErrorResponse::new(err, Status::InternalServerError))
|
||||
}
|
||||
|
||||
#[get("/gateways/all/report")]
|
||||
pub(crate) async fn gateways_full_report(
|
||||
storage: &State<NodeStatusStorage>,
|
||||
) -> Result<Json<Vec<GatewayStatusReport>>, ErrorResponse> {
|
||||
storage
|
||||
.get_all_gateway_reports()
|
||||
.await
|
||||
.map(Json)
|
||||
.map_err(|err| ErrorResponse::new(err, Status::InternalServerError))
|
||||
}
|
||||
|
||||
@@ -5,15 +5,13 @@ use crate::node_status_api::models::Uptime;
|
||||
use crate::node_status_api::{FIFTEEN_MINUTES, ONE_HOUR};
|
||||
use crate::storage::models::NodeStatus;
|
||||
use log::warn;
|
||||
use sqlx::types::time::OffsetDateTime;
|
||||
use std::cmp::min;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
// A temporary helper struct used to produce reports for active nodes.
|
||||
pub(crate) struct ActiveNodeDayStatuses {
|
||||
pub(crate) identity: String,
|
||||
pub(crate) owner: String,
|
||||
pub(crate) node_id: i64,
|
||||
|
||||
pub(crate) ipv4_statuses: Vec<NodeStatus>,
|
||||
pub(crate) ipv6_statuses: Vec<NodeStatus>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user