Skip to content

Commit

Permalink
feat(validator): add PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
sm-stack committed Apr 29, 2024
1 parent ad598d6 commit 8bdf892
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 255 deletions.
92 changes: 48 additions & 44 deletions kroma-validator/cmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,90 @@

This file contains the subcommands for the `kroma-validator` command line tool. It includes
the whole commands used to interact with the validator system. Especially, the commands for
the new validator system with the governance token are included.
the new validator system with the asset token are included.

## Usage

You can use these subcommands via running kroma-validator container.

```bash
kroma-validator [command]
docker compose exec kroma-validator validator [command]
```

The descriptions of whole or particular commands can be checked by running the following command:

```bash
kroma-validator --help
kroma-validator [command] --help
docker compose exec kroma-validator validator --help
docker compose exec kroma-validator validator [command] --help
```

## Commands

### Commands for Validator System V2
The following commands are available in Validator System V2:
- `approve` - Approve a contract to spend governance tokens. Default spender is the `ValidatorManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to approve (in Wei).
### Commands for Validator System V1
The following commands are available in Validator System V1. Note that these commands will be **deprecated** and
removed in the future after the new validator system is introduced. You can still use `withdraw` and `unbond` even
after the transition to the Validator System V2.
- `deposit` - Deposit ETH to `ValidatorPool`.
- `--amount [value]` - _(Required)_ The amount of ETH to deposit (in Wei).
```bash
kroma-validator approve --amount 100000000
docker compose exec kroma-validator validator deposit --amount 100000000
```
- `delegate` - Self-delegate governance tokens to the `ValidatorManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to delegate (in Wei).
- `withdraw` - Withdraw ETH from `ValidatorPool`.
- `--amount [value]` - _(Required)_ The amount of ETH to withdraw (in Wei).
```bash
kroma-validator delegate --amount 100000000
docker compose exec kroma-validator validator withdraw
```
- `undelegate init` - Initiate the undelegation of governance tokens from the `AssetManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to undelegate (in Wei).
- `unbond` - Manually unbond the bonded ETH from `ValidatorPool` (including reward distribution).
```bash
kroma-validator undelegate init --amount 100000000
docker compose exec kroma-validator validator unbond
```

- `undelegate finalize` - Finalize the undelegation of governance tokens from the `AssetManager`.
Should be called after 1 week has passed from the `undelegate init` command.
```bash
kroma-validator undelegate finalize
```
- `claim init` - Initiate the claim of governance tokens from the `AssetManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to claim (in Wei).
```bash
kroma-validator claim init --amount 100000000
```
- `claim finalize` - Finalize the claim of governance tokens from the `AssetManager`. Should be called after 1 week
has passed from the `claim init` command.
```bash
kroma-validator claim finalize
```
### Commands for Validator System V2 (_EXPERIMENTAL_)
The following commands are available in Validator System V2:
- `register` - Register a new validator.
- `--amount [value]` - _(Required)_ The amount of tokens to delegate initially (in Wei).
- `--commission-rate [value]` - _(Required)_ The initial commission rate of the validator (in %).
- `--commission-max-rate [value]` - _(Required)_ The max change rate of the commission of the validator (in %).
- `--commission-max-change-rate [value]` - _(Required)_ The max change rate of the commission of the validator (in %).
```bash
docker compose exec kroma-validator validator register --amount 100000000 --commission-rate 5 --commission-max-change-rate 5
```
- `activate` - Activate the validator to be eligible to submit output roots and create challenges.
```bash
kroma-validator register --amount 100000000 --commission-rate 5 --commission-max-rate 5
docker compose exec kroma-validator validator activate
```
- `unjail` - Unjail the validator.
```bash
kroma-validator unjail
docker compose exec kroma-validator validator unjail
```
- `changeCommissionRate` - Change the commission rate of the validator.
- `--commission-rate [value]` - _(Required)_ The new commission rate of the validator (in %).
```bash
kroma-validator changeCommissionRate --commission-rate 5
docker compose exec kroma-validator validator changeCommissionRate --commission-rate 5
```

