Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network: Cardona/Sepolia #26

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions core/allocs/hermez-cardona-internal.json

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions core/allocs/hermez-cardona.json

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ func TestHermezBlockRoots(t *testing.T) {
t.Errorf("wrong Hermez Testnet genesis state root, got %v, want %v", block.Root(), params.HermezTestnetGenesisHash)
}
})

t.Run("Hermez Cardona", func(t *testing.T) {
block, _, err := core.GenesisToBlock(core.HermezCardonaGenesisBlock(), "")
require.NoError(err)
if block.Root() != params.HermezCardonaGenesisHash {
t.Errorf("wrong Hermez Cardona genesis state root, got %v, want %v", block.Root(), params.HermezCardonaGenesisHash)
}
})

t.Run("Hermez Cardona Internal", func(t *testing.T) {
block, _, err := core.GenesisToBlock(core.HermezCardonaInternalGenesisBlock(), "")
require.NoError(err)
if block.Root() != params.HermezCardonaInternalGenesisHash {
t.Errorf("wrong Hermez Cardona Internal genesis state root, got %v, want %v", block.Root(), params.HermezCardonaInternalGenesisHash)
}
})
}

func TestGenesisBlockRoots(t *testing.T) {
Expand Down Expand Up @@ -96,18 +112,6 @@ func TestGenesisBlockRoots(t *testing.T) {
if block.Hash() != params.ChiadoGenesisHash {
t.Errorf("wrong Chiado genesis hash, got %v, want %v", block.Hash(), params.ChiadoGenesisHash)
}

block, _, err = core.GenesisToBlock(core.HermezMainnetGenesisBlock(), "")
require.NoError(err)
if block.Root() != params.HermezMainnetGenesisHash {
t.Errorf("wrong Hermez Mainnet genesis state root, got %v, want %v", block.Root(), params.HermezMainnetGenesisHash)
}

block, _, err = core.GenesisToBlock(core.HermezTestnetGenesisBlock(), "")
require.NoError(err)
if block.Root() != params.HermezTestnetGenesisHash {
t.Errorf("wrong Hermez Testnet genesis state root, got %v, want %v", block.Root(), params.HermezTestnetGenesisHash)
}
}

func TestCommitGenesisIdempotency(t *testing.T) {
Expand Down
24 changes: 24 additions & 0 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,26 @@ func HermezDevnetGenesisBlock() *types.Genesis {
}
}

func HermezCardonaGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.HermezCardonaChainConfig,
Timestamp: 1676996964,
GasLimit: 0x0,
Difficulty: big.NewInt(0x0),
Alloc: readPrealloc("allocs/hermez-cardona.json"),
}
}

func HermezCardonaInternalGenesisBlock() *types.Genesis {
return &types.Genesis{
Config: params.HermezCardonaInternalChainConfig,
Timestamp: 1676996964,
GasLimit: 0x0,
Difficulty: big.NewInt(0x0),
Alloc: readPrealloc("allocs/hermez-cardona-internal.json"),
}
}

// Pre-calculated version of:
//
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
Expand Down Expand Up @@ -720,6 +740,10 @@ func GenesisBlockByChainName(chain string) *types.Genesis {
return HermezTestnetGenesisBlock()
case networkname.HermezDevnetChainName:
return HermezDevnetGenesisBlock()
case networkname.HermezCardonaChainName:
return HermezCardonaGenesisBlock()
case networkname.HermezCardonaInternalChainName:
return HermezCardonaInternalGenesisBlock()
default:
return nil
}
Expand Down
19 changes: 19 additions & 0 deletions hermezconfig-cardona-internal.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
datadir : '/path/to/datadirs/hermez-cardona'
chain : "hermez-cardona"
http : true
private.api.addr : "localhost:9092"
zkevm.l2-chain-id: 2440
zkevm.l2-sequencer-rpc-url: "https://rpc.internal.zkevm-rpc.com/"
zkevm.l2-datastreamer-url: "datastream.internal.zkevm-rpc.com:6900"
zkevm.l1-chain-id: 11155111
zkevm.l1-rpc-url: "https://rpc.sepolia.org"
zkevm.l1-contract-address: "0xE2EF6215aDc132Df6913C8DD16487aBF118d1764"
zkevm.l1-matic-contract-address: "0xbA59560D9B3a697745695A01144536514afE0e2B"
zkevm.l1-ger-manager-contract-address: "0x2968D6d736178f8FE7393CC33C87f29D9C287e78"
zkevm.l1-first-block: 4794475
zkevm.rpc-ratelimit: 250
txpool.disable: true
torrent.port: 42070

