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

feat(contracts/avs): add AVS upgrade tests #2580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion contracts/avs/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ OmniAVS_canRegister_Test:test_canRegister_notAllowed() (gas: 225902)
OmniAVS_canRegister_Test:test_canRegister_notOperator() (gas: 120672)
OmniAVS_initialize_Test:test_initialize_defaultParams_succeeds() (gas: 3606316)
OmniAVS_syncWithOmni_Test:test_depositBeaconEth_succeeds() (gas: 638274)
OmniAVS_syncWithOmni_Test:test_unsupportedStrategyDeposit_succeeds() (gas: 1677678)
OmniAVS_syncWithOmni_Test:test_unsupportedStrategyDeposit_succeeds() (gas: 1677678)
OmniAVS_upgrade_Test:test_upgrade_invalidProxyOwner_reverts() (gas: 2698429)
OmniAVS_upgrade_Test:test_upgrade_succeeds() (gas: 2756363)
63 changes: 63 additions & 0 deletions contracts/avs/test/OmniAVS_upgrade.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity =0.8.12;

import { Base } from "./common/Base.sol";

import { OmniAVS } from "src/OmniAVS.sol";

import { IDelegationManager } from "src/ext/IDelegationManager.sol";
import { IAVSDirectory } from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

contract OmniAVS_upgrade_Test is Base {
function _checkAndHashState() internal view returns (bytes32) {
address _avsDirectory = omniAVS.avsDirectory();
uint32 _maxOperatorCount = omniAVS.maxOperatorCount();
uint64 _omniChainId = omniAVS.omniChainId();
uint64 _xcallGasLimitPerOperator = omniAVS.xcallGasLimitPerOperator();
uint64 _xcallBaseGasLimit = omniAVS.xcallBaseGasLimit();
uint96 _minOperatorStake = omniAVS.minOperatorStake();
bool _allowlistEnabled = omniAVS.allowlistEnabled();
address _ethStakeInbox = omniAVS.ethStakeInbox();
address _omni = address(omniAVS.omni());

return keccak256(
abi.encode(
_avsDirectory,
_maxOperatorCount,
_omniChainId,
_xcallGasLimitPerOperator,
_xcallBaseGasLimit,
_minOperatorStake,
_allowlistEnabled,
_ethStakeInbox,
_omni
)
);
}

function test_upgrade_succeeds() public {
address impl =
address(new OmniAVS(IDelegationManager(address(delegation)), IAVSDirectory(address(avsDirectory))));
ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(omniAVS));

bytes32 beforeUpgradeHash = _checkAndHashState();

vm.prank(proxyAdminOwner);
proxyAdmin.upgrade(proxy, impl);

bytes32 afterUpgradeHash = _checkAndHashState();

assertEq(proxyAdmin.getProxyImplementation(proxy), impl);
assertEq(beforeUpgradeHash, afterUpgradeHash);
}

function test_upgrade_invalidProxyOwner_reverts() public {
address impl =
address(new OmniAVS(IDelegationManager(address(delegation)), IAVSDirectory(address(avsDirectory))));
ITransparentUpgradeableProxy proxy = ITransparentUpgradeableProxy(address(omniAVS));

vm.expectRevert("Ownable: caller is not the owner");
proxyAdmin.upgrade(proxy, impl);
}
}
Loading