2015-07-07 00:54:22 +00:00
|
|
|
// Copyright 2014 The go-ethereum Authors
|
2015-07-22 16:48:40 +00:00
|
|
|
// This file is part of the go-ethereum library.
|
2015-07-07 00:54:22 +00:00
|
|
|
//
|
2015-07-23 16:35:11 +00:00
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
2015-07-07 00:54:22 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2015-07-22 16:48:40 +00:00
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
2015-07-07 00:54:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-07-22 16:48:40 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-07-07 00:54:22 +00:00
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2015-07-22 16:48:40 +00:00
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
2015-07-07 00:54:22 +00:00
|
|
|
|
2014-12-04 09:28:02 +00:00
|
|
|
package core
|
2014-02-14 22:56:09 +00:00
|
|
|
|
|
|
|
import (
|
2020-05-25 11:12:25 +00:00
|
|
|
"context"
|
2023-07-18 08:47:04 +00:00
|
|
|
"crypto/ecdsa"
|
2021-04-09 12:00:50 +00:00
|
|
|
"embed"
|
2020-05-26 12:27:21 +00:00
|
|
|
"encoding/binary"
|
2017-07-11 11:49:14 +00:00
|
|
|
"encoding/json"
|
2015-02-20 17:05:46 +00:00
|
|
|
"fmt"
|
2015-06-18 23:57:16 +00:00
|
|
|
"math/big"
|
2021-06-05 15:17:04 +00:00
|
|
|
"sync"
|
2014-08-21 12:47:58 +00:00
|
|
|
|
2022-08-24 10:38:59 +00:00
|
|
|
"github.com/c2h5oh/datasize"
|
2020-05-25 11:12:25 +00:00
|
|
|
"github.com/holiman/uint256"
|
2023-05-09 15:19:23 +00:00
|
|
|
"github.com/ledgerwatch/log/v3"
|
|
|
|
"golang.org/x/exp/slices"
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/chain"
|
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2023-06-09 06:46:58 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
2023-01-25 09:29:41 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv/rawdbv3"
|
2023-05-09 15:19:23 +00:00
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/common/hexutil"
|
2021-12-16 22:08:27 +00:00
|
|
|
"github.com/ledgerwatch/erigon/consensus/ethash"
|
2023-05-09 17:45:33 +00:00
|
|
|
"github.com/ledgerwatch/erigon/consensus/merge"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/core/rawdb"
|
|
|
|
"github.com/ledgerwatch/erigon/core/state"
|
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
|
|
|
"github.com/ledgerwatch/erigon/crypto"
|
2023-03-31 02:19:56 +00:00
|
|
|
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params"
|
2022-03-03 14:57:10 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params/networkname"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/turbo/trie"
|
2014-02-14 22:56:09 +00:00
|
|
|
)
|
|
|
|
|
2021-06-05 15:17:04 +00:00
|
|
|
// CommitGenesisBlock writes or updates the genesis block in db.
|
2017-03-02 13:03:33 +00:00
|
|
|
// The block that will be used is:
|
|
|
|
//
|
2022-08-10 12:04:13 +00:00
|
|
|
// genesis == nil genesis != nil
|
|
|
|
// +------------------------------------------
|
2023-03-20 15:44:22 +00:00
|
|
|
// db has no genesis | main-net | genesis
|
2022-08-10 12:04:13 +00:00
|
|
|
// db has genesis | from DB | genesis (if compatible)
|
2017-03-02 13:03:33 +00:00
|
|
|
//
|
|
|
|
// The stored chain configuration will be updated if it is compatible (i.e. does not
|
|
|
|
// specify a fork block below the local head block). In case of a conflict, the
|
|
|
|
// error is a *params.ConfigCompatError and the new, unwritten config is returned.
|
|
|
|
//
|
|
|
|
// The returned chain configuration is never nil.
|
2023-05-17 06:36:06 +00:00
|
|
|
func CommitGenesisBlock(db kv.RwDB, genesis *types.Genesis, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
|
|
|
|
return CommitGenesisBlockWithOverride(db, genesis, nil, tmpDir, logger)
|
2022-05-26 19:21:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-03 14:05:35 +00:00
|
|
|
func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *types.Genesis, overrideCancunTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
|
2021-06-05 15:17:04 +00:00
|
|
|
tx, err := db.BeginRw(context.Background())
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
2023-08-03 14:05:35 +00:00
|
|
|
c, b, err := WriteGenesisBlock(tx, genesis, overrideCancunTime, tmpDir, logger)
|
2021-06-05 15:17:04 +00:00
|
|
|
if err != nil {
|
|
|
|
return c, b, err
|
|
|
|
}
|
|
|
|
err = tx.Commit()
|
|
|
|
if err != nil {
|
|
|
|
return c, b, err
|
|
|
|
}
|
|
|
|
return c, b, nil
|
|
|
|
}
|
|
|
|
|
2023-08-03 14:05:35 +00:00
|
|
|
func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overrideCancunTime *big.Int, tmpDir string, logger log.Logger) (*chain.Config, *types.Block, error) {
|
2023-06-05 05:36:24 +00:00
|
|
|
var storedBlock *types.Block
|
2017-03-02 13:03:33 +00:00
|
|
|
if genesis != nil && genesis.Config == nil {
|
2023-03-29 07:27:06 +00:00
|
|
|
return params.AllProtocolChanges, nil, types.ErrGenesisNoConfig
|
2017-02-28 22:18:13 +00:00
|
|
|
}
|
2017-03-02 13:03:33 +00:00
|
|
|
// Just commit the new block if there is no stored genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
storedHash, storedErr := rawdb.ReadCanonicalHash(tx, 0)
|
2021-03-29 03:58:45 +00:00
|
|
|
if storedErr != nil {
|
2021-05-23 05:41:42 +00:00
|
|
|
return nil, nil, storedErr
|
2020-10-10 06:05:56 +00:00
|
|
|
}
|
2022-07-04 11:19:08 +00:00
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
applyOverrides := func(config *chain.Config) {
|
2023-08-03 14:05:35 +00:00
|
|
|
if overrideCancunTime != nil {
|
|
|
|
config.CancunTime = overrideCancunTime
|
2022-07-04 11:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
if (storedHash == libcommon.Hash{}) {
|
2021-04-09 16:44:25 +00:00
|
|
|
custom := true
|
2017-03-02 13:03:33 +00:00
|
|
|
if genesis == nil {
|
2023-05-17 06:36:06 +00:00
|
|
|
logger.Info("Writing main-net genesis block")
|
2023-03-20 15:44:22 +00:00
|
|
|
genesis = MainnetGenesisBlock()
|
2021-04-09 16:44:25 +00:00
|
|
|
custom = false
|
common: move big integer math to common/math (#3699)
* common: remove CurrencyToString
Move denomination values to params instead.
* common: delete dead code
* common: move big integer operations to common/math
This commit consolidates all big integer operations into common/math and
adds tests and documentation.
There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.
The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().
BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.
Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.
ParseUint64 is used in places where String2Big was used to decode a
uint64.
The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.
* common: delete unused big integer variables
* accounts/abi: replace uses of BytesToBig with use of encoding/binary
* common: remove BytesToBig
* common: remove Bytes2Big
* common: remove BigTrue
* cmd/utils: add BigFlag and use it for error-checked integer flags
While here, remove environment variable processing for DirectoryFlag
because we don't use it.
* core: add missing error checks in genesis block parser
* common: remove String2Big
* cmd/evm: use utils.BigFlag
* common/math: check for 256 bit overflow in ParseBig
This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.
* cmd/utils: fixup import
2017-02-26 21:21:51 +00:00
|
|
|
}
|
2022-07-04 11:19:08 +00:00
|
|
|
applyOverrides(genesis.Config)
|
2023-06-15 06:11:51 +00:00
|
|
|
block, _, err1 := write(tx, genesis, tmpDir)
|
2021-03-28 09:27:06 +00:00
|
|
|
if err1 != nil {
|
2021-05-23 05:41:42 +00:00
|
|
|
return genesis.Config, nil, err1
|
2019-07-18 12:26:22 +00:00
|
|
|
}
|
2021-04-09 16:44:25 +00:00
|
|
|
if custom {
|
2023-05-17 06:36:06 +00:00
|
|
|
logger.Info("Writing custom genesis block", "hash", block.Hash().String())
|
2021-04-09 16:44:25 +00:00
|
|
|
}
|
2021-05-23 05:41:42 +00:00
|
|
|
return genesis.Config, block, nil
|
core, cmd, vendor: fixes and database inspection tool (#15)
* core, eth: some fixes for freezer
* vendor, core/rawdb, cmd/geth: add db inspector
* core, cmd/utils: check ancient store path forceily
* cmd/geth, common, core/rawdb: a few fixes
* cmd/geth: support windows file rename and fix rename error
* core: support ancient plugin
* core, cmd: streaming file copy
* cmd, consensus, core, tests: keep genesis in leveldb
* core: write txlookup during ancient init
* core: bump database version
2019-05-14 14:07:44 +00:00
|
|
|
}
|
2021-05-23 05:41:42 +00:00
|
|
|
|
2017-03-02 13:03:33 +00:00
|
|
|
// Check whether the genesis block is already written.
|
|
|
|
if genesis != nil {
|
2023-03-29 07:27:06 +00:00
|
|
|
block, _, err1 := GenesisToBlock(genesis, tmpDir)
|
2021-03-23 07:25:10 +00:00
|
|
|
if err1 != nil {
|
2021-05-23 05:41:42 +00:00
|
|
|
return genesis.Config, nil, err1
|
2019-05-27 13:51:49 +00:00
|
|
|
}
|
|
|
|
hash := block.Hash()
|
2022-05-27 08:25:29 +00:00
|
|
|
if hash != storedHash {
|
2023-03-29 07:27:06 +00:00
|
|
|
return genesis.Config, block, &types.GenesisMismatchError{Stored: storedHash, New: hash}
|
2015-07-10 12:29:40 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-05 05:36:24 +00:00
|
|
|
number := rawdb.ReadHeaderNumber(tx, storedHash)
|
|
|
|
if number != nil {
|
|
|
|
var err error
|
2023-06-15 06:11:51 +00:00
|
|
|
storedBlock, _, err = rawdb.ReadBlockWithSenders(tx, storedHash, *number)
|
2023-06-05 05:36:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return genesis.Config, nil, err
|
|
|
|
}
|
2021-05-23 05:41:42 +00:00
|
|
|
}
|
2017-03-02 13:03:33 +00:00
|
|
|
// Get the existing chain configuration.
|
2023-03-29 07:27:06 +00:00
|
|
|
newCfg := genesis.ConfigOrDefault(storedHash)
|
2022-07-04 11:19:08 +00:00
|
|
|
applyOverrides(newCfg)
|
2022-05-27 08:25:29 +00:00
|
|
|
if err := newCfg.CheckConfigForkOrder(); err != nil {
|
|
|
|
return newCfg, nil, err
|
2019-10-16 11:23:14 +00:00
|
|
|
}
|
2023-03-29 07:27:06 +00:00
|
|
|
storedCfg, storedErr := rawdb.ReadChainConfig(tx, storedHash)
|
2022-12-07 11:34:14 +00:00
|
|
|
if storedErr != nil && newCfg.Bor == nil {
|
2022-05-27 08:25:29 +00:00
|
|
|
return newCfg, nil, storedErr
|
2020-10-24 06:57:09 +00:00
|
|
|
}
|
2022-05-27 08:25:29 +00:00
|
|
|
if storedCfg == nil {
|
2023-05-17 06:36:06 +00:00
|
|
|
logger.Warn("Found genesis block without chain config")
|
2023-03-29 07:27:06 +00:00
|
|
|
err1 := rawdb.WriteChainConfig(tx, storedHash, newCfg)
|
2020-10-24 06:57:09 +00:00
|
|
|
if err1 != nil {
|
2022-05-27 08:25:29 +00:00
|
|
|
return newCfg, nil, err1
|
2020-10-24 06:57:09 +00:00
|
|
|
}
|
2022-05-27 08:25:29 +00:00
|
|
|
return newCfg, storedBlock, nil
|
common: move big integer math to common/math (#3699)
* common: remove CurrencyToString
Move denomination values to params instead.
* common: delete dead code
* common: move big integer operations to common/math
This commit consolidates all big integer operations into common/math and
adds tests and documentation.
There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.
The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().
BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.
Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.
ParseUint64 is used in places where String2Big was used to decode a
uint64.
The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.
* common: delete unused big integer variables
* accounts/abi: replace uses of BytesToBig with use of encoding/binary
* common: remove BytesToBig
* common: remove Bytes2Big
* common: remove BigTrue
* cmd/utils: add BigFlag and use it for error-checked integer flags
While here, remove environment variable processing for DirectoryFlag
because we don't use it.
* core: add missing error checks in genesis block parser
* common: remove String2Big
* cmd/evm: use utils.BigFlag
* common/math: check for 256 bit overflow in ParseBig
This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.
* cmd/utils: fixup import
2017-02-26 21:21:51 +00:00
|
|
|
}
|
2022-06-23 08:41:15 +00:00
|
|
|
// Special case: don't change the existing config of a private chain if no new
|
2022-06-21 08:17:54 +00:00
|
|
|
// config is supplied. This is useful, for example, to preserve DB config created by erigon init.
|
2022-06-23 08:41:15 +00:00
|
|
|
// In that case, only apply the overrides.
|
|
|
|
if genesis == nil && params.ChainConfigByGenesisHash(storedHash) == nil {
|
|
|
|
newCfg = storedCfg
|
2022-07-04 11:19:08 +00:00
|
|
|
applyOverrides(newCfg)
|
2022-06-21 08:17:54 +00:00
|
|
|
}
|
2017-03-02 13:03:33 +00:00
|
|
|
// Check config compatibility and write the config. Compatibility errors
|
|
|
|
// are returned to the caller unless we're already at block zero.
|
2023-03-29 07:27:06 +00:00
|
|
|
height := rawdb.ReadHeaderNumber(tx, rawdb.ReadHeadHeaderHash(tx))
|
2022-05-27 08:25:29 +00:00
|
|
|
if height != nil {
|
|
|
|
compatibilityErr := storedCfg.CheckCompatible(newCfg, *height)
|
|
|
|
if compatibilityErr != nil && *height != 0 && compatibilityErr.RewindTo != 0 {
|
|
|
|
return newCfg, storedBlock, compatibilityErr
|
2021-03-19 21:24:49 +00:00
|
|
|
}
|
common: move big integer math to common/math (#3699)
* common: remove CurrencyToString
Move denomination values to params instead.
* common: delete dead code
* common: move big integer operations to common/math
This commit consolidates all big integer operations into common/math and
adds tests and documentation.
There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.
The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().
BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.
Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.
ParseUint64 is used in places where String2Big was used to decode a
uint64.
The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.
* common: delete unused big integer variables
* accounts/abi: replace uses of BytesToBig with use of encoding/binary
* common: remove BytesToBig
* common: remove Bytes2Big
* common: remove BigTrue
* cmd/utils: add BigFlag and use it for error-checked integer flags
While here, remove environment variable processing for DirectoryFlag
because we don't use it.
* core: add missing error checks in genesis block parser
* common: remove String2Big
* cmd/evm: use utils.BigFlag
* common/math: check for 256 bit overflow in ParseBig
This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.
* cmd/utils: fixup import
2017-02-26 21:21:51 +00:00
|
|
|
}
|
2023-03-29 07:27:06 +00:00
|
|
|
if err := rawdb.WriteChainConfig(tx, storedHash, newCfg); err != nil {
|
2022-05-27 08:25:29 +00:00
|
|
|
return newCfg, nil, err
|
2020-10-24 06:57:09 +00:00
|
|
|
}
|
2022-05-27 08:25:29 +00:00
|
|
|
return newCfg, storedBlock, nil
|
2017-03-02 13:03:33 +00:00
|
|
|
}
|
common: move big integer math to common/math (#3699)
* common: remove CurrencyToString
Move denomination values to params instead.
* common: delete dead code
* common: move big integer operations to common/math
This commit consolidates all big integer operations into common/math and
adds tests and documentation.
There should be no change in semantics for BigPow, BigMin, BigMax, S256,
U256, Exp and their behaviour is now locked in by tests.
The BigD, BytesToBig and Bytes2Big functions don't provide additional
value, all uses are replaced by new(big.Int).SetBytes().
BigToBytes is now called PaddedBigBytes, its minimum output size
parameter is now specified as the number of bytes instead of bits. The
single use of this function is in the EVM's MSTORE instruction.
Big and String2Big are replaced by ParseBig, which is slightly stricter.
It previously accepted leading zeros for hexadecimal inputs but treated
decimal inputs as octal if a leading zero digit was present.
ParseUint64 is used in places where String2Big was used to decode a
uint64.
The new functions MustParseBig and MustParseUint64 are now used in many
places where parsing errors were previously ignored.
* common: delete unused big integer variables
* accounts/abi: replace uses of BytesToBig with use of encoding/binary
* common: remove BytesToBig
* common: remove Bytes2Big
* common: remove BigTrue
* cmd/utils: add BigFlag and use it for error-checked integer flags
While here, remove environment variable processing for DirectoryFlag
because we don't use it.
* core: add missing error checks in genesis block parser
* common: remove String2Big
* cmd/evm: use utils.BigFlag
* common/math: check for 256 bit overflow in ParseBig
This is supposed to prevent silent overflow/truncation of values in the
genesis block JSON. Without this check, a genesis block that set a
balance larger than 256 bits would lead to weird behaviour in the VM.
* cmd/utils: fixup import
2017-02-26 21:21:51 +00:00
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func WriteGenesisState(g *types.Genesis, tx kv.RwTx, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
|
|
|
|
block, statedb, err := GenesisToBlock(g, tmpDir)
|
2019-05-27 13:51:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-06-11 04:49:53 +00:00
|
|
|
histV3, err := kvcfg.HistoryV3.Enabled(tx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2023-03-31 02:19:56 +00:00
|
|
|
var stateWriter state.StateWriter
|
|
|
|
if ethconfig.EnableHistoryV4InTest {
|
|
|
|
panic("implement me")
|
|
|
|
//tx.(*temporal.Tx).Agg().SetTxNum(0)
|
|
|
|
//stateWriter = state.NewWriterV4(tx.(kv.TemporalTx))
|
|
|
|
//defer tx.(*temporal.Tx).Agg().StartUnbufferedWrites().FinishWrites()
|
|
|
|
} else {
|
|
|
|
for addr, account := range g.Alloc {
|
|
|
|
if len(account.Code) > 0 || len(account.Storage) > 0 {
|
|
|
|
// Special case for weird tests - inaccessible storage
|
|
|
|
var b [8]byte
|
|
|
|
binary.BigEndian.PutUint64(b[:], state.FirstContractIncarnation)
|
|
|
|
if err := tx.Put(kv.IncarnationMap, addr[:], b[:]); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
2021-03-28 09:27:06 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-31 02:19:56 +00:00
|
|
|
stateWriter = state.NewPlainStateWriter(tx, tx, 0)
|
2021-03-28 09:27:06 +00:00
|
|
|
}
|
|
|
|
|
2017-07-11 11:49:14 +00:00
|
|
|
if block.Number().Sign() != 0 {
|
2019-05-27 13:51:49 +00:00
|
|
|
return nil, statedb, fmt.Errorf("can't commit genesis block with number > 0")
|
|
|
|
}
|
2020-05-31 06:57:47 +00:00
|
|
|
|
2023-03-31 02:19:56 +00:00
|
|
|
if err := statedb.CommitBlock(&chain.Rules{}, stateWriter); err != nil {
|
2021-10-04 15:16:52 +00:00
|
|
|
return nil, statedb, fmt.Errorf("cannot write state: %w", err)
|
2020-05-31 06:57:47 +00:00
|
|
|
}
|
2023-06-11 04:49:53 +00:00
|
|
|
if !histV3 {
|
|
|
|
if csw, ok := stateWriter.(state.WriterWithChangeSets); ok {
|
|
|
|
if err := csw.WriteChangeSets(); err != nil {
|
|
|
|
return nil, statedb, fmt.Errorf("cannot write change sets: %w", err)
|
|
|
|
}
|
|
|
|
if err := csw.WriteHistory(); err != nil {
|
|
|
|
return nil, statedb, fmt.Errorf("cannot write history: %w", err)
|
|
|
|
}
|
2023-03-31 02:19:56 +00:00
|
|
|
}
|
2020-04-09 17:23:29 +00:00
|
|
|
}
|
2020-05-07 05:59:00 +00:00
|
|
|
return block, statedb, nil
|
|
|
|
}
|
2023-03-29 07:27:06 +00:00
|
|
|
func MustCommitGenesis(g *types.Genesis, db kv.RwDB, tmpDir string) *types.Block {
|
|
|
|
tx, err := db.BeginRw(context.Background())
|
2021-06-05 15:17:04 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-03-29 07:27:06 +00:00
|
|
|
defer tx.Rollback()
|
2023-06-15 06:11:51 +00:00
|
|
|
block, _, err := write(tx, g, tmpDir)
|
2023-03-29 07:27:06 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
err = tx.Commit()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return block
|
2021-06-05 15:17:04 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 04:28:05 +00:00
|
|
|
// Write writes the block and state of a genesis specification to the database.
|
2020-05-07 05:59:00 +00:00
|
|
|
// The block is committed as the canonical head block.
|
2023-06-15 06:11:51 +00:00
|
|
|
func write(tx kv.RwTx, g *types.Genesis, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
|
2023-03-29 07:27:06 +00:00
|
|
|
block, statedb, err2 := WriteGenesisState(g, tx, tmpDir)
|
2021-03-26 10:05:35 +00:00
|
|
|
if err2 != nil {
|
|
|
|
return block, statedb, err2
|
2020-05-07 05:59:00 +00:00
|
|
|
}
|
|
|
|
config := g.Config
|
|
|
|
if config == nil {
|
2022-11-21 16:21:59 +00:00
|
|
|
config = params.AllProtocolChanges
|
2020-05-07 05:59:00 +00:00
|
|
|
}
|
|
|
|
if err := config.CheckConfigForkOrder(); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-05-22 08:49:21 +00:00
|
|
|
|
2023-06-15 06:11:51 +00:00
|
|
|
if err := rawdb.WriteBlock(tx, block); err != nil {
|
2021-03-26 10:05:35 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-06-15 06:11:51 +00:00
|
|
|
if err := rawdb.WriteTd(tx, block.Hash(), block.NumberU64(), g.Difficulty); err != nil {
|
2021-03-26 10:05:35 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-01-22 12:39:33 +00:00
|
|
|
if err := rawdbv3.TxNums.WriteForGenesis(tx, 1); err != nil {
|
2022-09-18 10:41:01 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2021-03-26 10:05:35 +00:00
|
|
|
if err := rawdb.WriteReceipts(tx, block.NumberU64(), nil); err != nil {
|
2020-10-24 06:57:09 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2021-04-19 21:58:05 +00:00
|
|
|
|
2021-03-26 10:05:35 +00:00
|
|
|
if err := rawdb.WriteCanonicalHash(tx, block.Hash(), block.NumberU64()); err != nil {
|
2020-10-24 06:57:09 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2021-04-19 21:58:05 +00:00
|
|
|
|
2021-03-26 10:05:35 +00:00
|
|
|
rawdb.WriteHeadBlockHash(tx, block.Hash())
|
|
|
|
if err := rawdb.WriteHeadHeaderHash(tx, block.Hash()); err != nil {
|
2020-10-25 08:38:55 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2021-03-26 10:05:35 +00:00
|
|
|
if err := rawdb.WriteChainConfig(tx, block.Hash(), config); err != nil {
|
2020-10-24 17:05:12 +00:00
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-05-09 15:19:23 +00:00
|
|
|
|
2023-05-09 17:45:33 +00:00
|
|
|
// We support ethash/merge for issuance (for now)
|
2023-01-13 18:12:18 +00:00
|
|
|
if g.Config.Consensus != chain.EtHashConsensus {
|
2021-12-16 22:08:27 +00:00
|
|
|
return block, statedb, nil
|
|
|
|
}
|
|
|
|
// Issuance is the sum of allocs
|
|
|
|
genesisIssuance := big.NewInt(0)
|
|
|
|
for _, account := range g.Alloc {
|
|
|
|
genesisIssuance.Add(genesisIssuance, account.Balance)
|
|
|
|
}
|
|
|
|
|
|
|
|
// BlockReward can be present at genesis
|
2023-05-09 17:45:33 +00:00
|
|
|
if block.Header().Difficulty.Cmp(merge.ProofOfStakeDifficulty) != 0 {
|
2021-12-16 22:08:27 +00:00
|
|
|
blockReward, _ := ethash.AccumulateRewards(g.Config, block.Header(), nil)
|
|
|
|
// Set BlockReward
|
|
|
|
genesisIssuance.Add(genesisIssuance, blockReward.ToBig())
|
|
|
|
}
|
|
|
|
if err := rawdb.WriteTotalIssued(tx, 0, genesisIssuance); err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
2023-01-27 04:39:34 +00:00
|
|
|
return block, statedb, rawdb.WriteTotalBurnt(tx, 0, libcommon.Big0)
|
2021-05-19 03:47:28 +00:00
|
|
|
}
|
2021-03-26 10:05:35 +00:00
|
|
|
|
2017-03-02 13:03:33 +00:00
|
|
|
// GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
|
2023-02-11 20:44:51 +00:00
|
|
|
func GenesisBlockForTesting(db kv.RwDB, addr libcommon.Address, balance *big.Int, tmpDir string) *types.Block {
|
2023-03-29 07:27:06 +00:00
|
|
|
g := types.Genesis{Alloc: types.GenesisAlloc{addr: {Balance: balance}}, Config: params.TestChainConfig}
|
|
|
|
block := MustCommitGenesis(&g, db, tmpDir)
|
2019-05-27 13:51:49 +00:00
|
|
|
return block
|
2015-10-05 11:01:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 13:08:28 +00:00
|
|
|
type GenAccount struct {
|
2023-01-13 18:12:18 +00:00
|
|
|
Addr libcommon.Address
|
2020-10-02 13:08:28 +00:00
|
|
|
Balance *big.Int
|
|
|
|
}
|
|
|
|
|
2023-02-11 20:44:51 +00:00
|
|
|
func GenesisWithAccounts(db kv.RwDB, accs []GenAccount, tmpDir string) *types.Block {
|
2023-03-29 07:27:06 +00:00
|
|
|
g := types.Genesis{Config: params.TestChainConfig}
|
|
|
|
allocs := make(map[libcommon.Address]types.GenesisAccount)
|
2020-10-02 13:08:28 +00:00
|
|
|
for _, acc := range accs {
|
2023-03-29 07:27:06 +00:00
|
|
|
allocs[acc.Addr] = types.GenesisAccount{Balance: acc.Balance}
|
2020-10-02 13:08:28 +00:00
|
|
|
}
|
|
|
|
g.Alloc = allocs
|
2023-03-29 07:27:06 +00:00
|
|
|
block := MustCommitGenesis(&g, db, tmpDir)
|
2020-10-02 13:08:28 +00:00
|
|
|
return block
|
|
|
|
}
|
|
|
|
|
2023-03-20 15:44:22 +00:00
|
|
|
// MainnetGenesisBlock returns the Ethereum main net genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
func MainnetGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2017-03-02 13:03:33 +00:00
|
|
|
Config: params.MainnetChainConfig,
|
|
|
|
Nonce: 66,
|
|
|
|
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
|
|
|
|
GasLimit: 5000,
|
|
|
|
Difficulty: big.NewInt(17179869184),
|
2021-04-09 12:00:50 +00:00
|
|
|
Alloc: readPrealloc("allocs/mainnet.json"),
|
2017-03-02 13:03:33 +00:00
|
|
|
}
|
2015-11-17 16:33:25 +00:00
|
|
|
}
|
|
|
|
|
2023-03-20 15:44:22 +00:00
|
|
|
// SepoliaGenesisBlock returns the Sepolia network genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
func SepoliaGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2022-02-10 07:27:36 +00:00
|
|
|
Config: params.SepoliaChainConfig,
|
|
|
|
Nonce: 0,
|
|
|
|
ExtraData: []byte("Sepolia, Athens, Attica, Greece!"),
|
|
|
|
GasLimit: 30000000,
|
|
|
|
Difficulty: big.NewInt(131072),
|
|
|
|
Timestamp: 1633267481,
|
|
|
|
Alloc: readPrealloc("allocs/sepolia.json"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 15:44:22 +00:00
|
|
|
// GoerliGenesisBlock returns the Görli network genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
func GoerliGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2018-11-16 15:58:24 +00:00
|
|
|
Config: params.GoerliChainConfig,
|
|
|
|
Timestamp: 1548854791,
|
|
|
|
ExtraData: hexutil.MustDecode("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
|
|
|
GasLimit: 10485760,
|
|
|
|
Difficulty: big.NewInt(1),
|
2021-04-09 12:00:50 +00:00
|
|
|
Alloc: readPrealloc("allocs/goerli.json"),
|
2018-11-16 15:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func MumbaiGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2022-02-07 21:30:46 +00:00
|
|
|
Config: params.MumbaiChainConfig,
|
|
|
|
Nonce: 0,
|
|
|
|
Timestamp: 1558348305,
|
|
|
|
GasLimit: 10000000,
|
|
|
|
Difficulty: big.NewInt(1),
|
2023-01-13 18:12:18 +00:00
|
|
|
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
|
|
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
|
2022-02-07 21:30:46 +00:00
|
|
|
Alloc: readPrealloc("allocs/mumbai.json"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 15:44:22 +00:00
|
|
|
// BorMainnetGenesisBlock returns the Bor Mainnet network genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
func BorMainnetGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2022-02-07 21:30:46 +00:00
|
|
|
Config: params.BorMainnetChainConfig,
|
|
|
|
Nonce: 0,
|
|
|
|
Timestamp: 1590824836,
|
|
|
|
GasLimit: 10000000,
|
|
|
|
Difficulty: big.NewInt(1),
|
2023-01-13 18:12:18 +00:00
|
|
|
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
|
|
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
|
2022-02-07 21:30:46 +00:00
|
|
|
Alloc: readPrealloc("allocs/bor_mainnet.json"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func BorDevnetGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2022-06-10 08:32:04 +00:00
|
|
|
Config: params.BorDevnetChainConfig,
|
|
|
|
Nonce: 0,
|
|
|
|
Timestamp: 1558348305,
|
|
|
|
GasLimit: 10000000,
|
|
|
|
Difficulty: big.NewInt(1),
|
2023-01-13 18:12:18 +00:00
|
|
|
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
|
|
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
|
2022-06-10 08:32:04 +00:00
|
|
|
Alloc: readPrealloc("allocs/bor_devnet.json"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func GnosisGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
2022-07-12 15:21:52 +00:00
|
|
|
Config: params.GnosisChainConfig,
|
2022-10-21 10:43:44 +00:00
|
|
|
Timestamp: 0,
|
|
|
|
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
2022-07-12 15:21:52 +00:00
|
|
|
GasLimit: 0x989680,
|
|
|
|
Difficulty: big.NewInt(0x20000),
|
2022-10-21 10:43:44 +00:00
|
|
|
Alloc: readPrealloc("allocs/gnosis.json"),
|
2022-07-12 15:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func ChiadoGenesisBlock() *types.Genesis {
|
|
|
|
return &types.Genesis{
|
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
|
|
|
Config: params.ChiadoChainConfig,
|
|
|
|
Timestamp: 0,
|
|
|
|
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
|
|
|
GasLimit: 0x989680,
|
|
|
|
Difficulty: big.NewInt(0x20000),
|
|
|
|
Alloc: readPrealloc("allocs/chiado.json"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 04:00:06 +00:00
|
|
|
// Pre-calculated version of:
|
2022-08-10 12:04:13 +00:00
|
|
|
//
|
|
|
|
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
|
|
|
|
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
|
2021-09-08 04:00:06 +00:00
|
|
|
var DevnetSignPrivateKey, _ = crypto.HexToECDSA("26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48")
|
2023-01-13 18:12:18 +00:00
|
|
|
var DevnetEtherbase = libcommon.HexToAddress("67b1d87101671b127f5f8714789c7192f7ad340e")
|
2021-09-07 09:12:49 +00:00
|
|
|
|
2023-07-18 08:47:04 +00:00
|
|
|
// DevnetSignKey is defined like this to allow the devnet process to pre-allocate keys
|
|
|
|
// for nodes and then pass the address via --miner.etherbase - the function will be called
|
|
|
|
// to retieve the mining key
|
|
|
|
var DevnetSignKey = func(address libcommon.Address) *ecdsa.PrivateKey {
|
|
|
|
return DevnetSignPrivateKey
|
|
|
|
}
|
|
|
|
|
2019-12-10 10:50:16 +00:00
|
|
|
// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
|
2023-03-29 07:27:06 +00:00
|
|
|
func DeveloperGenesisBlock(period uint64, faucet libcommon.Address) *types.Genesis {
|
2017-10-24 10:40:42 +00:00
|
|
|
// Override the default period to the user requested one
|
|
|
|
config := *params.AllCliqueProtocolChanges
|
|
|
|
config.Clique.Period = period
|
|
|
|
|
|
|
|
// Assemble and return the genesis with the precompiles and faucet pre-funded
|
2023-03-29 07:27:06 +00:00
|
|
|
return &types.Genesis{
|
2017-10-24 10:40:42 +00:00
|
|
|
Config: &config,
|
2019-08-22 13:14:06 +00:00
|
|
|
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
|
2020-07-16 12:08:38 +00:00
|
|
|
GasLimit: 11500000,
|
2017-10-24 10:40:42 +00:00
|
|
|
Difficulty: big.NewInt(1),
|
2022-02-26 07:27:22 +00:00
|
|
|
Alloc: readPrealloc("allocs/dev.json"),
|
2016-11-20 21:32:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
// ToBlock creates the genesis block and writes state of a genesis specification
|
|
|
|
// to the given database (or discards it if nil).
|
|
|
|
func GenesisToBlock(g *types.Genesis, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
|
|
|
|
_ = g.Alloc //nil-check
|
|
|
|
|
|
|
|
head := &types.Header{
|
|
|
|
Number: new(big.Int).SetUint64(g.Number),
|
|
|
|
Nonce: types.EncodeNonce(g.Nonce),
|
|
|
|
Time: g.Timestamp,
|
|
|
|
ParentHash: g.ParentHash,
|
|
|
|
Extra: g.ExtraData,
|
|
|
|
GasLimit: g.GasLimit,
|
|
|
|
GasUsed: g.GasUsed,
|
|
|
|
Difficulty: g.Difficulty,
|
|
|
|
MixDigest: g.Mixhash,
|
|
|
|
Coinbase: g.Coinbase,
|
|
|
|
BaseFee: g.BaseFee,
|
2023-07-28 10:12:05 +00:00
|
|
|
BlobGasUsed: g.BlobGasUsed,
|
|
|
|
ExcessBlobGas: g.ExcessBlobGas,
|
2023-03-29 07:27:06 +00:00
|
|
|
AuRaStep: g.AuRaStep,
|
|
|
|
AuRaSeal: g.AuRaSeal,
|
|
|
|
}
|
|
|
|
if g.GasLimit == 0 {
|
|
|
|
head.GasLimit = params.GenesisGasLimit
|
|
|
|
}
|
|
|
|
if g.Difficulty == nil {
|
|
|
|
head.Difficulty = params.GenesisDifficulty
|
|
|
|
}
|
2023-08-08 13:01:35 +00:00
|
|
|
if g.Config != nil && g.Config.IsLondon(0) {
|
2023-03-29 07:27:06 +00:00
|
|
|
if g.BaseFee != nil {
|
|
|
|
head.BaseFee = g.BaseFee
|
|
|
|
} else {
|
|
|
|
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var withdrawals []*types.Withdrawal
|
2023-08-08 13:01:35 +00:00
|
|
|
if g.Config != nil && g.Config.IsShanghai(g.Timestamp) {
|
2023-03-29 07:27:06 +00:00
|
|
|
withdrawals = []*types.Withdrawal{}
|
|
|
|
}
|
|
|
|
|
2023-08-08 13:01:35 +00:00
|
|
|
if g.Config != nil && g.Config.IsCancun(g.Timestamp) {
|
|
|
|
if g.BlobGasUsed != nil {
|
|
|
|
head.BlobGasUsed = g.BlobGasUsed
|
|
|
|
} else {
|
|
|
|
head.BlobGasUsed = new(uint64)
|
|
|
|
}
|
|
|
|
if g.ExcessBlobGas != nil {
|
|
|
|
head.ExcessBlobGas = g.ExcessBlobGas
|
|
|
|
} else {
|
|
|
|
head.ExcessBlobGas = new(uint64)
|
|
|
|
}
|
|
|
|
if g.ParentBeaconBlockRoot != nil {
|
|
|
|
head.ParentBeaconBlockRoot = g.ParentBeaconBlockRoot
|
|
|
|
} else {
|
|
|
|
head.ParentBeaconBlockRoot = &libcommon.Hash{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
var root libcommon.Hash
|
|
|
|
var statedb *state.IntraBlockState
|
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(1)
|
2023-05-15 04:07:13 +00:00
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
var err error
|
|
|
|
go func() { // we may run inside write tx, can't open 2nd write tx in same goroutine
|
|
|
|
// TODO(yperbasis): use memdb.MemoryMutation instead
|
|
|
|
defer wg.Done()
|
2023-05-15 04:07:13 +00:00
|
|
|
genesisTmpDB := mdbx.NewMDBX(log.New()).InMem(tmpDir).MapSize(2 * datasize.GB).GrowthStep(1 * datasize.MB).MustOpen()
|
|
|
|
defer genesisTmpDB.Close()
|
2023-03-29 07:27:06 +00:00
|
|
|
var tx kv.RwTx
|
|
|
|
if tx, err = genesisTmpDB.BeginRw(context.Background()); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
defer tx.Rollback()
|
2023-05-15 04:07:13 +00:00
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
r, w := state.NewDbStateReader(tx), state.NewDbStateWriter(tx, 0)
|
|
|
|
statedb = state.New(r)
|
|
|
|
|
|
|
|
hasConstructorAllocation := false
|
|
|
|
for _, account := range g.Alloc {
|
|
|
|
if len(account.Constructor) > 0 {
|
|
|
|
hasConstructorAllocation = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// See https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/LoadGenesisBlockAuRa.cs
|
|
|
|
if hasConstructorAllocation && g.Config.Aura != nil {
|
|
|
|
statedb.CreateAccount(libcommon.Address{}, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
keys := sortedAllocKeys(g.Alloc)
|
|
|
|
for _, key := range keys {
|
|
|
|
addr := libcommon.BytesToAddress([]byte(key))
|
|
|
|
account := g.Alloc[addr]
|
|
|
|
|
|
|
|
balance, overflow := uint256.FromBig(account.Balance)
|
|
|
|
if overflow {
|
|
|
|
panic("overflow at genesis allocs")
|
|
|
|
}
|
|
|
|
statedb.AddBalance(addr, balance)
|
|
|
|
statedb.SetCode(addr, account.Code)
|
|
|
|
statedb.SetNonce(addr, account.Nonce)
|
|
|
|
for key, value := range account.Storage {
|
|
|
|
key := key
|
|
|
|
val := uint256.NewInt(0).SetBytes(value.Bytes())
|
|
|
|
statedb.SetState(addr, &key, *val)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(account.Constructor) > 0 {
|
2023-06-02 20:26:19 +00:00
|
|
|
if _, err = SysCreate(addr, account.Constructor, *g.Config, statedb, head); err != nil {
|
2023-03-29 07:27:06 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(account.Code) > 0 || len(account.Storage) > 0 || len(account.Constructor) > 0 {
|
|
|
|
statedb.SetIncarnation(addr, state.FirstContractIncarnation)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err = statedb.FinalizeTx(&chain.Rules{}, w); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if root, err = trie.CalcRoot("genesis", tx); err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
head.Root = root
|
|
|
|
|
|
|
|
return types.NewBlock(head, nil, nil, nil, withdrawals), statedb, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func sortedAllocKeys(m types.GenesisAlloc) []string {
|
|
|
|
keys := make([]string, len(m))
|
|
|
|
i := 0
|
|
|
|
for k := range m {
|
|
|
|
keys[i] = string(k.Bytes())
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
slices.Sort(keys)
|
|
|
|
return keys
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:embed allocs
|
|
|
|
var allocs embed.FS
|
|
|
|
|
|
|
|
func readPrealloc(filename string) types.GenesisAlloc {
|
2021-04-09 12:00:50 +00:00
|
|
|
f, err := allocs.Open(filename)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not open genesis preallocation for %s: %v", filename, err))
|
2017-03-02 13:03:33 +00:00
|
|
|
}
|
2021-04-09 12:00:50 +00:00
|
|
|
defer f.Close()
|
|
|
|
decoder := json.NewDecoder(f)
|
2023-03-29 07:27:06 +00:00
|
|
|
ga := make(types.GenesisAlloc)
|
2021-04-09 12:00:50 +00:00
|
|
|
err = decoder.Decode(&ga)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Could not parse genesis preallocation for %s: %v", filename, err))
|
2017-01-09 11:09:37 +00:00
|
|
|
}
|
2017-03-02 13:03:33 +00:00
|
|
|
return ga
|
2015-11-17 16:33:25 +00:00
|
|
|
}
|
2022-03-03 14:57:10 +00:00
|
|
|
|
2023-03-29 07:27:06 +00:00
|
|
|
func GenesisBlockByChainName(chain string) *types.Genesis {
|
2022-03-03 14:57:10 +00:00
|
|
|
switch chain {
|
|
|
|
case networkname.MainnetChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return MainnetGenesisBlock()
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.SepoliaChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return SepoliaGenesisBlock()
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.GoerliChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return GoerliGenesisBlock()
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.MumbaiChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return MumbaiGenesisBlock()
|
2022-03-03 14:57:10 +00:00
|
|
|
case networkname.BorMainnetChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return BorMainnetGenesisBlock()
|
2022-06-10 08:32:04 +00:00
|
|
|
case networkname.BorDevnetChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return BorDevnetGenesisBlock()
|
2022-07-12 15:21:52 +00:00
|
|
|
case networkname.GnosisChainName:
|
2023-03-20 15:44:22 +00:00
|
|
|
return GnosisGenesisBlock()
|
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:
|
2023-03-20 15:44:22 +00:00
|
|
|
return ChiadoGenesisBlock()
|
2022-03-03 14:57:10 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|