externalcl: true
http.api : ["eth","debug","net","trace","web3","erigon","zkevm"]
21 changes: 21 additions & 0 deletions hermezconfig-cardona.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
datadir : '/path/to/datadirs/hermez-cardona'
chain : "hermez-cardona"
http : true
private.api.addr : "localhost:9092"
zkevm.l2-chain-id: 2442
zkevm.l2-sequencer-rpc-url: "https://rpc.cardona.zkevm-rpc.com/"
zkevm.l2-datastreamer-url: "datastream.cardona.zkevm-rpc.com:6900"
zkevm.l1-chain-id: 11155111
zkevm.l1-rpc-url: "https://rpc.sepolia.org"
zkevm.l1-contract-address: "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff"
zkevm.l1-matic-contract-address: "0x1850Dd35dE878238fb1dBa7aF7f929303AB6e8E4"
zkevm.l1-ger-manager-contract-address: "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF"
zkevm.l1-block-range: 20000
zkevm.l1-query-delay: 6000
zkevm.l1-first-block: 4789190
zkevm.rpc-ratelimit: 250
txpool.disable: true
torrent.port: 42070

externalcl: true
http.api : ["eth","debug","net","trace","web3","erigon","zkevm"]
26 changes: 26 additions & 0 deletions params/chainspecs/hermez-cardona-internal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ChainName": "devnet",
"chainId": 2440,
"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": {},
"mordorBlock": 0
}

26 changes: 26 additions & 0 deletions params/chainspecs/hermez-cardona.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ChainName": "devnet",
"chainId": 2442,
"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": {},
"mordorBlock": 0
}

