Skip to content

Commit

Permalink
Estimate_gas return issues (polkadot-evm#363)
Browse files Browse the repository at this point in the history
* Return error when OutOfFund

* Fix estimate_gas early return

* Update comments

* Update changelog

* Update message info
  • Loading branch information
boundless-forest authored May 18, 2021
1 parent 3c3f377 commit 6617295
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion client/rpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

## Unreleased

* `EthPubSubApi::new` takes an additional `overrides` parameter.
* `EthPubSubApi::new` takes an additional `overrides` parameter.
* Fix `estimate_gas` inaccurate issue.
8 changes: 4 additions & 4 deletions client/rpc/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,17 +891,17 @@ impl<B, C, P, CT, BE, H: ExHashT> EthApiT for EthApi<B, C, P, CT, BE, H> where
}

Err(err) => {
// if Err == OutofGas or OutofFund, we need more gas
// if Err == OutofGas, we need more gas
if err.code == ErrorCode::ServerError(0) {
lower = mid;
mid = (lower + upper + 1) / 2;
if mid == lower {
break;
}
} else {
// Other errors, return directly
return Err(err);
}

// Other errors, return directly
return Err(err);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<()
match reason {
ExitReason::Succeed(_) => Ok(()),
ExitReason::Error(e) => {
if *e == ExitError::OutOfGas || *e == ExitError::OutOfFund {
if *e == ExitError::OutOfGas {
// `ServerError(0)` will be useful in estimate gas
return Err(Error {
code: ErrorCode::ServerError(0),
message: format!("out of gas or fund"),
message: format!("out of gas"),
data: None,
});
}
Expand Down

0 comments on commit 6617295

Please sign in to comment.