Skip to content

Commit

Permalink
Fix estimate (#2142)
Browse files Browse the repository at this point in the history
* ingore rpc estimate flag

* keep estimate flag true for backward compatible
  • Loading branch information
ermalkaleci authored and xlc committed May 21, 2022
1 parent be49bc9 commit 0707093
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 149 deletions.
4 changes: 2 additions & 2 deletions modules/evm/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ where
gas_limit,
storage_limit,
access_list,
false,
true,
)
.map_err(|err| internal_err(format!("runtime error: {:?}", err)))?
.map_err(|err| internal_err(format!("execution fatal: {:?}", err)))?;
Expand All @@ -226,7 +226,7 @@ where
gas_limit,
storage_limit,
access_list,
false,
true,
)
.map_err(|err| internal_err(format!("runtime error: {:?}", err)))?
.map_err(|err| internal_err(format!("execution fatal: {:?}", err)))?;
Expand Down
72 changes: 23 additions & 49 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use frame_system::{EnsureRoot, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping, FixedRateOfForeignAsset};
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{CallInfo, CreateInfo, EvmChainId, EvmTask, Runner};
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
use module_relaychain::RelayChainCallBuilder;
use module_support::{AssetIdMapping, DispatchableTask};
Expand Down Expand Up @@ -1925,33 +1925,19 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CallInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn create(
Expand All @@ -1961,29 +1947,17 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CreateInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn get_estimate_resources_request(extrinsic: Vec<u8>) -> Result<EstimateResourcesRequest, sp_runtime::DispatchError> {
Expand Down
72 changes: 23 additions & 49 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use frame_system::{EnsureRoot, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping, FixedRateOfForeignAsset};
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{CallInfo, CreateInfo, EvmChainId, EvmTask, Runner};
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
use module_relaychain::RelayChainCallBuilder;
use module_support::{AssetIdMapping, DispatchableTask, ExchangeRateProvider};
Expand Down Expand Up @@ -1970,33 +1970,19 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CallInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn create(
Expand All @@ -2006,29 +1992,17 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CreateInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn get_estimate_resources_request(extrinsic: Vec<u8>) -> Result<EstimateResourcesRequest, sp_runtime::DispatchError> {
Expand Down
72 changes: 23 additions & 49 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use hex_literal::hex;
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping, FixedRateOfForeignAsset};
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::{BasicCurrencyAdapter, Currency};
use module_evm::{CallInfo, CreateInfo, EvmChainId, EvmTask, Runner};
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
use module_relaychain::RelayChainCallBuilder;
use module_support::{AssetIdMapping, DispatchableTask, ExchangeRateProvider};
Expand Down Expand Up @@ -2178,33 +2178,19 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CallInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_call(
from,
from,
to,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn create(
Expand All @@ -2214,29 +2200,17 @@ impl_runtime_apis! {
gas_limit: u64,
storage_limit: u32,
access_list: Option<Vec<AccessListItem>>,
estimate: bool,
_estimate: bool,
) -> Result<CreateInfo, sp_runtime::DispatchError> {
if estimate {
module_evm::runner::stack::Runner::<Runtime>::create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
} else {
<module_evm::runner::stack::Runner::<Runtime> as module_evm::runner::RunnerExtended<Runtime>>::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}
<Runtime as module_evm::Config>::Runner::rpc_create(
from,
data,
value,
gas_limit,
storage_limit,
access_list.unwrap_or_default().into_iter().map(|v| (v.address, v.storage_keys)).collect(),
<Runtime as module_evm::Config>::config(),
)
}

fn get_estimate_resources_request(extrinsic: Vec<u8>) -> Result<EstimateResourcesRequest, sp_runtime::DispatchError> {
Expand Down

0 comments on commit 0707093

Please sign in to comment.