42 changes: 30 additions & 12 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ func readChainSpec(filename string) *chain.Config {

// Genesis hashes to enforce below configs on.
var (
MainnetGenesisHash = libcommon.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
SepoliaGenesisHash = libcommon.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
RinkebyGenesisHash = libcommon.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
GoerliGenesisHash = libcommon.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
MumbaiGenesisHash = libcommon.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
BorMainnetGenesisHash = libcommon.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
BorDevnetGenesisHash = libcommon.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
GnosisGenesisHash = libcommon.HexToHash("0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756")
ChiadoGenesisHash = libcommon.HexToHash("0xada44fd8d2ecab8b08f256af07ad3e777f17fb434f8f8e678b312f576212ba9a")
HermezMainnetGenesisHash = libcommon.HexToHash("0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9")
HermezTestnetGenesisHash = libcommon.HexToHash("0x13a14c4a8288e782863d7ce916d224546c69dc428fbfa7115a0cc33a27a05b26")
HermezDevnetGenesisHash = libcommon.HexToHash("0x45cff376044a08f8f33f0244d589f2178ea4f4c5234d912daa2ff3c496b17862")
MainnetGenesisHash = libcommon.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
SepoliaGenesisHash = libcommon.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
RinkebyGenesisHash = libcommon.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
GoerliGenesisHash = libcommon.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
MumbaiGenesisHash = libcommon.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
BorMainnetGenesisHash = libcommon.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
BorDevnetGenesisHash = libcommon.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
GnosisGenesisHash = libcommon.HexToHash("0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756")
ChiadoGenesisHash = libcommon.HexToHash("0xada44fd8d2ecab8b08f256af07ad3e777f17fb434f8f8e678b312f576212ba9a")
HermezMainnetGenesisHash = libcommon.HexToHash("0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9")
HermezTestnetGenesisHash = libcommon.HexToHash("0x13a14c4a8288e782863d7ce916d224546c69dc428fbfa7115a0cc33a27a05b26")
HermezDevnetGenesisHash = libcommon.HexToHash("0x45cff376044a08f8f33f0244d589f2178ea4f4c5234d912daa2ff3c496b17862")
HermezCardonaGenesisHash = libcommon.HexToHash("0xf1a89745a08cfd1af739b93f960ad89546e3cec2a7babe8607703eb1e4e94b4d")
HermezCardonaInternalGenesisHash = libcommon.HexToHash("0x676657dd8a7dce782f4fe8a97ba794de3ff732b40233fce01da77d1ba1a24ee1")
)

var (
Expand Down Expand Up @@ -141,6 +143,10 @@ var (

HermezDevnetChainConfig = readChainSpec("chainspecs/hermez-devnet.json")

HermezCardonaChainConfig = readChainSpec("chainspecs/hermez-cardona.json")

HermezCardonaInternalChainConfig = readChainSpec("chainspecs/hermez-cardona-internal.json")

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

TestChainConfig = &chain.Config{
Expand Down Expand Up @@ -227,6 +233,10 @@ func ChainConfigByChainName(chain string) *chain.Config {
return HermezTestnetChainConfig
case networkname.HermezDevnetChainName:
return HermezDevnetChainConfig
case networkname.HermezCardonaChainName:
return HermezCardonaChainConfig
case networkname.HermezCardonaInternalChainName:
return HermezCardonaInternalChainConfig
default:
return nil
}
Expand Down Expand Up @@ -258,6 +268,10 @@ func GenesisHashByChainName(chain string) *libcommon.Hash {
return &HermezTestnetGenesisHash
case networkname.HermezDevnetChainName:
return &HermezDevnetGenesisHash
case networkname.HermezCardonaChainName:
return &HermezCardonaGenesisHash
case networkname.HermezCardonaInternalChainName:
return &HermezCardonaInternalGenesisHash
default:
return nil
}
Expand Down Expand Up @@ -289,6 +303,10 @@ func ChainConfigByGenesisHash(genesisHash libcommon.Hash) *chain.Config {
return HermezTestnetChainConfig
case genesisHash == HermezDevnetGenesisHash:
return HermezDevnetChainConfig
case genesisHash == HermezCardonaGenesisHash:
return HermezCardonaChainConfig
case genesisHash == HermezCardonaInternalGenesisHash:
return HermezCardonaInternalChainConfig
default:
return nil
}
Expand Down
30 changes: 17 additions & 13 deletions params/networkname/network_name.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package networkname

const (
MainnetChainName = "mainnet"
SepoliaChainName = "sepolia"
RinkebyChainName = "rinkeby"
GoerliChainName = "goerli"
DevChainName = "dev"
MumbaiChainName = "mumbai"
BorMainnetChainName = "bor-mainnet"
BorDevnetChainName = "bor-devnet"
GnosisChainName = "gnosis"
ChiadoChainName = "chiado"
HermezMainnetChainName = "hermez-mainnet"
HermezTestnetChainName = "hermez-testnet"
HermezDevnetChainName = "hermez-devnet"
MainnetChainName = "mainnet"
SepoliaChainName = "sepolia"
RinkebyChainName = "rinkeby"
GoerliChainName = "goerli"
DevChainName = "dev"
MumbaiChainName = "mumbai"
BorMainnetChainName = "bor-mainnet"
BorDevnetChainName = "bor-devnet"
GnosisChainName = "gnosis"
ChiadoChainName = "chiado"
HermezMainnetChainName = "hermez-mainnet"
HermezTestnetChainName = "hermez-testnet"
HermezDevnetChainName = "hermez-devnet"
HermezCardonaChainName = "hermez-cardona"
HermezCardonaInternalChainName = "hermez-cardona-internal"
)

var All = []string{
Expand All @@ -29,4 +31,6 @@ var All = []string{
HermezMainnetChainName,
HermezTestnetChainName,
HermezDevnetChainName,
HermezCardonaChainName,
HermezCardonaInternalChainName,
}
8 changes: 5 additions & 3 deletions zk/zkchainconfig/utils.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package zkchainconfig

var chainIds = []uint64{
1101,
1440,
1442,
1101, // mainnet
1440, // devnet
1442, // testnet
2440, // cardona internal
2442, // cardona
}

func IsZk(chainId uint64) bool {
Expand Down