Skip to content

Commit

Permalink
cmd, parlia: option to disable verify validators
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Mar 26, 2024
1 parent eda56e2 commit cc6c52e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/consensus/parlia"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/txpool/legacypool"
Expand Down Expand Up @@ -2471,6 +2472,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
if err != nil {
Fatalf("%v", err)
}
if parlia, ok := engine.(*parlia.Parlia); ok {
parlia.SetNoVerifyValidators(true)
}

if gcmode := ctx.String(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
}
Expand Down
12 changes: 10 additions & 2 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ type Parlia struct {
slashABI abi.ABI
stakeHubABI abi.ABI

noVerifyValidators bool

// The fields below are for testing only
fakeDiff bool // Skip difficulty verifications
}
Expand Down Expand Up @@ -1140,8 +1142,10 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
}
// If the block is an epoch end block, verify the validator list
// The verification can only be done when the state is ready, it can't be done in VerifyHeader.
if err := p.verifyValidators(header); err != nil {
return err
if !p.noVerifyValidators {
if err := p.verifyValidators(header); err != nil {
return err
}
}

cx := chainContext{Chain: chain, parlia: p}
Expand Down Expand Up @@ -1882,6 +1886,10 @@ func (p *Parlia) GetFinalizedHeader(chain consensus.ChainHeaderReader, header *t
return chain.GetHeader(snap.Attestation.SourceHash, snap.Attestation.SourceNumber)
}

func (p *Parlia) SetNoVerifyValidators(cond bool) {
p.noVerifyValidators = cond
}

// =========================== utility function ==========================
func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Address) uint64 {
if snap.inturn(val) {
Expand Down

0 comments on commit cc6c52e

Please sign in to comment.