Skip to content

Commit

Permalink
feat(config): add story mainnet flag (#77)
Browse files Browse the repository at this point in the history
* feat(config): add story mainnet flag

* chore(genesis): change alloc data for Homer

* chore(network): rename to homer mainnet

* chore(network): rename to story for mainnet chain

* chore(network): add todo for updating bootnodes
  • Loading branch information
0xHansLee authored Dec 13, 2024
1 parent f738866 commit ae9ad63
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,11 @@ var (
Usage: "odyssey test network: pre-configured proof-of-stake test network",
Category: flags.MiscCategory,
}
StoryFlag = &cli.BoolFlag{
Name: "story",
Usage: "story main network: pre-configured proof of stake main network",
Category: flags.MiscCategory,
}
LocalFlag = &cli.BoolFlag{
Name: "local",
Usage: "local test network: pre-configured local proof-of-stake test network",
Expand Down Expand Up @@ -993,7 +998,7 @@ var (
LocalFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
NetworkFlags = append([]cli.Flag{MainnetFlag, StoryFlag}, TestnetFlags...)

// DatabaseFlags is the flag group of all database flags.
DatabaseFlags = []cli.Flag{
Expand Down Expand Up @@ -1026,6 +1031,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.Bool(OdysseyFlag.Name) {
return filepath.Join(path, "odyssey")
}
if ctx.Bool(StoryFlag.Name) {
return filepath.Join(path, "story")
}
if ctx.Bool(LocalFlag.Name) {
return filepath.Join(path, "local")
}
Expand Down Expand Up @@ -1095,6 +1103,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.IliadBootnodes
case ctx.Bool(OdysseyFlag.Name):
urls = params.OdysseyBootnodes
case ctx.Bool(StoryFlag.Name):
urls = params.StoryBootnodes
case ctx.Bool(LocalFlag.Name):
urls = params.LocalBootnodes
}
Expand Down Expand Up @@ -1532,6 +1542,8 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "iliad")
case ctx.Bool(OdysseyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "odyssey")
case ctx.Bool(StoryFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "story")
case ctx.Bool(LocalFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "local")
}
Expand Down Expand Up @@ -1689,7 +1701,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, IliadFlag, OdysseyFlag, LocalFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, GoerliFlag, SepoliaFlag, HoleskyFlag, IliadFlag, OdysseyFlag, StoryFlag, LocalFlag)
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer

// Set configurations from CLI flags
Expand Down Expand Up @@ -1877,6 +1889,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
cfg.Genesis = core.DefaultOdysseyGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.OdysseyGenesisHash)
cfg.Miner.GasPrice = big.NewInt(params.GWei * 16)
case ctx.Bool(StoryFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1415
}
cfg.Genesis = core.DefaultStoryGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.StoryGenesisHash)
cfg.Miner.GasPrice = big.NewInt(params.GWei * 16)
case ctx.Bool(LocalFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1511
Expand Down Expand Up @@ -2209,6 +2228,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultIliadGenesisBlock()
case ctx.Bool(OdysseyFlag.Name):
genesis = core.DefaultOdysseyGenesisBlock()
case ctx.Bool(StoryFlag.Name):
genesis = core.DefaultStoryGenesisBlock()
case ctx.Bool(LocalFlag.Name):
genesis = core.DefaultLocalGenesisBlock()
case ctx.Bool(DeveloperFlag.Name):
Expand Down
12 changes: 12 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,18 @@ func DefaultOdysseyGenesisBlock() *Genesis {
}
}

// DefaultStoryGenesisBlock returns the Story main network genesis block.
func DefaultStoryGenesisBlock() *Genesis {
return &Genesis{
Config: params.StoryChainConfig,
Difficulty: big.NewInt(0x20000),
GasLimit: 0x7A1200,
Nonce: 0x42,
Timestamp: 0,
Alloc: decodePrealloc(storyAllocData), // TODO: change to Story mainnet alloc data
}
}

// DefaultLocalGenesisBlock returns the network genesis block for local testing.
func DefaultLocalGenesisBlock() *Genesis {
return &Genesis{
Expand Down
1 change: 1 addition & 0 deletions core/genesis_alloc.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ var OdysseyBootnodes = []string{
"enode://298bc05889e120e50e7a344e31adb72901caaff9e747b3e8f57c5786e6167452857cbd0ff7d5e0f849a8dfd26efcc3da1795e28d7cb05d120e97a89e79ec4b18@b2.odyssey-testnet.storyrpc.io:30303",
}

// StoryBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Story main network.
var StoryBootnodes = []string{
// Upstream bootnodes
// TODO: update bootnodes for mainnet
"enode://077aa94a5bf388adda35e0d5a7bd8cb5e9741ea5c18381fd14b16018e112497b7c0a400f50677deb4271af3bc0a1b74f093067a398257b76e3a0d7387a432110@b1.odyssey-testnet.storyrpc.io:30303",
"enode://298bc05889e120e50e7a344e31adb72901caaff9e747b3e8f57c5786e6167452857cbd0ff7d5e0f849a8dfd26efcc3da1795e28d7cb05d120e97a89e79ec4b18@b2.odyssey-testnet.storyrpc.io:30303",
}

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

Expand Down Expand Up @@ -187,6 +188,27 @@ var (
Enable4844: false,
}

StoryChainConfig = &ChainConfig{
ChainID: big.NewInt(1415),
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),
Enable4844: false,
}

LocalChainConfig = &ChainConfig{
ChainID: big.NewInt(1511),
HomesteadBlock: big.NewInt(0),
Expand Down

0 comments on commit ae9ad63

Please sign in to comment.