Governance proxy addresses mismatch

Hi,
I'm deploying this contracts with foundry in goerli network (https://github.com/NewfundametalsDAO/FrankenDAO), but I've the error:

Governance proxy addresses mismatch

/ SPDX-License-Identifier: UNLICENSED
 pragma solidity ^0.8.13;

import { Script } from "forge-std/Script.sol";
import "forge-std/Test.sol";

import { GovernanceProxy } from "src/proxy/GovernanceProxy.sol";
import { Executor } from "src/Executor.sol";
import { Staking } from "src/Staking.sol";
import { Governance } from "src/Governance.sol";

contract DeployScript is Script {
    Executor executor;
    Staking staking;
    Governance govImpl;
    Governance gov;

    address DEPLOY_WALLET = address(0); // @todo input for mainnet deployment
    address CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C;

    address FOUNDER_MULTISIG;
    address FOUNDER_MULTISIG_MAINNET = address(0); // @todo input for mainnet deployment
    address FOUNDER_MULTISIG_GOERLI = 0x1f3958B482d1Ff1660CEE66F8341Bdc1329De4e0; // z
    
    address COUNCIL_MULTISIG;
    address COUNCIL_MULTISIG_MAINNET = address(0); // @todo input for mainnet deployment
    address COUNCIL_MULTISIG_GOERLI = 0x20643627A2d02F520A006dF56Acc51E3e67E3Ee5; // dobs
    
    address FRANKENPUNKS;
    address FRANKENPUNKS_GOERLI = 0x75Ad4CeCB95b330890A93993a2A5A91d8e5D2f03; 
    address FRANKENPUNKS_MAINNET = 0x1FEC856e25F757FeD06eB90548B0224E91095738;

    address FRANKENMONSTERS;
    address FRANKENMONSTERS_GOERLI = 0xaFC74C56264824d92303072C5DB23c04ACa78D81;
    address FRANKENMONSTERS_MAINNET = 0x2cfBCB9e9C3D1ab06eF332f535266444aa8d9570;
    
    bytes32 SALT = bytes32("saltysalty");
    string BASE_TOKEN_URI = "http://frankenpunks.com/uris/"; // @todo input for mainnet deployment
    string CONTRACT_URI = "http://frankenpunks.com/uris/"; // @todo input for mainnet deployment

    function run() public {
        vm.startBroadcast(vm.envUint("PRIVATE_KEY"));
        
        _deployAllContracts(true, false); // @todo edit for mainnet deployment
        
        console.log("executor deployed to: ", address(executor));
        console.log("govImpl deployed to: ", address(govImpl));
        console.log("govProxy deployed to: ", address(gov));
        console.log("staking deployed to: ", address(staking));

        payable(address(gov)).transfer(0.5 ether);
        payable(address(staking)).transfer(0.5 ether);

        vm.stopBroadcast();
    }

    function _deployAllContracts(bool realDeploy, bool mainnet) internal {

        address create2Deployer = realDeploy ? CREATE2_DEPLOYER : address(this);
        address deployer = realDeploy ? DEPLOY_WALLET : address(this);

        FRANKENPUNKS = mainnet ? FRANKENPUNKS_MAINNET : FRANKENPUNKS_GOERLI;
        FRANKENMONSTERS = mainnet ? FRANKENMONSTERS_MAINNET : FRANKENMONSTERS_GOERLI;
        FOUNDER_MULTISIG = mainnet ? FOUNDER_MULTISIG_MAINNET : FOUNDER_MULTISIG_GOERLI;
        COUNCIL_MULTISIG = mainnet ? COUNCIL_MULTISIG_MAINNET : COUNCIL_MULTISIG_GOERLI;

        bytes memory proxyCreationCode = abi.encodePacked(
            type(GovernanceProxy).creationCode,
            abi.encode(FRANKENPUNKS, deployer, bytes(""))
        );

        address expectedGovProxyAddr = address(uint160(uint256(keccak256(
            abi.encodePacked(bytes1(0xff), create2Deployer, SALT, keccak256(proxyCreationCode))
        ))));
        
        // create executor
        executor = new Executor(expectedGovProxyAddr);

        // create staking 
        staking = new Staking(
            FRANKENPUNKS,
            FRANKENMONSTERS,
            expectedGovProxyAddr,
            address(executor),
            FOUNDER_MULTISIG,
            COUNCIL_MULTISIG,
            BASE_TOKEN_URI,
            CONTRACT_URI
        );

        // create governance (no need to initialize because nothing vulnerable in implementation)
        govImpl = new Governance();

        // create governance proxy and initialize
        gov = Governance(payable(address(new GovernanceProxy{salt:SALT}(FRANKENPUNKS, deployer, bytes("")))));
        require(address(gov) == expectedGovProxyAddr, "governance proxy address mismatch");

        (bool upgradeSuccess, bytes memory uR) = address(gov).call
            (abi.encodeWithSignature(
                "upgradeToAndCall(address,bytes)",
                address(govImpl),
                abi.encodeWithSignature(
                    "initialize(address,address,address,address,uint256,uint256,uint256,uint256)",
                    address(staking),
                    address(executor),
                    FOUNDER_MULTISIG,
                    COUNCIL_MULTISIG,
                    7 days, // Voting Period
                    1 days, // Voting Delay
                    500, // Proposal BPS: 5%
                    2000 // Quorum BPS: 20%
                )
            )
        );
        require(upgradeSuccess, "proxy upgrade failed");

        (bool changeAdminSuccess, ) = address(gov).call(
            abi.encodeWithSignature(
                "changeAdmin(address)",
                (address(executor))
            )
        );
        require(changeAdminSuccess, "proxy admin change failed");
    }

    // Harness so we can use the same script for testing.
    function deployAllContractsForTesting() public {
        return _deployAllContracts(false, true);
    }
}

