Skip to content

Commit

Permalink
Merge branch 'safe-global:main' into circleci-project-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dargon789 authored Jan 24, 2025
2 parents 9409fb7 + 1c8b24a commit dc1d3ea
Show file tree
Hide file tree
Showing 81 changed files with 2,722 additions and 1,293 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @safe-global/safe-protocol
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ assignees: ''

## Description

Please describe considely the bug you have found, and what you expect instead.
Please describe concisely the bug you have found, and what you expect instead.

## Environment

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/certora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
rule: ["owner", "safe", "module", "nativeTokenRefund", "signatures", "safeMigration", "safeToL2Migration", "safeToL2Setup"]
rule: ["execute", "extensible", "fallback", "guards", "hash", "module", "nativeTokenRefund", "owner", "safe", "safeMigration", "safeToL2Migration", "safeToL2Setup", "setup", "signatures"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ typechain-types

# zksync era node log
era_test_node.log
anvil-zksync.log
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ File: [`contracts/libraries/SignMessage.sol`](https://github.com/safe-global/saf

Expected behaviour:

The library is meant as a compatibility tool for the removed `signMessage` function from the pre-1.3.0 Safe contracts. It has the same signature and assumes the same storage layout as the previous Safe contract versions. After calling this function with a massage, the hash of that message should be marked as executed in the `signedMessages` mapping.
The library is meant as a compatibility tool for the removed `signMessage` function from the pre-1.3.0 Safe contracts. It has the same signature and assumes the same storage layout as the previous Safe contract versions. After calling this function with a message, the hash of that message should be marked as executed in the `signedMessages` mapping.

#### GnosisSafeStorage

Expand Down Expand Up @@ -714,7 +714,7 @@ Expected behaviour:

The `multiSend` is now payable therefore will enforce anymore that `msg.value` is 0. ETH that is not transferred out again will remain in `this` (the calling contract when used via a delegatecall or the contract when used via call, only possible with `MultiSendCallOnly`)

#### Add MuliSend that disallows delegate operation
#### Add MultiSend that disallows delegate operation

File: [`contracts/libraries/MultiSendCallOnly.sol`](https://github.com/safe-global/safe-smart-account/blob/ad6c7355d5bdf4f7fa348fbfcb9f07431769a3c9/contracts/libraries/MultiSendCallOnly.sol)

Expand All @@ -741,7 +741,7 @@ Note: **This contract is meant as an example to demonstrate how to mark Safe mes

Expected behaviour:

The library is meant as a compatibility tool for the removed `signMessage` function from the pre-1.3.0 Safe contracts. It has the same signature and assumes the same storage layout as the previous Safe contract versions. After calling this function with a massage, the hash of that message should be marked as executed in the `signedMessages` mapping.
The library is meant as a compatibility tool for the removed `signMessage` function from the pre-1.3.0 Safe contracts. It has the same signature and assumes the same storage layout as the previous Safe contract versions. After calling this function with a message, the hash of that message should be marked as executed in the `signedMessages` mapping.

#### Add Migration example to downgrade from 1.3.0 to 1.2.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To add support for a new network follow the steps of the ``Deploy`` section and

> :warning: **Make sure to use the correct commit when deploying the contracts.** Any change (even comments) within the contract files will result in different addresses. The tagged versions that are used by the Safe team can be found in the [releases](https://github.com/safe-global/safe-smart-account/releases).
> **Current version:** The latest release is [v1.4.1-build.0](https://github.com/safe-global/safe-smart-account/tree/v1.4.1-build.0) on the commit [192c7dc](https://github.com/safe-global/safe-smart-account/commit/192c7dc67290940fcbc75165522bb86a37187069)
> **Current version:** The latest release is [v1.4.1-3](https://github.com/safe-global/safe-smart-account/tree/v1.4.1-3) on the commit [21dc824](https://github.com/safe-global/safe-smart-account/commit/21dc82410445637820f600c7399a804ad55841d5)
This will deploy the contracts deterministically and verify the contracts on etherscan using [Solidity 0.7.6](https://github.com/ethereum/solidity/releases/tag/v0.7.6) by default.

Expand Down Expand Up @@ -96,7 +96,7 @@ This command will use the deployment artifacts to compile the contracts and comp
npx hardhat --network <network> local-verify
```

This command will upload the contract source to Etherescan
This command will upload the contract source to Etherscan
```bash
npx hardhat --network <network> etherscan-verify
```
Expand Down
48 changes: 36 additions & 12 deletions certora/applyHarness.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -druN Safe.sol Safe.sol
--- Safe.sol 2024-10-23 15:00:06
+++ Safe.sol 2024-10-23 15:04:05
--- Safe.sol 2024-12-16 07:43:06
+++ Safe.sol 2025-01-13 11:58:17
@@ -75,22 +75,24 @@
* so we create a Safe with 0 owners and threshold 1.
* This is an unusable Safe, perfect for the singleton
Expand Down Expand Up @@ -30,7 +30,7 @@ diff -druN Safe.sol Safe.sol
// setupOwners checks if the Threshold is already set, therefore preventing this method from being called more than once
setupOwners(_owners, _threshold);
if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
@@ -386,9 +388,6 @@
@@ -388,9 +390,6 @@
return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, chainId, this));
}

Expand All @@ -40,7 +40,7 @@ diff -druN Safe.sol Safe.sol
function getTransactionHash(
address to,
uint256 value,
@@ -400,7 +399,9 @@
@@ -402,7 +401,9 @@
address gasToken,
address refundReceiver,
uint256 _nonce
Expand All @@ -50,10 +50,21 @@ diff -druN Safe.sol Safe.sol
+
bytes32 domainHash = domainSeparator();

// We opted out for using assembly code here, because the way Solidity compiler we use (0.7.6)
// We opted for using assembly code here, because the way Solidity compiler we use (0.7.6) allocates memory is
@@ -452,7 +453,8 @@
// Store the domain separator
mstore(add(ptr, 32), domainHash)
// Calculate the hash
- txHash := keccak256(add(ptr, 30), 66)
+ //txHash := keccak256(add(ptr, 30), 66) // old
+ txHash := keccak256(add(ptr, 0), 128) // new
}
/* solhint-enable no-inline-assembly */
}

diff -druN base/Executor.sol base/Executor.sol
--- base/Executor.sol 2024-10-18 15:20:48
+++ base/Executor.sol 2024-10-23 15:03:22
--- base/Executor.sol 2024-12-16 07:43:06
+++ base/Executor.sol 2025-01-13 11:58:17
@@ -26,12 +26,8 @@
uint256 txGas
) internal returns (bool success) {
Expand All @@ -69,10 +80,23 @@ diff -druN base/Executor.sol base/Executor.sol
} else {
/* solhint-disable no-inline-assembly */
/// @solidity memory-safe-assembly
diff -druN base/FallbackManager.sol base/FallbackManager.sol
--- base/FallbackManager.sol 2024-12-16 07:43:06
+++ base/FallbackManager.sol 2025-01-13 12:07:42
@@ -63,7 +63,8 @@
// not going beyond the scratch space, etc)
// Solidity docs: https://docs.soliditylang.org/en/latest/assembly.html#memory-safety

- let handler := sload(FALLBACK_HANDLER_STORAGE_SLOT)
+ // let handler := sload(FALLBACK_HANDLER_STORAGE_SLOT)
+ let handler := and(0xffffffffffffffffffffffffffffffffffffffff, sload(FALLBACK_HANDLER_STORAGE_SLOT))

if iszero(handler) {
return(0, 0)
diff -druN interfaces/ISafe.sol interfaces/ISafe.sol
--- interfaces/ISafe.sol 2024-10-18 15:20:48
+++ interfaces/ISafe.sol 2024-10-23 15:03:22
@@ -110,7 +110,7 @@
--- interfaces/ISafe.sol 2024-12-16 07:43:06
+++ interfaces/ISafe.sol 2025-01-13 11:58:17
@@ -113,7 +113,7 @@
*/
function domainSeparator() external view returns (bytes32);

Expand All @@ -81,15 +105,15 @@ diff -druN interfaces/ISafe.sol interfaces/ISafe.sol
* @notice Returns transaction hash to be signed by owners.
* @param to Destination address.
* @param value Ether value.
@@ -123,7 +123,6 @@
@@ -126,7 +126,6 @@
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
* @param _nonce Transaction nonce.
* @return Transaction hash.
- */
function getTransactionHash(
address to,
uint256 value,
@@ -136,6 +135,8 @@
@@ -139,6 +138,8 @@
address refundReceiver,
uint256 _nonce
) external view returns (bytes32);
Expand Down
27 changes: 27 additions & 0 deletions certora/conf/execute.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"files": [
"certora/harnesses/SafeHarness.sol",
"certora/mocks/ModuleGuardMock.sol", // a module guard
"certora/mocks/TxnGuardMock.sol", // a (safe) guard
],
"link": [

],
"verify": "SafeHarness:certora/specs/Execute.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,
}
27 changes: 27 additions & 0 deletions certora/conf/extensible.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"files": [
"certora/harnesses/SafeHarness.sol",
"certora/harnesses/ExtensibleFallbackHandlerHarness.sol",
"certora/mocks/DummyHandler.sol"
],
"link": [

],
"verify": "SafeHarness:certora/specs/Extensible.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,
}
27 changes: 27 additions & 0 deletions certora/conf/fallback.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"files": [
"certora/harnesses/SafeHarness.sol",
"certora/harnesses/ExtensibleFallbackHandlerHarness.sol",
"certora/mocks/DummyHandler.sol"
],
"link": [

],
"verify": "SafeHarness:certora/specs/Fallback.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,
}
35 changes: 35 additions & 0 deletions certora/conf/guards.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// a conf file for safe module guards
{
"files": [
"certora/harnesses/SafeHarness.sol",
"certora/mocks/ModuleGuardMock.sol", // a module guard
"certora/mocks/ModuleGuardMockDuplicate.sol",
"certora/mocks/TxnGuardMock.sol", // a (safe) guard
"certora/mocks/TxnGuardMockDuplicate.sol",
],
"link": [

],
"verify": "SafeHarness:certora/specs/Guards.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,

"prover_args": [
" -verifyCache -verifyTACDumps -testMode -checkRuleDigest -callTraceHardFail on",
"-enableSolidityBasedInlining true"
],
}
25 changes: 25 additions & 0 deletions certora/conf/hash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"files": [
"certora/harnesses/SafeHarness.sol"
],
"link": [

],
"verify": "SafeHarness:certora/specs/Hash.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,
}
1 change: 0 additions & 1 deletion certora/conf/run.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
],
"rule_sanity": "basic",
"run_source": "MUTATION",
"send_only": true,
"solc": "solc7.6",
"verify": "SafeHarness:certora/specs/Safe.spec"
}
25 changes: 25 additions & 0 deletions certora/conf/setup.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"files": [
"certora/harnesses/SafeHarness.sol"
],
"link": [

],
"verify": "SafeHarness:certora/specs/Setup.spec",

"assert_autofinder_success": true,
"optimistic_summary_recursion": true,
"optimistic_contract_recursion": true,

"summary_recursion_limit": "2",
"contract_recursion_limit": "2",
"loop_iter": "3",
"optimistic_loop": true,
"optimistic_hashing": true,
"optimistic_fallback": true,

"rule_sanity": "basic",

"solc": "solc7.6",
"solc_via_ir": false,
}
11 changes: 11 additions & 0 deletions certora/harnesses/ExtensibleFallbackHandlerHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: LGPL-3.0-only
import "../munged/handler/ExtensibleFallbackHandler.sol";
import {ISafe} from "../munged/interfaces/ISafe.sol";

contract ExtensibleFallbackHandlerHarness is ExtensibleFallbackHandler {

function getSafeMethod(ISafe safe, bytes4 selector) public view returns (bytes32) {
return safeMethods[safe][selector];
}

}
Loading

0 comments on commit dc1d3ea

Please sign in to comment.