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

Create2 deployment by script does not use create2 to deploy libraries #4810

Closed
2 tasks done
Flydexo opened this issue Apr 23, 2023 · 2 comments · Fixed by #7711
Closed
2 tasks done

Create2 deployment by script does not use create2 to deploy libraries #4810

Flydexo opened this issue Apr 23, 2023 · 2 comments · Fixed by #7711
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug

Comments

@Flydexo
Copy link

Flydexo commented Apr 23, 2023

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (c49e5e1 2023-04-09T00:16:17.106319000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

I have the following deployment script

// SPDX-License-Indetifier: SEE LICENSE IN LICENSE

pragma solidity ^0.8.18;

import "forge-std/Script.sol";
import "../src/core/PermissiveFactory.sol";
import "../src/core/PermissiveAccount.sol";
import "../src/core/FeeManager.sol";
import "account-abstraction/interfaces/IEntryPoint.sol";

contract DeployScript is Script {
    function run() external {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        address entrypoint = vm.envAddress("ENTRYPOINT");
        bytes32 versionSalt = vm.envBytes32("VERSION_SALT");
        vm.startBroadcast(deployerPrivateKey);
        FeeManager feeManager = new FeeManager{salt: versionSalt}();
        PermissiveFactory factory = new PermissiveFactory{salt: versionSalt}(
            IEntryPoint(entrypoint),
            feeManager,
            versionSalt
        );
        vm.stopBroadcast();
    }
}

And the PermissiveFactory deploys the PermissiveAccount with the following

constructor(IEntryPoint _entryPoint, FeeManager feeManager, bytes32 salt) {
        accountImplementation = new PermissiveAccount{salt: salt}(
            address(_entryPoint),
            payable(address(feeManager))
        );
    }

But the problem is the following, the PermissiveAccount uses libraries with the use A for B notation. So the libraries need to be deployed and linked to the contract.

using ECDSA for bytes32;
using BytesLib for bytes;

The problem is that forge deploys the libraries without create2 opcode so they are not deterministic and impact the address of the account so the factory.

Example of what it looks like in the explorer

Screenshot 2023-04-23 at 15 10 49

  1. The deployment of the libraries (single contract) without create2
  2. Deployment of the feeManager with create2
  3. Deployment of the Factory with create2
@Flydexo Flydexo added the T-bug Type: bug label Apr 23, 2023
@gakonst gakonst added this to Foundry Apr 23, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Apr 23, 2023
@mds1 mds1 added C-forge Command: forge Cmd-forge-script Command: forge script labels Apr 24, 2023
@Flydexo
Copy link
Author

Flydexo commented Apr 24, 2023

Fixed it, my library was a linked library (contained external functions) Just replaced them with internal and were deployed correctly.

@Flydexo
Copy link
Author

Flydexo commented Apr 24, 2023

The responsible was a homemade library and not ECDSA and BytesLib

@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants