diff --git a/packages/contracts/contracts/test/AssetManager.t.sol b/packages/contracts/contracts/test/AssetManager.t.sol index c0a06a3ac..5742ce3e4 100644 --- a/packages/contracts/contracts/test/AssetManager.t.sol +++ b/packages/contracts/contracts/test/AssetManager.t.sol @@ -12,7 +12,6 @@ import { Uint128Math } from "../libraries/Uint128Math.sol"; import { AssetManager } from "../L1/AssetManager.sol"; import { IAssetManager } from "../L1/interfaces/IAssetManager.sol"; import { IValidatorManager } from "../L1/interfaces/IValidatorManager.sol"; -import { IKGHManager } from "../universal/IKGHManager.sol"; import { Proxy } from "../universal/Proxy.sol"; import { ValidatorSystemUpgrade_Initializer } from "./CommonTest.t.sol"; import { MockL2OutputOracle } from "./ValidatorManager.t.sol"; @@ -29,22 +28,20 @@ contract MockAssetManager is AssetManager { constructor( IERC20 _assetToken, IERC721 _kgh, - IKGHManager _kghManager, address _securityCouncil, + address _validatorRewardVault, IValidatorManager _validatorManager, - uint128 _undelegationPeriod, - uint128 _slashingRate, - uint128 _minSlashingAmount + uint128 _minDelegationPeriod, + uint128 _bondAmount ) AssetManager( _assetToken, _kgh, - _kghManager, _securityCouncil, + _validatorRewardVault, _validatorManager, - _undelegationPeriod, - _slashingRate, - _minSlashingAmount + _minDelegationPeriod, + _bondAmount ) {} diff --git a/packages/contracts/contracts/test/CommonTest.t.sol b/packages/contracts/contracts/test/CommonTest.t.sol index 35bc98413..a7cb92d83 100644 --- a/packages/contracts/contracts/test/CommonTest.t.sol +++ b/packages/contracts/contracts/test/CommonTest.t.sol @@ -36,7 +36,6 @@ import { CodeDeployer } from "../libraries/CodeDeployer.sol"; import { Constants } from "../libraries/Constants.sol"; import { Predeploys } from "../libraries/Predeploys.sol"; import { Types } from "../libraries/Types.sol"; -import { IKGHManager } from "../universal/IKGHManager.sol"; import { KromaMintableERC20 } from "../universal/KromaMintableERC20.sol"; import { KromaMintableERC20Factory } from "../universal/KromaMintableERC20Factory.sol"; import { Proxy } from "../universal/Proxy.sol"; @@ -195,12 +194,6 @@ contract MockKgh is ERC721 { } } -contract MockKghManager is IKGHManager { - function totalKroInKgh(uint256 /* tokenId */) external pure override returns (uint128) { - return 100e18; - } -} - contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { // Test target ValidatorPool pool; @@ -236,14 +229,14 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { // AssetManager constructor arguments MockKro assetToken; MockKgh kgh; - MockKghManager kghManager; - uint256 internal undelegationPeriod = 7 days; - uint128 internal slashingRate = 20; - uint128 internal minSlashingAmount = 1e18; + address internal validatorRewardVault = makeAddr("validatorRewardVault"); + uint128 internal minDelegationPeriod = 7 days; + uint128 internal bondAmount = 10e18; // ValidatorManager constructor arguments uint128 internal commissionChangeDelaySeconds = 7 days; - uint128 internal jailPeriodSeconds = 7 days; + uint128 internal softJailPeriodSeconds = 3 days; + uint128 internal hardJailPeriodSeconds = 7 days; uint128 internal jailThreshold = 2; uint128 internal maxOutputFinalizations = 10; uint128 internal baseReward = 20e18; @@ -279,10 +272,11 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { assetToken.mint(trusted, minActivateAmount * 10); assetToken.mint(asserter, minActivateAmount * 10); assetToken.mint(challenger, minActivateAmount * 10); + // Set up validatorRewardVault + assetToken.mint(validatorRewardVault, baseReward * 1000); - // Set up KGH and KGHManager + // Set up KGH kgh = new MockKgh(); - kghManager = new MockKghManager(); // Give actors some ETH vm.deal(trusted, requiredBondAmount * 10); @@ -299,6 +293,10 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { oracle = L2OutputOracle(address(new Proxy(multisig))); vm.label(address(oracle), "L2OutputOracle"); + // Allow AssetManager contract can get asset token from validatorRewardVault + vm.prank(validatorRewardVault); + assetToken.approve(address(assetMgr), baseReward * 1000); + ResourceMetering.ResourceConfig memory config = Constants.DEFAULT_RESOURCE_CONFIG(); systemConfig = new SystemConfig({ _owner: address(1), @@ -337,12 +335,11 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { assetManImpl = new AssetManager({ _assetToken: IERC20(assetToken), _kgh: IERC721(kgh), - _kghManager: IKGHManager(kghManager), _securityCouncil: guardian, + _validatorRewardVault: validatorRewardVault, _validatorManager: valMgr, - _undelegationPeriod: uint128(undelegationPeriod), - _slashingRate: slashingRate, - _minSlashingAmount: minSlashingAmount + _minDelegationPeriod: minDelegationPeriod, + _bondAmount: bondAmount }); // Deploy the ValidatorManager @@ -352,7 +349,8 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { _trustedValidator: trusted, _commissionChangeDelaySeconds: commissionChangeDelaySeconds, _roundDurationSeconds: uint128(roundDuration), - _jailPeriodSeconds: jailPeriodSeconds, + _softJailPeriodSeconds: softJailPeriodSeconds, + _hardJailPeriodSeconds: hardJailPeriodSeconds, _jailThreshold: jailThreshold, _maxOutputFinalizations: maxOutputFinalizations, _baseReward: baseReward, diff --git a/packages/contracts/contracts/test/ValidatorManager.t.sol b/packages/contracts/contracts/test/ValidatorManager.t.sol index e12148726..817f9a44d 100644 --- a/packages/contracts/contracts/test/ValidatorManager.t.sol +++ b/packages/contracts/contracts/test/ValidatorManager.t.sol @@ -8,7 +8,6 @@ import { Constants } from "../libraries/Constants.sol"; import { Types } from "../libraries/Types.sol"; import { Proxy } from "../universal/Proxy.sol"; import { IValidatorManager } from "../L1/interfaces/IValidatorManager.sol"; -import { IKGHManager } from "../universal/IKGHManager.sol"; import { L2OutputOracle } from "../L1/L2OutputOracle.sol"; import { ValidatorManager } from "../L1/ValidatorManager.sol"; import { ValidatorPool } from "../L1/ValidatorPool.sol"; @@ -154,12 +153,11 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { MockAssetManager mockAssetMgrImpl = new MockAssetManager( IERC20(assetToken), IERC721(kgh), - IKGHManager(kghManager), guardian, + validatorRewardVault, valMgr, - uint128(undelegationPeriod), - slashingRate, - minSlashingAmount + minDelegationPeriod, + bondAmount ); vm.prank(multisig); Proxy(payable(assetMgrAddress)).upgradeTo(address(mockAssetMgrImpl));