-
Notifications
You must be signed in to change notification settings - Fork 509
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
Estimate_gas return issues #363
Estimate_gas return issues #363
Conversation
@sorpaas This pr is ready for review. Should I update the crate version? |
Yeah. But I don't quiet understand the PR. With or without this condition it always returns. The difference is the error value the parent gets. Can you explain more about the PR? |
Sure, let me explain more details about this. Firstly, we have a pre-compile contract in which the transfer operation is performed. So, when somebody estimates the gas used of calling this precompile contract, if the balance is not sufficient, an |
User @AsceticBear, please sign the CLA here. |
There is an estimate_gas bug when the match calculate_gas_used(test_request) {
// if Ok -- try to reduce the gas used
Ok(used_gas) => {
old_best = best;
best = used_gas;
change_pct = (U256::from(100) * (old_best - best)) / old_best;
upper = mid;
mid = (lower + upper + 1) / 2;
log::debug!("bear: --- [Ok]: upper {:?}, mid {:?}", upper, mid);
}
Err(err) => {
log::debug!("bear: --- the calculate gas used err! {:?}", err);
// if Err == OutofGas or OutofFund, we need more gas
if err.code == ErrorCode::ServerError(0) {
lower = mid;
mid = (lower + upper + 1) / 2;
log::debug!("bear: --- [err]: lower {:?}, mid {:?}", lower, mid);
if mid == lower {
break;
}
}
// Other errors, return directly
return Err(err);
}
} debug info: 2021-05-08 15:16:01.710 DEBUG http.worker10 dc_rpc::eth: bear: --- the calculate gas used err! Error { code: ServerError(0), message: "out of gas or fund", data: None }
2021-05-08 15:16:01.710 DEBUG http.worker10 dc_rpc::eth: bear: --- [err]: lower 500010500, mid 750005250
2021-05-08 15:16:01.710 DEBUG http.worker10 dc_rpc::eth: bear: --- change_pct 37, threshold_pct 10
2021-05-08 15:16:01.803 DEBUG http.worker10 dc_rpc::eth: bear: --- [Ok]: upper 750005250, mid 625007875
2021-05-08 15:16:01.803 DEBUG http.worker10 dc_rpc::eth: bear: --- change_pct 0, threshold_pct 10 As we can see above, The estimate process return error when |
Please modify the comment in L824. It's outdated! |
* Return error when OutOfFund * Fix estimate_gas early return * Update comments * Update changelog * Update message info
If
OutOfFund
happened, should return right now instead of continuing with the estimating process.