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: implement KRO-based validator system #374

Merged
merged 81 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
bcafeda
feat(contracts): add arctangent library
sm-stack Mar 8, 2024
7bc46e5
feat(contracts): add AssetManager contract
sm-stack Mar 8, 2024
34a2700
feat(contracts): add interface for KGHManager contract
sm-stack Mar 8, 2024
15e0c7f
feat(contracts): add test codes for AssetManager
sm-stack Mar 8, 2024
cef7a30
feat(contracts): add Uint128Math library
sm-stack Mar 11, 2024
a726010
feat(contracts): add balanced weight tree library
seolaoh Mar 11, 2024
1c9e2ad
fix(contracts): check correct minimum timestamp for next output submi…
seolaoh Feb 28, 2024
62c9912
feat(contracts): add `ValidatorManager` contract and refac `AssetMana…
seolaoh Mar 29, 2024
0cb9f85
feat(contracts): handle validator system upgrade in `L2OutputOracle`
seolaoh Mar 18, 2024
208cd2a
feat(chain-ops): apply changes with `AssetManager` and `ValidatorMana…
seolaoh Mar 27, 2024
0108d07
chore(contracts): update bindings and snapshots
seolaoh Mar 29, 2024
c39f2da
feat(contracts): apply PR reviews
seolaoh Apr 18, 2024
a96e0a2
feat(contracts): upgrade validator system in `Colosseum`
seolaoh Apr 17, 2024
dbed8b6
refac(contracts): replace all errors with custom error in `Colosseum`
seolaoh Apr 17, 2024
1a693d3
feat(contracts): send the challenge loser to jail when slashing
seolaoh Apr 18, 2024
0d94687
refac(contracts): move interfaces to separate folder
seolaoh Apr 18, 2024
85f26e8
refac(contracts): add `IAssetManager`
seolaoh Apr 18, 2024
d30a495
test(contracts): modify tests related to slashing
seolaoh Apr 19, 2024
edf7208
test(contracts): add tests for validator system upgrade in `Colosseum`
seolaoh Apr 21, 2024
9d1bfff
chore(contracts): update bindings and snapshots
seolaoh Apr 21, 2024
16802c3
feat(contracts): apply PR reviews
seolaoh Apr 23, 2024
2511cbc
feat(validator): add logics for new validator system
sm-stack Apr 2, 2024
852e5b8
feat(e2e): add action tests for new validator system
sm-stack Apr 2, 2024
0c05940
chore: set required flags for devnet
sm-stack Apr 17, 2024
02d5012
fix(validator): add real-time update logic for terminate index of Val…
sm-stack Apr 21, 2024
333f513
fix(contracts): fix ValidatorPool to check termination by index
sm-stack Apr 22, 2024
95665a2
fix(validator): remove inJail status in the validator client
sm-stack Apr 22, 2024
8169f41
feat(validator): apply PR Reviews
sm-stack Apr 23, 2024
85c9784
feat(validator): add subcommands for the new validator system
sm-stack Apr 17, 2024
845b217
feat(validator): add flags used in subcommands
sm-stack Apr 23, 2024
8a5d782
docs(validator): add README for subcommands
sm-stack Apr 24, 2024
a5a8009
feat(validator): add PR reviews
sm-stack Apr 24, 2024
7142220
fix(validator): fix subcommand related changes
seolaoh May 2, 2024
6bfa308
test(validator): redeploy `ValidatorPool` to test `ValidatorManager`
seolaoh May 3, 2024
c99be8b
refac(validator): reorder functions of l2_validator
seolaoh May 7, 2024
2195eca
test(validator): add challenger actions test for `ValidatorManager`
seolaoh May 7, 2024
3d8e78b
refac(validator): reorder functions of l2_challenger_test
seolaoh May 7, 2024
80817d4
refac(validator): add runtime functions to use in validator actions test
seolaoh May 8, 2024
06bff6d
refac(validator): reorder functions of l2_runtime
seolaoh May 8, 2024
64592da
test(validator): apply PR reviews
seolaoh May 9, 2024
46cc561
Merge branch 'refs/heads/dev' into feat/implement-validator-system-v2
seolaoh May 10, 2024
6ce71fb
feat(validator): modify guardian to handle challenger timeout (#320)
seolaoh May 17, 2024
c6cce6f
feat(contracts): support validator system V2 from genesis (#322)
seolaoh May 21, 2024
7f91022
test(e2e): add tests about validator system V2 (#323)
seolaoh May 27, 2024
9c41722
fix: remove validator from tree when sending to jail (#325)
seolaoh May 29, 2024
9c507ba
fix(contracts): fix some bugs related to `AssetManager` (#327)
seolaoh Jun 5, 2024
1474ae4
fix(validator): change challenger and guardian scan until head L1 (#330)
seolaoh Jun 5, 2024
7359dbe
Merge branch 'refs/heads/dev' into feat/implement-validator-system-v2
seolaoh Jun 7, 2024
38772d2
Merge branch 'refs/heads/dev' into feat/implement-validator-system-v2
seolaoh Jul 3, 2024
14047a3
feat: deploy `GovernanceToken` using normal proxy for devnet
seolaoh Jul 4, 2024
481160e
Merge remote-tracking branch 'origin/dev' into feat/implement-validat…
seolaoh Jul 12, 2024
45760b5
feat(contracts): add withdraw account to validator (#343)
0xHansLee Jul 15, 2024
b9c706a
feat: add delay of commission rate change (#345)
seolaoh Jul 17, 2024
99e6a68
feat(contracts): separate validator kro from delegation pool (#344)
0xHansLee Jul 17, 2024
104b313
feat(contracts): fix interface of `ValidatorManager`, `AssetManager` …
seolaoh Jul 18, 2024
a7529b0
feat(contracts): bond validator KRO (#347)
seolaoh Jul 19, 2024
6e0ec89
feat: implement claimKghReward function (#348)
sm-stack Jul 19, 2024
bf82155
feat: remove KGH share and modify KGH delegation func (#349)
0xHansLee Jul 19, 2024
ceedcb0
feat(contracts): separate jail period (#352)
sm-stack Jul 22, 2024
b5b2ec9
feat(contracts): unbond validator KRO (#351)
seolaoh Jul 22, 2024
627c070
feat(contracts): add transferFrom when increasing reward of vault (#354)
sm-stack Jul 22, 2024
7abe40c
feat(contracts): update validator reward calculation (#355)
sm-stack Jul 22, 2024
8eab79f
feat(contracts): implement 1-step undelegation of KRO (#350)
0xHansLee Jul 22, 2024
e0f36b0
feat(contracts): implement 1-step undelegation for KGH (#353)
0xHansLee Jul 23, 2024
b7dd902
chore: remove 2 step claim of validator reward. (#356)
0xHansLee Jul 23, 2024
f8bbed7
feat(contracts): remove KRO in KGH (#358)
seolaoh Jul 23, 2024
0b00b05
feat(contracts): add withdraw method for validator (#357)
sm-stack Jul 23, 2024
3f0e5ec
test(contracts): setup for `AssetManager` and `ValidatorManager` (#359)
seolaoh Jul 23, 2024
c0c77dd
test(contracts): add `AssetManager` tests (#361)
seolaoh Jul 25, 2024
c77accc
feat: change validator client subcommands (#360)
sm-stack Jul 25, 2024
01f14c6
feat: modify validator client for validator system V2 (#362)
sm-stack Jul 26, 2024
b70a4e3
test(contracts): modify `Colosseum` tests related to V2 (#363)
seolaoh Jul 26, 2024
1c302b5
test: fix validator manager contract tests (#364)
0xHansLee Jul 26, 2024
042efa8
feat(contracts): modify deploy scripts (#365)
seolaoh Jul 30, 2024
5583cf9
test(validator): modify e2e tests related to V2 (#366)
seolaoh Jul 30, 2024
ab37de4
feat(contracts): auto activate validator when deposit (#367)
seolaoh Jul 31, 2024
aca9645
fix(validator): modify validator to be able to turn on without V2 (#368)
seolaoh Aug 1, 2024
f885f5f
fix(validator): disable validator to be turned on without V2 (#369)
seolaoh Aug 2, 2024
96aec79
fix(contracts): avoid overflow error during calculating output reward…
seolaoh Aug 2, 2024
4f5570d
feat(contracts): apply audit results (#373)
seolaoh Aug 22, 2024
75ae796
Merge branch 'refs/heads/dev' into feat/implement-validator-system-v2
seolaoh Aug 23, 2024
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
Prev Previous commit
Next Next commit
feat(contracts): apply PR reviews
  • Loading branch information
seolaoh committed Apr 19, 2024
commit c39f2da1fc87aef24797941c46e91135636f706b
9 changes: 8 additions & 1 deletion packages/contracts/contracts/L1/AssetManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ contract AssetManager is ISemver, IERC721Receiver {
*/
error NotAllowedCaller();

/**
* @notice Reverts when constructor parameters are invalid.
*/
error InvalidConstructorParams();

/**
* @notice Reverts when the status of validator is improper.
*/
Expand Down Expand Up @@ -426,6 +431,8 @@ contract AssetManager is ISemver, IERC721Receiver {
uint128 _slashingRate,
uint128 _minSlashingAmount
) {
if (_slashingRate > SLASHING_RATE_DENOM) revert InvalidConstructorParams();

ASSET_TOKEN = _assetToken;
KGH = _kgh;
KGH_MANAGER = _kghManager;
Expand Down Expand Up @@ -774,7 +781,7 @@ contract AssetManager is ISemver, IERC721Receiver {
}

/**
* @notice Initiate KRO undelegation of given shares for given validator.
* @notice Initiate the KRO undelegation of given shares for the given validator.
*
* @param validator Address of the validator.
* @param shares The amount of shares to undelegate.
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/contracts/L1/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ contract ValidatorManager is ISemver, IValidatorManager {
* @inheritdoc IValidatorManager
*/
function changeCommissionRate(uint8 newCommissionRate) external {
if (getStatus(msg.sender) <= ValidatorStatus.INACTIVE) revert ImproperValidatorStatus();
if (getStatus(msg.sender) < ValidatorStatus.ACTIVE) revert ImproperValidatorStatus();

Validator storage validatorInfo = _validatorInfo[msg.sender];

Expand Down Expand Up @@ -453,12 +453,12 @@ contract ValidatorManager is ISemver, IValidatorManager {
}

/**
* @notice Internal function to add output submission rewards to the vaults of finalized output
* @notice Private function to add output submission rewards to the vaults of finalized output
* submitters.
*
* @return Whether the reward distribution is done at least once or not.
*/
function _distributeReward() internal returns (bool) {
function _distributeReward() private returns (bool) {
uint256 outputIndex = L2_ORACLE.latestFinalizedOutputIndex() + 1;
uint256 latestOutputIndex = L2_ORACLE.latestOutputIndex();

Expand Down Expand Up @@ -578,9 +578,9 @@ contract ValidatorManager is ISemver, IValidatorManager {
*/
function _updatePriorityValidator() private {
uint120 weightSum = startedValidatorTotalWeight();
uint256 latestFinalizedOutputIndex = L2_ORACLE.latestFinalizedOutputIndex();

if (weightSum > 0) {
uint256 latestFinalizedOutputIndex = L2_ORACLE.latestFinalizedOutputIndex();
Types.CheckpointOutput memory output = L2_ORACLE.getL2Output(
latestFinalizedOutputIndex
);
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/contracts/L1/ValidatorPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ contract ValidatorPool is ReentrancyGuardUpgradeable, ISemver {
}
/**
* @notice Semantic version.
* @custom:semver 1.1.1
* @custom:semver 1.1.0
*/
string public constant version = "1.1.1";
string public constant version = "1.1.0";

/**
* @notice Constructs the ValidatorPool contract.
Expand Down
14 changes: 14 additions & 0 deletions packages/contracts/contracts/test/AssetManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@ contract AssetManagerTest is L2OutputOracle_ValidatorSystemUpgrade_Initializer {
assertEq(assetManager.MIN_SLASHING_AMOUNT(), minSlashingAmount);
}

function test_constructor_largeSlashingRate_reverts() external {
vm.expectRevert(AssetManager.InvalidConstructorParams.selector);
new MockAssetManager(
kro,
kgh,
kghManager,
address(guardian),
valMan,
uint128(undelegationPeriod),
1001,
minSlashingAmount
);
}

function test_delegate_succeeds() external {
_setUpKroDelegation(100e18);

Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/deploy/L1/007-ValidatorPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ const deployFn: DeployFunction = async (hre) => {
})
}

deployFn.tags = ['ValidatorPool', 'setup', 'l1']
deployFn.tags = ['ValidatorPool', 'setup', 'l1', 'validatorSystemUpgrade']

export default deployFn
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ const deployFn: DeployFunction = async (hre) => {
})
}

deployFn.tags = ['L2OutputOracle', 'setup', 'l1']
deployFn.tags = ['L2OutputOracle', 'setup', 'l1', 'validatorSystemUpgrade']

export default deployFn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
} from '../../src/deploy-utils'

const deployFn: DeployFunction = async (hre) => {
const zkVerifierProxyAddress = await getDeploymentAddress(hre, 'ZKVerifierProxy')
const zkVerifierProxyAddress = await getDeploymentAddress(
hre,
'ZKVerifierProxy'
)
const l2OutputOracleProxyAddress = await getDeploymentAddress(
hre,
'L2OutputOracleProxy'
Expand Down Expand Up @@ -90,6 +93,6 @@ const deployFn: DeployFunction = async (hre) => {
})
}

deployFn.tags = ['Colosseum', 'setup', 'l1']
deployFn.tags = ['Colosseum', 'setup', 'l1', 'validatorSystemUpgrade']

export default deployFn
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ const deployFn: DeployFunction = async (hre) => {
})
}

deployFn.tags = ['AssetManager', 'setup', 'l1']
deployFn.tags = ['AssetManager', 'setup', 'l1', 'validatorSystemUpgrade']

export default deployFn
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ const deployFn: DeployFunction = async (hre) => {
})
}

deployFn.tags = ['ValidatorManager', 'setup', 'l1']
deployFn.tags = ['ValidatorManager', 'setup', 'l1', 'validatorSystemUpgrade']

export default deployFn