-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request includes updates to the repository to reflect the new version 1.5.0, with a few improvements and updates to the documentation, contracts, and tests. ### Version Updates: * Updated the version number in `Safe.sol` from `1.4.1` to `1.5.0`. ### Documentation Updates: * Updated CHANGELOG to new addresses with `v1.5.0` and changes included with that version. * Updated `safe_tx_gas.md` to reflect changes in the `Safe.sol` contract, including detailed inline assembly code for error handling. ### Test Updates: * Updated migration tests to reflect the new version `1.5.0` in `UpgradeFromSafe111.spec.ts` and `UpgradeFromSafe120.spec.ts`. [[1]](diffhunk://#diff-fabd1eff3a7e83fccbd17c2ddd31b90179573d48337eb2d4af14cf7cdc45e68cL28-R28) [[2]](diffhunk://#diff-fabd1eff3a7e83fccbd17c2ddd31b90179573d48337eb2d4af14cf7cdc45e68cL39-R42) [[3]](diffhunk://#diff-77a3075c46c527d198eb5d1ccd5c10f9e0fae972ae7e45edc7ced44bcf6883fdL29-R29) [[4]](diffhunk://#diff-77a3075c46c527d198eb5d1ccd5c10f9e0fae972ae7e45edc7ced44bcf6883fdL40-R43) * Added new migration test (this is just added as a complimentary check, detailed checks are already added otherwise with Safe Migration Tests) to check `v1.3.0` & `v1.4.1` to `v1.5.1`
- Loading branch information
Showing
12 changed files
with
432 additions
and
71 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expect } from "chai"; | ||
import hre, { deployments } from "hardhat"; | ||
import { AddressZero } from "@ethersproject/constants"; | ||
import { getFactory, getMock, getMultiSend } from "../utils/setup"; | ||
import { buildSafeTransaction, executeTx, safeApproveHash } from "../../src/utils/execution"; | ||
import { verificationTests } from "./subTests.spec"; | ||
import deploymentData from "../json/safeDeployment.json"; | ||
import { calculateProxyAddress } from "../../src/utils/proxies"; | ||
|
||
describe("Upgrade from Safe 1.3.0", () => { | ||
before(function () { | ||
/** | ||
* ## There's no safe 1.3.0 on zkSync, so we skip this test | ||
*/ | ||
if (hre.network.zksync) this.skip(); | ||
}); | ||
|
||
// We migrate the Safe and run the verification tests | ||
const setupTests = deployments.createFixture(async ({ deployments }) => { | ||
await deployments.fixture(); | ||
const mock = await getMock(); | ||
const mockAddress = await mock.getAddress(); | ||
const [user1] = await hre.ethers.getSigners(); | ||
const singleton130 = (await (await user1.sendTransaction({ data: deploymentData.safe130.evm })).wait())?.contractAddress; | ||
if (!singleton130) throw new Error("Could not deploy Safe 1.3.0"); | ||
|
||
const factory = await getFactory(); | ||
const saltNonce = 42; | ||
const proxyAddress = await calculateProxyAddress(factory, singleton130, "0x", saltNonce); | ||
await factory.createProxyWithNonce(singleton130, "0x", saltNonce).then((tx) => tx.wait()); | ||
|
||
const safe = await hre.ethers.getContractAt("Safe", proxyAddress); | ||
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero); | ||
|
||
expect(await safe.VERSION()).to.be.eq("1.3.0"); | ||
const safeMigrationDeployment = await deployments.get("SafeMigration"); | ||
const safeMigration = await hre.ethers.getContractAt("SafeMigration", safeMigrationDeployment.address); | ||
const nonce = await safe.nonce(); | ||
const data = safeMigration.interface.encodeFunctionData("migrateSingleton"); | ||
const tx = buildSafeTransaction({ to: await safeMigration.getAddress(), data, nonce, operation: 1 }); | ||
await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]); | ||
expect(await safe.VERSION()).to.be.eq("1.5.0"); | ||
|
||
return { | ||
migratedSafe: safe, | ||
mock, | ||
multiSend: await getMultiSend(), | ||
}; | ||
}); | ||
|
||
it("passes the Safe 1.3.0 tests", async () => { | ||
await verificationTests(setupTests); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expect } from "chai"; | ||
import hre, { deployments } from "hardhat"; | ||
import { AddressZero } from "@ethersproject/constants"; | ||
import { getFactory, getMock, getMultiSend } from "../utils/setup"; | ||
import { buildSafeTransaction, executeTx, safeApproveHash } from "../../src/utils/execution"; | ||
import { verificationTests } from "./subTests.spec"; | ||
import deploymentData from "../json/safeDeployment.json"; | ||
import { calculateProxyAddress } from "../../src/utils/proxies"; | ||
|
||
describe("Upgrade from Safe 1.3.0 L2", () => { | ||
before(function () { | ||
/** | ||
* ## There's no safe 1.3.0 on zkSync, so we skip this test | ||
*/ | ||
if (hre.network.zksync) this.skip(); | ||
}); | ||
|
||
// We migrate the Safe and run the verification tests | ||
const setupTests = deployments.createFixture(async ({ deployments }) => { | ||
await deployments.fixture(); | ||
const mock = await getMock(); | ||
const mockAddress = await mock.getAddress(); | ||
const [user1] = await hre.ethers.getSigners(); | ||
const singleton130L2 = (await (await user1.sendTransaction({ data: deploymentData.safe130l2.evm })).wait())?.contractAddress; | ||
if (!singleton130L2) throw new Error("Could not deploy Safe 1.3.0 L2"); | ||
|
||
const factory = await getFactory(); | ||
const saltNonce = 42; | ||
const proxyAddress = await calculateProxyAddress(factory, singleton130L2, "0x", saltNonce); | ||
await factory.createProxyWithNonce(singleton130L2, "0x", saltNonce).then((tx) => tx.wait()); | ||
|
||
const safe = await hre.ethers.getContractAt("Safe", proxyAddress); | ||
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero); | ||
|
||
expect(await safe.VERSION()).to.be.eq("1.3.0"); | ||
const safeMigrationDeployment = await deployments.get("SafeMigration"); | ||
const safeMigration = await hre.ethers.getContractAt("SafeMigration", safeMigrationDeployment.address); | ||
const nonce = await safe.nonce(); | ||
const data = safeMigration.interface.encodeFunctionData("migrateSingleton"); | ||
const tx = buildSafeTransaction({ to: await safeMigration.getAddress(), data, nonce, operation: 1 }); | ||
await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]); | ||
expect(await safe.VERSION()).to.be.eq("1.5.0"); | ||
|
||
return { | ||
migratedSafe: safe, | ||
mock, | ||
multiSend: await getMultiSend(), | ||
}; | ||
}); | ||
|
||
it("passes the Safe 1.3.0 tests", async () => { | ||
await verificationTests(setupTests); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { expect } from "chai"; | ||
import hre, { deployments } from "hardhat"; | ||
import { AddressZero } from "@ethersproject/constants"; | ||
import { getAbi, getFactory, getMock, getMultiSend } from "../utils/setup"; | ||
import { buildSafeTransaction, executeTx, safeApproveHash } from "../../src/utils/execution"; | ||
import { verificationTests } from "./subTests.spec"; | ||
import deploymentData from "../json/safeDeployment.json"; | ||
import { calculateProxyAddress } from "../../src/utils/proxies"; | ||
|
||
describe("Upgrade from Safe 1.4.1", () => { | ||
// We migrate the Safe and run the verification tests | ||
const setupTests = deployments.createFixture(async ({ deployments }) => { | ||
await deployments.fixture(); | ||
const mock = await getMock(); | ||
const mockAddress = await mock.getAddress(); | ||
const [user1] = await hre.ethers.getSigners(); | ||
const safeDeploymentData = hre.network.zksync ? deploymentData.safe141.zksync : deploymentData.safe141.evm; | ||
const safeContractFactory = new hre.ethers.ContractFactory(await getAbi("Safe"), safeDeploymentData, user1); | ||
const singleton141 = await (await safeContractFactory.deploy()).getAddress(); | ||
if (!singleton141) throw new Error("Could not deploy Safe 1.4.1"); | ||
|
||
const factory = await getFactory(); | ||
const saltNonce = 42; | ||
const proxyAddress = await calculateProxyAddress(factory, singleton141, "0x", saltNonce, hre.network.zksync); | ||
await factory.createProxyWithNonce(singleton141, "0x", saltNonce).then((tx) => tx.wait()); | ||
|
||
const safe = await hre.ethers.getContractAt("Safe", proxyAddress); | ||
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero); | ||
|
||
expect(await safe.VERSION()).to.be.eq("1.4.1"); | ||
const safeMigrationDeployment = await deployments.get("SafeMigration"); | ||
const safeMigration = await hre.ethers.getContractAt("SafeMigration", safeMigrationDeployment.address); | ||
const nonce = await safe.nonce(); | ||
const data = safeMigration.interface.encodeFunctionData("migrateSingleton"); | ||
const tx = buildSafeTransaction({ to: await safeMigration.getAddress(), data, nonce, operation: 1 }); | ||
await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]); | ||
expect(await safe.VERSION()).to.be.eq("1.5.0"); | ||
|
||
return { | ||
migratedSafe: safe, | ||
mock, | ||
multiSend: await getMultiSend(), | ||
}; | ||
}); | ||
|
||
it("passes the Safe 1.4.1 tests", async () => { | ||
await verificationTests(setupTests); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { expect } from "chai"; | ||
import hre, { deployments } from "hardhat"; | ||
import { AddressZero } from "@ethersproject/constants"; | ||
import { getAbi, getFactory, getMock, getMultiSend } from "../utils/setup"; | ||
import { buildSafeTransaction, executeTx, safeApproveHash } from "../../src/utils/execution"; | ||
import { verificationTests } from "./subTests.spec"; | ||
import deploymentData from "../json/safeDeployment.json"; | ||
import { calculateProxyAddress } from "../../src/utils/proxies"; | ||
|
||
describe("Upgrade from Safe 1.4.1 L2", () => { | ||
// We migrate the Safe and run the verification tests | ||
const setupTests = deployments.createFixture(async ({ deployments }) => { | ||
await deployments.fixture(); | ||
const mock = await getMock(); | ||
const mockAddress = await mock.getAddress(); | ||
const [user1] = await hre.ethers.getSigners(); | ||
const safeDeploymentData = hre.network.zksync ? deploymentData.safe141l2.zksync : deploymentData.safe141l2.evm; | ||
const safeContractFactory = new hre.ethers.ContractFactory(await getAbi("Safe"), safeDeploymentData, user1); | ||
const singleton141L2 = await (await safeContractFactory.deploy()).getAddress(); | ||
if (!singleton141L2) throw new Error("Could not deploy Safe 1.4.1 L2"); | ||
|
||
const factory = await getFactory(); | ||
const saltNonce = 42; | ||
const proxyAddress = await calculateProxyAddress(factory, singleton141L2, "0x", saltNonce, hre.network.zksync); | ||
await factory.createProxyWithNonce(singleton141L2, "0x", saltNonce).then((tx) => tx.wait()); | ||
|
||
const safe = await hre.ethers.getContractAt("Safe", proxyAddress); | ||
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero); | ||
|
||
expect(await safe.VERSION()).to.be.eq("1.4.1"); | ||
const safeMigrationDeployment = await deployments.get("SafeMigration"); | ||
const safeMigration = await hre.ethers.getContractAt("SafeMigration", safeMigrationDeployment.address); | ||
const nonce = await safe.nonce(); | ||
const data = safeMigration.interface.encodeFunctionData("migrateSingleton"); | ||
const tx = buildSafeTransaction({ to: await safeMigration.getAddress(), data, nonce, operation: 1 }); | ||
await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]); | ||
expect(await safe.VERSION()).to.be.eq("1.5.0"); | ||
|
||
return { | ||
migratedSafe: safe, | ||
mock, | ||
multiSend: await getMultiSend(), | ||
}; | ||
}); | ||
|
||
it("passes the Safe 1.4.1 tests", async () => { | ||
await verificationTests(setupTests); | ||
}); | ||
}); |