Skip to content

Commit

Permalink
Support mainnet and testnet (#7)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* update

* update

* update

* update

* update
  • Loading branch information
zjg555543 authored Apr 3, 2024
1 parent 237c779 commit a5944ba
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 37 deletions.
86 changes: 86 additions & 0 deletions core/allocs/xlayer-mainnet.json

Large diffs are not rendered by default.

File renamed without changes.
6 changes: 4 additions & 2 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,10 @@ func GenesisBlockByChainName(chain string) *types.Genesis {
return HermezCardonaGenesisBlock()
case networkname.HermezBaliChainName:
return HermezCardonaInternalGenesisBlock()
case networkname.X1TestnetChainName:
return X1TestnetGenesisBlock()
case networkname.XLayerTestnetChainName:
return XLayerTestnetGenesisBlock()
case networkname.XLayerMainnetChainName:
return XLayerMainnetGenesisBlock()
default:
return nil
}
Expand Down
16 changes: 13 additions & 3 deletions core/genesis_write_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,23 @@ func HermezESTestGenesisBlock() *types.Genesis {
}
}

func X1TestnetGenesisBlock() *types.Genesis {
func XLayerTestnetGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.X1TestnetChainConfig,
Config: params.XLayerTestnetChainConfig,
Timestamp: 1699369668,
GasLimit: 0x0,
Difficulty: big.NewInt(0x0),
Alloc: readPrealloc("allocs/x1-testnet.json"),
Alloc: readPrealloc("allocs/xlayer-testnet.json"),
}
}

func XLayerMainnetGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.XLayerMainnetChainConfig,
Timestamp: 1711785755,
GasLimit: 0x0,
Difficulty: big.NewInt(0x0),
Alloc: readPrealloc("allocs/xlayer-mainnet.json"),
}
}

