fix (light/provider) : Make read_only executions read-only (#9591)
* `ExecutionsRequest` from light-clients as read-only This changes so all `ExecutionRequests` from light-clients are executed as read-only which the `virtual``flag == true ensures. This boost up the current transaction to always succeed Note, this only affects `eth_estimateGas` and `eth_call` AFAIK. * grumbles(revert renaming) : TransactionProof * grumbles(trace) : remove incorrect trace * grumbles(state/prove_tx) : explicit `virt` Remove the boolean flag to determine that a `state::prove_transaction` whether it should be executed in a virtual context or not. Because of that also rename the function to `state::prove_transction_virtual` to make more clear
This commit is contained in:
@@ -191,7 +191,7 @@ impl LightFetch {
|
||||
}
|
||||
|
||||
/// Helper for getting proved execution.
|
||||
pub fn proved_execution(&self, req: CallRequest, num: Trailing<BlockNumber>) -> impl Future<Item = ExecutionResult, Error = Error> + Send {
|
||||
pub fn proved_read_only_execution(&self, req: CallRequest, num: Trailing<BlockNumber>) -> impl Future<Item = ExecutionResult, Error = Error> + Send {
|
||||
const DEFAULT_GAS_PRICE: u64 = 21_000;
|
||||
// starting gas when gas not provided.
|
||||
const START_GAS: u64 = 50_000;
|
||||
@@ -256,14 +256,14 @@ impl LightFetch {
|
||||
_ => return Either::A(future::err(errors::unknown_block())),
|
||||
};
|
||||
|
||||
Either::B(execute_tx(gas_known, ExecuteParams {
|
||||
from: from,
|
||||
tx: tx,
|
||||
hdr: hdr,
|
||||
env_info: env_info,
|
||||
Either::B(execute_read_only_tx(gas_known, ExecuteParams {
|
||||
from,
|
||||
tx,
|
||||
hdr,
|
||||
env_info,
|
||||
engine: client.engine().clone(),
|
||||
on_demand: on_demand,
|
||||
sync: sync,
|
||||
on_demand,
|
||||
sync,
|
||||
}))
|
||||
}))
|
||||
}
|
||||
@@ -608,10 +608,10 @@ struct ExecuteParams {
|
||||
|
||||
// has a peer execute the transaction with given params. If `gas_known` is false,
|
||||
// this will double the gas on each `OutOfGas` error.
|
||||
fn execute_tx(gas_known: bool, params: ExecuteParams) -> impl Future<Item = ExecutionResult, Error = Error> + Send {
|
||||
fn execute_read_only_tx(gas_known: bool, params: ExecuteParams) -> impl Future<Item = ExecutionResult, Error = Error> + Send {
|
||||
if !gas_known {
|
||||
Box::new(future::loop_fn(params, |mut params| {
|
||||
execute_tx(true, params.clone()).and_then(move |res| {
|
||||
execute_read_only_tx(true, params.clone()).and_then(move |res| {
|
||||
match res {
|
||||
Ok(executed) => {
|
||||
// TODO: how to distinguish between actual OOG and
|
||||
|
||||
Reference in New Issue
Block a user