Add genesis block from plugins

This commit is contained in:
Austin Roberts 2023-10-02 13:18:05 -05:00
parent f7ad35eae9
commit 07e9739871
4 changed files with 274 additions and 270 deletions

View File

@ -1698,7 +1698,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil {
cfg.NetworkId = *pluginNetworkId cfg.NetworkId = *pluginNetworkId
} }
if cfg.EthDiscoveryURLs == nil { if cfg.EthDiscoveryURLs == nil {
var lightMode bool var lightMode bool
if cfg.SyncMode == downloader.LightSync { if cfg.SyncMode == downloader.LightSync {
@ -2204,6 +2203,11 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
case ctx.Bool(DeveloperFlag.Name): case ctx.Bool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral") Fatalf("Developer chains are ephemeral")
} }
//begin plugeth injection
if genesis == nil {
genesis = pluginGenesisBlock()
}
//end plugeth injection
return genesis return genesis
} }

View File

@ -9,7 +9,7 @@ import (
func DefaultDataDir(pl *plugins.PluginLoader, path string) string { func DefaultDataDir(pl *plugins.PluginLoader, path string) string {
dataDirPath := "" dataDirPath := ""
fnList := pl.Lookup("SetDefaultDataDir", func(item interface{}) bool { fnList := pl.Lookup("DefaultDataDir", func(item interface{}) bool {
_, ok := item.(func(string) string) _, ok := item.(func(string) string)
return ok return ok
}) })
@ -80,7 +80,7 @@ func PluginETHDiscoveryURLs(pl *plugins.PluginLoader, mode bool) []string {
return ok return ok
}) })
for _, fni := range fnList { for _, fni := range fnList {
if fn, ok := fni.(func(bool) []string); ok { if fn, ok := fni.(func(mode bool) []string); ok {
ethDiscoveryURLs = fn(mode) ethDiscoveryURLs = fn(mode)
} }
} }

View File

@ -22,7 +22,7 @@
"nonce": "0x0", "nonce": "0x0",
"timestamp": "0x603e6caa", "timestamp": "0x603e6caa",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760", "gasLimit": "0x1c9c380",
"difficulty": "0x1", "difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000", "coinbase": "0x0000000000000000000000000000000000000000",
@ -808,4 +808,4 @@
"number": "0x0", "number": "0x0",
"gasUsed": "0x0", "gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
} }

View File

@ -482,9 +482,9 @@ func CloneChainConfig(cf *gparams.ChainConfig) *params.ChainConfig {
if lv.Kind() != reflect.Invalid { if lv.Kind() != reflect.Invalid {
// If core.ChainConfig doesn't have this field, skip it. // If core.ChainConfig doesn't have this field, skip it.
if v.Type() == lv.Type() && lv.CanSet() { if v.Type() == lv.Type() && lv.CanSet() {
lv.Set(v) v.Set(lv)
} else { } else {
convertAndSet(lv, v) convertAndSet(v, lv)
} }
} }
} }