[WIP] Adding Support for Sepolia (#3462)

* [WIP] Adding Sepolia

* Fix formatting

* Added Timestamp to Sepolia genesis

* update config

* fixed formating
This commit is contained in:
Jared Doro 2022-02-10 01:27:36 -06:00 committed by GitHub
parent 7346f0b56d
commit 0223489183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 115 additions and 0 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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:

47
core/allocs/sepolia.json Normal file
View File

@ -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"
}
}

View File

@ -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{

View File

@ -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:

View File

@ -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,

View File

@ -2,6 +2,7 @@ package networkname
const (
MainnetChainName = "mainnet"
SepoliaChainName = "sepolia"
RopstenChainName = "ropsten"
RinkebyChainName = "rinkeby"
GoerliChainName = "goerli"

View File

@ -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: