Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geth iliad config and data folder defaults #7

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,11 @@ var (
TakesFile: true,
Category: flags.MiscCategory,
}
IliadFlag = &cli.BoolFlag{
Name: "iliad",
Usage: "iliad test network: pre-configured proof-of-stake test network",
Category: flags.MiscCategory,
}

// RPC settings
IPCDisabledFlag = &cli.BoolFlag{
Expand Down Expand Up @@ -967,6 +972,7 @@ var (
GoerliFlag,
SepoliaFlag,
HoleskyFlag,
IliadFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
Expand Down Expand Up @@ -996,6 +1002,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.Bool(HoleskyFlag.Name) {
return filepath.Join(path, "holesky")
}
if ctx.Bool(IliadFlag.Name) {
return filepath.Join(path, "iliad")
}
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
Expand Down Expand Up @@ -1058,6 +1067,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.SepoliaBootnodes
case ctx.Bool(GoerliFlag.Name):
urls = params.GoerliBootnodes
case ctx.Bool(IliadFlag.Name):
urls = params.IliadBootnodes
}
}
cfg.BootstrapNodes = mustParseBootnodes(urls)
Expand Down Expand Up @@ -1489,6 +1500,8 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "holesky")
case ctx.Bool(IliadFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "iliad")
}
}

Expand Down Expand Up @@ -1644,7 +1657,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// Avoid conflicting network flags
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, GoerliFlag, SepoliaFlag, HoleskyFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, GoerliFlag, SepoliaFlag, HoleskyFlag, IliadFlag)
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer

// Set configurations from CLI flags
Expand Down Expand Up @@ -1819,6 +1832,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
cfg.Genesis = core.DefaultGoerliGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash)
case ctx.Bool(IliadFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1723078116
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is number coming from?

}
cfg.Genesis = core.DefaultIliadGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.IliadGenesisHash)
case ctx.Bool(DeveloperFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337
Expand Down Expand Up @@ -2142,6 +2161,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultSepoliaGenesisBlock()
case ctx.Bool(GoerliFlag.Name):
genesis = core.DefaultGoerliGenesisBlock()
case ctx.Bool(IliadFlag.Name):
genesis = core.DefaultIliadGenesisBlock()
case ctx.Bool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral")
}
Expand Down
35 changes: 26 additions & 9 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ func getGenesisState(db ethdb.Database, blockhash common.Hash) (alloc types.Gene
genesis = DefaultSepoliaGenesisBlock()
case params.HoleskyGenesisHash:
genesis = DefaultHoleskyGenesisBlock()
case params.IliadGenesisHash:
genesis = DefaultIliadGenesisBlock()
}
if genesis != nil {
return genesis.Alloc, nil
Expand Down Expand Up @@ -409,6 +411,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.SepoliaChainConfig
case ghash == params.GoerliGenesisHash:
return params.GoerliChainConfig
case ghash == params.IliadGenesisHash:
return params.IliadChainConfig
default:
return params.AllEthashProtocolChanges
}
Expand Down Expand Up @@ -572,6 +576,18 @@ func DefaultHoleskyGenesisBlock() *Genesis {
}
}

// DefaultIliadGenesisBlock returns the iliad network genesis block.
func DefaultIliadGenesisBlock() *Genesis {
return &Genesis{
Config: params.IliadChainConfig,
Difficulty: big.NewInt(0x20000),
GasLimit: 0x7A1200,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any impact of the gas limit at genesis? 8m

Nonce: 0x42,
Timestamp: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 0?

Alloc: decodePrealloc(iliadAllocData),
}
}

// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
// Override the default period to the user requested one
Expand All @@ -584,16 +600,17 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(0),
Alloc: map[common.Address]types.Account{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, please remove the extra space to reduce the unnecessary changes.

common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
common.BytesToAddress([]byte{4}): {Balance: big.NewInt(1)}, // Identity
common.BytesToAddress([]byte{5}): {Balance: big.NewInt(1)}, // ModExp
common.BytesToAddress([]byte{6}): {Balance: big.NewInt(1)}, // ECAdd
common.BytesToAddress([]byte{7}): {Balance: big.NewInt(1)}, // ECScalarMul
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b
common.BytesToAddress([]byte{26}): {Balance: big.NewInt(1)}, // ipGraph

// Pre-deploy EIP-4788 system contract
params.BeaconRootsAddress: {Nonce: 1, Code: params.BeaconRootsCode, Balance: common.Big0},
},
Expand Down
1 change: 1 addition & 0 deletions core/genesis_alloc.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ func testSetupGenesis(t *testing.T, scheme string) {
wantHash: params.GoerliGenesisHash,
wantConfig: params.GoerliChainConfig,
},
{
name: "custom block in DB, genesis == iliad",
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
tdb := triedb.NewDatabase(db, newDbConfig(scheme))
customg.Commit(db, tdb)
return SetupGenesisBlock(db, tdb, DefaultIliadGenesisBlock())
},
wantErr: &GenesisMismatchError{Stored: customghash, New: params.IliadGenesisHash},
wantHash: params.IliadGenesisHash,
wantConfig: params.IliadChainConfig,
},
{
name: "compatible config in DB",
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
Expand Down Expand Up @@ -186,6 +197,7 @@ func TestGenesisHashes(t *testing.T) {
{DefaultGenesisBlock(), params.MainnetGenesisHash},
{DefaultGoerliGenesisBlock(), params.GoerliGenesisHash},
{DefaultSepoliaGenesisBlock(), params.SepoliaGenesisHash},
{DefaultIliadGenesisBlock(), params.IliadGenesisHash},
} {
// Test via MustCommit
db := rawdb.NewMemoryDatabase()
Expand Down
8 changes: 4 additions & 4 deletions node/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ func DefaultDataDir() string {
if home != "" {
switch runtime.GOOS {
case "darwin":
return filepath.Join(home, "Library", "Ethereum")
return filepath.Join(home, "Library", "Story", "geth")
case "windows":
// We used to put everything in %HOME%\AppData\Roaming, but this caused
// problems with non-typical setups. If this fallback location exists and
// is non-empty, use it, otherwise DTRT and check %LOCALAPPDATA%.
fallback := filepath.Join(home, "AppData", "Roaming", "Ethereum")
fallback := filepath.Join(home, "AppData", "Roaming", "Story", "geth")
appdata := windowsAppData()
if appdata == "" || isNonEmptyDir(fallback) {
return fallback
}
return filepath.Join(appdata, "Ethereum")
return filepath.Join(appdata, "Story", "geth")
default:
return filepath.Join(home, ".ethereum")
return filepath.Join(home, ".story", "geth")
}
}
// As we cannot guess a stable location, return empty and handle later
Expand Down
8 changes: 8 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ var SepoliaBootnodes = []string{
"enode://9e9492e2e8836114cc75f5b929784f4f46c324ad01daf87d956f98b3b6c5fcba95524d6e5cf9861dc96a2c8a171ea7105bb554a197455058de185fa870970c7c@138.68.123.152:30303", // sepolia-bootnode-1-ams3
}

// IliadBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Iliad test network.
var IliadBootnodes = []string{
// Upstream bootnodes
"enode://5e85033276299eff126d0c86a42b76cbad98920b4f77ae894b8a52daffa558f36de1281beca96b71e67795955bf769ce6ab3e35af66790816b37ada3d9c2b09a@52.9.220.233:30303",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup b1.testnet.storyrpc.io and b2.testnet.storyrpc.io

"enode://7f7685f85a6cfbdb5342ef977ae9d1c82dae4fa8d0f3b141c0c1bb86a01bbc7ac081aa336ff9b341b751f756d388ac4eabbd810e548b52dfb835de0c844bd8b9@54.241.155.73:30303",
}

// GoerliBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Görli test network.
var GoerliBootnodes = []string{
Expand Down
23 changes: 23 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
HoleskyGenesisHash = common.HexToHash("0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4")
SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
IliadGenesisHash = common.HexToHash("0x0be40479b95ce64a5d7662b6ac3f4fc5de2479d68095b7cd57e752309e2f060d")
)

func newUint64(val uint64) *uint64 { return &val }
Expand Down Expand Up @@ -137,6 +138,27 @@ var (
Epoch: 30000,
},
}

IliadChainConfig = &ChainConfig{
ChainID: big.NewInt(1513),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
PetersburgBlock: big.NewInt(0),
IstanbulBlock: big.NewInt(0),
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
TerminalTotalDifficulty: big.NewInt(0),
TerminalTotalDifficultyPassed: true,
ShanghaiTime: newUint64(0),
CancunTime: newUint64(0),
}

// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus.
AllEthashProtocolChanges = &ChainConfig{
Expand Down Expand Up @@ -316,6 +338,7 @@ var NetworkNames = map[string]string{
GoerliChainConfig.ChainID.String(): "goerli",
SepoliaChainConfig.ChainID.String(): "sepolia",
HoleskyChainConfig.ChainID.String(): "holesky",
IliadChainConfig.ChainID.String(): "iliad",
}

// ChainConfig is the core config which determines the blockchain settings.
Expand Down
Loading