Skip to content

Sentry REST API & functions documentation #473

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

Merged
merged 8 commits into from
Feb 25, 2022
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
2 changes: 1 addition & 1 deletion adapter/src/ethereum/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ mod test {
// make sure 1 TOKEN is the minimum set in Config
let config_token = eth_adapter
.config
.find_chain_token(channel.token)
.find_chain_of(channel.token)
.expect("Channel token should be present in Config")
.token;

Expand Down
4 changes: 4 additions & 0 deletions adapter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![deny(rust_2018_idioms)]
#![deny(clippy::all)]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub use {
self::adapter::{
state::{LockedState, UnlockedState},
Expand Down
4 changes: 4 additions & 0 deletions adview-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ async-std = "^1.8"
once_cell = "^1.8"
thiserror = "^1.0"
rand = "^0.8"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
1 change: 1 addition & 0 deletions adview-manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![deny(rust_2018_idioms)]
#![deny(clippy::all)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use adex_primitives::{
campaign::Validators,
Expand Down
5 changes: 3 additions & 2 deletions docs/config/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ spendable_find_limit = 200
wait_time = 500

msgs_find_limit = 10
analytics_find_limit_v5 = 5000
analytics_maxtime_v5 = 20000
analytics_find_limit = 5000
# in milliseconds
analytics_maxtime = 20000

heartbeat_time = 30000
health_threshold_promilles = 950
Expand Down
37 changes: 16 additions & 21 deletions docs/config/ganache.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
# based on: prod.toml
# Maximum number of channels to return per request
max_channels = 512

channels_find_limit = 512
campaigns_find_limit = 512
spendable_find_limit = 512

wait_time = 40000

# V4 Deprecated
aggr_throttle = 0

events_find_limit = 100
channels_find_limit = 200
campaigns_find_limit = 200
spendable_find_limit = 200
wait_time = 500

msgs_find_limit = 10
analytics_find_limit_v5 = 5000
analytics_maxtime_v5 = 15000
analytics_find_limit = 5000
# in milliseconds
analytics_maxtime = 20000

heartbeat_time = 60000
health_threshold_promilles = 970
health_unsignable_promilles = 770
propagation_timeout = 3000
heartbeat_time = 30000
health_threshold_promilles = 950
health_unsignable_promilles = 750
propagation_timeout = 1000

fetch_timeout = 10000
all_campaigns_timeout = 10000
channel_tick_timeout = 10000
fetch_timeout = 5000
all_campaigns_timeout = 5000
channel_tick_timeout = 5000

ip_rate_limit = { type = 'ip', timeframe = 1200000 }
sid_rate_limit = { type = 'sid', timeframe = 0 }

creators_whitelist = []
validators_whitelist = []
admins = ['0x80690751969B234697e9059e04ed72195c3507fa']
# Leader - 0xce07CbB7e054514D590a0262C93070D838bFBA2e
admins = ['0xce07CbB7e054514D590a0262C93070D838bFBA2e']

# Ethereum mainnet tokens
# [chain."Ganache #1"]
Expand Down
13 changes: 3 additions & 10 deletions docs/config/prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ max_channels = 512
channels_find_limit = 512
campaigns_find_limit = 512
spendable_find_limit = 512

wait_time = 40000

msgs_find_limit = 10
analytics_find_limit_v5 = 5000
analytics_maxtime_v5 = 15000
analytics_find_limit = 5000
# in milliseconds
analytics_maxtime = 15000

heartbeat_time = 60000
health_threshold_promilles = 970
Expand All @@ -23,13 +23,6 @@ channel_tick_timeout = 10000
ip_rate_limit = { type = 'ip', timeframe = 1200000 }
sid_rate_limit = { type = 'sid', timeframe = 0 }

# TODO: Replace with real contract address
outpace_address = '0x333420fc6a897356e69b62417cd17ff012177d2b'
# TODO: Replace with real contract address
sweeper_address = '0x333420fc6a897356e69b62417cd17ff012177d2b'

ethereum_network = 'http://localhost:8545'

creators_whitelist = []
validators_whitelist = []
admins = ['0x5d6A3F1AD7b124ecDFDf4841D9bB246eD5fBF04c']
Expand Down
4 changes: 4 additions & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ once_cell = "^1.8"
pretty_assertions = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
serde_urlencoded = "^0.7"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
2 changes: 0 additions & 2 deletions primitives/src/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use serde::{Deserialize, Serialize};

use self::query::{AllowedKey, Time};

pub const ANALYTICS_QUERY_LIMIT: u32 = 200;

#[cfg(feature = "postgres")]
pub mod postgres {
use super::{query::AllowedKey, AnalyticsQuery, OperatingSystem};
Expand Down
1 change: 1 addition & 0 deletions primitives/src/campaign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ mod campaign_id {

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
/// an Id of 16 bytes, (de)serialized as a `0x` prefixed hex
///
/// In this implementation of the `CampaignId` the value is generated from a `Uuid::new_v4().to_simple()`
pub struct CampaignId([u8; 16]);

Expand Down
6 changes: 3 additions & 3 deletions primitives/src/campaign_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Validator for Campaign {

// Check if Channel token is listed in the configuration token Chain ID & Address
let chain_context = config
.find_chain_token(self.channel.token)
.find_chain_of(self.channel.token)
.ok_or(Validation::UnlistedAsset)?;

// Check if the campaign budget is above the minimum deposit configured
Expand Down Expand Up @@ -345,7 +345,7 @@ mod test {
{
let mut campaign = DUMMY_CAMPAIGN.clone();
let campaign_token = config
.find_chain_token(campaign.channel.token)
.find_chain_of(campaign.channel.token)
.unwrap()
.token;

Expand Down Expand Up @@ -391,7 +391,7 @@ mod test {
let mut campaign = DUMMY_CAMPAIGN.clone();

let campaign_token = config
.find_chain_token(campaign.channel.token)
.find_chain_of(campaign.channel.token)
.unwrap()
.token;

Expand Down
11 changes: 6 additions & 5 deletions primitives/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{config::TokenInfo, util::ApiUrl, Address, Campaign, Channel};
///
/// # Ethereum Virtual Machine
///
/// For all the EVM-compatible Chain IDs visit https://chainid.network
/// For all the EVM-compatible Chain IDs visit <https://chainid.network>
#[derive(Serialize, Deserialize, Hash, Clone, Copy, Eq, PartialEq)]
#[serde(transparent)]
pub struct ChainId(u32);
Expand Down Expand Up @@ -42,8 +42,8 @@ pub struct Chain {
/// RPC url of the chain which will be used for Blockchain interactions.
///
/// # Ethereum Virtual Machine
/// Check out the metadata for all EVM-chains: https://github.com/ethereum-lists/chains
/// Or in json: https://chainid.network/chains.json
/// Check out the metadata for all EVM-chains: <https://github.com/ethereum-lists/chains>
/// Or in json: <https://chainid.network/chains.json>
pub rpc: ApiUrl,
/// The OUTPACE contract address on this Chain
pub outpace: Address,
Expand All @@ -52,8 +52,9 @@ pub struct Chain {
}

/// Context of [`TokenInfo`] & [`Chain`] information for given [`Channel`] or [`Campaign`].
/// The additional context of [`Channel`] is known after checking if the Channel token's
/// Chain & Address are whitelisted in the configuration.
///
/// The additional context of [`Channel`] is known after checking if the `Channel` token's
/// `Chain` & `Address` are whitelisted in the configuration.
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Hash, Clone)]
pub struct ChainOf<T = ()> {
pub context: T,
Expand Down
15 changes: 9 additions & 6 deletions primitives/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ pub struct Config {
pub spendable_find_limit: u32,
pub wait_time: u32,
pub msgs_find_limit: u32,
pub analytics_find_limit_v5: u32,
/// The maximum analytic results you can receive per request.
pub analytics_find_limit: u32,
/// A timeout to be used when collecting the Analytics for a request.
/// In milliseconds
pub analytics_maxtime_v5: u32,
pub analytics_maxtime: u32,
/// The amount of time between heartbeats.
/// In milliseconds
pub heartbeat_time: u32,
pub health_threshold_promilles: u32,
Expand All @@ -73,12 +76,12 @@ pub struct Config {
/// The key of this map is a human-readable text of the Chain name
/// for readability in the configuration file.
///
/// - To get the chain of a token address use [`Config::find_token_chain`].
/// - To get the chain of a token address use [`Config::find_chain_of()`].
///
/// - To get a chain RPC use [`Config::find_chain_rpc`].
/// - To get a [`ChainInfo`] only by a [`ChainId`] use [`Config::find_chain()`].
///
/// **NOTE:** Make sure that a Token [`Address`] is unique across all Chains,
/// otherwise `Config::find_chain_token` will fetch only one of them and cause unexpected problems.
/// otherwise [`Config::find_chain_of()`] will fetch only one of them and cause unexpected problems.
#[serde(rename = "chain")]
pub chains: HashMap<String, ChainInfo>,
}
Expand All @@ -99,7 +102,7 @@ impl Config {
}

/// Finds the pair of Chain & Token, given only a token [`Address`].
pub fn find_chain_token(&self, token: Address) -> Option<ChainOf<()>> {
pub fn find_chain_of(&self, token: Address) -> Option<ChainOf<()>> {
self.chains.values().find_map(|chain_info| {
chain_info
.tokens
Expand Down
8 changes: 6 additions & 2 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![deny(rust_2018_idioms)]
#![deny(clippy::all)]
#![allow(deprecated)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use std::{error, fmt};

pub use self::{
Expand Down Expand Up @@ -43,14 +44,17 @@ pub mod spender;
pub mod supermarket;
pub mod targeting;
#[cfg(feature = "test-util")]
#[cfg_attr(docsrs, doc(cfg(feature = "test-util")))]
pub mod test_util;
mod unified_num;
pub mod validator;

/// This module is available with the `postgres` feature
/// This module is available with the `postgres` feature.
///
/// Other places where you'd find `mod postgres` implementations is for many of the structs in the crate
/// all of which implement [`tokio_postgres::types::FromSql`], [`tokio_postgres::types::ToSql`] or [`From<&tokio_postgres::Row>`]
#[cfg(feature = "postgres")]
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
pub mod postgres {
use std::env::{self, VarError};

Expand Down
Loading