• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-core-protocol / 6299064684

25 Sep 2023 12:04PM UTC coverage: 91.395% (-8.6%) from 100.0%
6299064684

Pull #96

github

akshay-ap
[#95] Add rules
Pull Request #96: Setup certora workflow

124 of 128 branches covered (0.0%)

Branch coverage included in aggregate %.

28 of 28 new or added lines in 5 files covered. (100.0%)

184 of 209 relevant lines covered (88.04%)

12.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contracts/test/TestExecutorCertora.sol
1
// SPDX-License-Identifier: LGPL-3.0-only
2
pragma solidity ^0.8.18;
3
import {IAccount} from "../interfaces/Accounts.sol";
4

5
contract TestExecutorCertora is IAccount {
6
    bool public called;
7
    address public module;
8
    address[] public owners;
9
    address public fallbackHandler;
10
    bytes public data;
11

12
    constructor(address _fallbackHandler) {
13
        fallbackHandler = _fallbackHandler;
×
14
    }
15

16
    function setModule(address _module) external {
17
        module = _module;
×
18
    }
19

20
    function setFallbackHandler(address _fallbackHandler) external {
21
        fallbackHandler = _fallbackHandler;
×
22
    }
23

24
    function exec(address payable to, uint256 value, bytes calldata data) external {
25
        bool success;
×
26
        bytes memory response;
×
27
        (success, response) = to.call{value: value}(data);
×
28
        if (!success) {
×
29
            // solhint-disable-next-line no-inline-assembly
30
            assembly {
×
31
                revert(add(response, 0x20), mload(response))
32
            }
33
        }
34
    }
35

36
    function execTransactionFromModule(address payable, uint256, bytes calldata, uint8) external returns (bool success) {
37
        called = true;
×
38
        success = true;
×
39
    }
40

41
    function execTransactionFromModuleReturnData(
42
        address,
43
        uint256,
44
        bytes memory,
45
        uint8
46
    ) public returns (bool success, bytes memory returnData) {
47
        called = true;
×
48
        success = true;
×
49
        returnData = data;
×
50
    }
51

52
    function executeCallViaMock(
53
        address payable to,
54
        uint256 value,
55
        bytes memory,
56
        uint256 gas
57
    ) external returns (bool success, bytes memory response) {
58
        (success, response) = to.call{value: value, gas: gas}(data);
×
59
        if (!success) {
×
60
            // solhint-disable-next-line no-inline-assembly
61
            assembly {
×
62
                revert(add(response, 32), mload(response))
63
            }
64
        }
65
    }
66

67
    // @notice Forwards all calls to the fallback handler if set. Returns 0 if no handler is set.
68
    // @dev Appends the non-padded caller address to the calldata to be optionally used in the handler
69
    //      The handler can make us of `HandlerContext.sol` to extract the address.
70
    //      This is done because in the next call frame the `msg.sender` will be FallbackManager's address
71
    //      and having the original caller address may enable additional verification scenarios.
72
    // Source: https://github.com/safe-global/safe-contracts/blob/main/contracts/base/FallbackManager.sol#L62
73
    // solhint-disable-next-line payable-fallback,no-complex-fallback
74
    fallback() external {
75
        address handler = fallbackHandler;
×
76
        // solhint-disable-next-line no-inline-assembly
77
        assembly {
×
78
            // When compiled with the optimizer, the compiler relies on a certain assumptions on how the
79
            // memory is used, therefore we need to guarantee memory safety (keeping the free memory point 0x40 slot intact,
80
            // not going beyond the scratch space, etc)
81
            // Solidity docs: https://docs.soliditylang.org/en/latest/assembly.html#memory-safety
82
            function allocate(length) -> pos {
83
                pos := mload(0x40)
84
                mstore(0x40, add(pos, length))
85
            }
86

87
            if iszero(handler) {
88
                return(0, 0)
89
            }
90

91
            let calldataPtr := allocate(calldatasize())
92
            calldatacopy(calldataPtr, 0, calldatasize())
93

94
            // The msg.sender address is shifted to the left by 12 bytes to remove the padding
95
            // Then the address without padding is stored right after the calldata
96
            let senderPtr := allocate(20)
97
            mstore(senderPtr, shl(96, caller()))
98

99
            // Add 20 bytes for the address appended add the end
100
            let success := call(gas(), handler, 0, calldataPtr, add(calldatasize(), 20), 0, 0)
101

102
            let returnDataPtr := allocate(returndatasize())
103
            returndatacopy(returnDataPtr, 0, returndatasize())
104
            if iszero(success) {
105
                revert(returnDataPtr, returndatasize())
106
            }
107
            return(returnDataPtr, returndatasize())
108
        }
109
    }
110

111
    receive() external payable {}
112
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc