Skip to content

Enable Solidity IR Optimizations #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const soliditySettings = SOLIDITY_SETTINGS
? JSON.parse(SOLIDITY_SETTINGS)
: {
evmVersion: 'paris',
viaIR: true,
optimizer: {
enabled: true,
runs: 10_000_000,
Expand Down
47 changes: 9 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": "hardhat test",
"test:e2e": "HARDHAT_FORK=1 hardhat test",
"test:all": "npm run test && npm run test:e2e",
"coverage": "hardhat coverage --network hardhat",
"coverage": "hardhat coverage",
"coverage:check": "istanbul check-coverage ./coverage.json --statements 100 --branches 100 --functions 100 --lines 100",
"deploy-all": "hardhat deploy-contracts --network",
"deploy": "hardhat deploy --network",
Expand Down
32 changes: 16 additions & 16 deletions test/SafeTokenLock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,22 +963,7 @@ describe('SafeTokenLock', function () {
})

describe('Token Rescue', function () {
it('Should not allow non-owner to recover', async () => {
const { safeTokenLock, alice } = await setupTests()
expect(safeTokenLock.connect(alice).rescueToken(ZeroAddress, ZeroAddress, 0))
.to.be.revertedWithCustomError(safeTokenLock, 'OwnableUnauthorizedAccount')
.withArgs(alice)
})

it('Should not allow Safe token recovery', async () => {
const { safeToken, safeTokenLock, owner } = await setupTests()
expect(safeTokenLock.connect(owner).rescueToken(safeToken, ZeroAddress, 0)).to.be.revertedWithCustomError(
safeTokenLock,
'CannotRecoverSafeToken',
)
})

it('Should allow ERC20 recovery other than Safe token', async () => {
it('Should allow rescuing tokens other other than Safe token', async () => {
const { safeToken, safeTokenLock, owner, alice } = await setupTests()
const erc20 = await (await ethers.getContractFactory('TestERC20')).deploy('TEST', 'TEST')

Expand Down Expand Up @@ -1012,6 +997,21 @@ describe('SafeTokenLock', function () {
await expect(safeTokenLock.connect(owner).rescueToken(erc20ReturnFalseOnFailure, owner, 1)).to.be.reverted
await expect(safeTokenLock.connect(owner).rescueToken(erc20ReturnNothingOnSuccess, owner, 1)).to.not.be.reverted
})

it('Should not allow rescuing Safe token', async () => {
const { safeToken, safeTokenLock, owner } = await setupTests()
expect(safeTokenLock.connect(owner).rescueToken(safeToken, ZeroAddress, 0)).to.be.revertedWithCustomError(
safeTokenLock,
'CannotRecoverSafeToken',
)
})

it('Should not allow rescuing as non-owner', async () => {
const { safeTokenLock, alice } = await setupTests()
expect(safeTokenLock.connect(alice).rescueToken(ZeroAddress, ZeroAddress, 0))
.to.be.revertedWithCustomError(safeTokenLock, 'OwnableUnauthorizedAccount')
.withArgs(alice)
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I changed the order of the tests... While this may seem silly, there is a reason. The solidity-coverage took has some extra "hash de-duplication" logic when compiling via IR which messes up branch coverage computation. Changing the order of the tests fixes this. See:

sc-forks/solidity-coverage#863
sc-forks/solidity-coverage#868

})

describe('Operations', function () {
Expand Down