### Commands for Validator System V1
The following commands are available in Validator System V1. Note that these commands are **deprecated** and will be removed
in the future after the new validator system is introduced.
- `deposit` - Deposit ETH to `ValidatorPool`.
- `--amount [value]` - _(Required)_ The amount of tokens to deposit (in Wei).
- `delegate` - Self-delegate asset tokens to the `AssetManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to delegate (in Wei).
```bash
kroma-validator deposit --amount 100000000
docker compose exec kroma-validator validator delegate --amount 100000000
```
- `withdraw` - Withdraw ETH from `ValidatorPool`.
- `undelegate init` - Initiate the undelegations of asset tokens from the `AssetManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to undelegate (in Wei).
```bash
kroma-validator withdraw
docker compose exec kroma-validator validator undelegate init --amount 100000000
```
- `unbond` - Unbond the ETH (including reward) from `ValidatorPool`.

- `undelegate finalize` - Finalize the undelegations of asset tokens from the `AssetManager`.
Should be called after 1 week has passed from the `undelegate init` command.
```bash
docker compose exec kroma-validator validator undelegate finalize
```
- `claim init` - Initiate the claim of validator reward from the `AssetManager`.
- `--amount [value]` - _(Required)_ The amount of tokens to claim (in Wei).
```bash
docker compose exec kroma-validator validator claim init --amount 100000000
```
- `claim finalize` - Finalize the claim of validator reward from the `AssetManager`. Should be called after 1 week
has passed from the `claim init` command.
```bash
kroma-validator unbond
docker compose exec kroma-validator validator claim finalize
```
117 changes: 59 additions & 58 deletions kroma-validator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package main

import (
"fmt"

"os"

"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"

"github.com/ethereum-optimism/optimism/op-service/cliapp"
oplog "github.com/ethereum-optimism/optimism/op-service/log"

val "github.com/kroma-network/kroma/kroma-validator"
"github.com/kroma-network/kroma/kroma-validator/cmd/balance"
cmd "github.com/kroma-network/kroma/kroma-validator/cmd/validator"
"github.com/kroma-network/kroma/kroma-validator/flags"
)

