Skip to content

Commit

Permalink
Merge branch 'mainnet-config' into release/1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
whitebit-robot committed Aug 4, 2023
2 parents 4ee0958 + 5e385e1 commit 77a73b9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,11 @@ func prepare(ctx *cli.Context) {
case ctx.IsSet(utils.SepoliaFlag.Name):
log.Info("Starting Geth on Sepolia testnet...")

case ctx.IsSet(utils.WbtMainnetFlag.Name):
log.Info("Starting Geth on WhiteBIT mainnet...")

case ctx.IsSet(utils.WbtTestnetFlag.Name):
log.Info("Starting Geth on WhiteBIT test network...")
log.Info("Starting Geth on WhiteBIT testnet...")

case ctx.IsSet(utils.DeveloperFlag.Name):
log.Info("Starting Geth in ephemeral dev mode...")
Expand Down
20 changes: 17 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,14 @@ var (
Usage: "Sepolia network: pre-configured proof-of-work test network",
Category: flags.EthCategory,
}
WbtMainnetFlag = &cli.BoolFlag{
Name: "wbt-mainnet",
Usage: "WhiteBIT mainnet",
Category: flags.EthCategory,
}
WbtTestnetFlag = &cli.BoolFlag{
Name: "wbt-testnet",
Usage: "WhiteBIT test network",
Usage: "WhiteBIT testnet",
Category: flags.EthCategory,
}

Expand Down Expand Up @@ -1010,7 +1015,7 @@ var (
WbtTestnetFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
NetworkFlags = append([]cli.Flag{MainnetFlag, WbtMainnetFlag}, TestnetFlags...)

// DatabasePathFlags is the flag group of all database path flags.
DatabasePathFlags = []cli.Flag{
Expand Down Expand Up @@ -1093,6 +1098,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.RinkebyBootnodes
case ctx.Bool(GoerliFlag.Name):
urls = params.GoerliBootnodes
case ctx.Bool(WbtMainnetFlag.Name):
urls = params.WbtMainnetBootnodes
case ctx.Bool(WbtTestnetFlag.Name):
urls = params.WbtTestnetBootnodes
}
Expand Down Expand Up @@ -1736,7 +1743,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, RinkebyFlag, GoerliFlag, SepoliaFlag, WbtTestnetFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, WbtMainnetFlag, WbtTestnetFlag)
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
if ctx.String(GCModeFlag.Name) == "archive" && ctx.Uint64(TxLookupLimitFlag.Name) != 0 {
Expand Down Expand Up @@ -1902,6 +1909,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
cfg.Genesis = core.DefaultGoerliGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.GoerliGenesisHash)
case ctx.Bool(WbtMainnetFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1875
}
cfg.Genesis = core.DefaultWbtMainnetGenesisBlock()
case ctx.Bool(WbtTestnetFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 2625
Expand Down Expand Up @@ -2227,6 +2239,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultRinkebyGenesisBlock()
case ctx.Bool(GoerliFlag.Name):
genesis = core.DefaultGoerliGenesisBlock()
case ctx.Bool(WbtMainnetFlag.Name):
genesis = core.DefaultWbtMainnetGenesisBlock()
case ctx.Bool(WbtTestnetFlag.Name):
genesis = core.DefaultWbtTestnetGenesisBlock()
case ctx.Bool(DeveloperFlag.Name):
Expand Down
24 changes: 23 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ func CommitGenesisState(db ethdb.Database, triedb *trie.Database, blockhash comm
genesis = DefaultGoerliGenesisBlock()
case params.SepoliaGenesisHash:
genesis = DefaultSepoliaGenesisBlock()
case params.WbtMainnetGenesisHash:
genesis = DefaultWbtMainnetGenesisBlock()
case params.WbtTestnetGenesisHash:
genesis = DefaultWbtTestnetGenesisBlock()
}
Expand Down Expand Up @@ -429,6 +431,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.RinkebyChainConfig
case ghash == params.GoerliGenesisHash:
return params.GoerliChainConfig
case ghash == params.WbtMainnetGenesisHash:
return params.WbtMainnetChainConfig
case ghash == params.WbtTestnetGenesisHash:
return params.WbtTestnetChainConfig
default:
Expand Down Expand Up @@ -572,7 +576,25 @@ func DefaultSepoliaGenesisBlock() *Genesis {
}
}

// DefaultWbtTestnetGenesisBlock returns the WhiteBIT test network genesis block.
// DefaultWbtMainnetGenesisBlock returns the WhiteBIT mainnet genesis block.
func DefaultWbtMainnetGenesisBlock() *Genesis {
var alloc GenesisAlloc

if err := json.Unmarshal([]byte(wbtMainnetAllocData), &alloc); err != nil {
panic(err)
}

return &Genesis{
Config: params.WbtMainnetChainConfig,
Timestamp: 1691056800,
ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000a3e7238883a8c53d218dabf4a2541b569ac0b2320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 30000000,
Difficulty: big.NewInt(1),
Alloc: alloc,
}
}

// DefaultWbtTestnetGenesisBlock returns the WhiteBIT testnet genesis block.
func DefaultWbtTestnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.WbtTestnetChainConfig,
Expand Down
2 changes: 2 additions & 0 deletions core/genesis_alloc.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func TestGenesisHashes(t *testing.T) {
{DefaultGoerliGenesisBlock(), params.GoerliGenesisHash},
{DefaultRinkebyGenesisBlock(), params.RinkebyGenesisHash},
{DefaultSepoliaGenesisBlock(), params.SepoliaGenesisHash},
{DefaultWbtMainnetGenesisBlock(), params.WbtMainnetGenesisHash},
{DefaultWbtTestnetGenesisBlock(), params.WbtTestnetGenesisHash},
} {
// Test via MustCommit
Expand Down
6 changes: 6 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var GoerliBootnodes = []string{
"enode://d2b720352e8216c9efc470091aa91ddafc53e222b32780f505c817ceef69e01d5b0b0797b69db254c586f493872352f5a022b4d8479a00fc92ec55f9ad46a27e@88.99.70.182:30303",
}

var WbtMainnetBootnodes = []string{
"enode://57c5ddde0b818b4a2444818824e3f92407788d2d21b1eaacfbcba633329ddcdbc581da38f1d164746350936620e459d011de3c54fc8e41821e26a776bcd48c21@bootnode1.whitebit.network:30303",
"enode://32ede37c6615b7177133ea9bc85a392218a66e06b3bcf98788a15a30527abb24b5959e75af12fffdc673d72d4d1b707f330c900298d535d492c7f56d943f796e@bootnode2.whitebit.network:30303",
"enode://6732855203b88dd6155870083d233f67ddf57e366dfbcb62b098fd915dfbd8a0019f4a9c51df3b1b65e5671947f20060a7097aba634d7125b980e8cc3b3b1deb@bootnode3.whitebit.network:30303",
}

var WbtTestnetBootnodes = []string{
"enode://5da705c3da6701cade478c078c6c655a1996127d6141c9ced4cd7dd0f01a999333db0ca7efe322d0ea5cec94d8dd8fd2064035cc1e7b59d843ca156fa2280626@bootnode1-testnet.whitebit.network:30303",
"enode://15dd558bda09365ae0e86ab980c7192e50b91b07f308ece9d3ca1bd00ca7f0ff9a4f96f0ca0affb686e8453e4209e58cdc1c6504da2750f7766348121dad2f14@bootnode2-testnet.whitebit.network:30303",
Expand Down
46 changes: 43 additions & 3 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var (
SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
WbtMainnetGenesisHash = common.HexToHash("0x8df702fba44bb7a93f791cabad69d940a07884a9d196da39606897335f66be70")
WbtTestnetGenesisHash = common.HexToHash("0x3786ce655da7e41d4164e255422df800c7276d94b0c4b10f856ae67ab48119c4")
)

Expand Down Expand Up @@ -223,7 +224,45 @@ var (
Threshold: 2,
}

// WbtTestnetChainConfig contains config for the WhiteBIT test network
WbtMainnetFeeCollector = common.HexToAddress("0x0000000000000000000000000000000000001001")
WbtMainnetMintOwner = common.HexToAddress("0x6960B8EC5EEa77009F05b793c1865ba4F5168cb8")
WbtMainnetMintLimit = new(big.Int).Mul(big.NewInt(323816188), big.NewInt(Ether))

// WbtMainnetChainConfig contains config for the WhiteBIT mainnet
WbtMainnetChainConfig = &ChainConfig{
ChainID: big.NewInt(1875),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
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),
MuirGlacierBlock: nil,
BerlinBlock: nil,
LondonBlock: nil,
ArrowGlacierBlock: nil,
TerminalTotalDifficulty: nil,
TerminalTotalDifficultyPassed: false,
Clique: &CliqueConfig{
Period: 2,
Epoch: 30000,
},
MintContract: &MintContractConfig{
ActivationBlock: big.NewInt(1),
OwnerAddress: WbtMainnetMintOwner,
MintLimit: (*math.HexOrDecimal256)(WbtMainnetMintLimit),
},
FeeCollectorAddress: &WbtMainnetFeeCollector,
}

WbtTestnetMintOwner = common.HexToAddress("0xF8bd3D4C4482bDFF5e6be5f5029ab08Ad0401642")
WbtTestnetMintLimit = new(big.Int).Mul(big.NewInt(400000000), big.NewInt(Ether))

// WbtTestnetChainConfig contains config for the WhiteBIT testnet
WbtTestnetChainConfig = &ChainConfig{
ChainID: big.NewInt(2625),
HomesteadBlock: big.NewInt(0),
Expand All @@ -248,8 +287,8 @@ var (
},
MintContract: &MintContractConfig{
ActivationBlock: big.NewInt(3746350),
OwnerAddress: common.HexToAddress("0xF8bd3D4C4482bDFF5e6be5f5029ab08Ad0401642"),
MintLimit: (*math.HexOrDecimal256)(new(big.Int).Mul(big.NewInt(400000000), big.NewInt(Ether))),
OwnerAddress: WbtTestnetMintOwner,
MintLimit: (*math.HexOrDecimal256)(WbtTestnetMintLimit),
},
}

Expand Down Expand Up @@ -377,6 +416,7 @@ var NetworkNames = map[string]string{
RinkebyChainConfig.ChainID.String(): "rinkeby",
GoerliChainConfig.ChainID.String(): "goerli",
SepoliaChainConfig.ChainID.String(): "sepolia",
WbtMainnetChainConfig.ChainID.String(): "wbt-mainnet",
WbtTestnetChainConfig.ChainID.String(): "wbt-testnet",
}

Expand Down

0 comments on commit 77a73b9

Please sign in to comment.