Skip to content

Commit 3038e48

Browse files
MariusVanDerWijdenrjl493456442karalabe
authored
all: core rework for the merge transition (ethereum#23761)
* all: work for eth1/2 transtition * consensus/beacon, eth: change beacon difficulty to 0 * eth: updates * all: add terminalBlockDifficulty config, fix rebasing issues * eth: implemented merge interop spec * internal/ethapi: update to v1.0.0.alpha.2 This commit updates the code to the new spec, moving payloadId into it's own object. It also fixes an issue with finalizing an empty blockhash. It also properly sets the basefee * all: sync polishes, other fixes + refactors * core, eth: correct semantics for LeavePoW, EnterPoS * core: fixed rebasing artifacts * core: light: performance improvements * core: use keyed field (f) * core: eth: fix compilation issues + tests * eth/catalyst: dbetter error codes * all: move Merger to consensus/, remove reliance on it in bc * all: renamed EnterPoS and LeavePoW to ReachTDD and FinalizePoS * core: make mergelogs a function * core: use InsertChain instead of InsertBlock * les: drop merger from lightchain object * consensus: add merger * core: recoverAncestors in catalyst mode * core: fix nitpick * all: removed merger from beacon, use TTD, nitpicks * consensus: eth: add docstring, removed unnecessary code duplication * consensus/beacon: better comment * all: easy to fix nitpicks by karalabe * consensus/beacon: verify known headers to be sure * core: comments * core: eth: don't drop peers who advertise blocks, nitpicks * core: never add beacon blocks to the future queue * core: fixed nitpicks * consensus/beacon: simplify IsTTDReached check * consensus/beacon: correct IsTTDReached check Co-authored-by: rjl493456442 <[email protected]> Co-authored-by: Péter Szilágyi <[email protected]>
1 parent 519cf98 commit 3038e48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3233
-792
lines changed

cmd/geth/config.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/ethereum/go-ethereum/accounts/scwallet"
3333
"github.com/ethereum/go-ethereum/accounts/usbwallet"
3434
"github.com/ethereum/go-ethereum/cmd/utils"
35-
"github.com/ethereum/go-ethereum/eth/catalyst"
3635
"github.com/ethereum/go-ethereum/eth/ethconfig"
3736
"github.com/ethereum/go-ethereum/internal/ethapi"
3837
"github.com/ethereum/go-ethereum/log"
@@ -159,17 +158,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
159158
if ctx.GlobalIsSet(utils.OverrideArrowGlacierFlag.Name) {
160159
cfg.Eth.OverrideArrowGlacier = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideArrowGlacierFlag.Name))
161160
}
162-
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
163-
164-
// Configure catalyst.
165-
if ctx.GlobalBool(utils.CatalystFlag.Name) {
166-
if eth == nil {
167-
utils.Fatalf("Catalyst does not work in light client mode.")
168-
}
169-
if err := catalyst.Register(stack, eth); err != nil {
170-
utils.Fatalf("%v", err)
171-
}
161+
if ctx.GlobalIsSet(utils.OverrideTerminalTotalDifficulty.Name) {
162+
cfg.Eth.Genesis.Config.TerminalTotalDifficulty = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideTerminalTotalDifficulty.Name))
172163
}
164+
backend, _ := utils.RegisterEthService(stack, &cfg.Eth, ctx.GlobalBool(utils.CatalystFlag.Name))
173165

174166
// Configure GraphQL if requested
175167
if ctx.GlobalIsSet(utils.GraphQLEnabledFlag.Name) {

cmd/geth/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ var (
7272
utils.USBFlag,
7373
utils.SmartCardDaemonPathFlag,
7474
utils.OverrideArrowGlacierFlag,
75+
utils.OverrideTerminalTotalDifficulty,
7576
utils.EthashCacheDirFlag,
7677
utils.EthashCachesInMemoryFlag,
7778
utils.EthashCachesOnDiskFlag,

cmd/utils/flags.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import (
4545
"github.com/ethereum/go-ethereum/core/vm"
4646
"github.com/ethereum/go-ethereum/crypto"
4747
"github.com/ethereum/go-ethereum/eth"
48+
"github.com/ethereum/go-ethereum/eth/catalyst"
4849
"github.com/ethereum/go-ethereum/eth/downloader"
4950
"github.com/ethereum/go-ethereum/eth/ethconfig"
5051
"github.com/ethereum/go-ethereum/eth/gasprice"
@@ -248,6 +249,10 @@ var (
248249
Name: "override.arrowglacier",
249250
Usage: "Manually specify Arrow Glacier fork-block, overriding the bundled setting",
250251
}
252+
OverrideTerminalTotalDifficulty = cli.Uint64Flag{
253+
Name: "override.terminaltotaldifficulty",
254+
Usage: "Manually specify TerminalTotalDifficulty, overriding the bundled setting",
255+
}
251256
// Light server and client settings
252257
LightServeFlag = cli.IntFlag{
253258
Name: "light.serve",
@@ -1196,7 +1201,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
11961201
cfg.NetRestrict = list
11971202
}
11981203

1199-
if ctx.GlobalBool(DeveloperFlag.Name) || ctx.GlobalBool(CatalystFlag.Name) {
1204+
if ctx.GlobalBool(DeveloperFlag.Name) {
12001205
// --dev mode can't use p2p networking.
12011206
cfg.MaxPeers = 0
12021207
cfg.ListenAddr = ""
@@ -1705,13 +1710,18 @@ func SetDNSDiscoveryDefaults(cfg *ethconfig.Config, genesis common.Hash) {
17051710
// RegisterEthService adds an Ethereum client to the stack.
17061711
// The second return value is the full node instance, which may be nil if the
17071712
// node is running as a light client.
1708-
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend, *eth.Ethereum) {
1713+
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, isCatalyst bool) (ethapi.Backend, *eth.Ethereum) {
17091714
if cfg.SyncMode == downloader.LightSync {
17101715
backend, err := les.New(stack, cfg)
17111716
if err != nil {
17121717
Fatalf("Failed to register the Ethereum service: %v", err)
17131718
}
17141719
stack.RegisterAPIs(tracers.APIs(backend.ApiBackend))
1720+
if isCatalyst {
1721+
if err := catalyst.RegisterLight(stack, backend); err != nil {
1722+
Fatalf("Failed to register the catalyst service: %v", err)
1723+
}
1724+
}
17151725
return backend.ApiBackend, nil
17161726
}
17171727
backend, err := eth.New(stack, cfg)
@@ -1724,6 +1734,11 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) (ethapi.Backend
17241734
Fatalf("Failed to create the LES server: %v", err)
17251735
}
17261736
}
1737+
if isCatalyst {
1738+
if err := catalyst.Register(stack, backend); err != nil {
1739+
Fatalf("Failed to register the catalyst service: %v", err)
1740+
}
1741+
}
17271742
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
17281743
return backend.APIBackend, backend
17291744
}

0 commit comments

Comments
 (0)