From 02234891836ad1dd39913ad22531b4b5a3dcfef6 Mon Sep 17 00:00:00 2001 From: Jared Doro <56698307+DockBoss@users.noreply.github.com> Date: Thu, 10 Feb 2022 01:27:36 -0600 Subject: [PATCH] [WIP] Adding Support for Sepolia (#3462) * [WIP] Adding Sepolia * Fix formatting * Added Timestamp to Sepolia genesis * update config * fixed formating --- cmd/integration/commands/stages.go | 3 ++ cmd/sentry/sentry/sentry.go | 2 ++ cmd/utils/flags.go | 14 +++++++++ core/allocs/sepolia.json | 47 ++++++++++++++++++++++++++++++ core/genesis.go | 15 ++++++++++ params/bootnodes.go | 9 ++++++ params/config.go | 22 ++++++++++++++ params/networkname/network_name.go | 1 + turbo/node/node.go | 2 ++ 9 files changed, 115 insertions(+) create mode 100644 core/allocs/sepolia.json diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index e1feb3b9d..6ff43997a 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -1012,6 +1012,9 @@ func byChain() (*core.Genesis, *params.ChainConfig) { case "", networkname.MainnetChainName: chainConfig = params.MainnetChainConfig genesis = core.DefaultGenesisBlock() + case networkname.SepoliaChainName: + chainConfig = params.SepoliaChainConfig + genesis = core.DefaultSepoliaGenesisBlock() case networkname.RopstenChainName: chainConfig = params.RopstenChainConfig genesis = core.DefaultRopstenGenesisBlock() diff --git a/cmd/sentry/sentry/sentry.go b/cmd/sentry/sentry/sentry.go index d05f317aa..008554f91 100644 --- a/cmd/sentry/sentry/sentry.go +++ b/cmd/sentry/sentry/sentry.go @@ -167,6 +167,8 @@ func makeP2PServer( switch genesisHash { case params.MainnetGenesisHash: urls = params.MainnetBootnodes + case params.SepoliaGenesisHash: + urls = params.SepoliaBootnodes case params.RopstenGenesisHash: urls = params.RopstenBootnodes case params.GoerliGenesisHash: diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 670544524..f548fa603 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -653,6 +653,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { switch chain { case networkname.MainnetChainName: urls = params.MainnetBootnodes + case networkname.SepoliaChainName: + urls = params.SepoliaBootnodes case networkname.RopstenChainName: urls = params.RopstenBootnodes case networkname.RinkebyChainName: @@ -698,6 +700,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) { switch chain { case networkname.MainnetChainName: urls = params.MainnetBootnodes + case networkname.SepoliaChainName: + urls = params.SepoliaBootnodes case networkname.RopstenChainName: urls = params.RopstenBootnodes case networkname.RinkebyChainName: @@ -1016,6 +1020,8 @@ func DataDirForNetwork(datadir string, network string) string { return filepath.Join(datadir, "mumbai") case networkname.BorMainnetChainName: return filepath.Join(datadir, "bor-mainnet") + case networkname.SepoliaChainName: + return filepath.Join(datadir, "sepolia") default: return datadir } @@ -1424,6 +1430,12 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *node.Config, cfg *ethconfig.Conf } cfg.Genesis = core.DefaultGenesisBlock() SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash) + case networkname.SepoliaChainName: + if !ctx.GlobalIsSet(NetworkIdFlag.Name) { + cfg.NetworkID = 11155111 + } + cfg.Genesis = core.DefaultSepoliaGenesisBlock() + SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash) case networkname.RopstenChainName: if !ctx.GlobalIsSet(NetworkIdFlag.Name) { cfg.NetworkID = 3 @@ -1556,6 +1568,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { var genesis *core.Genesis chain := ctx.GlobalString(ChainFlag.Name) switch chain { + case networkname.SepoliaChainName: + genesis = core.DefaultSepoliaGenesisBlock() case networkname.RopstenChainName: genesis = core.DefaultRopstenGenesisBlock() case networkname.RinkebyChainName: diff --git a/core/allocs/sepolia.json b/core/allocs/sepolia.json new file mode 100644 index 000000000..e3d1af45c --- /dev/null +++ b/core/allocs/sepolia.json @@ -0,0 +1,47 @@ +{ + "0xa2A6d93439144FFE4D27c9E088dCD8b783946263": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xBc11295936Aa79d594139de1B2e12629414F3BDB": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0x7cF5b79bfe291A67AB02b393E456cCc4c266F753": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xaaec86394441f915bce3e6ab399977e9906f3b69": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xF47CaE1CF79ca6758Bfc787dbD21E6bdBe7112B8": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xd7eDDB78ED295B3C9629240E8924fb8D8874ddD8": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0x8b7F0977Bb4f0fBE7076FA22bC24acA043583F5e": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xe2e2659028143784d557bcec6ff3a0721048880a": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xd9a5179f091d85051d3c982785efd1455cec8699": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0xbeef32ca5b9a198d27B4e02F4c70439fE60356Cf": { + "balance": "0xD3C21BCECCEDA1000000" + }, + "0x0000006916a87b82333f4245046623b23794c65c": { + "balance": "0x84595161401484A000000" + }, + "0xb21c33de1fab3fa15499c62b59fe0cc3250020d1": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x10F5d45854e038071485AC9e402308cF80D2d2fE": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0xd7d76c58b3a519e9fA6Cc4D22dC017259BC49F1E": { + "balance": "0x52B7D2DCC80CD2E4000000" + }, + "0x799D329e5f583419167cD722962485926E338F4a": { + "balance": "0xDE0B6B3A7640000" + } +} \ No newline at end of file diff --git a/core/genesis.go b/core/genesis.go index 9bda4aa45..f47a8d6fd 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -283,6 +283,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { return g.Config case ghash == params.MainnetGenesisHash: return params.MainnetChainConfig + case ghash == params.SepoliaGenesisHash: + return params.SepoliaChainConfig case ghash == params.RopstenGenesisHash: return params.RopstenChainConfig case ghash == params.RinkebyGenesisHash: @@ -555,6 +557,19 @@ func DefaultGenesisBlock() *Genesis { } } +//DefaultSepoliaGenesisBlock returns the Sepolia network genesis block. +func DefaultSepoliaGenesisBlock() *Genesis { + return &Genesis{ + Config: params.SepoliaChainConfig, + Nonce: 0, + ExtraData: []byte("Sepolia, Athens, Attica, Greece!"), + GasLimit: 30000000, + Difficulty: big.NewInt(131072), + Timestamp: 1633267481, + Alloc: readPrealloc("allocs/sepolia.json"), + } +} + // DefaultRopstenGenesisBlock returns the Ropsten network genesis block. func DefaultRopstenGenesisBlock() *Genesis { return &Genesis{ diff --git a/params/bootnodes.go b/params/bootnodes.go index 5c04de094..eaaa4fbe2 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -32,6 +32,13 @@ var MainnetBootnodes = []string{ "enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303", // bootnode-azure-westus-001 } +// SepoliaBootnodes are the enode URLs of the P2P bootstrap nodes running on the +// Sepolia test network. +var SepoliaBootnodes = []string{ + "enode://7c9740e4d64674801fe62b76798d46778a038c49caebb15843d8c0f2b2f80d7ceba2585b4be366e6161988f81ddcfcd6fca98b5da52ae9a6f22c1b2a84b24a04@18.130.169.73:30303", + "enode://ec66ddcf1a974950bd4c782789a7e04f8aa7110a72569b6e65fcd51e937e74eed303b1ea734e4d19cfaec9fbff9b6ee65bf31dcb50ba79acce9dd63a6aca61c7@52.14.151.177:30303", +} + // RopstenBootnodes are the enode URLs of the P2P bootstrap nodes running on the // Ropsten test network. var RopstenBootnodes = []string{ @@ -160,6 +167,8 @@ func KnownDNSNetwork(genesis common.Hash, protocol string) string { switch genesis { case MainnetGenesisHash: net = "mainnet" + case SepoliaGenesisHash: + net = "sepolia" case RopstenGenesisHash: net = "ropsten" case RinkebyGenesisHash: diff --git a/params/config.go b/params/config.go index 987ab85c5..56fe2cfb5 100644 --- a/params/config.go +++ b/params/config.go @@ -41,6 +41,7 @@ const ( // Genesis hashes to enforce below configs on. var ( MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") + SepoliaGenesisHash = common.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9") RopstenGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177") GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a") @@ -89,6 +90,27 @@ var ( Ethash: new(EthashConfig), } + // SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network. + SepoliaChainConfig = &ChainConfig{ + ChainName: networkname.SepoliaChainName, + ChainID: big.NewInt(11155111), + Consensus: EtHashConsensus, + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + 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: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + Ethash: new(EthashConfig), + } + // RopstenChainConfig contains the chain parameters to run a node on the Ropsten test network. RopstenChainConfig = &ChainConfig{ ChainName: networkname.RopstenChainName, diff --git a/params/networkname/network_name.go b/params/networkname/network_name.go index 1ed8b068a..248362de6 100644 --- a/params/networkname/network_name.go +++ b/params/networkname/network_name.go @@ -2,6 +2,7 @@ package networkname const ( MainnetChainName = "mainnet" + SepoliaChainName = "sepolia" RopstenChainName = "ropsten" RinkebyChainName = "rinkeby" GoerliChainName = "goerli" diff --git a/turbo/node/node.go b/turbo/node/node.go index 3f1494e72..e4afae00d 100644 --- a/turbo/node/node.go +++ b/turbo/node/node.go @@ -57,6 +57,8 @@ func NewNodConfigUrfave(ctx *cli.Context) *node.Config { // If we're running a known preset, log it for convenience. chain := ctx.GlobalString(utils.ChainFlag.Name) switch chain { + case networkname.SepoliaChainName: + log.Info("Starting Erigon on Sepolia testnet...") case networkname.RopstenChainName: log.Info("Starting Erigon on Ropsten testnet...") case networkname.RinkebyChainName: