Skip to content

Commit 890e2ef

Browse files
authored
eth, cmd: remove syncTarget from eth config (#26330)
--syncTarget is a feature for development purpose in post-merge world. Previously it's added into eth.Config. But it turns out that's a stupid idea. - syncTarget is a block object, which is hard to be put in config file(large) - syncTarget is just a dev feature, doesn't make too much sense to add it in config file So I remove it from the eth config object. And it also fixes the #26328
1 parent a9dfac0 commit 890e2ef

File tree

4 files changed

+25
-39
lines changed

4 files changed

+25
-39
lines changed

cmd/geth/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/ethereum/go-ethereum/accounts/scwallet"
3232
"github.com/ethereum/go-ethereum/accounts/usbwallet"
3333
"github.com/ethereum/go-ethereum/cmd/utils"
34+
"github.com/ethereum/go-ethereum/eth/downloader"
3435
"github.com/ethereum/go-ethereum/eth/ethconfig"
3536
"github.com/ethereum/go-ethereum/internal/ethapi"
3637
"github.com/ethereum/go-ethereum/internal/flags"
@@ -165,7 +166,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
165166
cfg.Eth.OverrideTerminalTotalDifficultyPassed = &override
166167
}
167168

168-
backend, _ := utils.RegisterEthService(stack, &cfg.Eth)
169+
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
169170

170171
// Configure log filter RPC API.
171172
filterSystem := utils.RegisterFilterAPI(stack, backend, &cfg.Eth)
@@ -179,6 +180,11 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
179180
if cfg.Ethstats.URL != "" {
180181
utils.RegisterEthStatsService(stack, backend, cfg.Ethstats.URL)
181182
}
183+
184+
// Configure full-sync tester service if requested
185+
if ctx.IsSet(utils.SyncTargetFlag.Name) && cfg.Eth.SyncMode == downloader.FullSync {
186+
utils.RegisterFullSyncTester(stack, eth, ctx.Path(utils.SyncTargetFlag.Name))
187+
}
182188
return stack, backend
183189
}
184190

cmd/utils/flags.go

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,25 +1880,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18801880
cfg.EthDiscoveryURLs = SplitAndTrim(urls)
18811881
}
18821882
}
1883-
if ctx.IsSet(SyncTargetFlag.Name) {
1884-
path := ctx.Path(SyncTargetFlag.Name)
1885-
if path == "" {
1886-
Fatalf("Failed to resolve file path")
1887-
}
1888-
blob, err := os.ReadFile(path)
1889-
if err != nil {
1890-
Fatalf("Failed to read block file: %v", err)
1891-
}
1892-
rlpBlob, err := hexutil.Decode(string(bytes.TrimRight(blob, "\r\n")))
1893-
if err != nil {
1894-
Fatalf("Failed to decode block blob: %v", err)
1895-
}
1896-
var block types.Block
1897-
if err := rlp.DecodeBytes(rlpBlob, &block); err != nil {
1898-
Fatalf("Failed to decode block: %v", err)
1899-
}
1900-
cfg.SyncTarget = &block
1901-
}
19021883
// Override any default configs for hard coded networks.
19031884
switch {
19041885
case ctx.Bool(MainnetFlag.Name):
@@ -2052,13 +2033,6 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
20522033
Fatalf("Failed to register the Engine API service: %v", err)
20532034
}
20542035
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
2055-
2056-
// Register the auxiliary full-sync tester service in case the sync
2057-
// target is configured.
2058-
if cfg.SyncTarget != nil && cfg.SyncMode == downloader.FullSync {
2059-
ethcatalyst.RegisterFullSyncTester(stack, backend, cfg.SyncTarget)
2060-
log.Info("Registered full-sync tester", "number", cfg.SyncTarget.NumberU64(), "hash", cfg.SyncTarget.Hash())
2061-
}
20622036
return backend.APIBackend, backend
20632037
}
20642038

@@ -2090,6 +2064,24 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
20902064
return filterSystem
20912065
}
20922066

2067+
// RegisterFullSyncTester adds the full-sync tester service into node.
2068+
func RegisterFullSyncTester(stack *node.Node, eth *eth.Ethereum, path string) {
2069+
blob, err := os.ReadFile(path)
2070+
if err != nil {
2071+
Fatalf("Failed to read block file: %v", err)
2072+
}
2073+
rlpBlob, err := hexutil.Decode(string(bytes.TrimRight(blob, "\r\n")))
2074+
if err != nil {
2075+
Fatalf("Failed to decode block blob: %v", err)
2076+
}
2077+
var block types.Block
2078+
if err := rlp.DecodeBytes(rlpBlob, &block); err != nil {
2079+
Fatalf("Failed to decode block: %v", err)
2080+
}
2081+
ethcatalyst.RegisterFullSyncTester(stack, eth, &block)
2082+
log.Info("Registered full-sync tester", "number", block.NumberU64(), "hash", block.Hash())
2083+
}
2084+
20932085
func SetupMetrics(ctx *cli.Context) {
20942086
if metrics.Enabled {
20952087
log.Info("Enabling metrics collection")

eth/ethconfig/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/ethereum/go-ethereum/consensus/ethash"
3333
"github.com/ethereum/go-ethereum/core"
3434
"github.com/ethereum/go-ethereum/core/txpool"
35-
"github.com/ethereum/go-ethereum/core/types"
3635
"github.com/ethereum/go-ethereum/eth/downloader"
3736
"github.com/ethereum/go-ethereum/eth/gasprice"
3837
"github.com/ethereum/go-ethereum/ethdb"
@@ -212,10 +211,6 @@ type Config struct {
212211

213212
// OverrideTerminalTotalDifficultyPassed (TODO: remove after the fork)
214213
OverrideTerminalTotalDifficultyPassed *bool `toml:",omitempty"`
215-
216-
// SyncTarget defines the target block of sync. It's only used for
217-
// development purposes.
218-
SyncTarget *types.Block
219214
}
220215

221216
// CreateConsensusEngine creates a consensus engine for the given chain configuration.

eth/ethconfig/gen_config.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)