Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Add config for Gnosis Chain (erigontech#4671)
Browse files Browse the repository at this point in the history
* Draft: gnosis-chain

* Fix Gnosis allocation

Co-authored-by: yperbasis <andrey.ashikhmin@gmail.com>
  • Loading branch information
primalcs and yperbasis committed Jul 12, 2022
1 parent 6b6b74e commit cd5ef32
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,8 @@ func chainConfig(name string) error {
chainConfig = params.MumbaiChainConfig
case "bor-mainnet":
chainConfig = params.BorMainnetChainConfig
case "gnosis":
chainConfig = params.GnosisChainConfig
default:
return fmt.Errorf("unknown name: %s", name)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,8 @@ func DataDirForNetwork(datadir string, network string) string {
return filepath.Join(datadir, "bor-devnet")
case networkname.SepoliaChainName:
return filepath.Join(datadir, "sepolia")
case networkname.GnosisChainName:
return filepath.Join(datadir, "gnosis")
default:
return datadir
}
Expand Down
5 changes: 5 additions & 0 deletions consensus/aura/consensusconfig/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ import (
//go:embed poasokol.json
var Sokol []byte

//go:embed poagnosis.json
var Gnosis []byte

func GetConfigByChain(chainName string) []byte {
switch chainName {
case networkname.SokolChainName:
return Sokol
case networkname.GnosisChainName:
return Gnosis
default:
return Sokol
}
Expand Down
25 changes: 25 additions & 0 deletions consensus/aura/consensusconfig/poagnosis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"stepDuration": 5,
"blockReward": "0x0",
"maximumUncleCountTransition": 0,
"maximumUncleCount": 0,
"validators": {
"multi": {
"0": {
"safeContract": "0xcace5b3c29211740e595850e80478416ee77ca21"
},
"1300": {
"safeContract": "0x22e1229a2c5b95a60983b5577f745a603284f535"
},
"9186425": {
"safeContract": "0xB87BE9f7196F2AE084Ca1DE6af5264292976e013"
}
}
},
"blockRewardContractAddress": "0x867305d19606aadba405ce534e303d0e225f9556",
"blockRewardContractTransition": 1310,
"randomnessContractAddress": {
"9186425": "0x5870b0527DeDB1cFBD9534343Feda1a41Ce47766"
}
}

14 changes: 14 additions & 0 deletions core/allocs/gnosis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"0x0000000000000000000000000000000000000001": {
"balance": "0x1"
},
"0x0000000000000000000000000000000000000002": {
"balance": "0x1"
},
"0x0000000000000000000000000000000000000003": {
"balance": "0x1"
},
"0x0000000000000000000000000000000000000004": {
"balance": "0x1"
}
}
22 changes: 22 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,26 @@ func DefaultBorDevnetGenesisBlock() *Genesis {
}
}

func DefaultGnosisGenesisBlock() *Genesis {
sealRlp, err := rlp.EncodeToBytes([][]byte{
common.FromHex(""),
common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
})
if err != nil {
panic(err)
}
return &Genesis{
Config: params.GnosisChainConfig,
Timestamp: 0x0, //1558348305,
SealRlp: sealRlp,
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
//Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
//Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/gnosis.json"),
}
}

// Pre-calculated version of:
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
Expand Down Expand Up @@ -798,6 +818,8 @@ func DefaultGenesisBlockByChainName(chain string) *Genesis {
return DefaultBorDevnetGenesisBlock()
case networkname.KilnDevnetChainName:
return DefaultKilnDevnetGenesisBlock()
case networkname.GnosisChainName:
return DefaultGnosisGenesisBlock()
default:
return nil
}
Expand Down
42 changes: 42 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,46 @@ var BorMainnetBootnodes = []string{
"enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303",
}

var GnosisBootnodes = []string{
"enode://172fd36d5ff1bf9db202e0646c90719cec55507a1fa231ce955f6882d2a9295e65841c885d94d23a020347e3169889cef0718eba5a5f5f58dd185f3d5fa0e9b7@147.28.151.154:30303",
"enode://ee4eb9844cbd8f684a734b839b4931e37124358cb17c632e7d5a44fd9ce6d457c4a126a914ea1366670d186b9236820c1e9b2cb2d3584eaf6c540fc10d77f00d@147.28.151.146:30303",
"enode://86f5849a24b158cef9c0f9b03554c918cd20f9e3397b63ae2744d6392a28beb9e0373299cfc4446d9f8b97c1598bc161fe7c6b8e84929f5dec8ea6865e9e7414@145.40.69.162:30303",
"enode://b6ba2a508682143d3159f36b9ce96cf62c711c2e9d47763fe846602a62acb15dc20112fac40c488ce42ce2c9ad28635255a9e47688c1a8f0611b5a38706fd771@147.28.147.242:30303",
"enode://a20c13b1712d32028a277958346a5c29350e8a3e32d40de43a62cb35baa99f96f274960591e46be5a643be7ee77a15d6a4963170460156a77abcf500f0ba0ff0@104.237.150.151:30303",
"enode://f372b16932a4ee5b6be947556bcca1cf57e498267dd78a7a643a87514a0a5ef4f112cb6934aab5775d3e8940ba535e8f53dfa704e162a72970de61e6ef9fd9aa@45.79.158.26:30303",
"enode://fe9720c93e6335b8cacffa10df594c8c166208fa4be8dcb9275788e54111ae88899022fa9c358f2d0029ee57c2223a7fbc97eb06b294422d35ef796a49d87bff@94.237.98.201:30303",
"enode://6d12181aa8527251dd8f9d37a2ff7eadb46f2a90c69f2282352ac7889b105d6b5787a532facee656b29599ee1ee51eb5b1eb01d2a17190e32a6cbe6dfc996828@45.79.158.8:30303",
"enode://389a625160876776946bfea5a6ce4f4c761bd2062cf8e45e510da77595399ee50a802060868d9bf4580431fc2248cadc9ce61826b3513e090bd1cdd4ce11a9d8@161.97.172.191:30303",
"enode://d086bfbe0d15e841e403695c151920459261dd5d5f259858b32727e2bc64d92f48bdad3cc0120703dbb0e2abd2f51c0459cff517bfa16e683ca27018d82a6dcf@66.175.215.67:30303",
"enode://540a0bc258ba93e6fafc238f49eca0a2032b5d40b79c077dc9b9a304fd636af4167b638eb0f80aa455f5da1cf49b76c881f651ed301a1e28d6855a8a3fbe21a0@167.71.174.1:30303",
"enode://1ceea9d3fb22247edf85102f1e78cd31c2f330ace6ac2789c82766a232d56d7c3c1b2aeb504f2f761de754da22e7dfc5bdde3b00b8b98d1d003f6dd81612f8b3@66.175.211.178:30303",
"enode://4175e9ffd9ac9819c9c596a60b7748cc1c1846cf7e8db47ee97f8aa57e42e8cb3dad4201726498d34af94505b2c1429f9d3a508594c521080e8cd1a3fa24a3d5@37.120.245.155:30303",
"enode://b5eba653df9c583238ea238ca7cadf5d2746f1b4da81a8cfb2c1b600f62fe37df000fa5b5292059f74faa6bbf5af01b3b81f99284a1fbd5c0971d74db7dc4a34@66.175.213.149:30303",
"enode://2a8b64e96da7e67e525f04a157a0016b886dfb2d02553501abd0326b7b061aace7e92ad87c1225dc7d261b05e7886391552c812b386451597bff4b040eb43bec@173.212.236.163:30303",
"enode://5f187ae73b07db889c91e8955619b1e6b799696a4b7aab306f7c500a2ec4c7f66dfbea8ac28bde65100653a2fe84b96f2079aed2d61871e06b5a1e32c0f021af@45.79.150.105:30303",
"enode://22e442bf7b7fa9bb5960344ef5aa907b920a931bce83e14620b0378318b7eb73753f7245f0a8252590a71ad9568bcfbb9e5f03bd88ab3feb9c1096227bb8704a@168.119.136.44:30303",
"enode://ef98bc3c9195b9f27312ac646edb6d0096b04c983f93864c30b8f2b20c699ec974a7066cfae090832679e497d23655e0e315a2c96da4a27d75cc4693e6335bba@192.155.90.129:30303",
"enode://de1ab49beedda656976a8fcb01f91ebdb474178fd46e5ce87cf22f0eb90bc3a6721d619ec90c4a6453770a2c24a4bdbc4ef8b8111ffd49f491eb84016a3842d6@54.217.41.94:30303",
"enode://ba04a77c7c8ac0fdd325de91536c33bce3b71095de563aafc72e6ac4111ebf093570c7bdba48b06cc83b0af5596f72fc32563547160e067fcb45a1786b8f7150@45.56.105.53:30303",
"enode://56510b2d296000427e56eb0016d8454998c16347ec2c4ffed84cb82a996707de40ca2b9ea13c8796b4230b4c19ce46f844720ded93135d710b7bbc7352a061d3@50.35.89.213:30304",
"enode://a68b3f3f58ea56dcc70450d371bf0b83363d74cbfdb5f982be00536ae3168aa679c7e7e93bd9ffe34b59527173d73e0ebed0a105c095af2ee16bd1cc66103c80@69.164.215.62:30303",
"enode://e8c7a0db430429bb374c981438c0dbd95e565088a483388aa46d8377a3bd62f02cd83d7e2c7e5fc77606141bfef29d23d4285a7c1d9b7e743cf3029314506df7@80.240.16.221:30303",
"enode://80c8f6f27f80ba91830002a8ca64771f6baf440fd134e88fbecae3a67c8bc58722d624cecbd6439e1a2d28fbd0297d489fdaa40b10c2f3e07fee1913d52b3e30@45.79.185.92:30303",
"enode://da2449aaba873c40c6daf764de55f4b9eae24c4738daec893ef95b6ada96463c6b9624f8e376e1073d21dd820c5bb361e14575121b09bbd7735b6b556ee1b768@67.205.176.117:30303",
"enode://481e43a8e30cdfecfe3159dde960d9e65347c3e8c64dcedea87922df875e4d47a813f53c012920b6754e43cde47302cdfb120fd409b6aa2b47c48e391494c7f5@173.255.233.100:30303",
"enode://90b0a0e74a9a1ad258531b4ceec25587d8b52ff2cfb36206a34bf6ba1a8d21b2abd20da13260102508a2ac67afbeb2d2ab7a5e9d6bea3bce845cd81e655585cc@45.77.110.159:30303",
"enode://6012c883efeee664847a48784459980176a22f31bc98c2aae30011ad7ef0b44011364a0a9ae5eb056db1f052cf3556757bd97485677bbaf1781b131e43204971@69.164.222.63:30303",
"enode://5bc43a57273eb4012b59ce268f986cbeeb5f0f878aa25e3d2d71d9b7ff64029a9dd25a84303f80820a78d83ff3a2c570988d0fc68a17d355a98c20c0784aa14d@8.9.5.108:30303",
"enode://89e046a4f10c64265941789b2e3be900adf5132ced13756aeea126cf59b516445ed8053b600aa764860f1aad552f4f4f3b4250c59b3b8a84ead3d3527c005606@172.104.24.215:30303",
"enode://ab7f6c633ba2dc54795dfd2c739ba7d964f499541c0b8d8ba9d275bd3df1b789470a21a921a469fa515a3dfccc96a434a3fd016a169d88d0043fc6744f34288e@67.205.180.17:30303",
"enode://6674773f7aac78d5527fa90c847dcbca198de4081306406a8fec5c15f7a2e141362344041291dd10d0aafa7706a3d8f21a08b6f6834a5b1aab9cccd8ca35ccee@143.110.226.15:30303",
"enode://0caa2d84aef00d0bc5de6cf9db3e736da245d882ec8f91e201b3e1635960e62cbb2f8bfc57e679ff3e1d53da2773e31df624a56b2f457ecb51d09fdf9970c86b@167.99.4.175:30303",
"enode://7aa4c137b1ec078f2df3c17552e23c7213662819132821ed3aaa42f0212cb889dbb21211f9c5912c68fce577ab7fc99b0a47c0cb469ec0ad29c0acd9ce297659@45.33.84.107:30303",
"enode://e026b1a68e8a19106d14effc0df66050c494e10a6b8a4e9f6fd196d95306d7062d129a8c9510ffdbeaf3fe0154b884c116a0e77aec876c368e507de3420fba05@149.28.32.225:30303",
"enode://0a978bd436b850f61e31778fbbeb3e0182f91bb98a30c073674c741c182611e71842333c098d3db5108f06cd589c3a8341172e34be0421fa66d82f0dd83d8ae1@51.81.244.170:30303",
"enode://75f05df1e5a3094ed2c9df36f122b95852206c52288f777982503946d5b273c7ffd8bb06ad60a0df7a31510906d4090c7bd5fd9bcb04a5b4ac1825a2b7212f32@45.63.18.245:30303",
}

const dnsPrefix = "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@"

// KnownDNSNetwork returns the address of a public DNS-based node list for the given
Expand Down Expand Up @@ -259,6 +299,8 @@ func BootnodeURLsOfChain(chain string) []string {
return MumbaiBootnodes
case networkname.BorMainnetChainName:
return BorMainnetBootnodes
case networkname.GnosisChainName:
return GnosisBootnodes
default:
return []string{}
}
Expand Down
21 changes: 21 additions & 0 deletions params/chainspecs/gnosis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ChainName": "gnosis",
"chainId": 100,
"consensus": "aura",
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 1604400,
"petersburgBlock": 2508800,
"istanbulBlock": 7298030,
"berlinBlock": 16101500,
"londonBlock": 19040000,
"terminalBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"aura": {
"DBPath": "",
"InMemory": false,
"Etherbase": "0x0000000000000000000000000000000000000000"
}
}
20 changes: 18 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var (
MumbaiGenesisHash = common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
BorMainnetGenesisHash = common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
BorDevnetGenesisHash = common.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
GnosisGenesisHash = common.HexToHash("0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756")
)

