Changing the proxyAdmin contract so that I can deploy a forked version of a repo

Hi there, I'm looking to deploy a forked version of the Venus repo, but it seems that it keeps reverting to an old proxyAdmin contract (that I'm obviously not the owner of). How can I force my deployment to deploy a new proxyAdmin contract?

Hi, can you please elaborate on what you are trying to do? See How do I ask a good question?

What version of OpenZeppelin Contracts are you using? How are you doing deployments? Are you using Hardhat or Foundry with Upgrades Plugins?

Hi Eric,
Thanks for the reply. I'm using hardhat to deploy, with Upgrades Plugins I think.
This is the deploy script:

import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { getConfig } from "../helpers/deploymentConfig";
import { toAddress } from "../helpers/deploymentUtils";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
  const { deployments, getNamedAccounts } = hre;
  const { deploy } = deployments;
  const { deployer } = await getNamedAccounts();
  const { preconfiguredAddresses } = await getConfig(hre.network.name);

  const accessControlManagerAddress = await toAddress(
    preconfiguredAddresses.AccessControlManager || "AccessControlManager",
    hre,
  );
  
  const proxyOwnerAddress = await toAddress(preconfiguredAddresses.NormalTimelock || "account:deployer", hre);

  await deploy("PoolRegistry", {
    from: deployer,
    contract: "PoolRegistry",
    proxy: {
      owner: proxyOwnerAddress,
      proxyContract: "OpenZeppelinTransparentProxy",
      execute: {
        methodName: "initialize",
        args: [accessControlManagerAddress],
      },
      upgradeIndex: 0,
    },
    autoMine: true,
    log: true,
  });
};

func.tags = ["PoolRegistry", "il"];

export default func;

I am deploying a fork of the Venus repo, on the Sepolia network. It seems that this repo has previously been deployed on this chain, so the deployment is reverting to an old DefaultProxyAdmin contract that I don't own:

reusing "DefaultProxyAdmin" at 0x01435866babd91311b1355cf3af488cca36db68e

I can see the place inside the helpers.ts script in hardhat-deploy where it checks for an existing DefaultProxyAdmin contract, and then reuses one if it does exist. I'd like to change this behaviour from my deploy script so that it rather deploys a new DefaultProxyAdmin contract that I own.

Thanks for the information. Since you are deploying with hardhat-deploy, you may need to get support from https://github.com/wighawag/hardhat-deploy as that plugin is not developed by OpenZeppelin.

Hi Eric,
Thanks for coming back to me - I passed this on to @alcuadrado on the hardhat-deploy channel on discord. He came back to me with this: i'd recommend posting in open zeppelin's forums as that's specific to them
I tend to agree with you that it's a hardhat-deploy issue, as the code that 're-uses' the proxyAdmin is within helpers.ts within the hardhat-deploy node module.
However, I am feeling a little bit stuck as this kind of falls between both hardhat and oz. Could you perhaps answer just the part of the question that relates to OZ? If we leave hardhat out of it, is it possible to deploy a proxy and specify that it should deploy a new proxyAdmin contract rather than re-use an old one?
I can then feed this back to @alcuadrado.
Many thanks!

@RichJamo Sorry for the confusion, I was specifically referring to the hardhat-deploy project (github link above) which is a third-party plugin, which is neither maintained by Hardhat or OpenZeppelin.

Regarding usage of proxy admins in general, it depends if the proxy code is from OpenZeppelin Contracts v5 or v4.

When deploying a transparent proxy from OpenZeppelin Contracts v5, the transparent proxy's constructor always deploys a new ProxyAdmin. See https://docs.openzeppelin.com/contracts/5.x/api/proxy#TransparentUpgradeableProxy

When deploying a transparent proxy from OpenZeppelin Contracts v4, the transparent proxy's constructor allows you to pass in the address of any ProxyAdmin. See https://docs.openzeppelin.com/contracts/4.x/api/proxy#TransparentUpgradeableProxy. This could be a previously deployed ProxyAdmin, or you could deploy a new ProxyAdmin and then pass that address in to the transparent proxy's constructor.