From 9b3bcbd8ba14f019ae73ebbae84f304093178705 Mon Sep 17 00:00:00 2001 From: Mikhail <16622558+mmv08@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:48:59 +0200 Subject: [PATCH] Adjust compiler settings and document optimizer usage --- 4337/README.md | 8 ++++++++ 4337/hardhat.config.ts | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/4337/README.md b/4337/README.md index 4da8ff80b..e80cfe628 100644 --- a/4337/README.md +++ b/4337/README.md @@ -136,6 +136,14 @@ npx hardhat --network etherscan-verify npx hardhat --network local-verify ``` +### Compiler settings + +The project uses Solidity compiler version `0.8.21` with 10 million optimizer runs, as we want to optimize for the code execution costs. The evm version is set to `paris`, because not all of our target networks support the opcodes introduced in the `Shanghai` EVM upgrade. + +After careful consideration, we decided to enable the optimizer for the following reasons: +- The most critical functionality is handled by the Safe and Entrypoint contracts, such as signature checks and replay protection. +- The Entrypoint contract uses the optimizer + #### Custom Networks It is possible to use the `NODE_URL` env var to connect to any EVM based network via an RPC endpoint. This connection then can be used with the `custom` network. diff --git a/4337/hardhat.config.ts b/4337/hardhat.config.ts index 06bc3ad83..4daeb6521 100644 --- a/4337/hardhat.config.ts +++ b/4337/hardhat.config.ts @@ -36,8 +36,8 @@ import './src/tasks/local_verify' import './src/tasks/deploy_contracts' import './src/tasks/show_codesize' -const primarySolidityVersion = SOLIDITY_VERSION || '0.8.14' -const soliditySettings = !!SOLIDITY_SETTINGS ? JSON.parse(SOLIDITY_SETTINGS) : { optimizer: { enabled: true, runs: 200 } } +const primarySolidityVersion = SOLIDITY_VERSION || '0.8.21' +const soliditySettings = !!SOLIDITY_SETTINGS ? JSON.parse(SOLIDITY_SETTINGS) : { optimizer: { enabled: true, runs: 10_000_000 } } const userConfig: HardhatUserConfig = { paths: { @@ -47,7 +47,7 @@ const userConfig: HardhatUserConfig = { sources: 'contracts', }, solidity: { - compilers: [{ version: primarySolidityVersion, settings: soliditySettings }, { version: '0.6.12' }, { version: '0.5.17' }], + compilers: [{ version: primarySolidityVersion, settings: { evmVersion: 'paris', ...soliditySettings }}, { version: '0.6.12' }, { version: '0.5.17' }], }, networks: { hardhat: {