Skip to content

Commit

Permalink
add challenge enable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
curryxbo committed Nov 26, 2024
1 parent a47f1ae commit c5f375a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
7 changes: 7 additions & 0 deletions node/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ var (
EnvVar: prefixEnvVar("VALIDATOR"),
}

ChallengeEnable = cli.BoolFlag{
Name: "validator.challengeEnable",
Usage: "Enable the validator mode",
EnvVar: prefixEnvVar("VALIDATOR_CHALLENGE_ENABLE"),
}

// validator
ValidatorPrivateKey = cli.StringFlag{
Name: "validator.privateKey",
Expand Down Expand Up @@ -321,6 +327,7 @@ var Flags = []cli.Flag{
TendermintConfigPath,
MockEnabled,
ValidatorEnable,
ChallengeEnable,

// validator
ValidatorPrivateKey,
Expand Down
2 changes: 1 addition & 1 deletion node/validator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewConfig() *Config {
func (c *Config) SetCliContext(ctx *cli.Context) error {
l1NodeAddr := ctx.GlobalString(flags.L1NodeAddr.Name)
l1ChainID := ctx.GlobalUint64(flags.L1ChainID.Name)
c.challengeEnable = ctx.GlobalIsSet(flags.ValidatorEnable.Name)
c.challengeEnable = ctx.GlobalBool(flags.ChallengeEnable.Name)
if c.challengeEnable {
hexPrvKey := ctx.GlobalString(flags.ValidatorPrivateKey.Name)
hex := strings.TrimPrefix(hexPrvKey, "0x")
Expand Down
18 changes: 6 additions & 12 deletions node/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ func NewValidator(cfg *Config, rollup *bindings.Rollup, logger tmlog.Logger) (*V
return nil, fmt.Errorf("dial l1 node error:%v", err)
}
return &Validator{
cli: cli,
contract: rollup,
privateKey: cfg.PrivateKey,
l1ChainID: cfg.L1ChainID,
logger: logger,
cli: cli,
contract: rollup,
privateKey: cfg.PrivateKey,
l1ChainID: cfg.L1ChainID,
challengeEnable: cfg.challengeEnable,
logger: logger,
}, nil
}

Expand All @@ -68,13 +69,6 @@ func (v *Validator) ChallengeState(batchIndex uint64) error {
}
opts.GasPrice = gasPrice
opts.NoSend = true
//publicKey := v.privateKey.Public()
// publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
// if !ok {
// log.Error("cannot assert type: publicKey is not of type *ecdsa.PublicKey")
// }

//receiver := crypto.PubkeyToAddress(*publicKeyECDSA)
batchHash, err := v.contract.CommittedBatches(
&bind.CallOpts{
Pending: false,
Expand Down

0 comments on commit c5f375a

Please sign in to comment.