var (
Expand Down Expand Up @@ -165,6 +166,8 @@ var (

BorDevnetChainConfig = readChainSpec("chainspecs/bor-devnet.json")

GnosisChainConfig = readChainSpec("chainspecs/gnosis.json")

CliqueSnapshot = NewSnapshotConfig(10, 1024, 16384, true, "")

TestChainConfig = &ChainConfig{
Expand Down Expand Up @@ -278,6 +281,11 @@ type CliqueConfig struct {
Epoch uint64 `json:"epoch"` // Epoch length to reset votes and checkpoint
}

// String implements the stringer interface, returning the consensus engine details.
func (c *CliqueConfig) String() string {
return "clique"
}

// AuRaConfig is the consensus engine configs for proof-of-authority based sealing.
type AuRaConfig struct {
DBPath string
Expand All @@ -286,8 +294,8 @@ type AuRaConfig struct {
}

// String implements the stringer interface, returning the consensus engine details.
func (c *CliqueConfig) String() string {
return "clique"
func (c *AuRaConfig) String() string {
return "aura"
}

type ParliaConfig struct {
Expand Down Expand Up @@ -378,6 +386,8 @@ func (c *ChainConfig) String() string {
engine = c.Parlia
case c.Bor != nil:
engine = c.Bor
case c.Aura != nil:
engine = c.Aura
default:
engine = "unknown"
}
Expand Down Expand Up @@ -820,6 +830,8 @@ func ChainConfigByChainName(chain string) *ChainConfig {
return BorMainnetChainConfig
case networkname.BorDevnetChainName:
return BorDevnetChainConfig
case networkname.GnosisChainName:
return GnosisChainConfig
default:
return nil
}
Expand Down Expand Up @@ -855,6 +867,8 @@ func GenesisHashByChainName(chain string) *common.Hash {
return &BorMainnetGenesisHash
case networkname.BorDevnetChainName:
return &BorDevnetGenesisHash
case networkname.GnosisChainName:
return &GnosisGenesisHash
default:
return nil
}
Expand Down Expand Up @@ -888,6 +902,8 @@ func ChainConfigByGenesisHash(genesisHash common.Hash) *ChainConfig {
return MumbaiChainConfig
case genesisHash == BorMainnetGenesisHash:
return BorMainnetChainConfig
case genesisHash == GnosisGenesisHash:
return GnosisChainConfig
default:
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions params/networkname/network_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
MumbaiChainName = "mumbai"
BorMainnetChainName = "bor-mainnet"
BorDevnetChainName = "bor-devnet"
GnosisChainName = "gnosis"
)

var All = []string{
Expand All @@ -34,4 +35,5 @@ var All = []string{
MumbaiChainName,
BorMainnetChainName,
BorDevnetChainName,
GnosisChainName,
}

0 comments on commit cd5ef32

Please sign in to comment.