From 561e944504457b8a87448ecaaa9dc0d711df3412 Mon Sep 17 00:00:00 2001 From: seolaoh Date: Thu, 30 May 2024 16:54:00 +0900 Subject: [PATCH] chore: rename `assetMan` to `assetMgr` --- op-e2e/actions/l2_challenger_test.go | 10 +-- op-e2e/actions/l2_runtime.go | 18 ++-- .../contracts/test/AssetManager.t.sol | 2 +- .../contracts/contracts/test/CommonTest.t.sol | 12 +-- .../contracts/test/ValidatorManager.t.sol | 84 +++++++++---------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/op-e2e/actions/l2_challenger_test.go b/op-e2e/actions/l2_challenger_test.go index 455dbc955..6b3ef914e 100644 --- a/op-e2e/actions/l2_challenger_test.go +++ b/op-e2e/actions/l2_challenger_test.go @@ -147,7 +147,7 @@ interaction: require.NoError(rt.t, err) require.Equal(rt.t, val.StatusRegistered, valStatus) - afterAsset, err := rt.assetManContract.TotalKroAssets(nil, rt.validator.address) + afterAsset, err := rt.assetMgrContract.TotalKroAssets(nil, rt.validator.address) require.NoError(rt.t, err) require.Equal(rt.t, beforeAsset.Uint64()-slashingAmount.Uint64(), afterAsset.Uint64()) @@ -243,7 +243,7 @@ interaction: require.NoError(rt.t, err) require.Equal(rt.t, val.StatusRegistered, valStatus) - afterAsset, err := rt.assetManContract.TotalKroAssets(nil, rt.validator.address) + afterAsset, err := rt.assetMgrContract.TotalKroAssets(nil, rt.validator.address) require.NoError(rt.t, err) require.Equal(rt.t, beforeAsset.Uint64()-slashingAmount.Uint64(), afterAsset.Uint64()) @@ -337,7 +337,7 @@ interaction: require.NoError(rt.t, err) require.Equal(rt.t, val.StatusRegistered, valStatus) - afterAsset, err := rt.assetManContract.TotalKroAssets(nil, rt.challenger1.address) + afterAsset, err := rt.assetMgrContract.TotalKroAssets(nil, rt.challenger1.address) require.NoError(rt.t, err) require.Equal(rt.t, beforeAsset.Uint64()-slashingAmount.Uint64(), afterAsset.Uint64()) @@ -435,7 +435,7 @@ interaction: require.NoError(rt.t, err) require.Equal(rt.t, val.StatusRegistered, valStatus) - afterAsset, err := rt.assetManContract.TotalKroAssets(nil, rt.challenger1.address) + afterAsset, err := rt.assetMgrContract.TotalKroAssets(nil, rt.challenger1.address) require.NoError(rt.t, err) require.Equal(rt.t, beforeAsset.Uint64()-slashingAmount.Uint64(), afterAsset.Uint64()) @@ -659,7 +659,7 @@ interaction: require.NoError(rt.t, err) require.True(rt.t, inJail) - afterAsset, err := rt.assetManContract.TotalKroAssets(nil, rt.validator.address) + afterAsset, err := rt.assetMgrContract.TotalKroAssets(nil, rt.validator.address) require.NoError(rt.t, err) require.Equal(rt.t, beforeAsset.Uint64()-slashingAmount.Uint64(), afterAsset.Uint64()) diff --git a/op-e2e/actions/l2_runtime.go b/op-e2e/actions/l2_runtime.go index 512df0833..0f38b7c6f 100644 --- a/op-e2e/actions/l2_runtime.go +++ b/op-e2e/actions/l2_runtime.go @@ -53,7 +53,7 @@ type Runtime struct { securityCouncilContract *bindings.SecurityCouncil valPoolContract *bindings.ValidatorPoolCaller valMgrContract *bindings.ValidatorManagerCaller - assetManContract *bindings.AssetManagerCaller + assetMgrContract *bindings.AssetManagerCaller assetTokenContract *bindings.GovernanceTokenCaller targetInvalidBlockNumber uint64 outputIndex *big.Int @@ -175,10 +175,10 @@ func (rt *Runtime) bindContracts() { rt.valMgrContract, err = bindings.NewValidatorManagerCaller(rt.sd.DeploymentsL1.ValidatorManagerProxy, rt.miner.EthClient()) require.NoError(rt.t, err) - rt.assetManContract, err = bindings.NewAssetManagerCaller(rt.sd.DeploymentsL1.AssetManagerProxy, rt.miner.EthClient()) + rt.assetMgrContract, err = bindings.NewAssetManagerCaller(rt.sd.DeploymentsL1.AssetManagerProxy, rt.miner.EthClient()) require.NoError(rt.t, err) - assetTokenAddr, err := rt.assetManContract.ASSETTOKEN(nil) + assetTokenAddr, err := rt.assetMgrContract.ASSETTOKEN(nil) require.NoError(rt.t, err) rt.assetTokenContract, err = bindings.NewGovernanceTokenCaller(assetTokenAddr, rt.miner.EthClient()) require.NoError(rt.t, err) @@ -355,17 +355,17 @@ func (rt *Runtime) submitL2Output() { } func (rt *Runtime) fetchChallengeAssets(loser common.Address) (*big.Int, *big.Int, *big.Int) { - slashingRate, err := rt.assetManContract.SLASHINGRATE(nil) + slashingRate, err := rt.assetMgrContract.SLASHINGRATE(nil) require.NoError(rt.t, err) - slashingRateDenom, err := rt.assetManContract.SLASHINGRATEDENOM(nil) + slashingRateDenom, err := rt.assetMgrContract.SLASHINGRATEDENOM(nil) require.NoError(rt.t, err) - taxRate, err := rt.assetManContract.TAXNUMERATOR(nil) + taxRate, err := rt.assetMgrContract.TAXNUMERATOR(nil) require.NoError(rt.t, err) - taxDenom, err := rt.assetManContract.TAXDENOMINATOR(nil) + taxDenom, err := rt.assetMgrContract.TAXDENOMINATOR(nil) require.NoError(rt.t, err) - minSlashingAmount, err := rt.assetManContract.MINSLASHINGAMOUNT(nil) + minSlashingAmount, err := rt.assetMgrContract.MINSLASHINGAMOUNT(nil) require.NoError(rt.t, err) - totalAsset, err := rt.assetManContract.TotalKroAssets(nil, loser) + totalAsset, err := rt.assetMgrContract.TotalKroAssets(nil, loser) require.NoError(rt.t, err) slashingAmount := new(big.Int).Div(new(big.Int).Mul(totalAsset, slashingRate), slashingRateDenom) diff --git a/packages/contracts/contracts/test/AssetManager.t.sol b/packages/contracts/contracts/test/AssetManager.t.sol index 82de5a28e..50ff228fe 100644 --- a/packages/contracts/contracts/test/AssetManager.t.sol +++ b/packages/contracts/contracts/test/AssetManager.t.sol @@ -151,7 +151,7 @@ contract AssetManagerTest is ValidatorSystemUpgrade_Initializer { minSlashingAmount ); - address assetManagerAddr = address(assetMan); + address assetManagerAddr = address(assetMgr); vm.prank(multisig); Proxy(payable(assetManagerAddr)).upgradeTo(address(assetManagerImpl)); diff --git a/packages/contracts/contracts/test/CommonTest.t.sol b/packages/contracts/contracts/test/CommonTest.t.sol index 551cf75a8..03435fddf 100644 --- a/packages/contracts/contracts/test/CommonTest.t.sol +++ b/packages/contracts/contracts/test/CommonTest.t.sol @@ -205,7 +205,7 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { // Test target ValidatorPool pool; ValidatorPool poolImpl; - AssetManager assetMan; + AssetManager assetMgr; AssetManager assetManImpl; ValidatorManager valMgr; ValidatorManager valMgrImpl; @@ -291,8 +291,8 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { // Deploy proxies pool = ValidatorPool(address(new Proxy(multisig))); vm.label(address(pool), "ValidatorPool"); - assetMan = AssetManager(address(new Proxy(multisig))); - vm.label(address(assetMan), "AssetManager"); + assetMgr = AssetManager(address(new Proxy(multisig))); + vm.label(address(assetMgr), "AssetManager"); valMgr = ValidatorManager(address(new Proxy(multisig))); vm.label(address(valMgr), "ValidatorManager"); oracle = L2OutputOracle(address(new Proxy(multisig))); @@ -347,7 +347,7 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { // Deploy the ValidatorManager constructorParams = IValidatorManager.ConstructorParams({ _l2Oracle: oracle, - _assetManager: assetMan, + _assetManager: assetMgr, _trustedValidator: trusted, _commissionRateMinChangeSeconds: commissionRateMinChangeSeconds, _roundDurationSeconds: uint128(roundDuration), @@ -384,7 +384,7 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { ); vm.prank(multisig); - Proxy(payable(address(assetMan))).upgradeTo(address(assetManImpl)); + Proxy(payable(address(assetMgr))).upgradeTo(address(assetManImpl)); vm.prank(multisig); Proxy(payable(address(valMgr))).upgradeTo(address(valMgrImpl)); @@ -403,7 +403,7 @@ contract L2OutputOracle_Initializer is UpgradeGovernor_Initializer { function _registerValidator(address validator, uint128 assets) internal { vm.startPrank(validator); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); valMgr.registerValidator(assets, 10, 5); vm.stopPrank(); } diff --git a/packages/contracts/contracts/test/ValidatorManager.t.sol b/packages/contracts/contracts/test/ValidatorManager.t.sol index fa6340506..6bb233f8e 100644 --- a/packages/contracts/contracts/test/ValidatorManager.t.sol +++ b/packages/contracts/contracts/test/ValidatorManager.t.sol @@ -78,7 +78,7 @@ contract MockValidatorManager is ValidatorManager { contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { MockL2OutputOracle mockOracle; MockValidatorManager mockValMgr; - MockAssetManager mockAssetMan; + MockAssetManager mockAssetMgr; uint128 public VKRO_PER_KGH; event ValidatorRegistered( @@ -118,11 +118,11 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { for (uint256 i = startingTokenId; i < 100 + startingTokenId; i++) { kgh.mint(validator, i); vm.prank(validator); - kgh.approve(address(assetMan), i); + kgh.approve(address(assetMgr), i); tokenIds[i - startingTokenId] = i; } vm.prank(validator); - assetMan.delegateKghBatch(validator, tokenIds); + assetMgr.delegateKghBatch(validator, tokenIds); } function setUp() public override { @@ -149,8 +149,8 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { Proxy(payable(valMgrAddress)).upgradeTo(address(mockValMgrImpl)); mockValMgr = MockValidatorManager(valMgrAddress); - address assetManAddress = address(assetMan); - MockAssetManager mockAssetManImpl = new MockAssetManager( + address assetMgrAddress = address(assetMgr); + MockAssetManager mockAssetMgrImpl = new MockAssetManager( IERC20(assetToken), IERC721(kgh), IKGHManager(kghManager), @@ -161,10 +161,10 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { minSlashingAmount ); vm.prank(multisig); - Proxy(payable(assetManAddress)).upgradeTo(address(mockAssetManImpl)); - mockAssetMan = MockAssetManager(assetManAddress); + Proxy(payable(assetMgrAddress)).upgradeTo(address(mockAssetMgrImpl)); + mockAssetMgr = MockAssetManager(assetMgrAddress); - VKRO_PER_KGH = assetMan.VKRO_PER_KGH(); + VKRO_PER_KGH = assetMgr.VKRO_PER_KGH(); // Submit until terminateOutputIndex and set next output index to be finalized after it vm.prank(trusted); @@ -178,7 +178,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { function test_constructor_succeeds() external { assertEq(address(valMgr.L2_ORACLE()), address(oracle)); - assertEq(address(valMgr.ASSET_MANAGER()), address(assetMan)); + assertEq(address(valMgr.ASSET_MANAGER()), address(assetMgr)); assertEq(valMgr.TRUSTED_VALIDATOR(), trusted); assertEq(valMgr.MIN_REGISTER_AMOUNT(), minRegisterAmount); assertEq(valMgr.MIN_ACTIVATE_AMOUNT(), minActivateAmount); @@ -205,7 +205,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint8 commissionMaxChangeRate = 5; vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectEmit(true, false, false, true, address(valMgr)); emit ValidatorActivated(trusted, block.timestamp); vm.expectEmit(true, true, false, true, address(valMgr)); @@ -214,7 +214,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { vm.stopPrank(); assertEq(assetToken.balanceOf(trusted), trustedBalance - assets); - assertEq(assetMan.totalKroAssets(trusted), assets); + assertEq(assetMgr.totalKroAssets(trusted), assets); assertEq(valMgr.getCommissionRate(trusted), commissionRate); assertEq(valMgr.getCommissionMaxChangeRate(trusted), commissionMaxChangeRate); assertEq(mockValMgr.commissionRateChangedAt(trusted), block.timestamp); @@ -232,7 +232,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint8 commissionMaxChangeRate = 5; vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectEmit(true, true, false, true, address(valMgr)); emit ValidatorRegistered(trusted, false, commissionRate, commissionMaxChangeRate, assets); valMgr.registerValidator(assets, commissionRate, commissionMaxChangeRate); @@ -249,7 +249,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { _registerValidator(trusted, assets); vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectRevert(IValidatorManager.ImproperValidatorStatus.selector); valMgr.registerValidator(assets, 10, 5); } @@ -258,7 +258,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint128 assets = minRegisterAmount - 1; vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectRevert(IValidatorManager.InsufficientAsset.selector); valMgr.registerValidator(assets, 10, 5); } @@ -267,7 +267,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint128 assets = minRegisterAmount; vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectRevert(IValidatorManager.MaxCommissionRateExceeded.selector); valMgr.registerValidator(assets, 101, 5); } @@ -276,7 +276,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint128 assets = minRegisterAmount; vm.startPrank(trusted); - assetToken.approve(address(assetMan), uint256(assets)); + assetToken.approve(address(assetMgr), uint256(assets)); vm.expectRevert(IValidatorManager.MaxCommissionChangeRateExceeded.selector); valMgr.registerValidator(assets, 10, 101); } @@ -286,8 +286,8 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { _registerValidator(trusted, minActivateAmount - 1); vm.startPrank(asserter); - assetToken.approve(address(assetMan), 1); - assetMan.delegate(trusted, 1); + assetToken.approve(address(assetMgr), 1); + assetMgr.delegate(trusted, 1); vm.stopPrank(); assertTrue(valMgr.getStatus(trusted) == IValidatorManager.ValidatorStatus.READY); @@ -319,9 +319,9 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { function test_activateValidator_exited_reverts() external { _registerValidator(trusted, minActivateAmount); - uint128 kroShares = assetMan.getKroTotalShareBalance(trusted, trusted); + uint128 kroShares = assetMgr.getKroTotalShareBalance(trusted, trusted); vm.prank(trusted); - assetMan.initUndelegate(trusted, kroShares); + assetMgr.initUndelegate(trusted, kroShares); assertTrue(valMgr.getStatus(trusted) == IValidatorManager.ValidatorStatus.EXITED); @@ -334,15 +334,15 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { test_afterSubmitL2Output_tryJail_succeeds(); // Undelegate all assets of jailed validator - uint128 kroShares = assetMan.getKroTotalShareBalance(asserter, asserter); + uint128 kroShares = assetMgr.getKroTotalShareBalance(asserter, asserter); vm.prank(asserter); - assetMan.initUndelegate(asserter, kroShares); + assetMgr.initUndelegate(asserter, kroShares); assertTrue(valMgr.getStatus(asserter) == IValidatorManager.ValidatorStatus.EXITED); // Delegate to re-activate validator vm.startPrank(asserter); - assetToken.approve(address(assetMan), minActivateAmount); - assetMan.delegate(asserter, minActivateAmount); + assetToken.approve(address(assetMgr), minActivateAmount); + assetMgr.delegate(asserter, minActivateAmount); vm.stopPrank(); assertTrue(valMgr.getStatus(asserter) == IValidatorManager.ValidatorStatus.READY); @@ -366,7 +366,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { // Delegate 100 KGHs uint128 kghCounts = 100; _setUpHundredKghDelegation(trusted, 1); - assertEq(assetMan.totalKghNum(trusted), kghCounts); + assertEq(assetMgr.totalKghNum(trusted), kghCounts); // Submit the first output which interacts with ValidatorManager _submitL2OutputV2(false); @@ -395,12 +395,12 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { ); valMgr.afterSubmitL2Output(outputIndex); - uint128 kroReward = assetMan.totalKroAssets(trusted) - + uint128 kroReward = assetMgr.totalKroAssets(trusted) - minActivateAmount - kghCounts * VKRO_PER_KGH; vm.prank(trusted); - uint128 oneKghReward = mockAssetMan.convertToKghAssets(trusted, trusted, 1) - VKRO_PER_KGH; + uint128 oneKghReward = mockAssetMgr.convertToKghAssets(trusted, trusted, 1) - VKRO_PER_KGH; assertEq(kroReward, baseReward); assertEq(oneKghReward, boostedReward / kghCounts); @@ -576,9 +576,9 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { function test_changeCommissionRate_exited_reverts() external { _registerValidator(trusted, minActivateAmount); - uint128 kroShares = assetMan.getKroTotalShareBalance(trusted, trusted); + uint128 kroShares = assetMgr.getKroTotalShareBalance(trusted, trusted); vm.prank(trusted); - assetMan.initUndelegate(trusted, kroShares); + assetMgr.initUndelegate(trusted, kroShares); assertTrue(valMgr.getStatus(trusted) == IValidatorManager.ValidatorStatus.EXITED); @@ -703,8 +703,8 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { uint128 kghCounts = 100; _setUpHundredKghDelegation(asserter, 1); _setUpHundredKghDelegation(challenger, 1 + kghCounts); - assertEq(assetMan.totalKghNum(asserter), kghCounts); - assertEq(assetMan.totalKghNum(challenger), kghCounts); + assertEq(assetMgr.totalKghNum(asserter), kghCounts); + assertEq(assetMgr.totalKghNum(challenger), kghCounts); // Submit the first output which interacts with ValidatorManager mockValMgr.updatePriorityValidator(asserter); @@ -714,7 +714,7 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { // Suppose that the challenge is successful, so the winner is challenger uint128 slashingAmount = (minActivateAmount * slashingRate) / - assetMan.SLASHING_RATE_DENOM(); + assetMgr.SLASHING_RATE_DENOM(); vm.prank(address(colosseum)); vm.expectEmit(true, false, false, true, address(valMgr)); emit ValidatorStopped(asserter, block.timestamp); @@ -739,27 +739,27 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { vm.stopPrank(); // Asserter asset decreased by slashingAmount - uint128 asserterTotalKro = assetMan.totalKroAssets(asserter) - + uint128 asserterTotalKro = assetMgr.totalKroAssets(asserter) - kghCounts * kghManager.totalKroInKgh(1); assertEq(asserterTotalKro, minActivateAmount - slashingAmount); // Asserter has 0 rewards - assertEq(assetMan.reflectiveWeight(asserter), assetMan.totalKroAssets(asserter)); + assertEq(assetMgr.reflectiveWeight(asserter), assetMgr.totalKroAssets(asserter)); // Asserter removed from validator tree assertEq(valMgr.activatedValidatorCount(), count + 1); assertTrue(valMgr.getStatus(asserter) == IValidatorManager.ValidatorStatus.REGISTERED); // Security council balance of asset token increased by tax - uint128 taxAmount = (slashingAmount * assetMan.TAX_NUMERATOR()) / - assetMan.TAX_DENOMINATOR(); - assertEq(assetToken.balanceOf(assetMan.SECURITY_COUNCIL()), taxAmount); + uint128 taxAmount = (slashingAmount * assetMgr.TAX_NUMERATOR()) / + assetMgr.TAX_DENOMINATOR(); + assertEq(assetToken.balanceOf(assetMgr.SECURITY_COUNCIL()), taxAmount); // Challenger asset increased by output reward and challenge reward // Boosted reward with 100 kgh delegation uint128 boostedReward = 6283173600000736769; uint128 challengeReward = slashingAmount - taxAmount; - uint128 challengerAsset = assetMan.reflectiveWeight(challenger); + uint128 challengerAsset = assetMgr.reflectiveWeight(challenger); assertEq( challengerAsset, minActivateAmount + @@ -856,9 +856,9 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { _registerValidator(trusted, minActivateAmount); assertEq(valMgr.getWeight(trusted), minActivateAmount); - uint128 minUndelegateShares = assetMan.previewDelegate(trusted, 1); + uint128 minUndelegateShares = assetMgr.previewDelegate(trusted, 1); vm.prank(trusted); - assetMan.initUndelegate(trusted, minUndelegateShares); + assetMgr.initUndelegate(trusted, minUndelegateShares); assertTrue(valMgr.getStatus(trusted) == IValidatorManager.ValidatorStatus.REGISTERED); assertEq(valMgr.getWeight(trusted), 0); } @@ -879,8 +879,8 @@ contract ValidatorManagerTest is ValidatorSystemUpgrade_Initializer { count = valMgr.activatedValidatorCount(); totalWeight = valMgr.activatedValidatorTotalWeight(); vm.startPrank(challenger); - assetToken.approve(address(assetMan), 10); - assetMan.delegate(asserter, 10); + assetToken.approve(address(assetMgr), 10); + assetMgr.delegate(asserter, 10); vm.stopPrank(); assertEq(valMgr.activatedValidatorCount(), count); assertEq(valMgr.activatedValidatorTotalWeight(), totalWeight + 10);