-
Notifications
You must be signed in to change notification settings - Fork 18
feat: RPC redundancy #157
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
feat: RPC redundancy #157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend we create a utils crate and have a solana_multiurl_rpc
module or something in, and wrap the RpcClient there. Also, you need to update wss_url
as well and handle it in subscription.
I'll look again once you've addressed those.
# rate-limited, so a private endpoint should be used in most cases. | ||
rpc_url = "https://api2.pythnet.pyth.network" | ||
# API calls will cycle through each on failure. | ||
rpc_urls = ["https://api2.pythnet.pyth.network"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks backward compatibility, let's bump the version as a major one. (we can ship it with lazer in one go)
src/agent/solana.rs
Outdated
#[serde(default = "default_rpc_url")] | ||
pub rpc_url: String, | ||
pub rpc_urls: Vec<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we take our chance here to convert it to Vec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the websocket list below, or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry my bad, i wanted to say to convert it to Vec of Url :D (because we pass string everywhere and it's not great)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. It looks like the solana rpc client can directly take in Urls as of version 2, so I'll make that change in the wrapper struct when I'm able to bump the solana crates.
src/agent/services/exporter.rs
Outdated
let current_slot_future = | ||
self.rpc_clients[0].get_slot_with_commitment(CommitmentConfig::confirmed()); | ||
let latest_blockhash_future = self.rpc_clients[0].get_latest_blockhash(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's important for this to work properly as the data from these two are used in the transactions. Please loop through urls
@@ -83,6 +84,12 @@ where | |||
tracing::warn!(?sleep_time, "Subscriber restarting too quickly. Sleeping"); | |||
tokio::time::sleep(sleep_time).await; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also add a log to say which one failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
…pc-redundancy # Conflicts: # Cargo.lock
Change rpc_url to rpc_urls and for all calls, cycle through them until first success.