Skip to content

Commit

Permalink
Added network_id recognition (Trying to fix nil genesis) (#11990)
Browse files Browse the repository at this point in the history
closes #11797

---------

Co-authored-by: JkLondon <[email protected]>
  • Loading branch information
JkLondon and JkLondon authored Sep 17, 2024
1 parent fa268dc commit fef39d7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
9 changes: 8 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package utils
import (
"crypto/ecdsa"
"fmt"
"github.com/erigontech/erigon-lib/chain/networkid"
"math/big"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -1794,7 +1795,13 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
if ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkID = ctx.Uint64(NetworkIdFlag.Name)
if cfg.NetworkID != 1 && !ctx.IsSet(ChainFlag.Name) {
chain = "" // don't default to mainnet if NetworkID != 1
chainName, ok := networkid.NetworkNameByID[cfg.NetworkID]
if !ok {
chain = "" // don't default to mainnet if NetworkID != 1 and it's devchain or smth
} else {
chain = chainName // fetch network name from id if name wasn't provided
}

}
} else {
cfg.NetworkID = params.NetworkIDByChainName(chain)
Expand Down
36 changes: 36 additions & 0 deletions erigon-lib/chain/networkid/network_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package networkid

const (
MainnetChainID = 1
HoleskyChainID = 17000
SepoliaChainID = 11155111
DevChainName = 1337
AmoyChainID = 80002
BorMainnetChainID = 137
BorDevnetChainID = 1337
GnosisChainID = 100
ChiadoChainID = 10200
TestID = 1337
)

var All = []uint64{
MainnetChainID,
HoleskyChainID,
SepoliaChainID,
AmoyChainID,
BorMainnetChainID,
BorDevnetChainID,
GnosisChainID,
ChiadoChainID,
TestID,
}

var NetworkNameByID = map[uint64]string{
MainnetChainID: "mainnet",
HoleskyChainID: "holesky",
SepoliaChainID: "sepolia",
AmoyChainID: "amoy",
BorMainnetChainID: "bor-mainnet",
GnosisChainID: "gnosis",
ChiadoChainID: "chiado",
}
9 changes: 6 additions & 3 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,12 @@ func ExecV3(ctx context.Context,
// snapshots are often stored on chaper drives. don't expect low-read-latency and manually read-ahead.
// can't use OS-level ReadAhead - because Data >> RAM
// it also warmsup state a bit - by touching senders/coninbase accounts and code
var clean func()
readAhead, clean = blocksReadAhead(ctx, &cfg, 4, true)
defer clean()
if !execStage.CurrentSyncCycle.IsInitialCycle {
var clean func()

readAhead, clean = blocksReadAhead(ctx, &cfg, 4, true)
defer clean()
}
}

//fmt.Printf("exec blocks: %d -> %d\n", blockNum, maxBlockNum)
Expand Down

0 comments on commit fef39d7

Please sign in to comment.