Skip to content

Commit

Permalink
add galileo config
Browse files Browse the repository at this point in the history
add codegen for header
  • Loading branch information
Qi Zhou committed Mar 4, 2022
1 parent 695be14 commit 5c6dc6d
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 7 deletions.
19 changes: 18 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ var (
Name: "web3q_testnet",
Usage: "Web3Q network: pre-configured proof-of-authority test network",
}
Web3QGalileoFlag = cli.BoolFlag{
Name: "web3q_galileo",
Usage: "Web3Q network: pre-configured proof-of-authority BFT test network",
}
Web3QMainnetFlag = cli.BoolFlag{
Name: "web3q_mainnet",
Usage: "Web3Q mainnet",
Expand Down Expand Up @@ -822,6 +826,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(Web3QTestnetFlag.Name) {
return filepath.Join(path, "web3q_testnet")
}
if ctx.GlobalBool(Web3QGalileoFlag.Name) {
return filepath.Join(path, "web3q_galileo")
}
if ctx.GlobalBool(Web3QMainnetFlag.Name) {
return filepath.Join(path, "web3q_mainnet")
}
Expand Down Expand Up @@ -881,6 +888,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.GoerliBootnodes
case ctx.GlobalBool(Web3QTestnetFlag.Name):
urls = params.Web3QTestnetBootnodes
case ctx.GlobalBool(Web3QGalileoFlag.Name):
urls = params.Web3QGalileoBootnodes
case ctx.GlobalBool(Web3QMainnetFlag.Name):
urls = params.Web3QMainnetBootnodes
case cfg.BootstrapNodes != nil:
Expand Down Expand Up @@ -1306,6 +1315,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
case ctx.GlobalBool(Web3QTestnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "web3q_testnet")
case ctx.GlobalBool(Web3QGalileoFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "web3q_galileo")
case ctx.GlobalBool(Web3QMainnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "web3q_mainnet")
}
Expand Down Expand Up @@ -1493,7 +1504,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, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, Web3QTestnetFlag, Web3QMainnetFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag, Web3QTestnetFlag, Web3QGalileoFlag, Web3QMainnetFlag)
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
if ctx.GlobalString(GCModeFlag.Name) == "archive" && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
Expand Down Expand Up @@ -1661,6 +1672,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
cfg.Genesis = core.DefaultWeb3QTestnetGenesisBlock()
SetDNSDiscoveryDefaults(cfg, cfg.Genesis.ToBlock(nil).Hash())
case ctx.GlobalBool(Web3QGalileoFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 3334
}
cfg.Genesis = core.DefaultWeb3QGalileoGenesisBlock()
SetDNSDiscoveryDefaults(cfg, cfg.Genesis.ToBlock(nil).Hash())
case ctx.GlobalBool(Web3QMainnetFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 333
Expand Down
4 changes: 3 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func DefaultWeb3QTestnetGenesisBlock() *Genesis {
// DefaultWeb3QGalileoGenesisBlock returns the Web3Q test network genesis block.
func DefaultWeb3QGalileoGenesisBlock() *Genesis {
return &Genesis{
Config: params.Web3QTestnetChainConfig,
Config: params.Web3QGalileoChainConfig,
Nonce: 0,
ExtraData: hexutil.MustDecode("0x57656c636f6d6520746f20746865206272617665206e657720776f726c6421"),
GasLimit: 30000000,
Expand All @@ -451,6 +451,8 @@ func DefaultWeb3QGalileoGenesisBlock() *Genesis {
Alloc: map[common.Address]GenesisAccount{
common.HexToAddress("0x0E961a6A6235eFDB9a0F0BC753E395211B77cc28"): {Balance: new(big.Int).Mul(big.NewInt(1000000000000000000), big.NewInt(1000000000))}, // 1e9 Ether
},
NextValidators: []common.Address{common.HexToAddress("0xC7B6Ad1038b5a79c12B066d6E3e8972f3EceaDe7")},
NextValidatorPowers: []uint64{1},
}
}

Expand Down
49 changes: 48 additions & 1 deletion core/types/gen_header_rlp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ var Web3QTestnetBootnodes = []string{
"enode://0b1f72bd2cdf8af6b42e1f1b24b1e927afd393de4a43f69f5bc402e2754d06bc140c3c3baac12f94aaf0aa4513f2b216c768c5d1a66f0b3b6c923575f0db64b1@128.199.102.174:30303",
}

// TODO: to update
var Web3QGalileoBootnodes = []string{}

var Web3QMainnetBootnodes = []string{
"enode://0c2e9b39c4f8655d6cdd3dd3a57bee4fb1c20a3c844507b36bd806d7219048e3df6b7bc3dcc0a1830b59c7d25f983572c11a8ab8469e21a8d937f4ba84d98288@143.244.163.228:30303",
"enode://50206144578410407a682aef0353f6efc9372efaf8c0077b3e37b9d87a7d548531da4df8e7682da976e446f9a71af96e7ab0b279c876d17b48da9b351633a373@128.199.163.220:30303",
Expand Down
29 changes: 25 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/binary"
"fmt"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
"golang.org/x/crypto/sha3"
Expand Down Expand Up @@ -278,7 +279,7 @@ var (

// Web3QGalileoChainConfig contains the chain parameters to run a node on the Web3Q test network.
Web3QGalileoChainConfig = &ChainConfig{
ChainID: big.NewInt(3333),
ChainID: big.NewInt(3334),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
Expand All @@ -293,9 +294,28 @@ var (
BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: nil,
Clique: &CliqueConfig{
Period: 6,
Epoch: 100800, // one week
Tendermint: &TendermintConfig{
Epoch: 100800, // expect 6s block interval = one week
P2pPort: 33333,
ProposerRepetition: 8,
P2pBootstrap: "/ip4/127.0.0.1/udp/33333/quic/p2p/12D3KooWRqZRJf6gYeLgeUnNCnKeRb29KiEVQcvRWk2tet9Q3Hmy",
NodeKeyPath: "/Users/qizhou/.ssh/node_galileo.key",
ValKeyPath: "/Users/qizhou/.ssh/val_galileo.key",
consensusConfig: ConsensusConfig{
// WalPath: filepath.Join(defaultDataDir, "cs.wal", "wal"),
TimeoutPropose: 3000 * time.Millisecond,
TimeoutProposeDelta: 500 * time.Millisecond,
TimeoutPrevote: 1000 * time.Millisecond,
TimeoutPrevoteDelta: 500 * time.Millisecond,
TimeoutPrecommit: 1000 * time.Millisecond,
TimeoutPrecommitDelta: 500 * time.Millisecond,
TimeoutCommit: 5000 * time.Millisecond,
SkipTimeoutCommit: false,
PeerGossipSleepDuration: 100 * time.Millisecond,
PeerQueryMaj23SleepDuration: 2000 * time.Millisecond,
DoubleSignCheckHeight: uint64(0),
ConsensusSyncRequestDuration: 500 * time.Millisecond,
},
},
}

Expand Down Expand Up @@ -451,6 +471,7 @@ type TendermintConfig struct {
P2pBootstrap string
NodeName string
ProposerRepetition uint64
consensusConfig ConsensusConfig
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down

0 comments on commit 5c6dc6d

Please sign in to comment.