increase cost of eth_subscribe(newPendingTransactions)
This commit is contained in:
parent
f4a648223b
commit
3174fa5bad
@ -12,15 +12,17 @@ use tracing::{instrument, trace, warn};
|
|||||||
|
|
||||||
pub fn default_usd_per_cu(chain_id: u64) -> Decimal {
|
pub fn default_usd_per_cu(chain_id: u64) -> Decimal {
|
||||||
match chain_id {
|
match chain_id {
|
||||||
// TODO: only include if `cfg(test)`?
|
|
||||||
999_001_999 => Decimal::from_str("0.10").unwrap(),
|
999_001_999 => Decimal::from_str("0.10").unwrap(),
|
||||||
1 | 31337 => Decimal::from_str("0.000000400000000000000").unwrap(),
|
1 | 31337 => Decimal::from_str("0.000000400000000000000").unwrap(),
|
||||||
_ => Decimal::from_str("0.000000533333333333333").unwrap(),
|
_ => Decimal::from_str("0.000000533333333333333").unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_cu_per_byte(_chain_id: u64) -> Decimal {
|
pub fn default_cu_per_byte(_chain_id: u64, method: &str) -> Decimal {
|
||||||
Decimal::new(4, 2)
|
match method {
|
||||||
|
"eth_subscribe(newPendingTransactions)" => Decimal::new(16, 2),
|
||||||
|
_ => Decimal::new(4, 2),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -183,7 +185,7 @@ impl ComputeUnit {
|
|||||||
method: &str,
|
method: &str,
|
||||||
num_bytes: D,
|
num_bytes: D,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let cu = num_bytes.into() * default_cu_per_byte(chain_id);
|
let cu = num_bytes.into() * default_cu_per_byte(chain_id, method);
|
||||||
|
|
||||||
Self(cu)
|
Self(cu)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use std::time::Duration;
|
|||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
use web3_proxy::prelude::futures::future::try_join_all;
|
use web3_proxy::prelude::futures::future::try_join_all;
|
||||||
use web3_proxy::prelude::reqwest;
|
use web3_proxy::prelude::reqwest;
|
||||||
use web3_proxy::prelude::rust_decimal::Decimal;
|
use web3_proxy::prelude::rust_decimal::{Decimal, RoundingStrategy};
|
||||||
use web3_proxy::prelude::tokio::time::sleep;
|
use web3_proxy::prelude::tokio::time::sleep;
|
||||||
use web3_proxy::rpcs::blockchain::ArcBlock;
|
use web3_proxy::rpcs::blockchain::ArcBlock;
|
||||||
use web3_proxy::test_utils::TestInflux;
|
use web3_proxy::test_utils::TestInflux;
|
||||||
@ -204,6 +204,7 @@ async fn test_multiple_proxies_stats_add_up() {
|
|||||||
.replace('"', "")
|
.replace('"', "")
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.round_dp_with_strategy(10, RoundingStrategy::ToNegativeInfinity)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Decimal::from_str(
|
Decimal::from_str(
|
||||||
@ -218,6 +219,7 @@ async fn test_multiple_proxies_stats_add_up() {
|
|||||||
.replace('"', "")
|
.replace('"', "")
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.round_dp_with_strategy(10, RoundingStrategy::ToNegativeInfinity)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Decimal::from_str(&mysql_stats["sum_request_bytes"].to_string()).unwrap(),
|
Decimal::from_str(&mysql_stats["sum_request_bytes"].to_string()).unwrap(),
|
||||||
|
@ -4,7 +4,7 @@ use std::time::Duration;
|
|||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
use web3_proxy::prelude::futures::future::try_join_all;
|
use web3_proxy::prelude::futures::future::try_join_all;
|
||||||
use web3_proxy::prelude::reqwest;
|
use web3_proxy::prelude::reqwest;
|
||||||
use web3_proxy::prelude::rust_decimal::Decimal;
|
use web3_proxy::prelude::rust_decimal::{Decimal, RoundingStrategy};
|
||||||
use web3_proxy::prelude::tokio::time::sleep;
|
use web3_proxy::prelude::tokio::time::sleep;
|
||||||
use web3_proxy::rpcs::blockchain::ArcBlock;
|
use web3_proxy::rpcs::blockchain::ArcBlock;
|
||||||
use web3_proxy_cli::test_utils::create_provider_with_rpc_key::create_provider_for_user;
|
use web3_proxy_cli::test_utils::create_provider_with_rpc_key::create_provider_for_user;
|
||||||
@ -175,6 +175,7 @@ async fn test_single_proxy_stats_add_up() {
|
|||||||
.replace('"', "")
|
.replace('"', "")
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.round_dp_with_strategy(10, RoundingStrategy::ToNegativeInfinity)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Decimal::from_str(
|
Decimal::from_str(
|
||||||
@ -189,6 +190,7 @@ async fn test_single_proxy_stats_add_up() {
|
|||||||
.replace('"', "")
|
.replace('"', "")
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.round_dp_with_strategy(10, RoundingStrategy::ToNegativeInfinity)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Decimal::from_str(&mysql_stats["sum_request_bytes"].to_string()).unwrap(),
|
Decimal::from_str(&mysql_stats["sum_request_bytes"].to_string()).unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user