2016-03-01 22:32:43 +00:00
|
|
|
// Copyright 2016 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-10-20 11:36:29 +00:00
|
|
|
package params
|
2016-03-01 22:32:43 +00:00
|
|
|
|
|
|
|
import (
|
2022-05-15 16:37:42 +00:00
|
|
|
"embed"
|
|
|
|
"encoding/json"
|
2016-11-23 12:32:25 +00:00
|
|
|
"fmt"
|
2016-03-01 22:32:43 +00:00
|
|
|
"math/big"
|
2021-04-19 21:58:05 +00:00
|
|
|
"path"
|
2016-03-01 22:32:43 +00:00
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/chain"
|
2023-10-18 06:37:39 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/chain/networkname"
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2024-01-09 18:20:42 +00:00
|
|
|
"github.com/ledgerwatch/erigon/polygon/bor/borcfg"
|
2023-01-13 18:12:18 +00:00
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common/paths"
|
2021-04-08 07:39:40 +00:00
|
|
|
)
|
|
|
|
|
2022-05-15 16:37:42 +00:00
|
|
|
//go:embed chainspecs
|
|
|
|
var chainspecs embed.FS
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func readChainSpec(filename string) *chain.Config {
|
2022-05-15 16:37:42 +00:00
|
|
|
f, err := chainspecs.Open(filename)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not open chainspec for %s: %v", filename, err))
|
|
|
|
}
|
|
|
|
defer f.Close()
|
2024-01-04 09:44:57 +00:00
|
|
|
|
2022-05-15 16:37:42 +00:00
|
|
|
decoder := json.NewDecoder(f)
|
2023-01-13 18:12:18 +00:00
|
|
|
spec := &chain.Config{}
|
2022-05-15 16:37:42 +00:00
|
|
|
err = decoder.Decode(&spec)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not parse chainspec for %s: %v", filename, err))
|
|
|
|
}
|
2024-01-04 09:44:57 +00:00
|
|
|
|
|
|
|
if spec.BorJSON != nil {
|
|
|
|
borConfig := &borcfg.BorConfig{}
|
|
|
|
err = json.Unmarshal(spec.BorJSON, borConfig)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not parse 'bor' chainspec for %s: %v", filename, err))
|
|
|
|
}
|
|
|
|
spec.Bor = borConfig
|
|
|
|
}
|
|
|
|
|
2022-05-15 16:37:42 +00:00
|
|
|
return spec
|
|
|
|
}
|
|
|
|
|
2018-06-05 10:31:34 +00:00
|
|
|
// Genesis hashes to enforce below configs on.
|
2017-07-04 09:28:58 +00:00
|
|
|
var (
|
2023-02-25 02:54:12 +00:00
|
|
|
MainnetGenesisHash = libcommon.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
|
|
|
|
HoleskyGenesisHash = libcommon.HexToHash("0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4")
|
|
|
|
SepoliaGenesisHash = libcommon.HexToHash("0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9")
|
|
|
|
GoerliGenesisHash = libcommon.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
|
|
|
|
MumbaiGenesisHash = libcommon.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
|
|
|
|
AmoyGenesisHash = libcommon.HexToHash("0x7202b2b53c5a0836e773e319d18922cc756dd67432f9a1f65352b61f4406c697")
|
|
|
|
BorMainnetGenesisHash = libcommon.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
|
|
|
|
BorDevnetGenesisHash = libcommon.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
|
|
|
|
GnosisGenesisHash = libcommon.HexToHash("0x4f1dd23188aab3a76b463e4af801b52b1248ef073c648cbdc4c9333d3da79756")
|
|
|
|
ChiadoGenesisHash = libcommon.HexToHash("0xada44fd8d2ecab8b08f256af07ad3e777f17fb434f8f8e678b312f576212ba9a")
|
|
|
|
PulsechainGenesisHash = libcommon.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
|
2023-02-26 19:52:40 +00:00
|
|
|
PulsechainDevnetGenesisHash = libcommon.HexToHash("0xdbc883fdd1357c5340e4bb624a3dd9af4788602a23af0a42080b31a382c9fba8")
|
2023-02-25 02:54:12 +00:00
|
|
|
PulsechainTetnetGenesisHash = libcommon.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
|
2021-06-07 11:01:54 +00:00
|
|
|
)
|
|
|
|
|
2021-07-02 08:00:41 +00:00
|
|
|
var (
|
2023-01-13 18:12:18 +00:00
|
|
|
GnosisGenesisStateRoot = libcommon.HexToHash("0x40cf4430ecaa733787d1a65154a3b9efb560c95d9e324a23b97f0609b539133b")
|
|
|
|
ChiadoGenesisStateRoot = libcommon.HexToHash("0x9ec3eaf4e6188dfbdd6ade76eaa88289b57c63c9a2cde8d35291d5a29e143d31")
|
2017-07-04 09:28:58 +00:00
|
|
|
)
|
|
|
|
|
2017-03-02 13:03:33 +00:00
|
|
|
var (
|
|
|
|
// MainnetChainConfig is the chain parameters to run a node on the main network.
|
2022-05-15 16:37:42 +00:00
|
|
|
MainnetChainConfig = readChainSpec("chainspecs/mainnet.json")
|
2017-03-02 13:03:33 +00:00
|
|
|
|
2023-08-26 10:31:29 +00:00
|
|
|
// HoleskyChainConfi contains the chain parameters to run a node on the Holesky test network.
|
|
|
|
HoleskyChainConfig = readChainSpec("chainspecs/holesky.json")
|
|
|
|
|
2022-02-10 07:27:36 +00:00
|
|
|
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
|
2022-05-15 16:37:42 +00:00
|
|
|
SepoliaChainConfig = readChainSpec("chainspecs/sepolia.json")
|
2022-05-13 20:22:48 +00:00
|
|
|
|
2018-11-16 15:58:24 +00:00
|
|
|
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
|
2022-05-15 16:37:42 +00:00
|
|
|
GoerliChainConfig = readChainSpec("chainspecs/goerli.json")
|
2018-11-16 15:58:24 +00:00
|
|
|
|
2022-11-21 16:21:59 +00:00
|
|
|
// AllProtocolChanges contains every protocol change (EIPs) introduced
|
|
|
|
// and accepted by the Ethereum core developers into the main net protocol.
|
2023-01-13 18:12:18 +00:00
|
|
|
AllProtocolChanges = &chain.Config{
|
2022-11-21 16:21:59 +00:00
|
|
|
ChainID: big.NewInt(1337),
|
2023-01-13 18:12:18 +00:00
|
|
|
Consensus: chain.EtHashConsensus,
|
2022-11-21 16:21:59 +00:00
|
|
|
HomesteadBlock: big.NewInt(0),
|
|
|
|
TangerineWhistleBlock: big.NewInt(0),
|
|
|
|
SpuriousDragonBlock: 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),
|
|
|
|
ArrowGlacierBlock: big.NewInt(0),
|
|
|
|
GrayGlacierBlock: big.NewInt(0),
|
|
|
|
TerminalTotalDifficulty: big.NewInt(0),
|
|
|
|
TerminalTotalDifficultyPassed: true,
|
2022-12-07 17:45:44 +00:00
|
|
|
ShanghaiTime: big.NewInt(0),
|
2023-08-08 13:01:35 +00:00
|
|
|
CancunTime: big.NewInt(0),
|
2023-01-13 18:12:18 +00:00
|
|
|
Ethash: new(chain.EthashConfig),
|
2023-02-25 02:54:12 +00:00
|
|
|
PrimordialPulseBlock: nil,
|
|
|
|
PulseChain: nil,
|
2021-05-02 09:34:19 +00:00
|
|
|
}
|
2017-10-24 10:40:42 +00:00
|
|
|
|
|
|
|
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
|
|
|
|
// and accepted by the Ethereum core developers into the Clique consensus.
|
2023-01-13 18:12:18 +00:00
|
|
|
AllCliqueProtocolChanges = &chain.Config{
|
2022-05-26 10:08:59 +00:00
|
|
|
ChainID: big.NewInt(1337),
|
2023-01-13 18:12:18 +00:00
|
|
|
Consensus: chain.CliqueConsensus,
|
2022-05-26 10:08:59 +00:00
|
|
|
HomesteadBlock: big.NewInt(0),
|
|
|
|
TangerineWhistleBlock: big.NewInt(0),
|
|
|
|
SpuriousDragonBlock: 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),
|
2023-01-13 18:12:18 +00:00
|
|
|
Clique: &chain.CliqueConfig{Period: 0, Epoch: 30000},
|
2021-05-02 09:34:19 +00:00
|
|
|
}
|
2017-10-24 10:40:42 +00:00
|
|
|
|
2022-05-15 16:37:42 +00:00
|
|
|
MumbaiChainConfig = readChainSpec("chainspecs/mumbai.json")
|
2022-02-07 21:30:46 +00:00
|
|
|
|
2023-11-30 01:19:52 +00:00
|
|
|
AmoyChainConfig = readChainSpec("chainspecs/amoy.json")
|
|
|
|
|
2022-05-15 16:37:42 +00:00
|
|
|
BorMainnetChainConfig = readChainSpec("chainspecs/bor-mainnet.json")
|
2022-02-07 21:30:46 +00:00
|
|
|
|
2022-06-10 08:32:04 +00:00
|
|
|
BorDevnetChainConfig = readChainSpec("chainspecs/bor-devnet.json")
|
|
|
|
|
2022-07-12 15:21:52 +00:00
|
|
|
GnosisChainConfig = readChainSpec("chainspecs/gnosis.json")
|
|
|
|
|
feat: add chiado config (#6058)
Hey guys, I'm trying to add the Chiado network ([Gnosis'
testnet](https://docs.gnosischain.com/about/networks/chiado)) now that
Gnosis can be synced fully with Erigon, so we can test it on the testnet
as well.
This is mostly inspired from
https://github.com/ledgerwatch/erigon/commit/cd5ef32f379ff51043b7ce1b0c3c471e18b99459.
Probably missing:
- [ ] The right consensus config (currently only a copy of Gnosis)
- [ ] Fixes to the chainspec?
- [ ] Presumably something in `cl/clparams/config.go`
Current state:
```
$ ./build/bin/erigon --chain=chiado --log.console.verbosity=debug
WARN[11-16|11:52:28.188] no log dir set, console logging only
WARN[11-16|11:52:28.193] no log dir set, console logging only
INFO[11-16|11:52:28.193] Build info git_branch=feat/chiado git_tag=v2021.10.03-2291-g17fae73f8 git_commit=17fae73f8af5348ba7c04684f2a2978daf81b67e
INFO[11-16|11:52:28.193] Starting Erigon on devnet=chiado
INFO[11-16|11:52:28.194] Maximum peer count ETH=100 total=100
INFO[11-16|11:52:28.194] starting HTTP APIs APIs=eth,erigon,engine
INFO[11-16|11:52:28.194] torrent verbosity level=WRN
INFO[11-16|11:52:30.300] Set global gas cap cap=50000000
INFO[11-16|11:52:30.302] Opening Database label=chaindata path=/home/filoozom/.local/share/erigon/chiado/chaindata
INFO[11-16|11:52:30.310] Initialised chain configuration config="{ChainID: 10200, Homestead: 0, DAO: <nil>, DAO Support: false, Tangerine Whistle: 0, Spurious Dragon: 0, Byzantium: 0, Constantinople: 0, Petersburg: 0, Istanbul: 0, Muir Glacier: <nil>, Berlin: 0, London: 0, Arrow Glacier: <nil>, Gray Glacier: <nil>, Terminal Total Difficulty: <nil>, Merge Netsplit: <nil>, Shanghai: <nil>, Cancun: <nil>, Engine: aura}" genesis=0xf463abeb7ee27fa62be3ac36a264e8174ee3458da451e6403df47618fd2cf415
WARN[11-16|11:52:30.311] Incorrect snapshot enablement got=true change_to=false
INFO[11-16|11:52:30.311] Effective prune_flags= snapshot_flags= history.v3=false
INFO[11-16|11:52:30.312] Initialising Ethereum protocol network=10200
INFO[11-16|11:52:30.329] Starting private RPC server on=127.0.0.1:9090
INFO[11-16|11:52:30.329] new subscription to logs established
INFO[11-16|11:52:30.329] rpc filters: subscribing to Erigon events
DBUG[11-16|11:52:30.330] Establishing event subscription channel with the RPC daemon ...
INFO[11-16|11:52:30.330] New txs subscriber joined
INFO[11-16|11:52:30.330] new subscription to newHeaders established
INFO[11-16|11:52:30.330] Reading JWT secret path=/home/filoozom/.local/share/erigon/chiado/jwt.hex
INFO[11-16|11:52:30.331] HTTP endpoint opened for Engine API url=localhost:8551 ws=true ws.compression=true
INFO[11-16|11:52:30.332] HTTP endpoint opened url=localhost:8545 ws=false ws.compression=true grpc=false
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=tcp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=udp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.341] [1/16 Snapshots] DONE in=134.7µs
INFO[11-16|11:52:30.341] [txpool] Started
INFO[11-16|11:52:30.341] [2/16 Headers] Waiting for headers... from=0
DBUG[11-16|11:52:30.341] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=tcp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=udp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.344] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.346] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.347] Started P2P networking version=67 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30304 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:30.351] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.351] Started P2P networking version=66 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30303 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:31.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:52:32.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
INFO[11-16|11:37:00.062] [p2p] GoodPeers eth66=0 eth67=0
INFO[11-16|11:37:00.077] [txpool] stat block=0 pending=0 baseFee=0 queued=0 alloc=42.7MB sys=79.5MB
INFO[11-16|11:37:00.089] [2/16 Headers] No block headers to write in this log period block number=0
INFO[11-16|11:37:00.089] Req/resp stats req=0 reqMin=0 reqMax=0 skel=0 skelMin=0 skelMax=0 resp=0 respMin=0 respMax=0 dups=0
DBUG[11-16|11:37:00.089] [Downloader] Queue sizes anchors=0 links=0 persisted=1
DBUG[11-16|11:37:00.089] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:37:06.095] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
```
I guess it comes down to:
```
--- FAIL: TestDefaultBSCGenesisBlock (0.34s)
genesis_test.go:27:
Error Trace: /home/filoozom/projects/erigon/core/genesis_test.go:27
/home/filoozom/projects/erigon/core/genesis_test.go:30
Error: Not equal:
expected: []byte{0xe8, 0x72, 0x46, 0x2c, 0x6b, 0xd5, 0xf4, 0x2, 0xec, 0x81, 0xde, 0x7c, 0x5b, 0xd2, 0x82, 0x3e, 0x13, 0x7c, 0x66, 0x6b, 0x78, 0xe8, 0x2b, 0x7e, 0xb0, 0xbe, 0x95, 0xaf, 0x5e, 0xce, 0xa1, 0x8d}
actual : []byte{0xad, 0xa4, 0x4f, 0xd8, 0xd2, 0xec, 0xab, 0x8b, 0x8, 0xf2, 0x56, 0xaf, 0x7, 0xad, 0x3e, 0x77, 0x7f, 0x17, 0xfb, 0x43, 0x4f, 0x8f, 0x8e, 0x67, 0x8b, 0x31, 0x2f, 0x57, 0x62, 0x12, 0xba, 0x9a}
Diff:
--- Expected
+++ Actual
@@ -1,4 +1,4 @@
([]uint8) (len=32) {
- 00000000 e8 72 46 2c 6b d5 f4 02 ec 81 de 7c 5b d2 82 3e |.rF,k......|[..>|
- 00000010 13 7c 66 6b 78 e8 2b 7e b0 be 95 af 5e ce a1 8d |.|fkx.+~....^...|
+ 00000000 ad a4 4f d8 d2 ec ab 8b 08 f2 56 af 07 ad 3e 77 |..O.......V...>w|
+ 00000010 7f 17 fb 43 4f 8f 8e 67 8b 31 2f 57 62 12 ba 9a |...CO..g.1/Wb...|
}
Test: TestDefaultBSCGenesisBlock
Messages: chiado
FAIL
FAIL github.com/ledgerwatch/erigon/core 0.823s
```
----------
Turns out that the `code` in Erigon's chainspec is not the same as
`constructor` in Nethermind for example.
Comparison for Sokol:
- Erigon:
https://github.com/ledgerwatch/erigon/blob/devel/core/allocs/sokol.json#L20-L34
- Nethermind:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Chains/sokol.json#L248-L252
2022-11-18 11:54:18 +00:00
|
|
|
ChiadoChainConfig = readChainSpec("chainspecs/chiado.json")
|
|
|
|
|
2023-02-25 02:54:12 +00:00
|
|
|
PulsechainChainConfig = readChainSpec("chainspecs/pulsechain.json")
|
|
|
|
|
2023-02-26 19:52:40 +00:00
|
|
|
PulsechainDevnetChainConfig = readChainSpec("chainspecs/pulsechain-devnet.json")
|
|
|
|
|
2023-04-13 19:57:33 +00:00
|
|
|
PulsechainTestnetV4ChainConfig = readChainSpec("chainspecs/pulsechain-testnet-v4.json")
|
2023-02-25 02:54:12 +00:00
|
|
|
|
2021-06-16 10:57:58 +00:00
|
|
|
CliqueSnapshot = NewSnapshotConfig(10, 1024, 16384, true, "")
|
2021-05-02 09:34:19 +00:00
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
TestChainConfig = &chain.Config{
|
2022-10-28 15:19:18 +00:00
|
|
|
ChainID: big.NewInt(1337),
|
2023-01-13 18:12:18 +00:00
|
|
|
Consensus: chain.EtHashConsensus,
|
2022-05-26 10:08:59 +00:00
|
|
|
HomesteadBlock: big.NewInt(0),
|
|
|
|
TangerineWhistleBlock: big.NewInt(0),
|
|
|
|
SpuriousDragonBlock: 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),
|
2023-01-13 18:12:18 +00:00
|
|
|
Ethash: new(chain.EthashConfig),
|
2023-02-25 02:54:12 +00:00
|
|
|
PrimordialPulseBlock: nil,
|
|
|
|
PulseChain: nil,
|
2021-05-02 09:34:19 +00:00
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
TestChainAuraConfig = &chain.Config{
|
2022-05-26 10:08:59 +00:00
|
|
|
ChainID: big.NewInt(1),
|
2023-01-13 18:12:18 +00:00
|
|
|
Consensus: chain.AuRaConsensus,
|
2022-05-26 10:08:59 +00:00
|
|
|
HomesteadBlock: big.NewInt(0),
|
|
|
|
TangerineWhistleBlock: big.NewInt(0),
|
|
|
|
SpuriousDragonBlock: 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),
|
2023-03-03 07:00:54 +00:00
|
|
|
LondonBlock: big.NewInt(0),
|
2023-01-13 18:12:18 +00:00
|
|
|
Aura: &chain.AuRaConfig{},
|
2021-10-13 01:31:04 +00:00
|
|
|
}
|
|
|
|
|
2022-12-07 17:45:44 +00:00
|
|
|
TestRules = TestChainConfig.Rules(0, 0)
|
2017-03-02 13:03:33 +00:00
|
|
|
)
|
2017-02-28 22:18:13 +00:00
|
|
|
|
2021-12-05 02:03:08 +00:00
|
|
|
type ConsensusSnapshotConfig struct {
|
2021-04-19 21:58:05 +00:00
|
|
|
CheckpointInterval uint64 // Number of blocks after which to save the vote snapshot to the database
|
|
|
|
InmemorySnapshots int // Number of recent vote snapshots to keep in memory
|
|
|
|
InmemorySignatures int // Number of recent block signatures to keep in memory
|
|
|
|
DBPath string
|
|
|
|
InMemory bool
|
|
|
|
}
|
|
|
|
|
|
|
|
const cliquePath = "clique"
|
|
|
|
|
2021-12-05 02:03:08 +00:00
|
|
|
func NewSnapshotConfig(checkpointInterval uint64, inmemorySnapshots int, inmemorySignatures int, inmemory bool, dbPath string) *ConsensusSnapshotConfig {
|
2021-04-19 21:58:05 +00:00
|
|
|
if len(dbPath) == 0 {
|
|
|
|
dbPath = paths.DefaultDataDir()
|
|
|
|
}
|
|
|
|
|
2021-12-05 02:03:08 +00:00
|
|
|
return &ConsensusSnapshotConfig{
|
2021-04-19 21:58:05 +00:00
|
|
|
checkpointInterval,
|
|
|
|
inmemorySnapshots,
|
|
|
|
inmemorySignatures,
|
|
|
|
path.Join(dbPath, cliquePath),
|
|
|
|
inmemory,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func ChainConfigByChainName(chain string) *chain.Config {
|
2022-03-03 14:57:10 +00:00
|
|
|
switch chain {
|
|
|
|
case networkname.MainnetChainName:
|
|
|
|
return MainnetChainConfig
|
2023-11-01 10:08:47 +00:00
|
|
|
case networkname.DevChainName:
|
|
|
|
return AllCliqueProtocolChanges
|
2023-08-26 10:31:29 +00:00
|
|
|
case networkname.HoleskyChainName:
|
|
|
|
return HoleskyChainConfig
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.SepoliaChainName:
|
|
|
|
return SepoliaChainConfig
|
|
|
|
case networkname.GoerliChainName:
|
|
|
|
return GoerliChainConfig
|
|
|
|
case networkname.MumbaiChainName:
|
|
|
|
return MumbaiChainConfig
|
2023-11-30 01:19:52 +00:00
|
|
|
case networkname.AmoyChainName:
|
|
|
|
return AmoyChainConfig
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.BorMainnetChainName:
|
|
|
|
return BorMainnetChainConfig
|
2022-06-10 08:32:04 +00:00
|
|
|
case networkname.BorDevnetChainName:
|
|
|
|
return BorDevnetChainConfig
|
2022-07-12 15:21:52 +00:00
|
|
|
case networkname.GnosisChainName:
|
|
|
|
return GnosisChainConfig
|
feat: add chiado config (#6058)
Hey guys, I'm trying to add the Chiado network ([Gnosis'
testnet](https://docs.gnosischain.com/about/networks/chiado)) now that
Gnosis can be synced fully with Erigon, so we can test it on the testnet
as well.
This is mostly inspired from
https://github.com/ledgerwatch/erigon/commit/cd5ef32f379ff51043b7ce1b0c3c471e18b99459.
Probably missing:
- [ ] The right consensus config (currently only a copy of Gnosis)
- [ ] Fixes to the chainspec?
- [ ] Presumably something in `cl/clparams/config.go`
Current state:
```
$ ./build/bin/erigon --chain=chiado --log.console.verbosity=debug
WARN[11-16|11:52:28.188] no log dir set, console logging only
WARN[11-16|11:52:28.193] no log dir set, console logging only
INFO[11-16|11:52:28.193] Build info git_branch=feat/chiado git_tag=v2021.10.03-2291-g17fae73f8 git_commit=17fae73f8af5348ba7c04684f2a2978daf81b67e
INFO[11-16|11:52:28.193] Starting Erigon on devnet=chiado
INFO[11-16|11:52:28.194] Maximum peer count ETH=100 total=100
INFO[11-16|11:52:28.194] starting HTTP APIs APIs=eth,erigon,engine
INFO[11-16|11:52:28.194] torrent verbosity level=WRN
INFO[11-16|11:52:30.300] Set global gas cap cap=50000000
INFO[11-16|11:52:30.302] Opening Database label=chaindata path=/home/filoozom/.local/share/erigon/chiado/chaindata
INFO[11-16|11:52:30.310] Initialised chain configuration config="{ChainID: 10200, Homestead: 0, DAO: <nil>, DAO Support: false, Tangerine Whistle: 0, Spurious Dragon: 0, Byzantium: 0, Constantinople: 0, Petersburg: 0, Istanbul: 0, Muir Glacier: <nil>, Berlin: 0, London: 0, Arrow Glacier: <nil>, Gray Glacier: <nil>, Terminal Total Difficulty: <nil>, Merge Netsplit: <nil>, Shanghai: <nil>, Cancun: <nil>, Engine: aura}" genesis=0xf463abeb7ee27fa62be3ac36a264e8174ee3458da451e6403df47618fd2cf415
WARN[11-16|11:52:30.311] Incorrect snapshot enablement got=true change_to=false
INFO[11-16|11:52:30.311] Effective prune_flags= snapshot_flags= history.v3=false
INFO[11-16|11:52:30.312] Initialising Ethereum protocol network=10200
INFO[11-16|11:52:30.329] Starting private RPC server on=127.0.0.1:9090
INFO[11-16|11:52:30.329] new subscription to logs established
INFO[11-16|11:52:30.329] rpc filters: subscribing to Erigon events
DBUG[11-16|11:52:30.330] Establishing event subscription channel with the RPC daemon ...
INFO[11-16|11:52:30.330] New txs subscriber joined
INFO[11-16|11:52:30.330] new subscription to newHeaders established
INFO[11-16|11:52:30.330] Reading JWT secret path=/home/filoozom/.local/share/erigon/chiado/jwt.hex
INFO[11-16|11:52:30.331] HTTP endpoint opened for Engine API url=localhost:8551 ws=true ws.compression=true
INFO[11-16|11:52:30.332] HTTP endpoint opened url=localhost:8545 ws=false ws.compression=true grpc=false
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=tcp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=udp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.341] [1/16 Snapshots] DONE in=134.7µs
INFO[11-16|11:52:30.341] [txpool] Started
INFO[11-16|11:52:30.341] [2/16 Headers] Waiting for headers... from=0
DBUG[11-16|11:52:30.341] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=tcp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=udp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.344] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.346] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.347] Started P2P networking version=67 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30304 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:30.351] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.351] Started P2P networking version=66 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30303 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:31.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:52:32.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
INFO[11-16|11:37:00.062] [p2p] GoodPeers eth66=0 eth67=0
INFO[11-16|11:37:00.077] [txpool] stat block=0 pending=0 baseFee=0 queued=0 alloc=42.7MB sys=79.5MB
INFO[11-16|11:37:00.089] [2/16 Headers] No block headers to write in this log period block number=0
INFO[11-16|11:37:00.089] Req/resp stats req=0 reqMin=0 reqMax=0 skel=0 skelMin=0 skelMax=0 resp=0 respMin=0 respMax=0 dups=0
DBUG[11-16|11:37:00.089] [Downloader] Queue sizes anchors=0 links=0 persisted=1
DBUG[11-16|11:37:00.089] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:37:06.095] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
```
I guess it comes down to:
```
--- FAIL: TestDefaultBSCGenesisBlock (0.34s)
genesis_test.go:27:
Error Trace: /home/filoozom/projects/erigon/core/genesis_test.go:27
/home/filoozom/projects/erigon/core/genesis_test.go:30
Error: Not equal:
expected: []byte{0xe8, 0x72, 0x46, 0x2c, 0x6b, 0xd5, 0xf4, 0x2, 0xec, 0x81, 0xde, 0x7c, 0x5b, 0xd2, 0x82, 0x3e, 0x13, 0x7c, 0x66, 0x6b, 0x78, 0xe8, 0x2b, 0x7e, 0xb0, 0xbe, 0x95, 0xaf, 0x5e, 0xce, 0xa1, 0x8d}
actual : []byte{0xad, 0xa4, 0x4f, 0xd8, 0xd2, 0xec, 0xab, 0x8b, 0x8, 0xf2, 0x56, 0xaf, 0x7, 0xad, 0x3e, 0x77, 0x7f, 0x17, 0xfb, 0x43, 0x4f, 0x8f, 0x8e, 0x67, 0x8b, 0x31, 0x2f, 0x57, 0x62, 0x12, 0xba, 0x9a}
Diff:
--- Expected
+++ Actual
@@ -1,4 +1,4 @@
([]uint8) (len=32) {
- 00000000 e8 72 46 2c 6b d5 f4 02 ec 81 de 7c 5b d2 82 3e |.rF,k......|[..>|
- 00000010 13 7c 66 6b 78 e8 2b 7e b0 be 95 af 5e ce a1 8d |.|fkx.+~....^...|
+ 00000000 ad a4 4f d8 d2 ec ab 8b 08 f2 56 af 07 ad 3e 77 |..O.......V...>w|
+ 00000010 7f 17 fb 43 4f 8f 8e 67 8b 31 2f 57 62 12 ba 9a |...CO..g.1/Wb...|
}
Test: TestDefaultBSCGenesisBlock
Messages: chiado
FAIL
FAIL github.com/ledgerwatch/erigon/core 0.823s
```
----------
Turns out that the `code` in Erigon's chainspec is not the same as
`constructor` in Nethermind for example.
Comparison for Sokol:
- Erigon:
https://github.com/ledgerwatch/erigon/blob/devel/core/allocs/sokol.json#L20-L34
- Nethermind:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Chains/sokol.json#L248-L252
2022-11-18 11:54:18 +00:00
|
|
|
case networkname.ChiadoChainName:
|
|
|
|
return ChiadoChainConfig
|
2023-02-25 02:54:12 +00:00
|
|
|
case networkname.PulsechainChainName:
|
|
|
|
return PulsechainChainConfig
|
2023-02-26 19:52:40 +00:00
|
|
|
case networkname.PulsechainDevnetChainName:
|
|
|
|
return PulsechainDevnetChainConfig
|
2023-04-13 19:57:33 +00:00
|
|
|
case networkname.PulsechainTestnetV4ChainName:
|
|
|
|
return PulsechainTestnetV4ChainConfig
|
2022-03-03 14:57:10 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func GenesisHashByChainName(chain string) *libcommon.Hash {
|
2022-03-03 14:57:10 +00:00
|
|
|
switch chain {
|
|
|
|
case networkname.MainnetChainName:
|
|
|
|
return &MainnetGenesisHash
|
2023-08-26 10:31:29 +00:00
|
|
|
case networkname.HoleskyChainName:
|
|
|
|
return &HoleskyGenesisHash
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.SepoliaChainName:
|
|
|
|
return &SepoliaGenesisHash
|
|
|
|
case networkname.GoerliChainName:
|
|
|
|
return &GoerliGenesisHash
|
|
|
|
case networkname.MumbaiChainName:
|
|
|
|
return &MumbaiGenesisHash
|
2023-11-30 01:19:52 +00:00
|
|
|
case networkname.AmoyChainName:
|
|
|
|
return &AmoyGenesisHash
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.BorMainnetChainName:
|
|
|
|
return &BorMainnetGenesisHash
|
2022-06-10 08:32:04 +00:00
|
|
|
case networkname.BorDevnetChainName:
|
|
|
|
return &BorDevnetGenesisHash
|
2022-07-12 15:21:52 +00:00
|
|
|
case networkname.GnosisChainName:
|
|
|
|
return &GnosisGenesisHash
|
feat: add chiado config (#6058)
Hey guys, I'm trying to add the Chiado network ([Gnosis'
testnet](https://docs.gnosischain.com/about/networks/chiado)) now that
Gnosis can be synced fully with Erigon, so we can test it on the testnet
as well.
This is mostly inspired from
https://github.com/ledgerwatch/erigon/commit/cd5ef32f379ff51043b7ce1b0c3c471e18b99459.
Probably missing:
- [ ] The right consensus config (currently only a copy of Gnosis)
- [ ] Fixes to the chainspec?
- [ ] Presumably something in `cl/clparams/config.go`
Current state:
```
$ ./build/bin/erigon --chain=chiado --log.console.verbosity=debug
WARN[11-16|11:52:28.188] no log dir set, console logging only
WARN[11-16|11:52:28.193] no log dir set, console logging only
INFO[11-16|11:52:28.193] Build info git_branch=feat/chiado git_tag=v2021.10.03-2291-g17fae73f8 git_commit=17fae73f8af5348ba7c04684f2a2978daf81b67e
INFO[11-16|11:52:28.193] Starting Erigon on devnet=chiado
INFO[11-16|11:52:28.194] Maximum peer count ETH=100 total=100
INFO[11-16|11:52:28.194] starting HTTP APIs APIs=eth,erigon,engine
INFO[11-16|11:52:28.194] torrent verbosity level=WRN
INFO[11-16|11:52:30.300] Set global gas cap cap=50000000
INFO[11-16|11:52:30.302] Opening Database label=chaindata path=/home/filoozom/.local/share/erigon/chiado/chaindata
INFO[11-16|11:52:30.310] Initialised chain configuration config="{ChainID: 10200, Homestead: 0, DAO: <nil>, DAO Support: false, Tangerine Whistle: 0, Spurious Dragon: 0, Byzantium: 0, Constantinople: 0, Petersburg: 0, Istanbul: 0, Muir Glacier: <nil>, Berlin: 0, London: 0, Arrow Glacier: <nil>, Gray Glacier: <nil>, Terminal Total Difficulty: <nil>, Merge Netsplit: <nil>, Shanghai: <nil>, Cancun: <nil>, Engine: aura}" genesis=0xf463abeb7ee27fa62be3ac36a264e8174ee3458da451e6403df47618fd2cf415
WARN[11-16|11:52:30.311] Incorrect snapshot enablement got=true change_to=false
INFO[11-16|11:52:30.311] Effective prune_flags= snapshot_flags= history.v3=false
INFO[11-16|11:52:30.312] Initialising Ethereum protocol network=10200
INFO[11-16|11:52:30.329] Starting private RPC server on=127.0.0.1:9090
INFO[11-16|11:52:30.329] new subscription to logs established
INFO[11-16|11:52:30.329] rpc filters: subscribing to Erigon events
DBUG[11-16|11:52:30.330] Establishing event subscription channel with the RPC daemon ...
INFO[11-16|11:52:30.330] New txs subscriber joined
INFO[11-16|11:52:30.330] new subscription to newHeaders established
INFO[11-16|11:52:30.330] Reading JWT secret path=/home/filoozom/.local/share/erigon/chiado/jwt.hex
INFO[11-16|11:52:30.331] HTTP endpoint opened for Engine API url=localhost:8551 ws=true ws.compression=true
INFO[11-16|11:52:30.332] HTTP endpoint opened url=localhost:8545 ws=false ws.compression=true grpc=false
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=tcp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=udp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.341] [1/16 Snapshots] DONE in=134.7µs
INFO[11-16|11:52:30.341] [txpool] Started
INFO[11-16|11:52:30.341] [2/16 Headers] Waiting for headers... from=0
DBUG[11-16|11:52:30.341] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=tcp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=udp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.344] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.346] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.347] Started P2P networking version=67 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30304 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:30.351] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.351] Started P2P networking version=66 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30303 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:31.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:52:32.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
INFO[11-16|11:37:00.062] [p2p] GoodPeers eth66=0 eth67=0
INFO[11-16|11:37:00.077] [txpool] stat block=0 pending=0 baseFee=0 queued=0 alloc=42.7MB sys=79.5MB
INFO[11-16|11:37:00.089] [2/16 Headers] No block headers to write in this log period block number=0
INFO[11-16|11:37:00.089] Req/resp stats req=0 reqMin=0 reqMax=0 skel=0 skelMin=0 skelMax=0 resp=0 respMin=0 respMax=0 dups=0
DBUG[11-16|11:37:00.089] [Downloader] Queue sizes anchors=0 links=0 persisted=1
DBUG[11-16|11:37:00.089] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:37:06.095] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
```
I guess it comes down to:
```
--- FAIL: TestDefaultBSCGenesisBlock (0.34s)
genesis_test.go:27:
Error Trace: /home/filoozom/projects/erigon/core/genesis_test.go:27
/home/filoozom/projects/erigon/core/genesis_test.go:30
Error: Not equal:
expected: []byte{0xe8, 0x72, 0x46, 0x2c, 0x6b, 0xd5, 0xf4, 0x2, 0xec, 0x81, 0xde, 0x7c, 0x5b, 0xd2, 0x82, 0x3e, 0x13, 0x7c, 0x66, 0x6b, 0x78, 0xe8, 0x2b, 0x7e, 0xb0, 0xbe, 0x95, 0xaf, 0x5e, 0xce, 0xa1, 0x8d}
actual : []byte{0xad, 0xa4, 0x4f, 0xd8, 0xd2, 0xec, 0xab, 0x8b, 0x8, 0xf2, 0x56, 0xaf, 0x7, 0xad, 0x3e, 0x77, 0x7f, 0x17, 0xfb, 0x43, 0x4f, 0x8f, 0x8e, 0x67, 0x8b, 0x31, 0x2f, 0x57, 0x62, 0x12, 0xba, 0x9a}
Diff:
--- Expected
+++ Actual
@@ -1,4 +1,4 @@
([]uint8) (len=32) {
- 00000000 e8 72 46 2c 6b d5 f4 02 ec 81 de 7c 5b d2 82 3e |.rF,k......|[..>|
- 00000010 13 7c 66 6b 78 e8 2b 7e b0 be 95 af 5e ce a1 8d |.|fkx.+~....^...|
+ 00000000 ad a4 4f d8 d2 ec ab 8b 08 f2 56 af 07 ad 3e 77 |..O.......V...>w|
+ 00000010 7f 17 fb 43 4f 8f 8e 67 8b 31 2f 57 62 12 ba 9a |...CO..g.1/Wb...|
}
Test: TestDefaultBSCGenesisBlock
Messages: chiado
FAIL
FAIL github.com/ledgerwatch/erigon/core 0.823s
```
----------
Turns out that the `code` in Erigon's chainspec is not the same as
`constructor` in Nethermind for example.
Comparison for Sokol:
- Erigon:
https://github.com/ledgerwatch/erigon/blob/devel/core/allocs/sokol.json#L20-L34
- Nethermind:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Chains/sokol.json#L248-L252
2022-11-18 11:54:18 +00:00
|
|
|
case networkname.ChiadoChainName:
|
|
|
|
return &ChiadoGenesisHash
|
2023-02-25 02:54:12 +00:00
|
|
|
case networkname.PulsechainChainName:
|
|
|
|
return &PulsechainGenesisHash
|
2023-02-26 19:52:40 +00:00
|
|
|
case networkname.PulsechainDevnetChainName:
|
|
|
|
return &PulsechainDevnetGenesisHash
|
2023-04-13 19:57:33 +00:00
|
|
|
case networkname.PulsechainTestnetV4ChainName:
|
2023-02-25 02:54:12 +00:00
|
|
|
return &PulsechainTetnetGenesisHash
|
2022-03-03 14:57:10 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func ChainConfigByGenesisHash(genesisHash libcommon.Hash) *chain.Config {
|
2022-02-23 20:24:13 +00:00
|
|
|
switch {
|
|
|
|
case genesisHash == MainnetGenesisHash:
|
|
|
|
return MainnetChainConfig
|
2023-08-26 10:31:29 +00:00
|
|
|
case genesisHash == HoleskyGenesisHash:
|
|
|
|
return HoleskyChainConfig
|
2022-02-23 20:24:13 +00:00
|
|
|
case genesisHash == SepoliaGenesisHash:
|
|
|
|
return SepoliaChainConfig
|
|
|
|
case genesisHash == GoerliGenesisHash:
|
|
|
|
return GoerliChainConfig
|
|
|
|
case genesisHash == MumbaiGenesisHash:
|
|
|
|
return MumbaiChainConfig
|
2023-11-30 01:19:52 +00:00
|
|
|
case genesisHash == AmoyGenesisHash:
|
|
|
|
return AmoyChainConfig
|
2022-02-23 20:24:13 +00:00
|
|
|
case genesisHash == BorMainnetGenesisHash:
|
|
|
|
return BorMainnetChainConfig
|
2022-12-09 11:04:08 +00:00
|
|
|
case genesisHash == BorDevnetGenesisHash:
|
|
|
|
return BorDevnetChainConfig
|
2022-07-12 15:21:52 +00:00
|
|
|
case genesisHash == GnosisGenesisHash:
|
|
|
|
return GnosisChainConfig
|
feat: add chiado config (#6058)
Hey guys, I'm trying to add the Chiado network ([Gnosis'
testnet](https://docs.gnosischain.com/about/networks/chiado)) now that
Gnosis can be synced fully with Erigon, so we can test it on the testnet
as well.
This is mostly inspired from
https://github.com/ledgerwatch/erigon/commit/cd5ef32f379ff51043b7ce1b0c3c471e18b99459.
Probably missing:
- [ ] The right consensus config (currently only a copy of Gnosis)
- [ ] Fixes to the chainspec?
- [ ] Presumably something in `cl/clparams/config.go`
Current state:
```
$ ./build/bin/erigon --chain=chiado --log.console.verbosity=debug
WARN[11-16|11:52:28.188] no log dir set, console logging only
WARN[11-16|11:52:28.193] no log dir set, console logging only
INFO[11-16|11:52:28.193] Build info git_branch=feat/chiado git_tag=v2021.10.03-2291-g17fae73f8 git_commit=17fae73f8af5348ba7c04684f2a2978daf81b67e
INFO[11-16|11:52:28.193] Starting Erigon on devnet=chiado
INFO[11-16|11:52:28.194] Maximum peer count ETH=100 total=100
INFO[11-16|11:52:28.194] starting HTTP APIs APIs=eth,erigon,engine
INFO[11-16|11:52:28.194] torrent verbosity level=WRN
INFO[11-16|11:52:30.300] Set global gas cap cap=50000000
INFO[11-16|11:52:30.302] Opening Database label=chaindata path=/home/filoozom/.local/share/erigon/chiado/chaindata
INFO[11-16|11:52:30.310] Initialised chain configuration config="{ChainID: 10200, Homestead: 0, DAO: <nil>, DAO Support: false, Tangerine Whistle: 0, Spurious Dragon: 0, Byzantium: 0, Constantinople: 0, Petersburg: 0, Istanbul: 0, Muir Glacier: <nil>, Berlin: 0, London: 0, Arrow Glacier: <nil>, Gray Glacier: <nil>, Terminal Total Difficulty: <nil>, Merge Netsplit: <nil>, Shanghai: <nil>, Cancun: <nil>, Engine: aura}" genesis=0xf463abeb7ee27fa62be3ac36a264e8174ee3458da451e6403df47618fd2cf415
WARN[11-16|11:52:30.311] Incorrect snapshot enablement got=true change_to=false
INFO[11-16|11:52:30.311] Effective prune_flags= snapshot_flags= history.v3=false
INFO[11-16|11:52:30.312] Initialising Ethereum protocol network=10200
INFO[11-16|11:52:30.329] Starting private RPC server on=127.0.0.1:9090
INFO[11-16|11:52:30.329] new subscription to logs established
INFO[11-16|11:52:30.329] rpc filters: subscribing to Erigon events
DBUG[11-16|11:52:30.330] Establishing event subscription channel with the RPC daemon ...
INFO[11-16|11:52:30.330] New txs subscriber joined
INFO[11-16|11:52:30.330] new subscription to newHeaders established
INFO[11-16|11:52:30.330] Reading JWT secret path=/home/filoozom/.local/share/erigon/chiado/jwt.hex
INFO[11-16|11:52:30.331] HTTP endpoint opened for Engine API url=localhost:8551 ws=true ws.compression=true
INFO[11-16|11:52:30.332] HTTP endpoint opened url=localhost:8545 ws=false ws.compression=true grpc=false
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=tcp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] Couldn't add port mapping proto=udp extport=30304 intport=30304 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.336] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.341] [1/16 Snapshots] DONE in=134.7µs
INFO[11-16|11:52:30.341] [txpool] Started
INFO[11-16|11:52:30.341] [2/16 Headers] Waiting for headers... from=0
DBUG[11-16|11:52:30.341] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=tcp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.343] Couldn't add port mapping proto=udp extport=30303 intport=30303 interface="UPnP or NAT-PMP" err="no UPnP or NAT-PMP router discovered"
DBUG[11-16|11:52:30.344] QuerySeeds read nodes from the node DB count=0
DBUG[11-16|11:52:30.346] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.347] Started P2P networking version=67 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30304 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:30.351] QuerySeeds read nodes from the node DB count=0
INFO[11-16|11:52:30.351] Started P2P networking version=66 self=enode://47d2e31d90fe140bfd967f147c1d4e8a4834b4c6b895a4bb7082100be60aa5e9a73e98e996da9b0257f02f9ad39b683755abe6ca3e9aefe0170a478a8559dcfb@127.0.0.1:30303 name=erigon/v2.30.0-dev-17fae73f/linux-amd64/go1.18.1
DBUG[11-16|11:52:31.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:52:32.342] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
INFO[11-16|11:37:00.062] [p2p] GoodPeers eth66=0 eth67=0
INFO[11-16|11:37:00.077] [txpool] stat block=0 pending=0 baseFee=0 queued=0 alloc=42.7MB sys=79.5MB
INFO[11-16|11:37:00.089] [2/16 Headers] No block headers to write in this log period block number=0
INFO[11-16|11:37:00.089] Req/resp stats req=0 reqMin=0 reqMax=0 skel=0 skelMin=0 skelMax=0 resp=0 respMin=0 respMax=0 dups=0
DBUG[11-16|11:37:00.089] [Downloader] Queue sizes anchors=0 links=0 persisted=1
DBUG[11-16|11:37:00.089] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
[...]
DBUG[11-16|11:37:06.095] [Downloader] Request skeleton anchors=0 top seen height=0 highestInDb=0
```
I guess it comes down to:
```
--- FAIL: TestDefaultBSCGenesisBlock (0.34s)
genesis_test.go:27:
Error Trace: /home/filoozom/projects/erigon/core/genesis_test.go:27
/home/filoozom/projects/erigon/core/genesis_test.go:30
Error: Not equal:
expected: []byte{0xe8, 0x72, 0x46, 0x2c, 0x6b, 0xd5, 0xf4, 0x2, 0xec, 0x81, 0xde, 0x7c, 0x5b, 0xd2, 0x82, 0x3e, 0x13, 0x7c, 0x66, 0x6b, 0x78, 0xe8, 0x2b, 0x7e, 0xb0, 0xbe, 0x95, 0xaf, 0x5e, 0xce, 0xa1, 0x8d}
actual : []byte{0xad, 0xa4, 0x4f, 0xd8, 0xd2, 0xec, 0xab, 0x8b, 0x8, 0xf2, 0x56, 0xaf, 0x7, 0xad, 0x3e, 0x77, 0x7f, 0x17, 0xfb, 0x43, 0x4f, 0x8f, 0x8e, 0x67, 0x8b, 0x31, 0x2f, 0x57, 0x62, 0x12, 0xba, 0x9a}
Diff:
--- Expected
+++ Actual
@@ -1,4 +1,4 @@
([]uint8) (len=32) {
- 00000000 e8 72 46 2c 6b d5 f4 02 ec 81 de 7c 5b d2 82 3e |.rF,k......|[..>|
- 00000010 13 7c 66 6b 78 e8 2b 7e b0 be 95 af 5e ce a1 8d |.|fkx.+~....^...|
+ 00000000 ad a4 4f d8 d2 ec ab 8b 08 f2 56 af 07 ad 3e 77 |..O.......V...>w|
+ 00000010 7f 17 fb 43 4f 8f 8e 67 8b 31 2f 57 62 12 ba 9a |...CO..g.1/Wb...|
}
Test: TestDefaultBSCGenesisBlock
Messages: chiado
FAIL
FAIL github.com/ledgerwatch/erigon/core 0.823s
```
----------
Turns out that the `code` in Erigon's chainspec is not the same as
`constructor` in Nethermind for example.
Comparison for Sokol:
- Erigon:
https://github.com/ledgerwatch/erigon/blob/devel/core/allocs/sokol.json#L20-L34
- Nethermind:
https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Chains/sokol.json#L248-L252
2022-11-18 11:54:18 +00:00
|
|
|
case genesisHash == ChiadoGenesisHash:
|
|
|
|
return ChiadoChainConfig
|
2022-02-23 20:24:13 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2022-03-03 14:57:10 +00:00
|
|
|
|
|
|
|
func NetworkIDByChainName(chain string) uint64 {
|
2023-11-01 10:08:47 +00:00
|
|
|
config := ChainConfigByChainName(chain)
|
|
|
|
if config == nil {
|
|
|
|
return 0
|
2022-03-03 14:57:10 +00:00
|
|
|
}
|
2023-11-01 10:08:47 +00:00
|
|
|
return config.ChainID.Uint64()
|
2022-03-03 14:57:10 +00:00
|
|
|
}
|
2023-08-22 11:40:36 +00:00
|
|
|
|
|
|
|
func IsChainPoS(chainConfig *chain.Config, currentTDProvider func() *big.Int) bool {
|
|
|
|
return isChainIDPoS(chainConfig.ChainID) || hasChainPassedTerminalTD(chainConfig, currentTDProvider)
|
|
|
|
}
|
|
|
|
|
|
|
|
func isChainIDPoS(chainID *big.Int) bool {
|
|
|
|
ids := []*big.Int{
|
|
|
|
MainnetChainConfig.ChainID,
|
2023-08-29 14:29:14 +00:00
|
|
|
HoleskyChainConfig.ChainID,
|
2023-08-22 11:40:36 +00:00
|
|
|
GoerliChainConfig.ChainID,
|
|
|
|
SepoliaChainConfig.ChainID,
|
|
|
|
GnosisChainConfig.ChainID,
|
|
|
|
ChiadoChainConfig.ChainID,
|
|
|
|
}
|
|
|
|
for _, id := range ids {
|
|
|
|
if id.Cmp(chainID) == 0 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func hasChainPassedTerminalTD(chainConfig *chain.Config, currentTDProvider func() *big.Int) bool {
|
|
|
|
if chainConfig.TerminalTotalDifficultyPassed {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
terminalTD := chainConfig.TerminalTotalDifficulty
|
|
|
|
if terminalTD == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
currentTD := currentTDProvider()
|
|
|
|
return (currentTD != nil) && (terminalTD.Cmp(currentTD) <= 0)
|
|
|
|
}
|