Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Safe BLS module #54

Merged
merged 5 commits into from
Aug 29, 2023
Merged

Safe BLS module #54

merged 5 commits into from
Aug 29, 2023

Conversation

blakecduncan
Copy link
Contributor

@blakecduncan blakecduncan commented Aug 25, 2023

Blocked by: #52

Adding a Safe module that uses BLS sigs to verify a transaction. I added a hardhat test that submits a userOp to the entrypoint directly. This way we don't need to run a bundler or start a node to test a module.

I'm wondering if we should reorganize our test directory. Right now we have three forms of tests.

  • hardhat test - all you need is yarn hardhat test and the tests should work. Hardhat tests are useful for verification types that are hard/not possible in solidity.
  • Integration test - Need to run a bundler and a node separately for the tests to pass.
  • Forge tests - just need forge test, and tests are written in solidity.

Should rename/organise these differently? For example, the two ideas I have are:

  • test/hardhat
  • test/forge
  • test/integration

or

  • test/hardhat
  • test/hardhat/integration (since the integration tests use hardhat)
  • test/forge

Base automatically changed from 28-add-initial-forge-test-for-webauthn-verification to main August 25, 2023 16:30
Copy link
Contributor

@JohnGuilding JohnGuilding left a comment

Choose a reason for hiding this comment

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

Looks good - Approving!

Left a few Qs

@@ -0,0 +1,101 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
pragma abicoder v2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seen that this is included in the SafeECDSAPlugin too. I believe abicoder was defaulted to v2 as of solidity 0.8.0. I think it makes sense here and in the ECDSA plugin as we're using solidity>=0.7.0. Curious if we want to keep supporting versions of solidity less than 0.8.0? Open question don't really have a strong opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry just getting around to these comments. Yeah, I don't have a preference either. I haven't really done a deep dive to know if it's still necessary to support the older versions

UserOperation calldata userOp,
bytes32 userOpHash
) internal view override returns (uint256 validationData) {
require(userOp.signature.length == 64, "VG: Sig bytes length must be 64");
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about custom errors as opposed to require statements with strings? https://soliditylang.org/blog/2021/04/21/custom-errors/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, I'll make the update

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we are importing 4337 contracts, should we rename this to something more generic? Maybe something like TypesHelper?

import { ethers } from "hardhat";
import { expect } from "chai";
import { AddressZero } from "@ethersproject/constants";
import { utils } from "ethers-v5";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need ethers-v5 here instead of v6?

userWallet,
entryPoint,
safe,
safeProxyFactory,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're creating a safeProxyFactory variable and others before the describe block and then assigning to them, is there a reason to return them in this function as well?

@JohnGuilding JohnGuilding merged commit 5a98d15 into main Aug 29, 2023
@JohnGuilding JohnGuilding deleted the safe-bls-module branch August 29, 2023 09:46
@blakecduncan blakecduncan mentioned this pull request Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants