Skip to content

Commit

Permalink
Fixed and More Consistent Pragmas (#458)
Browse files Browse the repository at this point in the history
Fixes
hats-finance#17

This PR changes the pragmas in the passkeys contract to be:
1. More consistent: we use `^0.8.20` everywhere for "non-top-level"
contracts. The version was chosen as this it the first version that
supports all of the compiler features that we make use of. Notably, we
have `@custom:` NatSpec items which are only officially supported as of
v0.8.20 (incidentally, this is the same version used by OpenZeppelin
contracts for similar reason:
[source](OpenZeppelin/openzeppelin-contracts#4489)).
The choice to use floating pragmas here is to make using these support
contracts easier across other projects (namely, the `WebAuthn` and
`P256` libraries are useful outside of this project). Furthermore, we
use `^` versions so that breaking changes introduced in a potential
Solidity v0.9 would not affect the security and integrity of the
contract code.
2. Use fixed pragmas for "top-level" contracts that we deploy:
    - `SafeWebAuthnProxyFactory`
    - `SafeWebAuthnSharedSigner`
    - `FCLP256Verifier`

I am aware that Solidity v0.8.20 doesn't play nice with chains like BNB
by default, however this can be worked around by explicitly by setting
the EVM version target (as we do in this project) and do not believe
this is an issue.
  • Loading branch information
nlordell authored Jul 5, 2024
1 parent 61a4e06 commit bb5e1f7
Show file tree
Hide file tree
Showing 16 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion modules/passkey/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ npx hardhat --network $NETWORK verify $SAFE_WEBAUTHN_SIGNER_SINGLETON_ADDRESS --

### Compiler settings

The project uses Solidity compiler version `0.8.24` 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 our target networks support the opcodes introduced in the `Shanghai` EVM upgrade.
The project uses Solidity compiler version `0.8.26` 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 our target networks support the opcodes introduced in the `Shanghai` EVM upgrade.

#### Custom Networks

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/SafeWebAuthnSignerProxy.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
/* solhint-disable no-complex-fallback */
pragma solidity >=0.8.0;
pragma solidity ^0.8.20;

import {P256} from "./libraries/WebAuthn.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/SafeWebAuthnSignerSingleton.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.20;

import {SignatureValidator} from "./base/SignatureValidator.sol";
import {P256, WebAuthn} from "./libraries/WebAuthn.sol";
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/base/SignatureValidator.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.20;

import {ERC1271} from "../libraries/ERC1271.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/interfaces/IP256Verifier.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
/* solhint-disable payable-fallback */
pragma solidity ^0.8.0;
pragma solidity ^0.8.20;

/**
* @title P-256 Elliptic Curve Verifier.
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/interfaces/ISafe.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 <0.9.0;
pragma solidity ^0.8.20;

/**
* @title Safe Smart Account
Expand Down
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 <0.9.0;
pragma solidity ^0.8.20;

import {P256} from "../libraries/P256.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/libraries/ERC1271.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.20;

/**
* @title ERC-1271 Magic Values
Expand Down
4 changes: 2 additions & 2 deletions modules/passkey/contracts/libraries/P256.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.20;

import {IP256Verifier} from "../interfaces/IP256Verifier.sol";

Expand Down Expand Up @@ -116,7 +116,7 @@ library P256 {
mstore(add(input, 128), y)

// Perform staticcall and check result, note that Yul evaluates expressions from right
// to left. See <https://docs.soliditylang.org/en/v0.8.24/yul.html#function-calls>.
// to left. See <https://docs.soliditylang.org/en/v0.8.26/yul.html#function-calls>.
mstore(0, 0)
success := and(
and(
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/libraries/WebAuthn.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.20;

import {P256} from "./P256.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/test/Benchmarker.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.20;

contract Benchmarker {
function call(address to, bytes memory data) external returns (uint256 gas, bytes memory returnData) {
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/test/DummyP256Verifier.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.0;
pragma solidity ^0.8.20;

import {IP256Verifier} from "../interfaces/IP256Verifier.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/test/TestDependencies.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-only
/* solhint-disable no-global-import */
pragma solidity >=0.8.0;
pragma solidity ^0.8.20;

import "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import "@account-abstraction/contracts/samples/VerifyingPaymaster.sol";
Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/test/TestP256Lib.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.20;

import {IP256Verifier, P256} from "../libraries/P256.sol";

Expand Down
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.20;

import {SafeWebAuthnSharedSigner} from "../4337/SafeWebAuthnSharedSigner.sol";

Expand Down
2 changes: 1 addition & 1 deletion modules/passkey/contracts/test/TestWebAuthnLib.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.20;

import {P256, WebAuthn} from "../libraries/WebAuthn.sol";

Expand Down

0 comments on commit bb5e1f7

Please sign in to comment.