Skip to content

Commit

Permalink
chore(contracts): add create3 compatible proxy admin (#613)
Browse files Browse the repository at this point in the history
Allow setting owner in ProxyAdmin constructor.

To be able to deploy a ProxyAdmin via Create3 factory, we 
need to be able to specify the owner in the constructor. 

task: https://app.asana.com/0/1206208509925075/1206874791954734
  • Loading branch information
kevinhalliday authored Mar 20, 2024
1 parent ee0def4 commit 1dbdd48
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
11 changes: 9 additions & 2 deletions contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ version: ## Print tool versions.
build: version ## Build contracts.
forge build



CONTRACTS := OmniPortal FeeOracleV1 OmniAVS OmniStake Create3 TransparentUpgradeableProxy \
DelegationManager StrategyManager StrategyBase AVSDirectory \
src/deploy/ProxyAdmin.sol:ProxyAdmin \
test/avs/common/MockERC20.sol:MockERC20

.PHONY: bindings
bindings: check-abigen-version build ## Generate golang contract bindings.
./bindings/scripts/gen.sh OmniPortal FeeOracleV1 OmniAVS OmniStake Create3 TransparentUpgradeableProxy ProxyAdmin DelegationManager StrategyManager StrategyBase AVSDirectory test/avs/common/MockERC20.sol:MockERC20
./bindings/scripts/genmore.sh OmniStake
./bindings/scripts/gen.sh $(CONTRACTS)
./bindings/scripts/genmore.sh OmniStake # Need OmniStake deployedBytecode
go run ./bindings/scripts/commenttypes.go -- bindings/strategymanager.go IStrategyManagerDeprecatedStructQueuedWithdrawal IStrategyManagerDeprecatedStructWithdrawerAndNonce
go run ./bindings/scripts/commenttypes.go -- bindings/avsdirectory.go ISignatureUtilsSignatureWithSaltAndExpiry

Expand Down
2 changes: 1 addition & 1 deletion contracts/bindings/mockerc20.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions contracts/bindings/proxyadmin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions contracts/src/deploy/ProxyAdmin.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.12;

import { ProxyAdmin as OZProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";

/**
* @title ProxyAdmin
* @notice Wrapper around OpenZeppelin's ProxyAdmin that allows for setting the owner on deployment.
* @dev This allows us to use Create3 to deploy
*/
contract ProxyAdmin is OZProxyAdmin {
constructor(address owner) OZProxyAdmin() {
_transferOwnership(owner);
}
}
11 changes: 4 additions & 7 deletions contracts/test/portal/common/Fixtures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity =0.8.24;

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { ProxyAdmin } from "src/deploy/ProxyAdmin.sol";
import { XTypes } from "src/libraries/XTypes.sol";
import { FeeOracleV1 } from "src/protocol/FeeOracleV1.sol";
import { OmniPortal } from "src/protocol/OmniPortal.sol";
Expand Down Expand Up @@ -322,8 +322,7 @@ contract Fixtures is CommonBase, StdCheats {

vm.chainId(thisChainId); // portal constructor uses block.chainid

proxyAdmin = new ProxyAdmin();
proxyAdmin.transferOwnership(owner);
proxyAdmin = new ProxyAdmin(owner);

feeOracleImpl = new FeeOracleV1();
feeOracle = FeeOracleV1(
Expand Down Expand Up @@ -356,8 +355,7 @@ contract Fixtures is CommonBase, StdCheats {

vm.chainId(chainAId);

chainAProxyAdmin = new ProxyAdmin();
chainAProxyAdmin.transferOwnership(owner);
chainAProxyAdmin = new ProxyAdmin(owner);

chainAfeeOracleImpl = new FeeOracleV1();
chainAFeeOracle = FeeOracleV1(
Expand Down Expand Up @@ -390,8 +388,7 @@ contract Fixtures is CommonBase, StdCheats {

vm.chainId(chainBId);

chainBProxyAdmin = new ProxyAdmin();
chainBProxyAdmin.transferOwnership(owner);
chainBProxyAdmin = new ProxyAdmin(owner);

chainBfeeOracleImpl = new FeeOracleV1();
chainBFeeOracle = FeeOracleV1(
Expand Down
9 changes: 4 additions & 5 deletions e2e/netman/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func deployOmniContracts(ctx context.Context, txOpts *bind.TransactOpts, backend
owner := txOpts.From
fee := new(big.Int).SetUint64(params.GWei)

proxyAdmin, err := DeployProxyAdmin(ctx, txOpts, backend)
proxyAdmin, err := DeployProxyAdmin(ctx, txOpts, backend, owner)
if err != nil {
return common.Address{}, nil, errors.Wrap(err, "deploy proxy admin")
}
Expand All @@ -49,10 +49,9 @@ func deployOmniContracts(ctx context.Context, txOpts *bind.TransactOpts, backend
return portal, contract, nil
}

func DeployProxyAdmin(ctx context.Context, txOpts *bind.TransactOpts, backend *ethbackend.Backend) (
common.Address, error,
) {
proxyAdmin, tx, _, err := bindings.DeployProxyAdmin(txOpts, backend)
func DeployProxyAdmin(ctx context.Context, txOpts *bind.TransactOpts, backend *ethbackend.Backend, owner common.Address,
) (common.Address, error) {
proxyAdmin, tx, _, err := bindings.DeployProxyAdmin(txOpts, backend, owner)
if err != nil {
return common.Address{}, errors.Wrap(err, "deploy proxy admin")
}
Expand Down
2 changes: 1 addition & 1 deletion lib/avs/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (d *Deployer) Deploy(ctx context.Context, backend *ethbackend.Backend, owne
}

// TODO: use same proxy admin for portal & avs on same chain
proxyAdmin, err := netman.DeployProxyAdmin(ctx, txOpts, backend)
proxyAdmin, err := netman.DeployProxyAdmin(ctx, txOpts, backend, owner)
if err != nil {
return errors.Wrap(err, "deploy proxy admin")
}
Expand Down

0 comments on commit 1dbdd48

Please sign in to comment.