Skip to content

Commit

Permalink
increase evm gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin committed Nov 19, 2024
1 parent f0d5c91 commit 142f048
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runtime/hydradx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx-runtime"
version = "271.0.0"
version = "272.0.0"
authors = ["GalacticCouncil"]
edition = "2021"
license = "Apache 2.0"
Expand Down
19 changes: 13 additions & 6 deletions runtime/hydradx/src/evm/erc20_currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use sp_runtime::{DispatchError, SaturatedConversion};
use sp_std::boxed::Box;
use sp_std::vec::Vec;

/// Execution gas limit.
const GAS_LIMIT: u64 = 400_000;

#[module_evm_utility_macro::generate_function_selector]
#[derive(RuntimeDebug, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
#[repr(u32)]
Expand Down Expand Up @@ -118,7 +121,7 @@ where
// amount
data.extend_from_slice(H256::from_uint(&U256::from(value.saturated_into::<u128>())).as_bytes());

handle_result(Executor::<T>::call(context, data, U256::zero(), 200_000))
handle_result(Executor::<T>::call(context, data, U256::zero(), GAS_LIMIT))
}

// Calls the transfer method on an ERC20 contract using the given context.
Expand All @@ -129,7 +132,7 @@ where
// amount
data.extend_from_slice(H256::from_uint(&U256::from(value.saturated_into::<u128>())).as_bytes());

handle_result(Executor::<T>::call(context, data, U256::zero(), 200_000))
handle_result(Executor::<T>::call(context, data, U256::zero(), GAS_LIMIT))
}

fn transfer_from(context: CallContext, from: EvmAddress, to: EvmAddress, value: Balance) -> DispatchResult {
Expand All @@ -141,7 +144,7 @@ where
// amount
data.extend_from_slice(H256::from_uint(&U256::from(value.saturated_into::<u128>())).as_bytes());

handle_result(Executor::<T>::call(context, data, U256::zero(), 200_000))
handle_result(Executor::<T>::call(context, data, U256::zero(), GAS_LIMIT))
}
}

Expand Down Expand Up @@ -188,14 +191,18 @@ fn handle_result(result: CallResult) -> DispatchResult {
match exit_reason {
ExitReason::Succeed(_) => {
if Some(false) == decode_bool(value) {
log::error!(target: "evm", "evm transfer returned false");
Err(DispatchError::Other("evm: erc20 transfer returned false"))
} else {
Ok(())
}
}
_ => Err(DispatchError::Other(&*Box::leak(
format!("evm:0x{}", hex::encode(value)).into_boxed_str(),
))),
e @ _ => {
log::error!(target: "evm", "evm call failed with : {:?}, value {:?}", e, value);
Err(DispatchError::Other(&*Box::leak(
format!("evm:0x{}", hex::encode(value)).into_boxed_str(),
)))
},
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/hydradx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("hydradx"),
impl_name: create_runtime_str!("hydradx"),
authoring_version: 1,
spec_version: 271,
spec_version: 272,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down

0 comments on commit 142f048

Please sign in to comment.