Skip to content

Commit 26c5ca9

Browse files
committed
beacon/params: merged LightChainConfig into ChainConfig
1 parent ef011bf commit 26c5ca9

File tree

5 files changed

+46
-57
lines changed

5 files changed

+46
-57
lines changed

beacon/blsync/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
type Client struct {
3333
urls []string
3434
customHeader map[string]string
35-
config *params.LightClientConfig
35+
config *params.ClientConfig
3636
scheduler *request.Scheduler
3737
blockSync *beaconBlockSync
3838
engineRPC *rpc.Client
@@ -41,11 +41,11 @@ type Client struct {
4141
engineClient *engineClient
4242
}
4343

44-
func NewClient(config params.LightClientConfig) *Client {
44+
func NewClient(config params.ClientConfig) *Client {
4545
// create data structures
4646
var (
4747
db = memorydb.New()
48-
committeeChain = light.NewCommitteeChain(db, config.ChainConfig, config.Threshold, !config.NoFilter)
48+
committeeChain = light.NewCommitteeChain(db, &config.ChainConfig, config.Threshold, !config.NoFilter)
4949
headTracker = light.NewHeadTracker(committeeChain, config.Threshold)
5050
)
5151
headSync := sync.NewHeadSync(headTracker, committeeChain)

beacon/blsync/engineclient.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ import (
3232
)
3333

3434
type engineClient struct {
35-
config *params.LightClientConfig
35+
config *params.ClientConfig
3636
rpc *rpc.Client
3737
rootCtx context.Context
3838
cancelRoot context.CancelFunc
3939
wg sync.WaitGroup
4040
}
4141

42-
func startEngineClient(config *params.LightClientConfig, rpc *rpc.Client, headCh <-chan types.ChainHeadEvent) *engineClient {
42+
func startEngineClient(config *params.ClientConfig, rpc *rpc.Client, headCh <-chan types.ChainHeadEvent) *engineClient {
4343
ctx, cancel := context.WithCancel(context.Background())
4444
ec := &engineClient{
4545
config: config,

beacon/params/config.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,21 @@ const syncCommitteeDomain = 7
3939

4040
var knownForks = []string{"GENESIS", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB"}
4141

42-
// LightClientConfig contains beacon light client configuration.
43-
type LightClientConfig struct {
44-
LightChainConfig
42+
// ClientConfig contains beacon light client configuration.
43+
type ClientConfig struct {
44+
ChainConfig
4545
Apis []string
4646
CustomHeader map[string]string
4747
Threshold int
4848
NoFilter bool
4949
}
5050

51-
// LightChainConfig contains beacon light chain configuration.
52-
type LightChainConfig struct {
53-
*ChainConfig
54-
Checkpoint common.Hash
55-
}
56-
5751
// ChainConfig contains the beacon chain configuration.
5852
type ChainConfig struct {
5953
GenesisTime uint64 // Unix timestamp of slot 0
6054
GenesisValidatorsRoot common.Hash // Root hash of the genesis validator set, used for signature domain calculation
6155
Forks Forks
56+
Checkpoint common.Hash
6257
}
6358

6459
// ForkAtEpoch returns the latest active fork at the given epoch.

beacon/params/networks.go

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,36 @@ import (
2121
)
2222

2323
var (
24-
MainnetLightConfig = LightChainConfig{
25-
ChainConfig: (&ChainConfig{
26-
GenesisValidatorsRoot: common.HexToHash("0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"),
27-
GenesisTime: 1606824023,
28-
}).
29-
AddFork("GENESIS", 0, []byte{0, 0, 0, 0}).
30-
AddFork("ALTAIR", 74240, []byte{1, 0, 0, 0}).
31-
AddFork("BELLATRIX", 144896, []byte{2, 0, 0, 0}).
32-
AddFork("CAPELLA", 194048, []byte{3, 0, 0, 0}).
33-
AddFork("DENEB", 269568, []byte{4, 0, 0, 0}),
34-
Checkpoint: common.HexToHash("0x6509b691f4de4f7b083f2784938fd52f0e131675432b3fd85ea549af9aebd3d0"),
35-
}
24+
MainnetLightConfig = (&ChainConfig{
25+
GenesisValidatorsRoot: common.HexToHash("0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"),
26+
GenesisTime: 1606824023,
27+
Checkpoint: common.HexToHash("0x6509b691f4de4f7b083f2784938fd52f0e131675432b3fd85ea549af9aebd3d0"),
28+
}).
29+
AddFork("GENESIS", 0, []byte{0, 0, 0, 0}).
30+
AddFork("ALTAIR", 74240, []byte{1, 0, 0, 0}).
31+
AddFork("BELLATRIX", 144896, []byte{2, 0, 0, 0}).
32+
AddFork("CAPELLA", 194048, []byte{3, 0, 0, 0}).
33+
AddFork("DENEB", 269568, []byte{4, 0, 0, 0})
3634

37-
SepoliaLightConfig = LightChainConfig{
38-
ChainConfig: (&ChainConfig{
39-
GenesisValidatorsRoot: common.HexToHash("0xd8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078"),
40-
GenesisTime: 1655733600,
41-
}).
42-
AddFork("GENESIS", 0, []byte{144, 0, 0, 105}).
43-
AddFork("ALTAIR", 50, []byte{144, 0, 0, 112}).
44-
AddFork("BELLATRIX", 100, []byte{144, 0, 0, 113}).
45-
AddFork("CAPELLA", 56832, []byte{144, 0, 0, 114}).
46-
AddFork("DENEB", 132608, []byte{144, 0, 0, 115}),
47-
Checkpoint: common.HexToHash("0x456e85f5608afab3465a0580bff8572255f6d97af0c5f939e3f7536b5edb2d3f"),
48-
}
35+
SepoliaLightConfig = (&ChainConfig{
36+
GenesisValidatorsRoot: common.HexToHash("0xd8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078"),
37+
GenesisTime: 1655733600,
38+
Checkpoint: common.HexToHash("0x456e85f5608afab3465a0580bff8572255f6d97af0c5f939e3f7536b5edb2d3f"),
39+
}).
40+
AddFork("GENESIS", 0, []byte{144, 0, 0, 105}).
41+
AddFork("ALTAIR", 50, []byte{144, 0, 0, 112}).
42+
AddFork("BELLATRIX", 100, []byte{144, 0, 0, 113}).
43+
AddFork("CAPELLA", 56832, []byte{144, 0, 0, 114}).
44+
AddFork("DENEB", 132608, []byte{144, 0, 0, 115})
4945

50-
HoleskyLightConfig = LightChainConfig{
51-
ChainConfig: (&ChainConfig{
52-
GenesisValidatorsRoot: common.HexToHash("0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1"),
53-
GenesisTime: 1695902400,
54-
}).
55-
AddFork("GENESIS", 0, []byte{1, 1, 112, 0}).
56-
AddFork("ALTAIR", 0, []byte{2, 1, 112, 0}).
57-
AddFork("BELLATRIX", 0, []byte{3, 1, 112, 0}).
58-
AddFork("CAPELLA", 256, []byte{4, 1, 112, 0}).
59-
AddFork("DENEB", 29696, []byte{5, 1, 112, 0}),
60-
Checkpoint: common.HexToHash("0x6456a1317f54d4b4f2cb5bc9d153b5af0988fe767ef0609f0236cf29030bcff7"),
61-
}
46+
HoleskyLightConfig = (&ChainConfig{
47+
GenesisValidatorsRoot: common.HexToHash("0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1"),
48+
GenesisTime: 1695902400,
49+
Checkpoint: common.HexToHash("0x6456a1317f54d4b4f2cb5bc9d153b5af0988fe767ef0609f0236cf29030bcff7"),
50+
}).
51+
AddFork("GENESIS", 0, []byte{1, 1, 112, 0}).
52+
AddFork("ALTAIR", 0, []byte{2, 1, 112, 0}).
53+
AddFork("BELLATRIX", 0, []byte{3, 1, 112, 0}).
54+
AddFork("CAPELLA", 256, []byte{4, 1, 112, 0}).
55+
AddFork("DENEB", 29696, []byte{5, 1, 112, 0})
6256
)

cmd/utils/flags.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,20 +1892,20 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18921892

18931893
// MakeBeaconLightConfig constructs a beacon light client config based on the
18941894
// related command line flags.
1895-
func MakeBeaconLightConfig(ctx *cli.Context) bparams.LightClientConfig {
1896-
var config bparams.LightClientConfig
1895+
func MakeBeaconLightConfig(ctx *cli.Context) bparams.ClientConfig {
1896+
var config bparams.ClientConfig
18971897
customConfig := ctx.IsSet(BeaconConfigFlag.Name)
18981898
CheckExclusive(ctx, MainnetFlag, SepoliaFlag, HoleskyFlag, BeaconConfigFlag)
18991899
switch {
19001900
case ctx.Bool(MainnetFlag.Name):
1901-
config.LightChainConfig = bparams.MainnetLightConfig
1901+
config.ChainConfig = *bparams.MainnetLightConfig
19021902
case ctx.Bool(SepoliaFlag.Name):
1903-
config.LightChainConfig = bparams.SepoliaLightConfig
1903+
config.ChainConfig = *bparams.SepoliaLightConfig
19041904
case ctx.Bool(HoleskyFlag.Name):
1905-
config.LightChainConfig = bparams.HoleskyLightConfig
1905+
config.ChainConfig = *bparams.HoleskyLightConfig
19061906
default:
19071907
if !customConfig {
1908-
config.LightChainConfig = bparams.MainnetLightConfig
1908+
config.ChainConfig = *bparams.MainnetLightConfig
19091909
}
19101910
}
19111911
// Genesis root and time should always be specified together with custom chain config
@@ -1919,7 +1919,7 @@ func MakeBeaconLightConfig(ctx *cli.Context) bparams.LightClientConfig {
19191919
if !ctx.IsSet(BeaconCheckpointFlag.Name) {
19201920
Fatalf("Custom beacon chain config is specified but checkpoint is missing")
19211921
}
1922-
config.ChainConfig = &bparams.ChainConfig{
1922+
config.ChainConfig = bparams.ChainConfig{
19231923
GenesisTime: ctx.Uint64(BeaconGenesisTimeFlag.Name),
19241924
}
19251925
if c, err := hexutil.Decode(ctx.String(BeaconGenesisRootFlag.Name)); err == nil && len(c) <= 32 {

0 commit comments

Comments
 (0)