Expand Down
24 changes: 24 additions & 0 deletions params/chainspecs/xlayer-mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"ChainName": "xlayer-mainnet",
"chainId": 196,
"consensus": "ethash",
"homesteadBlock": 0,
"daoForkBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 9999999999999999999999999999999999999999999999999,
"arrowGlacierBlock": 9999999999999999999999999999999999999999999999999,
"grayGlacierBlock": 9999999999999999999999999999999999999999999999999,
"terminalTotalDifficulty": 58750000000000000000000,
"terminalTotalDifficultyPassed": false,
"shanghaiTime": 9999999999999999999999999999999999999999999999999,
"cancunTime": 9999999999999999999999999999999999999999999999999,
"pragueTime": 9999999999999999999999999999999999999999999999999,
"ethash": {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ChainName": "x1-testnet",
"ChainName": "xlayer-testnet",
"chainId": 195,
"consensus": "ethash",
"homesteadBlock": 0,
Expand Down
25 changes: 17 additions & 8 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ var (
HermezESTestGenesisHash = libcommon.HexToHash("0x8c630b598fab24a99b59cdd8257f41b35d0aca992f13cd381c7591f5e89eec58")
HermezCardonaGenesisHash = libcommon.HexToHash("0x676c1a76a6c5855a32bdf7c61977a0d1510088a4eeac1330466453b3d08b60b9")
HermezCardonaInternalGenesisHash = libcommon.HexToHash("0x7311011ce6ab98ef0a15e44fe29f7680909588322534d1736361daa678543038")
X1TestnetGenesisHash = libcommon.HexToHash("0x0ffb92e130f1acaabd8b12aa1bb409b46561ef7568cb8aa7eb8d102a6ab76566")
XLayerTestnetGenesisHash = libcommon.HexToHash("0x0ffb92e130f1acaabd8b12aa1bb409b46561ef7568cb8aa7eb8d102a6ab76566")
XLayerMainnetGenesisHash = libcommon.HexToHash("0x11f32f605beb94a1acb783cb3b6da6d7975461ce3addf441e7ad60c2ec95e88f")
HermezEtrogGenesisHash = libcommon.HexToHash("0xccfed260e3ef666b058dcd577551de8e00c743c47774a39ca7dbcd9214ba370a")
)

Expand Down Expand Up @@ -152,7 +153,9 @@ var (

HermezBaliChainConfig = readChainSpec("chainspecs/hermez-bali.json")

X1TestnetChainConfig = readChainSpec("chainspecs/x1-testnet.json")
XLayerTestnetChainConfig = readChainSpec("chainspecs/xlayer-testnet.json")

XLayerMainnetChainConfig = readChainSpec("chainspecs/xlayer-mainnet.json")

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

Expand Down Expand Up @@ -248,8 +251,10 @@ func ChainConfigByChainName(chain string) *chain.Config {
return HermezCardonaChainConfig
case networkname.HermezBaliChainName:
return HermezBaliChainConfig
case networkname.X1TestnetChainName:
return X1TestnetChainConfig
case networkname.XLayerTestnetChainName:
return XLayerTestnetChainConfig
case networkname.XLayerMainnetChainName:
return XLayerMainnetChainConfig
default:
return nil
}
Expand Down Expand Up @@ -289,8 +294,10 @@ func GenesisHashByChainName(chain string) *libcommon.Hash {
return &HermezCardonaGenesisHash
case networkname.HermezBaliChainName:
return &HermezCardonaInternalGenesisHash
case networkname.X1TestnetChainName:
return &X1TestnetGenesisHash
case networkname.XLayerTestnetChainName:
return &XLayerTestnetGenesisHash
case networkname.XLayerMainnetChainName:
return &XLayerMainnetGenesisHash
default:
return nil
}
Expand Down Expand Up @@ -326,8 +333,10 @@ func ChainConfigByGenesisHash(genesisHash libcommon.Hash) *chain.Config {
return HermezESTestChainConfig
case genesisHash == HermezCardonaGenesisHash:
return HermezCardonaChainConfig
case genesisHash == HermezCardonaInternalGenesisHash:
return HermezBaliChainConfig
case genesisHash == XLayerTestnetGenesisHash:
return XLayerTestnetChainConfig
case genesisHash == XLayerMainnetGenesisHash:
return XLayerMainnetChainConfig
default:
panic(fmt.Sprintf("Unknown genesis hash: %s", genesisHash.Hex()))
return nil
Expand Down
6 changes: 4 additions & 2 deletions params/networkname/network_name_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const (
HermezESTestChainName = "hermez-estest"
HermezCardonaChainName = "hermez-cardona"
HermezBaliChainName = "hermez-bali"
X1TestnetChainName = "x1-testnet"
XLayerTestnetChainName = "xlayer-testnet"
XLayerMainnetChainName = "xlayer-mainnet"
HermezEtrogChainName = "hermez-etrog"
)

Expand All @@ -19,5 +20,6 @@ var Zkevm = []string{
HermezEtrogChainName,
HermezCardonaChainName,
HermezBaliChainName,
X1TestnetChainName,
XLayerTestnetChainName,
XLayerMainnetChainName,
}
19 changes: 0 additions & 19 deletions x1config-testnet.yaml.example

This file was deleted.

25 changes: 25 additions & 0 deletions xlayerconfig-mainet.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
datadir: /data/erigon-data/xlayer-mainnet
chain: xlayer-mainnet
http: true
private.api.addr: localhost:9091
zkevm.l2-chain-id: 196
zkevm.l2-sequencer-rpc-url: https://rpc.xlayer.tech
zkevm.l2-datastreamer-url: stream.xlayer.tech:8800
zkevm.l1-chain-id: 1
zkevm.l1-rpc-url: https://rpc.ankr.com/eth/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zkevm.l1-polygon-rollup-manager: "0x5132a183e9f3cb7c848b0aac5ae0c4f0491b7ab2"
zkevm.l1-rollup: "0x2B0ee28D4D51bC9aDde5E58E295873F61F4a0507"
zkevm.l1-matic-contract-address: "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6"
zkevm.l1-ger-manager-contract-address: "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb"
zkevm.l1-topic-verification: "0x9c72852172521097ba7e1482e6b44b351323df0155f97f4ea18fcec28e1f5966"
zkevm.l1-topic-sequence: "0x3e54d0825ed78523037d00a81759237eb436ce774bd546993ee67a1b67b6e766"
zkevm.l1-first-block: 19218658
zkevm.l1-block-range: 100
zkevm.l1-query-delay: 6000
zkevm.rpc-ratelimit: 250
zkevm.datastream-version: 2

externalcl: true
http.api: [eth, debug, net, trace, web3, erigon, zkevm]
http.addr: 0.0.0.0
http.port: 8545
25 changes: 25 additions & 0 deletions xlayerconfig-testnet.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
datadir: /data/erigon-data/xlayer-testnet
chain: xlayer-testnet
http: true
private.api.addr: localhost:9091
zkevm.l2-chain-id: 195
zkevm.l2-sequencer-rpc-url: https://testrpc.xlayer.tech
zkevm.l2-datastreamer-url: teststream.xlayer.tech:8800
zkevm.l1-chain-id: 11155111
zkevm.l1-rpc-url: https://rpc.ankr.com/eth_sepolia/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
zkevm.l1-polygon-rollup-manager: "0x6662621411A8DACC3cA7049C8BddABaa9a999ce3"
zkevm.l1-rollup: "0x01469dACfDDA885D68Ff0f8628F2629c14F95a20"
zkevm.l1-matic-contract-address: "0x3F4B6664338F23d2397c953f2AB4Ce8031663f80"
zkevm.l1-ger-manager-contract-address: "0x66E61bA00F58b857A9DD2C500F3aBc424A46BD20"
zkevm.l1-topic-verification: "0x9c72852172521097ba7e1482e6b44b351323df0155f97f4ea18fcec28e1f5966"
zkevm.l1-topic-sequence: "0x3e54d0825ed78523037d00a81759237eb436ce774bd546993ee67a1b67b6e766"
zkevm.l1-first-block: 4648290
zkevm.l1-block-range: 100
zkevm.l1-query-delay: 6000
zkevm.rpc-ratelimit: 250
zkevm.datastream-version: 2

externalcl: true
http.api: [eth, debug, net, trace, web3, erigon, zkevm]
http.addr: 0.0.0.0
http.port: 8545
6 changes: 4 additions & 2 deletions zk/zkchainconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package zkchainconfig
import "github.com/ledgerwatch/erigon/params/networkname"

var chainIds = []uint64{
195, // x1-testnet
195, // xlayer-testnet
196, // xlayer-mainet
1101, // mainnet
2440, // cardona internal
2442, // cardona
Expand All @@ -12,7 +13,8 @@ var chainIds = []uint64{
}

var chainIdToName = map[uint64]string{
195: networkname.X1TestnetChainName,
195: networkname.XLayerTestnetChainName,
196: networkname.XLayerMainnetChainName,
1101: networkname.HermezMainnetChainName,
2440: networkname.HermezBaliChainName,
2442: networkname.HermezCardonaChainName,
Expand Down

0 comments on commit a5944ba

Please sign in to comment.