Skip to content

Commit

Permalink
Fix evm validate (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwangningbo authored Dec 17, 2024
1 parent 51bf31c commit c7ef441
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions runtime/bifrost-polkadot/src/evm/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ where
let account_id = T::AddressMapping::into_account_id(source);
let account_nonce = frame_system::Pallet::<T>::account_nonce(&account_id);

let (balance, b_weight) = B::get_balance_in_currency(evm_currency, &account_id, base_fee)
.map_err(|_| RunnerError {
error: R::Error::from(TransactionValidationError::BalanceTooLow),
weight,
})?;
let (balance, b_weight) =
match B::get_balance_in_currency(evm_currency, &account_id, base_fee) {
Ok((balance, b_weight)) => (balance, b_weight),
Err(_) => (0, T::DbWeight::get().reads(2)),
};

let (source_account, inner_weight) = (
Account {
Expand Down
6 changes: 3 additions & 3 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
};

// don't allow calling EVM RPC or Runtime API from a bound address
if EVMAccounts::bound_account_id(from).is_some() {
if !estimate && EVMAccounts::bound_account_id(from).is_some() {
return Err(pallet_evm_accounts::Error::<Runtime>::BoundAddressCannotBeUsed.into())
};

Expand Down Expand Up @@ -2228,9 +2228,9 @@ impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
};

// don't allow calling EVM RPC or Runtime API from a bound address
if EVMAccounts::bound_account_id(from).is_some() {
if !estimate && EVMAccounts::bound_account_id(from).is_some() {
return Err(pallet_evm_accounts::Error::<Runtime>::BoundAddressCannotBeUsed.into())
};
};

// the address needs to have a permission to deploy smart contract
if !EVMAccounts::can_deploy_contracts(from) {
Expand Down

0 comments on commit c7ef441

Please sign in to comment.