forked from cerc-io/plugeth
cmd, eth: implement full-sync tester (#26035)
This PR adds a parameter to startup, --synctarget. The synctarget flag is a developer-flag, that can be useful in some scenarios as a replacement for a CL node. It defines a fixed block sync target: geth --syncmode=full --synctarget=./block_15816882.hex_rlp The --synctarget is only made available during syncmode=full
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
@@ -211,6 +212,10 @@ type Config struct {
|
||||
|
||||
// OverrideTerminalTotalDifficultyPassed (TODO: remove after the fork)
|
||||
OverrideTerminalTotalDifficultyPassed *bool `toml:",omitempty"`
|
||||
|
||||
// SyncTarget defines the target block of sync. It's only used for
|
||||
// development purposes.
|
||||
SyncTarget *types.Block
|
||||
}
|
||||
|
||||
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/txpool"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||
"github.com/ethereum/go-ethereum/miner"
|
||||
@@ -63,6 +64,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
|
||||
OverrideTerminalTotalDifficulty *big.Int `toml:",omitempty"`
|
||||
OverrideTerminalTotalDifficultyPassed *bool `toml:",omitempty"`
|
||||
FullSyncTarget *types.Block
|
||||
}
|
||||
var enc Config
|
||||
enc.Genesis = c.Genesis
|
||||
@@ -109,6 +111,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
||||
enc.CheckpointOracle = c.CheckpointOracle
|
||||
enc.OverrideTerminalTotalDifficulty = c.OverrideTerminalTotalDifficulty
|
||||
enc.OverrideTerminalTotalDifficultyPassed = c.OverrideTerminalTotalDifficultyPassed
|
||||
enc.FullSyncTarget = c.SyncTarget
|
||||
return &enc, nil
|
||||
}
|
||||
|
||||
@@ -159,6 +162,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
|
||||
OverrideTerminalTotalDifficulty *big.Int `toml:",omitempty"`
|
||||
OverrideTerminalTotalDifficultyPassed *bool `toml:",omitempty"`
|
||||
FullSyncTarget *types.Block
|
||||
}
|
||||
var dec Config
|
||||
if err := unmarshal(&dec); err != nil {
|
||||
@@ -296,5 +300,8 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
||||
if dec.OverrideTerminalTotalDifficultyPassed != nil {
|
||||
c.OverrideTerminalTotalDifficultyPassed = dec.OverrideTerminalTotalDifficultyPassed
|
||||
}
|
||||
if dec.FullSyncTarget != nil {
|
||||
c.SyncTarget = dec.FullSyncTarget
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user