mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
beacon/params: merged LightChainConfig into ChainConfig
This commit is contained in:
parent
ef011bf489
commit
26c5ca9e07
5 changed files with 46 additions and 57 deletions
|
|
@ -32,7 +32,7 @@ import (
|
|||
type Client struct {
|
||||
urls []string
|
||||
customHeader map[string]string
|
||||
config *params.LightClientConfig
|
||||
config *params.ClientConfig
|
||||
scheduler *request.Scheduler
|
||||
blockSync *beaconBlockSync
|
||||
engineRPC *rpc.Client
|
||||
|
|
@ -41,11 +41,11 @@ type Client struct {
|
|||
engineClient *engineClient
|
||||
}
|
||||
|
||||
func NewClient(config params.LightClientConfig) *Client {
|
||||
func NewClient(config params.ClientConfig) *Client {
|
||||
// create data structures
|
||||
var (
|
||||
db = memorydb.New()
|
||||
committeeChain = light.NewCommitteeChain(db, config.ChainConfig, config.Threshold, !config.NoFilter)
|
||||
committeeChain = light.NewCommitteeChain(db, &config.ChainConfig, config.Threshold, !config.NoFilter)
|
||||
headTracker = light.NewHeadTracker(committeeChain, config.Threshold)
|
||||
)
|
||||
headSync := sync.NewHeadSync(headTracker, committeeChain)
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ import (
|
|||
)
|
||||
|
||||
type engineClient struct {
|
||||
config *params.LightClientConfig
|
||||
config *params.ClientConfig
|
||||
rpc *rpc.Client
|
||||
rootCtx context.Context
|
||||
cancelRoot context.CancelFunc
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func startEngineClient(config *params.LightClientConfig, rpc *rpc.Client, headCh <-chan types.ChainHeadEvent) *engineClient {
|
||||
func startEngineClient(config *params.ClientConfig, rpc *rpc.Client, headCh <-chan types.ChainHeadEvent) *engineClient {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ec := &engineClient{
|
||||
config: config,
|
||||
|
|
|
|||
|
|
@ -39,26 +39,21 @@ const syncCommitteeDomain = 7
|
|||
|
||||
var knownForks = []string{"GENESIS", "ALTAIR", "BELLATRIX", "CAPELLA", "DENEB"}
|
||||
|
||||
// LightClientConfig contains beacon light client configuration.
|
||||
type LightClientConfig struct {
|
||||
LightChainConfig
|
||||
// ClientConfig contains beacon light client configuration.
|
||||
type ClientConfig struct {
|
||||
ChainConfig
|
||||
Apis []string
|
||||
CustomHeader map[string]string
|
||||
Threshold int
|
||||
NoFilter bool
|
||||
}
|
||||
|
||||
// LightChainConfig contains beacon light chain configuration.
|
||||
type LightChainConfig struct {
|
||||
*ChainConfig
|
||||
Checkpoint common.Hash
|
||||
}
|
||||
|
||||
// ChainConfig contains the beacon chain configuration.
|
||||
type ChainConfig struct {
|
||||
GenesisTime uint64 // Unix timestamp of slot 0
|
||||
GenesisValidatorsRoot common.Hash // Root hash of the genesis validator set, used for signature domain calculation
|
||||
Forks Forks
|
||||
Checkpoint common.Hash
|
||||
}
|
||||
|
||||
// ForkAtEpoch returns the latest active fork at the given epoch.
|
||||
|
|
|
|||
|
|
@ -21,42 +21,36 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
MainnetLightConfig = LightChainConfig{
|
||||
ChainConfig: (&ChainConfig{
|
||||
MainnetLightConfig = (&ChainConfig{
|
||||
GenesisValidatorsRoot: common.HexToHash("0x4b363db94e286120d76eb905340fdd4e54bfe9f06bf33ff6cf5ad27f511bfe95"),
|
||||
GenesisTime: 1606824023,
|
||||
Checkpoint: common.HexToHash("0x6509b691f4de4f7b083f2784938fd52f0e131675432b3fd85ea549af9aebd3d0"),
|
||||
}).
|
||||
AddFork("GENESIS", 0, []byte{0, 0, 0, 0}).
|
||||
AddFork("ALTAIR", 74240, []byte{1, 0, 0, 0}).
|
||||
AddFork("BELLATRIX", 144896, []byte{2, 0, 0, 0}).
|
||||
AddFork("CAPELLA", 194048, []byte{3, 0, 0, 0}).
|
||||
AddFork("DENEB", 269568, []byte{4, 0, 0, 0}),
|
||||
Checkpoint: common.HexToHash("0x6509b691f4de4f7b083f2784938fd52f0e131675432b3fd85ea549af9aebd3d0"),
|
||||
}
|
||||
AddFork("DENEB", 269568, []byte{4, 0, 0, 0})
|
||||
|
||||
SepoliaLightConfig = LightChainConfig{
|
||||
ChainConfig: (&ChainConfig{
|
||||
SepoliaLightConfig = (&ChainConfig{
|
||||
GenesisValidatorsRoot: common.HexToHash("0xd8ea171f3c94aea21ebc42a1ed61052acf3f9209c00e4efbaaddac09ed9b8078"),
|
||||
GenesisTime: 1655733600,
|
||||
Checkpoint: common.HexToHash("0x456e85f5608afab3465a0580bff8572255f6d97af0c5f939e3f7536b5edb2d3f"),
|
||||
}).
|
||||
AddFork("GENESIS", 0, []byte{144, 0, 0, 105}).
|
||||
AddFork("ALTAIR", 50, []byte{144, 0, 0, 112}).
|
||||
AddFork("BELLATRIX", 100, []byte{144, 0, 0, 113}).
|
||||
AddFork("CAPELLA", 56832, []byte{144, 0, 0, 114}).
|
||||
AddFork("DENEB", 132608, []byte{144, 0, 0, 115}),
|
||||
Checkpoint: common.HexToHash("0x456e85f5608afab3465a0580bff8572255f6d97af0c5f939e3f7536b5edb2d3f"),
|
||||
}
|
||||
AddFork("DENEB", 132608, []byte{144, 0, 0, 115})
|
||||
|
||||
HoleskyLightConfig = LightChainConfig{
|
||||
ChainConfig: (&ChainConfig{
|
||||
HoleskyLightConfig = (&ChainConfig{
|
||||
GenesisValidatorsRoot: common.HexToHash("0x9143aa7c615a7f7115e2b6aac319c03529df8242ae705fba9df39b79c59fa8b1"),
|
||||
GenesisTime: 1695902400,
|
||||
Checkpoint: common.HexToHash("0x6456a1317f54d4b4f2cb5bc9d153b5af0988fe767ef0609f0236cf29030bcff7"),
|
||||
}).
|
||||
AddFork("GENESIS", 0, []byte{1, 1, 112, 0}).
|
||||
AddFork("ALTAIR", 0, []byte{2, 1, 112, 0}).
|
||||
AddFork("BELLATRIX", 0, []byte{3, 1, 112, 0}).
|
||||
AddFork("CAPELLA", 256, []byte{4, 1, 112, 0}).
|
||||
AddFork("DENEB", 29696, []byte{5, 1, 112, 0}),
|
||||
Checkpoint: common.HexToHash("0x6456a1317f54d4b4f2cb5bc9d153b5af0988fe767ef0609f0236cf29030bcff7"),
|
||||
}
|
||||
AddFork("DENEB", 29696, []byte{5, 1, 112, 0})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1892,20 +1892,20 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
|
||||
// MakeBeaconLightConfig constructs a beacon light client config based on the
|
||||
// related command line flags.
|
||||
func MakeBeaconLightConfig(ctx *cli.Context) bparams.LightClientConfig {
|
||||
var config bparams.LightClientConfig
|
||||
func MakeBeaconLightConfig(ctx *cli.Context) bparams.ClientConfig {
|
||||
var config bparams.ClientConfig
|
||||
customConfig := ctx.IsSet(BeaconConfigFlag.Name)
|
||||
CheckExclusive(ctx, MainnetFlag, SepoliaFlag, HoleskyFlag, BeaconConfigFlag)
|
||||
switch {
|
||||
case ctx.Bool(MainnetFlag.Name):
|
||||
config.LightChainConfig = bparams.MainnetLightConfig
|
||||
config.ChainConfig = *bparams.MainnetLightConfig
|
||||
case ctx.Bool(SepoliaFlag.Name):
|
||||
config.LightChainConfig = bparams.SepoliaLightConfig
|
||||
config.ChainConfig = *bparams.SepoliaLightConfig
|
||||
case ctx.Bool(HoleskyFlag.Name):
|
||||
config.LightChainConfig = bparams.HoleskyLightConfig
|
||||
config.ChainConfig = *bparams.HoleskyLightConfig
|
||||
default:
|
||||
if !customConfig {
|
||||
config.LightChainConfig = bparams.MainnetLightConfig
|
||||
config.ChainConfig = *bparams.MainnetLightConfig
|
||||
}
|
||||
}
|
||||
// Genesis root and time should always be specified together with custom chain config
|
||||
|
|
@ -1919,7 +1919,7 @@ func MakeBeaconLightConfig(ctx *cli.Context) bparams.LightClientConfig {
|
|||
if !ctx.IsSet(BeaconCheckpointFlag.Name) {
|
||||
Fatalf("Custom beacon chain config is specified but checkpoint is missing")
|
||||
}
|
||||
config.ChainConfig = &bparams.ChainConfig{
|
||||
config.ChainConfig = bparams.ChainConfig{
|
||||
GenesisTime: ctx.Uint64(BeaconGenesisTimeFlag.Name),
|
||||
}
|
||||
if c, err := hexutil.Decode(ctx.String(BeaconGenesisRootFlag.Name)); err == nil && len(c) <= 32 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue