p2w-client: move rpc_interval to config, test fast rate accuracy (#334)
This commit is contained in:
parent
e97b3bd7cf
commit
ef37c86b32
|
@ -30,6 +30,9 @@ pub struct AttestationConfig {
|
|||
default // Uses Option::default() which is None
|
||||
)]
|
||||
pub mapping_addr: Option<Pubkey>,
|
||||
#[serde(default = "default_min_rpc_interval_ms")]
|
||||
/// Rate-limiting minimum delay between RPC requests in milliseconds"
|
||||
pub min_rpc_interval_ms: u64,
|
||||
pub symbol_groups: Vec<SymbolGroup>,
|
||||
}
|
||||
|
||||
|
@ -103,6 +106,10 @@ pub const fn default_min_msg_reuse_interval_ms() -> u64 {
|
|||
10_000 // 10s
|
||||
}
|
||||
|
||||
pub const fn default_min_rpc_interval_ms() -> u64 {
|
||||
150
|
||||
}
|
||||
|
||||
pub const fn default_min_interval_secs() -> u64 {
|
||||
60
|
||||
}
|
||||
|
@ -258,6 +265,7 @@ mod tests {
|
|||
let cfg = AttestationConfig {
|
||||
min_msg_reuse_interval_ms: 1000,
|
||||
max_msg_accounts: 100_000,
|
||||
min_rpc_interval_ms: 2123,
|
||||
mapping_addr: None,
|
||||
symbol_groups: vec![fastbois, slowbois],
|
||||
};
|
||||
|
@ -276,6 +284,7 @@ mod tests {
|
|||
let empty_config = AttestationConfig {
|
||||
min_msg_reuse_interval_ms: 1000,
|
||||
max_msg_accounts: 100,
|
||||
min_rpc_interval_ms: 42422,
|
||||
mapping_addr: None,
|
||||
symbol_groups: vec![],
|
||||
};
|
||||
|
|
|
@ -30,12 +30,6 @@ pub struct Cli {
|
|||
pub payer: String,
|
||||
#[clap(short, long, default_value = "http://localhost:8899")]
|
||||
pub rpc_url: String,
|
||||
#[clap(
|
||||
long = "rpc-interval",
|
||||
default_value = "150",
|
||||
help = "Rate-limiting minimum delay between RPC requests in milliseconds"
|
||||
)]
|
||||
pub rpc_interval_ms: u64,
|
||||
#[clap(long, default_value = "confirmed")]
|
||||
pub commitment: CommitmentConfig,
|
||||
#[clap(long)]
|
||||
|
|
|
@ -198,7 +198,6 @@ async fn main() -> Result<(), ErrBox> {
|
|||
|
||||
handle_attest(
|
||||
cli.rpc_url,
|
||||
Duration::from_millis(cli.rpc_interval_ms),
|
||||
cli.commitment,
|
||||
payer,
|
||||
p2w_addr,
|
||||
|
@ -235,7 +234,6 @@ async fn main() -> Result<(), ErrBox> {
|
|||
/// Send a series of batch attestations for symbols of an attestation config.
|
||||
async fn handle_attest(
|
||||
rpc_url: String,
|
||||
rpc_interval: Duration,
|
||||
commitment: CommitmentConfig,
|
||||
payer: Keypair,
|
||||
p2w_addr: Pubkey,
|
||||
|
@ -300,7 +298,7 @@ async fn handle_attest(
|
|||
timeout: confirmation_timeout,
|
||||
commitment: commitment.clone(),
|
||||
},
|
||||
rpc_interval,
|
||||
Duration::from_millis(attestation_cfg.min_rpc_interval_ms),
|
||||
));
|
||||
|
||||
let message_q_mtx = Arc::new(Mutex::new(P2WMessageQueue::new(
|
||||
|
|
|
@ -188,10 +188,12 @@ if P2W_ATTESTATION_CFG is None:
|
|||
cfg_yaml = f"""
|
||||
---
|
||||
mapping_addr: {mapping_addr}
|
||||
min_rpc_interval_ms: 0 # RIP RPC
|
||||
max_batch_jobs: 1000 # Where we're going there's no oomkiller
|
||||
symbol_groups:
|
||||
- group_name: fast_interval_only
|
||||
conditions:
|
||||
min_interval_secs: 3
|
||||
min_interval_secs: 1
|
||||
symbols:
|
||||
"""
|
||||
|
||||
|
@ -210,6 +212,8 @@ symbol_groups:
|
|||
price_addr: {price}
|
||||
product_addr: {product}"""
|
||||
|
||||
# End of fast_interval_only
|
||||
|
||||
cfg_yaml += f"""
|
||||
- group_name: longer_interval_sensitive_changes
|
||||
conditions:
|
||||
|
|
Loading…
Reference in New Issue