Skip to content

Commit

Permalink
Merge pull request #2 from abacus-network/trevor/better-quorum-provid…
Browse files Browse the repository at this point in the history
…er-errors

More detailed quorum provider errors, fix gas estimation on Optimism
  • Loading branch information
tkporter authored Sep 1, 2022
2 parents 211e42e + aafd758 commit 01478d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,14 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
block: Option<BlockId>,
) -> Result<U256, ProviderError> {
let tx = utils::serialize(tx);
let block = utils::serialize(&block.unwrap_or_else(|| BlockNumber::Latest.into()));
self.request("eth_estimateGas", [tx, block]).await
// Some chains (e.g. Optimism) don't support a block ID being passed as a param,
// so refrain from defaulting to BlockNumber::Latest.
let params = if let Some(block_id) = block {
vec![tx, utils::serialize(&block_id)]
} else {
vec![tx]
};
self.request("eth_estimateGas", params).await
}

async fn create_access_list(
Expand Down
3 changes: 2 additions & 1 deletion ethers-providers/src/transports/quorum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ impl<T: JsonRpcClientWrapper> QuorumProvider<T> {
"eth_getStorageAt" |
"eth_getCode" |
"eth_getProof" |
"eth_estimateGas" |
"trace_call" |
"trace_block" => {
// calls that include the block number in the params at the last index of json array
Expand Down Expand Up @@ -401,7 +402,7 @@ impl<T> WeightedProvider<T> {
#[derive(Error, Debug)]
/// Error thrown when sending an HTTP request
pub enum QuorumError {
#[error("No Quorum reached.")]
#[error("No Quorum reached. (Values: {:?}, Errors: {:?})", values, errors)]
NoQuorumReached { values: Vec<Value>, errors: Vec<ProviderError> },
}

Expand Down

0 comments on commit 01478d1

Please sign in to comment.