Skip to content

Commit ee92957

Browse files
rmeissnermmv08
andauthored
Backmerge 1.3.0 libs.0 (#383)
* move signMessageLib out of examples and deploy it (#333) * fix signmessagelib deployment * add polygon config * add bsc to config * add arbitrum config * add fantom testnet configuration * Extended SignMessageLib tests (#347) * add test for using invalid operation with signmessagelib * extract singed messages mapping storage slot to a constant * add test for SignMessageLib storage manipulations * update lockfile * update description of test that checks storage slots * change nonce visibility to internal * use EOA acc to test DELEGATECALL enforcement * test desc correction * test desc correction 2 * Feature: Storage tests for GnosisSafeStorage and GnosisSafe contracts (#348) * gnosissafestorage tests wip * trying to hack the matcher * add mastercopy storage tests * test disc fix * formatting improvement * use startsWith in test, change mastercopy to singleton * Support custom singleton factory (#344) * PoC of custom singleton factory * Adjust readme * Bump node version * Use npm packages * Update solidity coverage * Update changelog§ (#350) * Improve readme * Update factory * fix tests naming (#401) * Remove duplicate SignMessage contract Co-authored-by: Mikhail Mikheev <mmvsha73@gmail.com>
1 parent 9b8b8df commit ee92957

File tree

15 files changed

+768
-78
lines changed

15 files changed

+768
-78
lines changed

.env.sample

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ MNEMONIC=""
33
INFURA_KEY=""
44
# Used for custom network
55
NODE_URL=""
6-
ETHERSCAN_API_KEY=""
6+
ETHERSCAN_API_KEY=""
7+
# Use the Safe singleton factory for singleton deployment. This is required if EIP-155 is enforce on a chain.
8+
# CUSTOM_DETERMINISTIC_DEPLOYMENT="true"

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.7.0
1+
v16.7.0

CHANGELOG.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,77 @@
22

33
This changelog only contains changes starting from version 1.3.0
44

5+
# Version 1.3.0-libs.0
6+
7+
## Compiler settings
8+
9+
Solidity compiler: [0.7.6](https://github.com/ethereum/solidity/releases/tag/v0.7.6) (more info see issue [#251](https://github.com/gnosis/safe-contracts/issues/251))
10+
11+
Solidity optimizer: `disabled`
12+
13+
## Expected addresses with [Deterministic Deployment Proxy](https://github.com/Arachnid/deterministic-deployment-proxy) (default)
14+
15+
### Core contracts
16+
- `GnosisSafe` at `0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552`
17+
- `GnosisSafeL2` at `0x3E5c63644E683549055b9Be8653de26E0B4CD36E`
18+
### Factory contracts
19+
- `GnosisSafeProxyFactory` at `0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2`
20+
### Handler contracts
21+
- `DefaultCallbackHandler` at `0x1AC114C2099aFAf5261731655Dc6c306bFcd4Dbd`
22+
- `CompatibilityFallbackHandler` at `0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4`
23+
### Lib contracts
24+
- `MultiSend` at `0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761`
25+
- `MultiSendCallOnly` at `0x40A2aCCbd92BCA938b02010E17A5b8929b49130D`
26+
- `CreateCall` at `0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4`
27+
- `SignMessageLib` at `0xA65387F16B013cf2Af4605Ad8aA5ec25a2cbA3a2`
28+
### Storage reader contracts
29+
- `SimulateTxAccessor` at `0x59AD6735bCd8152B84860Cb256dD9e96b85F69Da`
30+
31+
## Expected addresses with [Safe Singleton Factory](https://github.com/gnosis/safe-singleton-factory)
32+
33+
### Core contracts
34+
- `GnosisSafe` at `0x69f4D1788e39c87893C980c06EdF4b7f686e2938`
35+
- `GnosisSafeL2` at `0xfb1bffC9d739B8D520DaF37dF666da4C687191EA`
36+
### Factory contracts
37+
- `GnosisSafeProxyFactory` at `0xC22834581EbC8527d974F8a1c97E1bEA4EF910BC`
38+
### Handler contracts
39+
- `DefaultCallbackHandler` at `0x3d8E605B02032A941Cfe26897Ca94d77a5BC24b3`
40+
- `CompatibilityFallbackHandler` at `0x017062a1dE2FE6b99BE3d9d37841FeD19F573804`
41+
### Lib contracts
42+
- `MultiSend` at `0x998739BFdAAdde7C933B942a68053933098f9EDa`
43+
- `MultiSendCallOnly` at `0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B`
44+
- `CreateCall` at `0xB19D6FFc2182150F8Eb585b79D4ABcd7C5640A9d`
45+
- `SignMessageLib` at `0x98FFBBF51bb33A056B08ddf711f289936AafF717`
46+
### Storage reader contracts
47+
- `SimulateTxAccessor` at `0x727a77a074D1E6c4530e814F89E618a3298FC044`
48+
49+
## Changes
50+
51+
### Deployment process
52+
53+
To support deployment to networks that require replay protection support for the [Safe Singleton Factory](https://github.com/gnosis/safe-singleton-factory) has been added. This will result in an additional set of deterministic addresses which are listed above.
54+
55+
### Libraries
56+
57+
The following libraries have been marked as production ready.
58+
59+
#### SignMessageLib
60+
61+
File: [`contracts/libraries/SignMessage.sol`](https://github.com/gnosis/safe-contracts/blob/e57df14ea96dc7dabf93f041c7531f2ab6755c76/contracts/libraries/SignMessage.sol)
62+
63+
Expected behaviour:
64+
65+
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.
66+
67+
#### GnosisSafeStorage
68+
69+
70+
File: [`contracts/libraries/GnosisSafeStorage.sol`](https://github.com/gnosis/safe-contracts/blob/e57df14ea96dc7dabf93f041c7531f2ab6755c76/contracts/libraries/GnosisSafeStorage.sol)
71+
72+
Expected behaviour:
73+
74+
The contract contains the basic storage layout of the `GnosisSafe.sol` contract and can be used by library contracts to access the storage variables.
75+
576
# Version 1.3.0
677

778
## Compiler settings

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ The resulting addresses should be on all networks the same.
6464

6565
Note: Address will vary if contract code is changed or a different Solidity version is used.
6666

67+
#### Replay protection (EIP-155)
68+
69+
Some networks require replay protection. This is not possible with the default deployment process as it relies on a presigned transaction without replay protection (see https://github.com/Arachnid/deterministic-deployment-proxy).
70+
71+
It is possible to enable deployment via a different determinisitic deployment proxy (https://github.com/gnosis/safe-singleton-factory). To enable this the `CUSTOM_DETERMINISTIC_DEPLOYMENT` env var has to be set to `true` (see `.env.sample`). To make sure that the latest version of this package is install, make sure to run `yarn add @gnosis.pm/safe-singleton-factory` before deployment.
72+
73+
Note: This will result in different addresses compared to the default deployment process.
74+
6775
### Verify contract
6876

6977
This command will use the deployment artifacts to compile the contracts and compare them to the onchain code

contracts/examples/libraries/Migrate_1_3_0_to_1_2_0.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ contract Migration is GnosisSafeStorage {
2525
require(address(this) != migrationSingleton, "Migration should only be called via delegatecall");
2626
// Master copy address cannot be null.
2727
singleton = safe120Singleton;
28-
domainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));
28+
_deprecatedDomainSeparator = keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, this));
2929
emit ChangedMasterCopy(singleton);
3030
}
3131
}

contracts/libraries/GnosisSafeStorage.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ contract GnosisSafeStorage {
1414
uint256 internal threshold;
1515

1616
// From /GnosisSafe.sol
17-
bytes32 internal nonce;
18-
bytes32 internal domainSeparator;
17+
uint256 internal nonce;
18+
bytes32 internal _deprecatedDomainSeparator;
1919
mapping(bytes32 => uint256) internal signedMessages;
2020
mapping(address => mapping(bytes32 => uint256)) internal approvedHashes;
2121
}

hardhat.config.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
12
import "@nomiclabs/hardhat-etherscan";
23
import "@nomiclabs/hardhat-waffle";
34
import "solidity-coverage";
45
import "hardhat-deploy";
56
import dotenv from "dotenv";
6-
import type { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
77
import yargs from "yargs";
8+
import { getSingletonFactoryInfo } from "@gnosis.pm/safe-singleton-factory";
89

910
const argv = yargs
1011
.option("network", {
@@ -16,7 +17,7 @@ const argv = yargs
1617

1718
// Load environment variables.
1819
dotenv.config();
19-
const { NODE_URL, INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK, SOLIDITY_VERSION, SOLIDITY_SETTINGS } = process.env;
20+
const { NODE_URL, INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY, PK, SOLIDITY_VERSION, SOLIDITY_SETTINGS, CUSTOM_DETERMINISTIC_DEPLOYMENT } = process.env;
2021

2122
const DEFAULT_MNEMONIC =
2223
"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
@@ -39,10 +40,23 @@ if (["mainnet", "rinkeby", "kovan", "goerli", "ropsten", "mumbai", "polygon"].in
3940
import "./src/tasks/local_verify"
4041
import "./src/tasks/deploy_contracts"
4142
import "./src/tasks/show_codesize"
43+
import { BigNumber } from "@ethersproject/bignumber";
4244

4345
const primarySolidityVersion = SOLIDITY_VERSION || "0.7.6"
4446
const soliditySettings = !!SOLIDITY_SETTINGS ? JSON.parse(SOLIDITY_SETTINGS) : undefined
4547

48+
const deterministicDeployment = CUSTOM_DETERMINISTIC_DEPLOYMENT == "true" ?
49+
(network: string) => {
50+
const info = getSingletonFactoryInfo(parseInt(network))
51+
if (!info) return undefined
52+
return {
53+
factory: info.address,
54+
deployer: info.signerAddress,
55+
funding: BigNumber.from(info.gasLimit).mul(BigNumber.from(info.gasPrice)).toString(),
56+
signedTx: info.transaction
57+
}
58+
} : undefined
59+
4660
const userConfig: HardhatUserConfig = {
4761
paths: {
4862
artifacts: "build/artifacts",
@@ -103,7 +117,20 @@ const userConfig: HardhatUserConfig = {
103117
...sharedNetworkConfig,
104118
url: `https://volta-rpc.energyweb.org`,
105119
},
120+
bsc: {
121+
...sharedNetworkConfig,
122+
url: `https://bsc-dataseed.binance.org/`,
123+
},
124+
arbitrum: {
125+
...sharedNetworkConfig,
126+
url: `https://arb1.arbitrum.io/rpc`,
127+
},
128+
fantomTestnet: {
129+
...sharedNetworkConfig,
130+
url: `https://rpc.testnet.fantom.network/`,
131+
}
106132
},
133+
deterministicDeployment,
107134
namedAccounts: {
108135
deployer: 0,
109136
},

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"test": "hardhat test",
2020
"coverage": "hardhat coverage",
2121
"benchmark": "yarn test benchmark/*.ts",
22+
"deploy-custom": "rm -rf deployments/custom && yarn deploy-all custom",
2223
"deploy-all": "hardhat deploy-contracts --network",
2324
"deploy": "hardhat deploy --network",
2425
"lint": "yarn lint:sol && yarn lint:ts",
@@ -44,16 +45,17 @@
4445
},
4546
"devDependencies": {
4647
"@gnosis.pm/mock-contract": "^4.0.0",
48+
"@gnosis.pm/safe-singleton-factory": "^1.0.3",
4749
"@nomiclabs/hardhat-ethers": "^2.0.0",
4850
"@nomiclabs/hardhat-etherscan": "^2.1.0",
4951
"@nomiclabs/hardhat-waffle": "^2.0.0",
5052
"@openzeppelin/contracts": "^3.4.0",
5153
"@types/chai": "^4.2.14",
5254
"@types/mocha": "^8.2.0",
5355
"@types/node": "^14.14.21",
56+
"@types/yargs": "^15.0.10",
5457
"@typescript-eslint/eslint-plugin": "^4.7.0",
5558
"@typescript-eslint/parser": "^4.7.0",
56-
"@types/yargs": "^15.0.10",
5759
"argv": "^0.0.2",
5860
"chai": "^4.2.0",
5961
"debug": "^4.2.0",
@@ -66,14 +68,14 @@
6668
"ethereum-waffle": "^3.3.0",
6769
"ethers": "^5.1.4",
6870
"hardhat": "^2.2.1",
69-
"hardhat-deploy": "^0.7.5",
71+
"hardhat-deploy": "0.9.2",
7072
"husky": "^5.1.3",
7173
"prettier": "^2.1.2",
7274
"prettier-plugin-solidity": "^1.0.0-alpha.60",
7375
"solc": "0.7.6",
7476
"solhint": "^3.3.2",
7577
"solhint-plugin-prettier": "^0.0.5",
76-
"solidity-coverage": "^0.7.16",
78+
"solidity-coverage": "^0.7.17",
7779
"ts-node": "^9.1.1",
7880
"typescript": "^4.2.4",
7981
"yargs": "^16.1.1"

src/deploy/deploy_libraries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const deploy: DeployFunction = async function (
88
const { deployer } = await getNamedAccounts();
99
const { deploy } = deployments;
1010

11+
1112
await deploy("CreateCall", {
1213
from: deployer,
1314
args: [],

0 commit comments

Comments
 (0)