Skip to content

Commit

Permalink
Optimize Compiler Settings
Browse files Browse the repository at this point in the history
I noticed that the IR optimizer is better for all contracts **except**
the FCL library. This PR optimizes the compiler configuration to take
advantage of the IR optimizer, while adding an exception for the FCL
P-256 verifier contract so that it does not suffer any regressions.

```
=== BEFORE ===
  Gas Benchmarking [@bench]
    SafeWebAuthnSignerProxy
      ⛽ deployment: 94366
      ✔ Benchmark signer deployment cost (476ms)
      ⛽ verification (FreshCryptoLib): 216907
      ✔ Benchmark signer verification cost with FreshCryptoLib verifier (116ms)
      ⛽ verification (Daimo): 346809
      ✔ Benchmark signer verification cost with Daimo verifier (103ms)
      ⛽ verification (Dummy): 14309
      ✔ Benchmark signer verification cost with Dummy verifier (100ms)
      ⛽ verification (Precompile): 15098
      ✔ Benchmark signer verification cost with Precompile verifier (104ms)

=== AFTER  ===
  Gas Benchmarking [@bench]
    SafeWebAuthnSignerProxy
      ⛽ deployment: 90399
      ✔ Benchmark signer deployment cost (494ms)
      ⛽ verification (FreshCryptoLib): 215532
      ✔ Benchmark signer verification cost with FreshCryptoLib verifier (123ms)
      ⛽ verification (Daimo): 345458
      ✔ Benchmark signer verification cost with Daimo verifier (103ms)
      ⛽ verification (Dummy): 12911
      ✔ Benchmark signer verification cost with Dummy verifier (96ms)
      ⛽ verification (Precompile): 13726
      ✔ Benchmark signer verification cost with Precompile verifier (106ms)
```
  • Loading branch information
nlordell committed Jun 21, 2024
1 parent 75e56fd commit 8cc718d
Showing 1 changed file with 21 additions and 9 deletions.
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.24',
settings: {
optimizer: {
enabled: true,
runs: 10_000_000,
},
viaIR: true,
evmVersion: 'paris',
},
}

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,
settings: {
optimizer: {
enabled: true,
runs: 10_000_000,
},
...compilerSettings.settings,
viaIR: false,
evmVersion: 'paris',
},
},
],
},
},
namedAccounts: {
deployer: 0,
Expand Down

0 comments on commit 8cc718d

Please sign in to comment.