1

Suppose that you perform a low-level call, and for whatever reason you do not check if the call reverted or not (in other words, you do not bubble up the revert).

Now, further suppose that that low-level call applied state changes before it reverted. Would those state changes persist if the caller contract does not bubble up the revert?

1 Answer 1

1

No, the state changes won't apply. Take the following code:

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.13;

contract Foo {
    uint256 public counter;

    function bumpCounter() external {
        counter += 1;
        revert();
    }
}

contract Bar {
    function callBumpCounter(Foo foo) external returns (bool success, bytes memory response) {
        bytes memory data = abi.encodeCall(Foo.bumpCounter, ());
        (success, response) = address(foo).call(data);
    }
}

The counter storage variable of the Foo contract will not be incremented by calling the callBumpCounter function on the Bar contract.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.