Expand All @@ -25,98 +27,97 @@ func main() {
app := cli.NewApp()
app.Flags = cliapp.ProtectFlags(flags.Flags)
app.Version = fmt.Sprintf("%s-%s", Version, Meta)
app.Name = "kroma-validator"
app.Name = "validator"
app.Usage = "L2 Output Submitter and Challenger Service"
app.Description = "Service for generating and submitting L2 output checkpoints to the L2OutputOracle contract as an L2 Output Submitter, " + "detecting and correcting invalid L2 outputs as a Challenger to ensure the integrity of the L2 state."
app.Action = curryMain(Version)
app.Commands = cli.Commands{
{
Name: "approve",
Usage: "Approve the AssetManager to spend governance tokens",
Flags: []cli.Flag{TokenAmountFlag},
Action: validator.Approve,
Name: "deposit",
Usage: "Deposit ETH into ValidatorPool to be used as bond",
Description: "This command will be deprecated in a future release of validator system V2. Please use the 'register' command to register as a validator.",
Flags: []cli.Flag{cmd.EthAmountFlag},
Action: cmd.Deposit,
},
{
Name: "withdraw",
Usage: "Withdraw ETH from ValidatorPool",
Description: "This command will be deprecated in a future release of validator system V2. You can still use this command to withdraw your asset from the ValidatorPool.",
Flags: []cli.Flag{cmd.EthAmountFlag},
Action: cmd.Withdraw,
},
{
Name: "unbond",
Usage: "Attempt to unbond in ValidatorPool",
Description: "This command will be deprecated in a future release of validator system V2. You can still use this command to unbond your asset from the ValidatorPool.",
Action: cmd.Unbond,
},
{
Name: "register",
Usage: "(EXPERIMENTAL) Register the validator to ValidatorManager",
Flags: []cli.Flag{
cmd.TokenAmountFlag,
cmd.CommissionRateFlag,
cmd.CommissionMaxChangeRateFlag,
},
Action: cmd.RegisterValidator,
},
{
Name: "activate",
Usage: "(EXPERIMENTAL) Activate the validator",
Action: cmd.Activate,
},
{
Name: "unjail",
Usage: "(EXPERIMENTAL) Attempt to unjail the validator",
Action: cmd.Unjail,
},
{
Name: "changeCommissionRate",
Usage: "(EXPERIMENTAL) Change the commission rate of the validator",
Flags: []cli.Flag{cmd.CommissionRateFlag},
Action: cmd.ChangeCommissionRate,
},
{
Name: "delegate",
Usage: "Attempt to self-delegate governance tokens",
Flags: []cli.Flag{TokenAmountFlag},
Action: validator.Delegate,
Usage: "(EXPERIMENTAL) Attempt to self-delegate governance tokens",
Flags: []cli.Flag{cmd.TokenAmountFlag},
Action: cmd.Delegate,
},
{
Name: "undelegate",
Usage: "Undelegate governance tokens",
Usage: "(EXPERIMENTAL) Undelegate governance tokens",
Subcommands: []*cli.Command{
{
Name: "init",
Usage: "Initiate an undelegation of governance tokens",
Flags: []cli.Flag{TokenAmountFlag},
Action: validator.InitUndelegate,
Flags: []cli.Flag{cmd.TokenAmountFlag},
Action: cmd.InitUndelegate,
},
{
Name: "finalize",
Usage: "Finalize an undelegation of governance tokens",
Action: validator.FinalizeUndelegate,
Action: cmd.FinalizeUndelegate,
},
},
},
{
Name: "claim",
Usage: "Claim validator rewards",
Usage: "(EXPERIMENTAL) Claim validator rewards",
Subcommands: []*cli.Command{
{
Name: "init",
Usage: "Initiate a claim of validator rewards",
Flags: []cli.Flag{TokenAmountFlag},
Action: validator.InitClaimValidatorReward,
Flags: []cli.Flag{cmd.TokenAmountFlag},
Action: cmd.InitClaimValidatorReward,
},
{
Name: "finalize",
Usage: "Finalize a claim of validator rewards",
Action: validator.FinalizeClaimValidatorReward,
Action: cmd.FinalizeClaimValidatorReward,
},
},
},
{
Name: "register",
Usage: "Register the validator to ValidatorManager",
Flags: []cli.Flag{
TokenAmountFlag,
CommissionRateFlag,
CommissionMaxChangeRateFlag,
},
Action: validator.RegisterValidator,
},
{
Name: "unjail",
Usage: "Attempt to unjail the validator",
Action: validator.Unjail,
},
{
Name: "changeCommissionRate",
Usage: "Change the commission rate of the validator",
Flags: []cli.Flag{CommissionRateFlag},
Action: validator.ChangeCommissionRate,
},
{
Name: "deposit",
Usage: "(DEPRECATED) Deposit ETH into ValidatorPool to be used as bond",
Description: "This command will be deprecated in a future release of validator system V2. Please use the 'register' command to register as a validator.",
Flags: []cli.Flag{EthAmountFlag},
Action: validator.Deposit,
},
{
Name: "withdraw",
Usage: "(DEPRECATED) Withdraw ETH from ValidatorPool",
Description: "This command will be deprecated in a future release of validator system V2. You can still use this command to withdraw your asset from the ValidatorPool.",
Flags: []cli.Flag{EthAmountFlag},
Action: validator.Withdraw,
},
{
Name: "unbond",
Usage: "(DEPRECATED) Attempt to unbond in ValidatorPool",
Description: "This command will be deprecated in a future release of validator system V2. You can still use this command to unbond your asset from the ValidatorPool.",
Action: validator.Unbond,
},
}

err := app.Run(os.Args)
Expand Down
Loading

0 comments on commit 8bdf892

Please sign in to comment.