I have this simple contracts which forwards the calldata to and external contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract AccountTest {
/**
* execute a transaction (called directly from owner, or by entryPoint)
*/
function execute(address dest, uint256 value, bytes calldata func) external {
call(dest, value, func);
}
function call(address target, uint256 value, bytes memory data) internal {
(bool success, bytes memory result) = target.call{value : value}(data);
if (!success) {
assembly {
revert(add(result, 32), mload(result))
}
}
}
And then I deployed it and called execute
with a non-existing address in my local dev node:
const walletContract = await ethers.getContractFactory("AccountTest");
let factory = await walletContract.deploy();
await factory.waitForDeployment();
let tx = await factory.execute("0x1f9090aae28b8a3dceadf281b0f12828e676c326", 0, "0x");
let r = await tx.wait()
console.log(r.status == 1 ? "success" : "fail")
What I expect is that the tx should be reverted, and the status should be fail
, but on the contrary, it returns success
, and tx is not reverted.
I try to search for documents of the underlying behavior of CALL
but didn't get a clue.
Does anyone knows why this is? Thanks!