Skip to content

Commit

Permalink
Fix revert (#149)
Browse files Browse the repository at this point in the history
Co-authored-by: Xavier Lau <[email protected]>
  • Loading branch information
boundless-forest and AurevoirXavier authored Dec 21, 2022
1 parent e4cf09a commit 893a46e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions runtime/crab/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ where
// darwinia
use darwinia_precompile_assets::AccountToAssetId;

let (code_address, caller) = (handle.code_address(), handle.context().caller);
let (code_addr, context_addr) = (handle.code_address(), handle.context().address);
// Filter known precompile addresses except Ethereum officials
if self.is_precompile(code_address) && code_address > addr(9) && code_address != caller {
if self.is_precompile(code_addr) && code_addr > addr(9) && code_addr != context_addr {
return Some(Err(precompile_utils::revert(
"cannot be called with DELEGATECALL or CALLCODE",
)));
};

match code_address {
match code_addr {
// Ethereum precompiles:
a if a == addr(1) => Some(pallet_evm_precompile_simple::ECRecover::execute(handle)),
a if a == addr(2) => Some(pallet_evm_precompile_simple::Sha256::execute(handle)),
Expand Down
6 changes: 3 additions & 3 deletions runtime/darwinia/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ where
// darwinia
use darwinia_precompile_assets::AccountToAssetId;

let (code_address, caller) = (handle.code_address(), handle.context().caller);
let (code_addr, context_addr) = (handle.code_address(), handle.context().address);
// Filter known precompile addresses except Ethereum officials
if self.is_precompile(code_address) && code_address > addr(9) && code_address != caller {
if self.is_precompile(code_addr) && code_addr > addr(9) && code_addr != context_addr {
return Some(Err(precompile_utils::revert(
"cannot be called with DELEGATECALL or CALLCODE",
)));
};

match code_address {
match code_addr {
// Ethereum precompiles:
a if a == addr(1) => Some(pallet_evm_precompile_simple::ECRecover::execute(handle)),
a if a == addr(2) => Some(pallet_evm_precompile_simple::Sha256::execute(handle)),
Expand Down
6 changes: 3 additions & 3 deletions runtime/pangolin/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ where
// darwinia
use darwinia_precompile_assets::AccountToAssetId;

let (code_address, caller) = (handle.code_address(), handle.context().caller);
let (code_addr, context_addr) = (handle.code_address(), handle.context().address);
// Filter known precompile addresses except Ethereum officials
if self.is_precompile(code_address) && code_address > addr(9) && code_address != caller {
if self.is_precompile(code_addr) && code_addr > addr(9) && code_addr != context_addr {
return Some(Err(precompile_utils::revert(
"cannot be called with DELEGATECALL or CALLCODE",
)));
};

match code_address {
match code_addr {
// Ethereum precompiles:
a if a == addr(1) => Some(pallet_evm_precompile_simple::ECRecover::execute(handle)),
a if a == addr(2) => Some(pallet_evm_precompile_simple::Sha256::execute(handle)),
Expand Down

0 comments on commit 893a46e

Please sign in to comment.