Skip to content
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

Optimize Compiler Settings #448

Merged
merged 2 commits into from
Jun 25, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;
pragma solidity 0.8.26;

import {SignatureValidator} from "../base/SignatureValidator.sol";
import {ISafe} from "../interfaces/ISafe.sol";
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/SafeWebAuthnSignerFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.0;
pragma solidity 0.8.26;

import {ISafeSignerFactory} from "./interfaces/ISafeSignerFactory.sol";
import {SafeWebAuthnSignerProxy} from "./SafeWebAuthnSignerProxy.sol";
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/verifiers/FCLP256Verifier.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
/* solhint-disable no-complex-fallback */
/* solhint-disable payable-fallback */
pragma solidity 0.8.24;
pragma solidity 0.8.26;

import {IP256Verifier} from "../interfaces/IP256Verifier.sol";
import {FCL_ecdsa} from "../vendor/FCL/FCL_ecdsa.sol";
Expand Down
30 changes: 21 additions & 9 deletions modules/passkey/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ const customNetwork = CUSTOM_NODE_URL
}
: {}

const compilerSettings = {
version: '0.8.26',
settings: {
optimizer: {
enabled: true,
runs: 10_000_000,
},
viaIR: true,
evmVersion: 'paris',
Copy link
Member

Choose a reason for hiding this comment

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

paris is pre-push0, right? maybe we don't need this either?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do, so we are BNB compatible.

Also, note that hardhat currently defaults to paris anyway (at least it did when I experimented with switching this setting off), so this is more to explicitly document the EVM version that is being targetted.

Copy link
Member

Choose a reason for hiding this comment

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

it seems like BNB already has push0? https://forum.bnbchain.org/t/bnb-chain-roadmap-mainnet/936

Copy link
Collaborator Author

@nlordell nlordell Jun 24, 2024

Choose a reason for hiding this comment

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

This is super recent! It wasn't the case 4 days ago: hats-finance#19 (comment)

Then s/BNB/Linea/g: I think the point remains the same that PUSH0 isn't generally well supported across L2s:

$ curl -s https://rpc.linea.build -H 'content-type: application/json' --data '{"jsonrpc":"2.0","id":0,"method":"eth_call","params":[{"data":"0x5f"},"latest"]}'
{"jsonrpc":"2.0","id":0,"error":{"code":-32000,"message":"invalid opcode: PUSH0"}}

Copy link
Member

Choose a reason for hiding this comment

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

interesting, the forum post says it was implemented in Kepler: 2024/01/23 hardfork

},
}

const config: HardhatUserConfig = {
paths: {
artifacts: 'build/artifacts',
Expand All @@ -54,19 +66,19 @@ const config: HardhatUserConfig = {
...customNetwork,
},
solidity: {
compilers: [
{
version: '0.8.24',
compilers: [compilerSettings],
overrides: {
// FCL library does not optimize well via IR. In order to take advantage of the IR optimizer
// in the rest of the project without causing significant regressions to the FCL verifier, we
// add a compiler setting override for that specific contract.
'contracts/verifiers/FCLP256Verifier.sol': {
...compilerSettings,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
...compilerSettings,
version: compilerSettings.version,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this on purpose to future proof in case new fields were added. Agree it isn't strictly necessary here, but wanted to future proof just in case. Also it feels to convey intent a bit more IMO: we want exactly compilerSettings except for this single value.

settings: {
optimizer: {
enabled: true,
runs: 10_000_000,
},
...compilerSettings.settings,
viaIR: false,
evmVersion: 'paris',
},
},
],
},
},
namedAccounts: {
deployer: 0,
Expand Down
Loading