Skip to content

Commit ef37c86

Browse files
author
Stanisław Drozd
authored
p2w-client: move rpc_interval to config, test fast rate accuracy (#334)
1 parent e97b3bd commit ef37c86

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

solana/pyth2wormhole/client/src/attestation_cfg.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct AttestationConfig {
3030
default // Uses Option::default() which is None
3131
)]
3232
pub mapping_addr: Option<Pubkey>,
33+
#[serde(default = "default_min_rpc_interval_ms")]
34+
/// Rate-limiting minimum delay between RPC requests in milliseconds"
35+
pub min_rpc_interval_ms: u64,
3336
pub symbol_groups: Vec<SymbolGroup>,
3437
}
3538

@@ -103,6 +106,10 @@ pub const fn default_min_msg_reuse_interval_ms() -> u64 {
103106
10_000 // 10s
104107
}
105108

109+
pub const fn default_min_rpc_interval_ms() -> u64 {
110+
150
111+
}
112+
106113
pub const fn default_min_interval_secs() -> u64 {
107114
60
108115
}
@@ -258,6 +265,7 @@ mod tests {
258265
let cfg = AttestationConfig {
259266
min_msg_reuse_interval_ms: 1000,
260267
max_msg_accounts: 100_000,
268+
min_rpc_interval_ms: 2123,
261269
mapping_addr: None,
262270
symbol_groups: vec![fastbois, slowbois],
263271
};
@@ -276,6 +284,7 @@ mod tests {
276284
let empty_config = AttestationConfig {
277285
min_msg_reuse_interval_ms: 1000,
278286
max_msg_accounts: 100,
287+
min_rpc_interval_ms: 42422,
279288
mapping_addr: None,
280289
symbol_groups: vec![],
281290
};

solana/pyth2wormhole/client/src/cli.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ pub struct Cli {
3030
pub payer: String,
3131
#[clap(short, long, default_value = "http://localhost:8899")]
3232
pub rpc_url: String,
33-
#[clap(
34-
long = "rpc-interval",
35-
default_value = "150",
36-
help = "Rate-limiting minimum delay between RPC requests in milliseconds"
37-
)]
38-
pub rpc_interval_ms: u64,
3933
#[clap(long, default_value = "confirmed")]
4034
pub commitment: CommitmentConfig,
4135
#[clap(long)]

solana/pyth2wormhole/client/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ async fn main() -> Result<(), ErrBox> {
198198

199199
handle_attest(
200200
cli.rpc_url,
201-
Duration::from_millis(cli.rpc_interval_ms),
202201
cli.commitment,
203202
payer,
204203
p2w_addr,
@@ -235,7 +234,6 @@ async fn main() -> Result<(), ErrBox> {
235234
/// Send a series of batch attestations for symbols of an attestation config.
236235
async fn handle_attest(
237236
rpc_url: String,
238-
rpc_interval: Duration,
239237
commitment: CommitmentConfig,
240238
payer: Keypair,
241239
p2w_addr: Pubkey,
@@ -300,7 +298,7 @@ async fn handle_attest(
300298
timeout: confirmation_timeout,
301299
commitment: commitment.clone(),
302300
},
303-
rpc_interval,
301+
Duration::from_millis(attestation_cfg.min_rpc_interval_ms),
304302
));
305303

306304
let message_q_mtx = Arc::new(Mutex::new(P2WMessageQueue::new(

third_party/pyth/p2w_autoattest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,12 @@ def find_and_log_seqnos(s):
188188
cfg_yaml = f"""
189189
---
190190
mapping_addr: {mapping_addr}
191+
min_rpc_interval_ms: 0 # RIP RPC
192+
max_batch_jobs: 1000 # Where we're going there's no oomkiller
191193
symbol_groups:
192194
- group_name: fast_interval_only
193195
conditions:
194-
min_interval_secs: 3
196+
min_interval_secs: 1
195197
symbols:
196198
"""
197199

@@ -210,6 +212,8 @@ def find_and_log_seqnos(s):
210212
price_addr: {price}
211213
product_addr: {product}"""
212214

215+
# End of fast_interval_only
216+
213217
cfg_yaml += f"""
214218
- group_name: longer_interval_sensitive_changes
215219
conditions:

0 commit comments

Comments
 (0)