getTransaction from the private rpcs

This commit is contained in:
Bryan Stitt 2022-06-30 00:52:04 +00:00
parent fe53ffdb40
commit f36ca5e702
3 changed files with 22 additions and 6 deletions

View File

@ -30,6 +30,7 @@
- even after removing a bunch of the locks, the deadlock still happens. i can't reliably reproduce. i just let it run for awhile and it happens.
- running gdb shows the thread at tokio tungstenite thread is spinning near 100% cpu and none of the rest of the program is proceeding
- fixed by https://github.com/gakonst/ethers-rs/pull/1287
- [ ] when sending with private relays, brownie's tx.wait can think the transaction was dropped. smarter retry on eth_getTransactionByHash and eth_getTransactionReceipt (maybe only if we sent the transaction ourselves)
- [ ] rpc errors propagate too far. one subscription failing ends the app. isolate the providers more
- [ ] if web3 proxy gets an http error back, retry another node
- [ ] endpoint for health checks. if no synced servers, give a 502 error
@ -41,6 +42,7 @@
## V1
- [ ] some things that are cached locally should probably be in shared redis caches
- [ ] stats when forks are resolved (and what chain they were on?)
- [ ] incoming rate limiting (by api key)
- [ ] failsafe. if no blocks or transactions in the last second, warn and reset the connection

View File

@ -570,7 +570,10 @@ impl Web3ProxyApp {
| "personal_unlockAccount"
| "personal_sendTransaction"
| "personal_sign"
| "personal_ecRecover" => Err(anyhow::anyhow!("unimplemented")),
| "personal_ecRecover" => {
// TODO: proper error code
Err(anyhow::anyhow!("unimplemented"))
}
"eth_sendRawTransaction" => {
// there are private rpcs configured and the request is eth_sendSignedTransaction. send to all private rpcs
// TODO: think more about this lock. i think it won't actually help the herd. it probably makes it worse if we have a tight lag_limit
@ -579,7 +582,7 @@ impl Web3ProxyApp {
.instrument(span)
.await
}
_ => {
method => {
// this is not a private transaction (or no private relays are configured)
let (cache_key, response_cache) = match self.get_cached_response(&request) {
@ -631,10 +634,20 @@ impl Web3ProxyApp {
}
}
let response = self
.balanced_rpcs
.try_send_best_upstream_server(request)
.await?;
let response = match method {
"eth_getTransactionByHash" | "eth_getTransactionReceipt" => {
// TODO: try_send_all serially with retries instead of parallel
self.private_rpcs
.try_send_all_upstream_servers(request)
.await?
}
_ => {
// TODO: retries?
self.balanced_rpcs
.try_send_best_upstream_server(request)
.await?
}
};
// TODO: small race condidition here. parallel requests with the same query will both be saved to the cache
let mut response_cache = response_cache.write();

View File

@ -715,6 +715,7 @@ impl Web3Connections {
warn!(?self, "No servers in sync!");
// TODO: sleep how long? until synced_connections changes or rate limits are available
// TODO: subscribe to head_block_sender
sleep(Duration::from_millis(200)).await;
continue;