diff --git a/node/flags/flags.go b/node/flags/flags.go index aa359e8f..5ab047b0 100644 --- a/node/flags/flags.go +++ b/node/flags/flags.go @@ -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", @@ -321,6 +327,7 @@ var Flags = []cli.Flag{ TendermintConfigPath, MockEnabled, ValidatorEnable, + ChallengeEnable, // validator ValidatorPrivateKey, diff --git a/node/validator/config.go b/node/validator/config.go index 29f95cfa..986fd16d 100644 --- a/node/validator/config.go +++ b/node/validator/config.go @@ -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") diff --git a/node/validator/validator.go b/node/validator/validator.go index 627123c4..224c8c3d 100644 --- a/node/validator/validator.go +++ b/node/validator/validator.go @@ -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 } @@ -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,