Please post all the relevant code (and only the relevant code) in plain text.

Please include the procedure which results with this error (presumably, an offchain script which interacts with your contract).

Create2deployer and deployer I put same address, but gov and expectedGovProxyAddress in console.log when deploy is different I dont understand

Code please, or by the least a proper description, step-by-step, of the functions that you execute and the input that you pass to each one of them.

 address DEPLOY_WALLET =0xb984e387F84c79e1Adc08F9F0E0A7D88dDE192ff;
 address CREATE2_DEPLOYER = 0xb984e387F84c79e1Adc08F9F0E0A7D88dDE192ff;

In console:

forge script script/Deploy.s.sol:DeployScript --fork-url goerli --broadcast --verify -vvvvv

Result:

    address expectedGovProxyAddr = address(uint160(uint256(keccak256(
            abi.encodePacked(bytes1(0xff), create2Deployer, SALT, keccak256(proxyCreationCode))
        ))));

        // create governance proxy and initialize
        gov = Governance(payable(address(new GovernanceProxy{salt:SALT}(FRANKENPUNKS, deployer, bytes("")))));

        console.logAddress(address(gov));
        console.logAddress(expectedGovProxyAddr);
        
        require(address(gov) == expectedGovProxyAddr, "governance proxy address mismatch");
Traces:
  [9418108] → new DeployScript@0x5b73C5498c1E3b4dbA84de0F1833c4a029d90519
    └─ ← 45784 bytes of code

  [9196538] DeployScript::run() 
    ├─ [0] VM::envUint(PRIVATE_KEY) [staticcall]
    │   └─ ← <env var value>
    ├─ [0] VM::startBroadcast(<pk>)
    │   └─ ← ()
    ├─ [471235] → new Executor@0x1A171B3b36b237561470B19CA9AcC0DE0F341D8B
    │   └─ ← 2242 bytes of code
    ├─ [4230623] → new Staking@0xf9Af02eE8f3560055022215842653Df38C119239
    │   └─ ← 15233 bytes of code
    ├─ [3720796] → new Governance@0xA6c4e72AecAE29048413c0BcC20643efB1934250
    │   └─ ← 18583 bytes of code
    ├─ [442684] → new GovernanceProxy@0xf924aA28B0bd24a45E6cdd948084a095d3743738
    │   ├─ emit Upgraded(implementation: 0x91EDD116983A6dE70ab739584595811eD29Eb3e5)
    │   ├─ emit AdminChanged(previousAdmin: 0x0000000000000000000000000000000000000000, newAdmin: 0xb984e387F84c79e1Adc08F9F0E0A7D88dDE192ff)
    │   └─ ← 1958 bytes of code
    ├─ [0] console::log(GovernanceProxy: [0xf924aA28B0bd24a45E6cdd948084a095d3743738]) [staticcall]
    │   └─ ← ()
    ├─ [0] console::log(0xF5fea2504c6e1A513920fE2B67B125cDCF013a10) [staticcall]
    │   └─ ← ()
    └─ ← "governance proxy address mismatch"



== Logs ==
  0xf924aA28B0bd24a45E6cdd948084a095d3743738
  0xF5fea2504c6e1A513920fE2B67B125cDCF013a10
Error: 
governance proxy address mismatch

The value of create2Deployer here must be the address of the actual deployer, which is the current contract of course.

In other words, in order to predict the address that your new GovernanceProxy is going to be deployed at, you need to use address(this).

Ok it works with this configuration:

    address DEPLOY_WALLET = 0xb984e387F84c79e1Adc08F9F0E0A7D88dDE192ff; // my wallet
    address CREATE2_DEPLOYER = 0x4e59b44847b379578588920cA78FbF26c0B4956C; 

but the CREATE2_DEPLOYER address I dont understand what type of contract is.

The address of the deployer of the GovernanceProxy instance.

In other words, the address of the contract which executes new GovernanceProxy(...).