erigon-pulse/core/genesis.go

896 lines
33 KiB
Go
Raw Permalink Normal View History

2015-07-07 02:54:22 +02:00
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
2015-07-07 02:54:22 +02:00
//
// The go-ethereum library is free software: you can redistribute it and/or modify
2015-07-07 02:54:22 +02: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.
//
// The go-ethereum library is distributed in the hope that it will be useful,
2015-07-07 02:54:22 +02:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2015-07-07 02:54:22 +02:00
// 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/>.
2015-07-07 02:54:22 +02:00
2014-12-04 10:28:02 +01:00
package core
2014-02-14 23:56:09 +01:00
import (
"bytes"
"context"
"embed"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
2015-02-20 18:05:46 +01:00
"fmt"
"math/big"
"sync"
"github.com/c2h5oh/datasize"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/chain"
libcommon "github.com/ledgerwatch/erigon-lib/common"
2021-07-29 18:53:13 +07:00
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
2023-01-25 16:29:41 +07:00
"github.com/ledgerwatch/erigon-lib/kv/rawdbv3"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/hexutil"
"github.com/ledgerwatch/erigon/common/math"
"github.com/ledgerwatch/erigon/consensus/ethash"
"github.com/ledgerwatch/erigon/consensus/serenity"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/params/networkname"
"github.com/ledgerwatch/erigon/turbo/trie"
2023-01-25 16:29:41 +07:00
"github.com/ledgerwatch/log/v3"
"golang.org/x/exp/slices"
2014-02-14 23:56:09 +01:00
)
//go:generate gencodec -type Genesis -field-override genesisSpecMarshaling -out gen_genesis.go
//go:generate gencodec -type GenesisAccount -field-override genesisAccountMarshaling -out gen_genesis_account.go
//go:embed allocs
var allocs embed.FS
State cache switching writes to reads during commit (#1368) * State cache init * More code * Fix lint * More tests * More tests * More tests * Fix test * Transformations * remove writeQueue, before fixing the tests * Fix tests * Add more tests, incarnation to the code items * Fix lint * Fix lint * Remove shards prototype, add incarnation to the state reader code * Clean up and replace cache in call_traces stage * fix flaky test * Save changes * Readers to use addrHash, writes - addresses * Fix lint * Fix lint * More accurate tracking of size * Optimise for smaller write batches * Attempt to integrate state cache into Execution stage * cacheSize to default flags * Print correct cache sizes and batch sizes * cacheSize in the integration * Fix tests * Fix lint * Remove print * Fix exec stage * Fix test * Refresh sequence on write * No double increment * heap.Remove * Try to fix alignment * Refactoring, adding hashItems * More changes * Fix compile errors * Fix lint * Wrapping cached reader * Wrap writer into cached writer * Turn state cache off by default * Fix plain state writer * Fix for code/storage mixup * Fix tests * Fix clique test * Better fix for the tests * Add test and fix some more * Fix compile error| * More functions * Fixes * Fix for the tests * sepatate DeletedFlag and AbsentFlag * Minor fixes * Test refactoring * More changes * Fix some tests * More test fixes * More test fixes * Fix lint * Move blockchain_test to be able to use stagedsync * More fixes * Fixes and cleanup * Fix tests in turbo/stages * Fix lint * Fix lint * Intemediate * Fix tests * Intemediate * More fixes * Compilation fixes * More fixes * Fix compile errors * More test fixes * More fixes * More test fixes * Fix compile error * Fixes * Fix * Fix * More fixes * Fixes * More fixes and cleanup * Further fix * Check gas used and bloom with header Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
2020-12-08 09:44:29 +00:00
var ErrGenesisNoConfig = errors.New("genesis has no chain configuration")
// Genesis specifies the header fields, state of a genesis block. It also defines hard
// fork switch-over blocks through the chain configuration.
type Genesis struct {
Config *chain.Config `json:"config"`
Nonce uint64 `json:"nonce"`
Timestamp uint64 `json:"timestamp"`
ExtraData []byte `json:"extraData"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Mixhash libcommon.Hash `json:"mixHash"`
Coinbase libcommon.Address `json:"coinbase"`
Alloc GenesisAlloc `json:"alloc" gencodec:"required"`
AuRaStep uint64 `json:"auRaStep"`
AuRaSeal []byte `json:"auRaSeal"`
// These fields are used for consensus tests. Please don't use them
// in actual genesis blocks.
Number uint64 `json:"number"`
GasUsed uint64 `json:"gasUsed"`
ParentHash libcommon.Hash `json:"parentHash"`
BaseFee *big.Int `json:"baseFeePerGas"`
}
// GenesisAlloc specifies the initial state that is part of the genesis block.
type GenesisAlloc map[libcommon.Address]GenesisAccount
type AuthorityRoundSeal struct {
/// Seal step.
Step uint64 `json:"step"`
/// Seal signature.
Signature libcommon.Hash `json:"signature"`
}
var genesisTmpDB kv.RwDB
var genesisDBLock sync.Mutex
func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error {
m := make(map[common.UnprefixedAddress]GenesisAccount)
if err := json.Unmarshal(data, &m); err != nil {
return err
}
*ga = make(GenesisAlloc)
for addr, a := range m {
(*ga)[libcommon.Address(addr)] = a
}
return nil
}
// GenesisAccount is an account in the state of the genesis block.
// Either use "constructor" for deployment code or "code" directly for the final code.
type GenesisAccount struct {
Constructor []byte `json:"constructor,omitempty"` // deployment code
Code []byte `json:"code,omitempty"` // final contract code
Storage map[libcommon.Hash]libcommon.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
Nonce uint64 `json:"nonce,omitempty"`
PrivateKey []byte `json:"secretKey,omitempty"` // for tests
}
// field type overrides for gencodec
type genesisSpecMarshaling struct {
Nonce math.HexOrDecimal64
Timestamp math.HexOrDecimal64
ExtraData hexutil.Bytes
GasLimit math.HexOrDecimal64
GasUsed math.HexOrDecimal64
Number math.HexOrDecimal64
Difficulty *math.HexOrDecimal256
2021-07-11 04:05:56 +00:00
BaseFee *math.HexOrDecimal256
Alloc map[common.UnprefixedAddress]GenesisAccount
}
type genesisAccountMarshaling struct {
Constructor hexutil.Bytes
Code hexutil.Bytes
Balance *math.HexOrDecimal256
Nonce math.HexOrDecimal64
Storage map[storageJSON]storageJSON
PrivateKey hexutil.Bytes
}
// storageJSON represents a 256 bit byte array, but allows less than 256 bits when
// unmarshaling from hex.
type storageJSON libcommon.Hash
func (h *storageJSON) UnmarshalText(text []byte) error {
text = bytes.TrimPrefix(text, []byte("0x"))
if len(text) > 64 {
return fmt.Errorf("too many hex characters in storage key/value %q", text)
}
offset := len(h) - len(text)/2 // pad on the left
if _, err := hex.Decode(h[offset:], text); err != nil {
return fmt.Errorf("invalid hex storage key/value %q", text)
}
return nil
}
func (h storageJSON) MarshalText() ([]byte, error) {
return hexutil.Bytes(h[:]).MarshalText()
}
// GenesisMismatchError is raised when trying to overwrite an existing
// genesis block with an incompatible one.
type GenesisMismatchError struct {
Stored, New libcommon.Hash
}
func (e *GenesisMismatchError) Error() string {
config := params.ChainConfigByGenesisHash(e.Stored)
if config == nil {
return fmt.Sprintf("database contains incompatible genesis (have %x, new %x)", e.Stored, e.New)
}
return fmt.Sprintf("database contains incompatible genesis (try with --chain=%s)", config.ChainName)
}
// CommitGenesisBlock writes or updates the genesis block in db.
// The block that will be used is:
//
2022-08-10 19:04:13 +07:00
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
//
// 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.
func CommitGenesisBlock(db kv.RwDB, genesis *Genesis, tmpDir string) (*chain.Config, *types.Block, error) {
return CommitGenesisBlockWithOverride(db, genesis, nil, tmpDir)
}
func CommitGenesisBlockWithOverride(db kv.RwDB, genesis *Genesis, overrideShanghaiTime *big.Int, tmpDir string) (*chain.Config, *types.Block, error) {
tx, err := db.BeginRw(context.Background())
if err != nil {
return nil, nil, err
}
defer tx.Rollback()
c, b, err := WriteGenesisBlock(tx, genesis, overrideShanghaiTime, tmpDir)
if err != nil {
return c, b, err
}
err = tx.Commit()
if err != nil {
return c, b, err
}
return c, b, nil
}
func MustCommitGenesisBlock(db kv.RwDB, genesis *Genesis, tmpDir string) (*chain.Config, *types.Block) {
c, b, err := CommitGenesisBlock(db, genesis, tmpDir)
if err != nil {
panic(err)
}
return c, b
}
func WriteGenesisBlock(db kv.RwTx, genesis *Genesis, overrideShanghaiTime *big.Int, tmpDir string) (*chain.Config, *types.Block, error) {
if genesis != nil && genesis.Config == nil {
return params.AllProtocolChanges, nil, ErrGenesisNoConfig
}
// Just commit the new block if there is no stored genesis block.
storedHash, storedErr := rawdb.ReadCanonicalHash(db, 0)
if storedErr != nil {
2021-05-23 12:41:42 +07:00
return nil, nil, storedErr
}
applyOverrides := func(config *chain.Config) {
if overrideShanghaiTime != nil {
config.ShanghaiTime = overrideShanghaiTime
}
}
if (storedHash == libcommon.Hash{}) {
custom := true
if genesis == nil {
log.Info("Writing default main-net genesis block")
genesis = DefaultGenesisBlock()
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 22:21:51 +01:00
}
applyOverrides(genesis.Config)
block, _, err1 := genesis.Write(db, tmpDir)
if err1 != nil {
2021-05-23 12:41:42 +07:00
return genesis.Config, nil, err1
}
if custom {
log.Info("Writing custom genesis block", "hash", block.Hash().String())
}
2021-05-23 12:41:42 +07:00
return genesis.Config, block, nil
}
// Assume mainnet chainId first
chainId := params.MainnetChainConfig.ChainID.Uint64()
// Note: The `genesis` argument will be one of:
// - nil: if running without the `init` command and without providing a chain flag (pulsechain, ropsten, etc..)
// - defaulted: when a chain flag is provided (pulsechain, ropsten, etc..), genesis will hold the defaults
// - custom: if running with the `init` command supplying a custom genesis.json file, genesis will hold the file contents
// Check whether the genesis block is already written.
2021-05-23 12:41:42 +07:00
// Check whether the genesis block is already written.
if genesis != nil {
block, _, err1 := genesis.ToBlock(tmpDir)
if err1 != nil {
2021-05-23 12:41:42 +07:00
return genesis.Config, nil, err1
}
chainId = genesis.Config.ChainID.Uint64()
hash := block.Hash()
if hash != storedHash {
return genesis.Config, block, &GenesisMismatchError{storedHash, hash}
}
}
storedBlock, err := rawdb.ReadBlockByHash(db, storedHash)
2021-05-23 12:41:42 +07:00
if err != nil {
return genesis.Config, nil, err
2021-05-23 12:41:42 +07:00
}
// Get the existing chain configuration.
newCfg := genesis.configOrDefault(storedHash, chainId)
applyOverrides(newCfg)
if err := newCfg.CheckConfigForkOrder(); err != nil {
return newCfg, nil, err
}
storedCfg, storedErr := rawdb.ReadChainConfig(db, storedHash)
if storedErr != nil && newCfg.Bor == nil {
return newCfg, nil, storedErr
}
if storedCfg == nil {
log.Warn("Found genesis block without chain config")
err1 := rawdb.WriteChainConfig(db, storedHash, newCfg)
if err1 != nil {
return newCfg, nil, err1
}
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 22:21:51 +01:00
}
// Special case: don't change the existing config of a private chain if no new
// config is supplied. This is useful, for example, to preserve DB config created by erigon init.
// In that case, only apply the overrides.
// Added: support custom config for PrimordialPulse fork with mainnet genesis
// and non-standard chain id.
if genesis == nil && (storedCfg.PrimordialPulseBlock != nil ||
params.ChainConfigByGenesisHash(storedHash) == nil) {
newCfg = storedCfg
applyOverrides(newCfg)
}
// Check config compatibility and write the config. Compatibility errors
// are returned to the caller unless we're already at block zero.
height := rawdb.ReadHeaderNumber(db, rawdb.ReadHeadHeaderHash(db))
if height != nil {
compatibilityErr := storedCfg.CheckCompatible(newCfg, *height)
if compatibilityErr != nil && *height != 0 && compatibilityErr.RewindTo != 0 {
return newCfg, storedBlock, compatibilityErr
More updates to downloader, new p2psentry protocol (#1559) * Initial commit * Add sentry gRPC interface * p2psentry directory * Update README.md * Update README.md * Update README.md * Add go package * Correct syntax * add external downloader interface (#2) * Add txpool (#3) * Add private API (#4) * Invert control.proto, add PeerMinBlock, Separare incoming Tx message into a separate stream (#5) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Separate upload messages into its own stream (#6) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Only send changed accounts to listeners (#7) * Txpool interface doc (#9) * More additions * More additions * Fix locking * Intermediate * Fix separation of phases * Intermediate * Fix test * More transformations * New simplified way of downloading headers * Fix hard-coded header sync * Fixed syncing near the tip of the chain * Add architecture diagram source and picture (#10) * More fixes * rename tip to link * Use preverified hashes instead of preverified headers * Fix preverified hashes generation * more parametrisation * Continue parametrisation * Fix grpc data limit, interruption of headers stage * Add ropsten preverified hashes * Typed hashes (#11) * Typed hashes * Fix PeerId * 64-bit tx nonce * Disable penalties * Add goerli settings, bootstrap nodes * Try to fix goerly sync * Remove interfaces * Add proper golang packages, max_block into p2p sentry Status * Prepare for proto overhaul * Squashed 'interfaces/' content from commit ce36053c2 git-subtree-dir: interfaces git-subtree-split: ce36053c24db2f56e48ac752808de60afa1dfb4b * Change EtherReply to address * Adaptations to new types * Switch to new types * Fixes * Fix formatting * Fix lint * Lint fixes, reverse order in types * Fix lint * Fix lint * Fix lint * Fix test * Not supporting eth/66 yet * Fix shutdown * Fix lint * Fix lint * Fix lint * return stopped check Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> Co-authored-by: b00ris <b00ris@mail.ru> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> Co-authored-by: canepat <16927169+canepat@users.noreply.github.com>
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 22:21:51 +01:00
}
if err := rawdb.WriteChainConfig(db, storedHash, newCfg); err != nil {
return newCfg, nil, err
}
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 22:21:51 +01:00
func (g *Genesis) configOrDefault(genesisHash libcommon.Hash, chainId uint64) *chain.Config {
pulseChainConfig := params.ChainConfigByChainName(networkname.PulsechainChainName)
2023-03-23 16:00:27 -05:00
pulseChainTestnetV3Config := params.ChainConfigByChainName(networkname.PulsechainTestnetV3ChainName)
config := &chain.Config{}
switch {
case g != nil:
return g.Config
case pulseChainConfig.ChainID.Uint64() == chainId:
config = params.ChainConfigByChainName(networkname.PulsechainChainName)
break
2023-03-23 16:00:27 -05:00
case pulseChainTestnetV3Config.ChainID.Uint64() == chainId:
config = params.ChainConfigByChainName(networkname.PulsechainTestnetV3ChainName)
break
default:
config = params.ChainConfigByGenesisHash(genesisHash)
}
if config != nil {
return config
} else {
return params.AllProtocolChanges
}
}
func sortedAllocKeys(m GenesisAlloc) []string {
keys := make([]string, len(m))
i := 0
for k := range m {
keys[i] = string(k.Bytes())
i++
}
slices.Sort(keys)
return keys
}
2015-02-20 18:05:46 +01:00
// ToBlock creates the genesis block and writes state of a genesis specification
// to the given database (or discards it if nil).
func (g *Genesis) ToBlock(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,
AuRaStep: g.AuRaStep,
AuRaSeal: g.AuRaSeal,
}
if g.GasLimit == 0 {
head.GasLimit = params.GenesisGasLimit
}
if g.Difficulty == nil {
head.Difficulty = params.GenesisDifficulty
}
if g.Config != nil && (g.Config.IsLondon(0)) {
if g.BaseFee != nil {
head.BaseFee = g.BaseFee
} else {
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
}
}
Withdrawals part 2 (#6180) Continuation of PR #6009. Storage and retrieval of withdrawals. - [x] storage of withdrawals on writeblock - [x] composite key (block number | block hash) - [x] value ([]withdrawal) - [x] retrieval of withdrawals with block - [x] tests around storing/retrieving withdrawals - [x] tested in hive - [x] commits tidied ## Hive Failures - [x] Withdrawals Fork on Block 2 - [x] Withdrawals Fork on Block 3 - [ ] Sync after 2 blocks - Withdrawals on Block 1 - Single Withdrawal Account - No Transactions ( Syncing client rejected valid chain) - [ ] Sync after 2 blocks - Withdrawals on Block 1 - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 2 blocks - Withdrawals on Genesis - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 2 blocks - Withdrawals on Block 2 - Single Withdrawal Account - No Transactions (Syncing client rejected valid chain) - [ ] Sync after 2 blocks - Withdrawals on Block 2 - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 128 blocks - Withdrawals on Block 2 - Multiple Withdrawal Accounts (Unexpected error on BalanceAt: Post "http://172.17.0.4:8545/": context deadline exceeded, expected=<None>) - [ ] Withdrawals Fork on Block 1 - 8 Block Re-Org, Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Block 8 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded)
2022-12-20 09:09:04 +00:00
var withdrawals []*types.Withdrawal
if g.Config != nil && (g.Config.IsShanghai(g.Timestamp)) {
withdrawals = []*types.Withdrawal{}
}
var root libcommon.Hash
var statedb *state.IntraBlockState
wg := sync.WaitGroup{}
wg.Add(1)
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()
genesisDBLock.Lock()
defer genesisDBLock.Unlock()
if genesisTmpDB == nil {
genesisTmpDB = mdbx.NewMDBX(log.New()).InMem(tmpDir).MapSize(2 * datasize.GB).PageSize(2 * 4096).MustOpen()
}
var tx kv.RwTx
if tx, err = genesisTmpDB.BeginRw(context.Background()); err != nil {
return
}
defer tx.Rollback()
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 {
if _, err = SysCreate(addr, account.Constructor, *g.Config, statedb, head); err != nil {
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
Withdrawals part 2 (#6180) Continuation of PR #6009. Storage and retrieval of withdrawals. - [x] storage of withdrawals on writeblock - [x] composite key (block number | block hash) - [x] value ([]withdrawal) - [x] retrieval of withdrawals with block - [x] tests around storing/retrieving withdrawals - [x] tested in hive - [x] commits tidied ## Hive Failures - [x] Withdrawals Fork on Block 2 - [x] Withdrawals Fork on Block 3 - [ ] Sync after 2 blocks - Withdrawals on Block 1 - Single Withdrawal Account - No Transactions ( Syncing client rejected valid chain) - [ ] Sync after 2 blocks - Withdrawals on Block 1 - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 2 blocks - Withdrawals on Genesis - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 2 blocks - Withdrawals on Block 2 - Single Withdrawal Account - No Transactions (Syncing client rejected valid chain) - [ ] Sync after 2 blocks - Withdrawals on Block 2 - Single Withdrawal Account (Timeout while waiting for secondary client to sync) - [ ] Sync after 128 blocks - Withdrawals on Block 2 - Multiple Withdrawal Accounts (Unexpected error on BalanceAt: Post "http://172.17.0.4:8545/": context deadline exceeded, expected=<None>) - [ ] Withdrawals Fork on Block 1 - 8 Block Re-Org, Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Block 8 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded) - [ ] Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org Sync (Expected no error on EngineNewPayloadV2: error=Post "http://172.17.0.4:8551/": context deadline exceeded)
2022-12-20 09:09:04 +00:00
return types.NewBlock(head, nil, nil, nil, withdrawals), statedb, nil
}
func (g *Genesis) WriteGenesisState(tx kv.RwTx, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
block, statedb, err := g.ToBlock(tmpDir)
if err != nil {
return nil, nil, err
}
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
}
}
}
if block.Number().Sign() != 0 {
return nil, statedb, fmt.Errorf("can't commit genesis block with number > 0")
}
blockWriter := state.NewPlainStateWriter(tx, tx, 0)
if err := statedb.CommitBlock(&chain.Rules{}, blockWriter); err != nil {
2021-10-04 17:16:52 +02:00
return nil, statedb, fmt.Errorf("cannot write state: %w", err)
}
if err := blockWriter.WriteChangeSets(); err != nil {
2021-10-04 17:16:52 +02:00
return nil, statedb, fmt.Errorf("cannot write change sets: %w", err)
}
if err := blockWriter.WriteHistory(); err != nil {
2021-10-04 17:16:52 +02:00
return nil, statedb, fmt.Errorf("cannot write history: %w", err)
}
return block, statedb, nil
}
func (g *Genesis) MustWrite(tx kv.RwTx, tmpDir string, history bool) (*types.Block, *state.IntraBlockState) {
b, s, err := g.Write(tx, tmpDir)
if err != nil {
panic(err)
}
return b, s
}
// Write writes the block and state of a genesis specification to the database.
// The block is committed as the canonical head block.
func (g *Genesis) Write(tx kv.RwTx, tmpDir string) (*types.Block, *state.IntraBlockState, error) {
block, statedb, err2 := g.WriteGenesisState(tx, tmpDir)
if err2 != nil {
return block, statedb, err2
}
config := g.Config
if config == nil {
config = params.AllProtocolChanges
}
if err := config.CheckConfigForkOrder(); err != nil {
return nil, nil, err
}
if err := rawdb.WriteTd(tx, block.Hash(), block.NumberU64(), g.Difficulty); err != nil {
return nil, nil, err
}
if err := rawdb.WriteBlock(tx, block); err != nil {
return nil, nil, err
}
2023-01-22 19:39:33 +07:00
if err := rawdbv3.TxNums.WriteForGenesis(tx, 1); err != nil {
return nil, nil, err
}
if err := rawdb.WriteReceipts(tx, block.NumberU64(), nil); err != nil {
return nil, nil, err
}
if err := rawdb.WriteCanonicalHash(tx, block.Hash(), block.NumberU64()); err != nil {
return nil, nil, err
}
rawdb.WriteHeadBlockHash(tx, block.Hash())
if err := rawdb.WriteHeadHeaderHash(tx, block.Hash()); err != nil {
return nil, nil, err
}
if err := rawdb.WriteChainConfig(tx, block.Hash(), config); err != nil {
2020-10-25 00:05:12 +07:00
return nil, nil, err
}
// We support ethash/serenity for issuance (for now)
if g.Config.Consensus != chain.EtHashConsensus {
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
if block.Header().Difficulty.Cmp(serenity.SerenityDifficulty) == 0 {
// Proof-of-stake is 0.3 ether per block (TODO: revisit)
genesisIssuance.Add(genesisIssuance, serenity.RewardSerenity)
} else {
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
}
return block, statedb, rawdb.WriteTotalBurnt(tx, 0, libcommon.Big0)
}
// MustCommit writes the genesis block and state to db, panicking on error.
// The block is committed as the canonical head block.
func (g *Genesis) MustCommit(db kv.RwDB, tmpDir string) *types.Block {
tx, err := db.BeginRw(context.Background())
if err != nil {
panic(err)
}
defer tx.Rollback()
block, _ := g.MustWrite(tx, tmpDir, true)
err = tx.Commit()
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 22:21:51 +01:00
if err != nil {
panic(err)
}
return block
}
// GenesisBlockForTesting creates and writes a block in which addr has the given wei balance.
func GenesisBlockForTesting(db kv.RwDB, addr libcommon.Address, balance *big.Int, tmpDir string) *types.Block {
g := Genesis{Alloc: GenesisAlloc{addr: {Balance: balance}}, Config: params.TestChainConfig}
block := g.MustCommit(db, tmpDir)
return block
2015-10-05 13:01:34 +02:00
}
type GenAccount struct {
Addr libcommon.Address
Balance *big.Int
}
func GenesisWithAccounts(db kv.RwDB, accs []GenAccount, tmpDir string) *types.Block {
g := Genesis{Config: params.TestChainConfig}
allocs := make(map[libcommon.Address]GenesisAccount)
for _, acc := range accs {
allocs[acc.Addr] = GenesisAccount{Balance: acc.Balance}
}
g.Alloc = allocs
block := g.MustCommit(db, tmpDir)
return block
}
// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis {
return &Genesis{
Config: params.MainnetChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
GasLimit: 5000,
Difficulty: big.NewInt(17179869184),
Alloc: readPrealloc("allocs/mainnet.json"),
}
}
// DefaultSepoliaGenesisBlock returns the Sepolia network genesis block.
func DefaultSepoliaGenesisBlock() *Genesis {
return &Genesis{
Config: params.SepoliaChainConfig,
Nonce: 0,
ExtraData: []byte("Sepolia, Athens, Attica, Greece!"),
GasLimit: 30000000,
Difficulty: big.NewInt(131072),
Timestamp: 1633267481,
Alloc: readPrealloc("allocs/sepolia.json"),
}
}
// DefaultRinkebyGenesisBlock returns the Rinkeby network genesis block.
func DefaultRinkebyGenesisBlock() *Genesis {
return &Genesis{
Config: params.RinkebyChainConfig,
Timestamp: 1492009146,
ExtraData: hexutil.MustDecode("0x52657370656374206d7920617574686f7269746168207e452e436172746d616e42eb768f2244c8811c63729a21a3569731535f067ffc57839b00206d1ad20c69a1981b489f772031b279182d99e65703f0076e4812653aab85fca0f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 4700000,
Difficulty: big.NewInt(1),
Alloc: readPrealloc("allocs/rinkeby.json"),
}
}
// DefaultGoerliGenesisBlock returns the Görli network genesis block.
func DefaultGoerliGenesisBlock() *Genesis {
return &Genesis{
Config: params.GoerliChainConfig,
Timestamp: 1548854791,
ExtraData: hexutil.MustDecode("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 10485760,
Difficulty: big.NewInt(1),
Alloc: readPrealloc("allocs/goerli.json"),
}
}
func DefaultSokolGenesisBlock() *Genesis {
/*
header rlp: f9020da00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0fad4af258fd11939fae0c6c6eec9d340b1caac0b0196fd9a1bc3f489c5bf00b3a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008083663be080808080b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
*/
return &Genesis{
Config: params.SokolChainConfig,
Timestamp: 0x0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x663BE0,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/sokol.json"),
}
}
Full BSC support with validator mode (#3233) * migrated consensus and chain config files for bsc support * migrated more files from bsc * fixed consensus crashing * updated erigon lib for parlia snapshot prefix * added staticpeers for bsc * [+] added system contracts [*] fixed bug with loading snapshot [+] enabled gas bailout [+] added fix to prevent syncing more than 1000 headers (for testing only) [*] fixed bug with crashing sender recover sometimes * migrated system contract calls * [*] fixed bug with returning mutable balance object [+] migrated lightclient contracts from bsc [*] fixed parlia consensus config param * [*] fixed tendermint deps * [+] added some logs * [+] enabled bsc forks [*] fixed syscalls from coinbase [*] more logging * Fix call sys contract gas calculation * [*] fixed executing system transactions * [*] enabled receipt hash, gas and bloom filter checks * [-] removed some logging scripts [*] set header checkpoint to 10 million blocks (for testing forks) * [*] fixed bug with commiting dirty inter block state state after system transaction execution [-] removed some extra logs and comments * [+] added chapel and rialto testnet support * [*] fixed chapel allocs * [-] removed 6 mil block limit for headers sync * Fix hardforks on chapel and other testnets * [*] fixed header sync issue after merge * [*] tiny code cleanup * [-] removed some comments * [*] increased mdbx map size to 4 TB * [*] increased max chaindata size to 6 tb * [*] bring more compatibility with origin erigon and some code cleanup * [+] added support of validator mode for BSC chain * [*] enable private key load for bsc, rialto and chapel chains * [*] fixed running BSC validator node * Fix the branch list * [*] tiny fixes for linter * [*] formatted imports for core and parlia packages * [*] fixed import rules in other files * Revert "[*] formatted imports for core and parlia packages" This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227. * [*] changed import rules in more packages * [*] fixed type mismatch in hack command * [*] fixed crash on new epoch, enabled bootstrap flags * [*] fixed linter errors * [*] fixed missing err check for syscalls * [*] now BSC implementation is fully compatible with erigon original sources * Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)" This reverts commit 3d048b7f1a5e74ca318af96268472e2fb0262d3b. * Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)" This reverts commit ee99f17fbe0889483004f0ee113e37ad0c5c8283. * [*] fixed several issues after merge * [*] fixed integration compilation * Revert "Fix the branch list" This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b. * [-] removed receipt repair migration * [*] fixed parlia fork numbers output * [*] bring more devel compatibility, fixed bsc address list for access list calculation * [*] fixed bug with commiting state transition for bad blocks in BSC * [*] fixed bsc changes apply for integration command and updated config print for parlia * [*] fixed bug with applying bsc forks for chapel and rialto testnet chains [*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block * Fix compilation errors in hack.go * Fix lint * reset changes in erigon-snapshots to devel * Remove unrelated changes * Fix embed * Remove more unrelated changes * Remove more unrelated changes * Restore clique and aura miner config * Refactor interfaces not to use slice pointers * Refactor parlia functions to return tx and receipt instead of dealing with slices * Fix for header panic * Fix lint, restore system contract addresses * Remove more unrelated changes, unify GatherForks Co-authored-by: Dmitry Ivanov <convexman18@gmail.com> Co-authored-by: j75689 <j75689@gmail.com> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-01-14 22:06:35 +03:00
func DefaultBSCGenesisBlock() *Genesis {
return &Genesis{
Config: params.BSCChainConfig,
Nonce: 0x00,
Timestamp: 0x5e9da7ce,
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000002a7cdd959bfe8d9487b2a43b33565295a698f7e26488aa4d1955ee33403f8ccb1d4de5fb97c7ade29ef9f4360c606c7ab4db26b016007d3ad0ab86a0ee01c3b1283aa067c58eab4709f85e99d46de5fe685b1ded8013785d6623cc18d214320b6bb6475978f3adfc719c99674c072166708589033e2d9afec2be4ec20253b8642161bc3f444f53679c1f3d472f7be8361c80a4c1e7e9aaf001d0877f1cfde218ce2fd7544e0b2cc94692d4a704debef7bcb61328b8f7166496996a7da21cf1f1b04d9b3e26a3d0772d4c407bbe49438ed859fe965b140dcf1aab71a96bbad7cf34b5fa511d8e963dbba288b1960e75d64430b3230294d12c6ab2aac5c2cd68e80b16b581ea0a6e3c511bbd10f4519ece37dc24887e11b55d7ae2f5b9e386cd1b50a4550696d957cb4900f03a82012708dafc9e1b880fd083b32182b869be8e0922b81f8e175ffde54d797fe11eb03f9e3bf75f1d68bf0b8b6fb4e317a0f9d6f03eaf8ce6675bc60d8c4d90829ce8f72d0163c1d5cf348a862d55063035e7a025f4da968de7e4d7e4004197917f4070f1d6caa02bbebaebb5d7e581e4b66559e635f805ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x2625a00,
Difficulty: big.NewInt(0x1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE"),
Full BSC support with validator mode (#3233) * migrated consensus and chain config files for bsc support * migrated more files from bsc * fixed consensus crashing * updated erigon lib for parlia snapshot prefix * added staticpeers for bsc * [+] added system contracts [*] fixed bug with loading snapshot [+] enabled gas bailout [+] added fix to prevent syncing more than 1000 headers (for testing only) [*] fixed bug with crashing sender recover sometimes * migrated system contract calls * [*] fixed bug with returning mutable balance object [+] migrated lightclient contracts from bsc [*] fixed parlia consensus config param * [*] fixed tendermint deps * [+] added some logs * [+] enabled bsc forks [*] fixed syscalls from coinbase [*] more logging * Fix call sys contract gas calculation * [*] fixed executing system transactions * [*] enabled receipt hash, gas and bloom filter checks * [-] removed some logging scripts [*] set header checkpoint to 10 million blocks (for testing forks) * [*] fixed bug with commiting dirty inter block state state after system transaction execution [-] removed some extra logs and comments * [+] added chapel and rialto testnet support * [*] fixed chapel allocs * [-] removed 6 mil block limit for headers sync * Fix hardforks on chapel and other testnets * [*] fixed header sync issue after merge * [*] tiny code cleanup * [-] removed some comments * [*] increased mdbx map size to 4 TB * [*] increased max chaindata size to 6 tb * [*] bring more compatibility with origin erigon and some code cleanup * [+] added support of validator mode for BSC chain * [*] enable private key load for bsc, rialto and chapel chains * [*] fixed running BSC validator node * Fix the branch list * [*] tiny fixes for linter * [*] formatted imports for core and parlia packages * [*] fixed import rules in other files * Revert "[*] formatted imports for core and parlia packages" This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227. * [*] changed import rules in more packages * [*] fixed type mismatch in hack command * [*] fixed crash on new epoch, enabled bootstrap flags * [*] fixed linter errors * [*] fixed missing err check for syscalls * [*] now BSC implementation is fully compatible with erigon original sources * Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)" This reverts commit 3d048b7f1a5e74ca318af96268472e2fb0262d3b. * Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)" This reverts commit ee99f17fbe0889483004f0ee113e37ad0c5c8283. * [*] fixed several issues after merge * [*] fixed integration compilation * Revert "Fix the branch list" This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b. * [-] removed receipt repair migration * [*] fixed parlia fork numbers output * [*] bring more devel compatibility, fixed bsc address list for access list calculation * [*] fixed bug with commiting state transition for bad blocks in BSC * [*] fixed bsc changes apply for integration command and updated config print for parlia * [*] fixed bug with applying bsc forks for chapel and rialto testnet chains [*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block * Fix compilation errors in hack.go * Fix lint * reset changes in erigon-snapshots to devel * Remove unrelated changes * Fix embed * Remove more unrelated changes * Remove more unrelated changes * Restore clique and aura miner config * Refactor interfaces not to use slice pointers * Refactor parlia functions to return tx and receipt instead of dealing with slices * Fix for header panic * Fix lint, restore system contract addresses * Remove more unrelated changes, unify GatherForks Co-authored-by: Dmitry Ivanov <convexman18@gmail.com> Co-authored-by: j75689 <j75689@gmail.com> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-01-14 22:06:35 +03:00
Alloc: readPrealloc("allocs/bsc.json"),
Number: 0x00,
GasUsed: 0x00,
}
}
func DefaultChapelGenesisBlock() *Genesis {
return &Genesis{
Config: params.ChapelChainConfig,
Nonce: 0x00,
Timestamp: 0x5e9da7ce,
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001284214b9b9c85549ab3d2b972df0deef66ac2c9b71b214cb885500844365e95cd9942c7276e7fd8a2959d3f95eae5dc7d70144ce1b73b403b7eb6e0980a75ecd1309ea12fa2ed87a8744fbfc9b863d535552c16704d214347f29fa77f77da6d75d7c752f474cf03cceff28abc65c9cbae594f725c80e12d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x2625a00,
Difficulty: big.NewInt(0x1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE"),
Full BSC support with validator mode (#3233) * migrated consensus and chain config files for bsc support * migrated more files from bsc * fixed consensus crashing * updated erigon lib for parlia snapshot prefix * added staticpeers for bsc * [+] added system contracts [*] fixed bug with loading snapshot [+] enabled gas bailout [+] added fix to prevent syncing more than 1000 headers (for testing only) [*] fixed bug with crashing sender recover sometimes * migrated system contract calls * [*] fixed bug with returning mutable balance object [+] migrated lightclient contracts from bsc [*] fixed parlia consensus config param * [*] fixed tendermint deps * [+] added some logs * [+] enabled bsc forks [*] fixed syscalls from coinbase [*] more logging * Fix call sys contract gas calculation * [*] fixed executing system transactions * [*] enabled receipt hash, gas and bloom filter checks * [-] removed some logging scripts [*] set header checkpoint to 10 million blocks (for testing forks) * [*] fixed bug with commiting dirty inter block state state after system transaction execution [-] removed some extra logs and comments * [+] added chapel and rialto testnet support * [*] fixed chapel allocs * [-] removed 6 mil block limit for headers sync * Fix hardforks on chapel and other testnets * [*] fixed header sync issue after merge * [*] tiny code cleanup * [-] removed some comments * [*] increased mdbx map size to 4 TB * [*] increased max chaindata size to 6 tb * [*] bring more compatibility with origin erigon and some code cleanup * [+] added support of validator mode for BSC chain * [*] enable private key load for bsc, rialto and chapel chains * [*] fixed running BSC validator node * Fix the branch list * [*] tiny fixes for linter * [*] formatted imports for core and parlia packages * [*] fixed import rules in other files * Revert "[*] formatted imports for core and parlia packages" This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227. * [*] changed import rules in more packages * [*] fixed type mismatch in hack command * [*] fixed crash on new epoch, enabled bootstrap flags * [*] fixed linter errors * [*] fixed missing err check for syscalls * [*] now BSC implementation is fully compatible with erigon original sources * Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)" This reverts commit 3d048b7f1a5e74ca318af96268472e2fb0262d3b. * Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)" This reverts commit ee99f17fbe0889483004f0ee113e37ad0c5c8283. * [*] fixed several issues after merge * [*] fixed integration compilation * Revert "Fix the branch list" This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b. * [-] removed receipt repair migration * [*] fixed parlia fork numbers output * [*] bring more devel compatibility, fixed bsc address list for access list calculation * [*] fixed bug with commiting state transition for bad blocks in BSC * [*] fixed bsc changes apply for integration command and updated config print for parlia * [*] fixed bug with applying bsc forks for chapel and rialto testnet chains [*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block * Fix compilation errors in hack.go * Fix lint * reset changes in erigon-snapshots to devel * Remove unrelated changes * Fix embed * Remove more unrelated changes * Remove more unrelated changes * Restore clique and aura miner config * Refactor interfaces not to use slice pointers * Refactor parlia functions to return tx and receipt instead of dealing with slices * Fix for header panic * Fix lint, restore system contract addresses * Remove more unrelated changes, unify GatherForks Co-authored-by: Dmitry Ivanov <convexman18@gmail.com> Co-authored-by: j75689 <j75689@gmail.com> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-01-14 22:06:35 +03:00
Alloc: readPrealloc("allocs/chapel.json"),
Number: 0x00,
GasUsed: 0x00,
}
}
func DefaultRialtoGenesisBlock() *Genesis {
return &Genesis{
Config: params.RialtoChainConfig,
Nonce: 0x00,
Timestamp: 0x5e9da7ce,
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001284214b9b9c85549ab3d2b972df0deef66ac2c9b71b214cb885500844365e95cd9942c7276e7fd8a2959d3f95eae5dc7d70144ce1b73b403b7eb6e0980a75ecd1309ea12fa2ed87a8744fbfc9b863d535552c16704d214347f29fa77f77da6d75d7c752f474cf03cceff28abc65c9cbae594f725c80e12d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x2625a00,
Difficulty: big.NewInt(0x1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE"),
Full BSC support with validator mode (#3233) * migrated consensus and chain config files for bsc support * migrated more files from bsc * fixed consensus crashing * updated erigon lib for parlia snapshot prefix * added staticpeers for bsc * [+] added system contracts [*] fixed bug with loading snapshot [+] enabled gas bailout [+] added fix to prevent syncing more than 1000 headers (for testing only) [*] fixed bug with crashing sender recover sometimes * migrated system contract calls * [*] fixed bug with returning mutable balance object [+] migrated lightclient contracts from bsc [*] fixed parlia consensus config param * [*] fixed tendermint deps * [+] added some logs * [+] enabled bsc forks [*] fixed syscalls from coinbase [*] more logging * Fix call sys contract gas calculation * [*] fixed executing system transactions * [*] enabled receipt hash, gas and bloom filter checks * [-] removed some logging scripts [*] set header checkpoint to 10 million blocks (for testing forks) * [*] fixed bug with commiting dirty inter block state state after system transaction execution [-] removed some extra logs and comments * [+] added chapel and rialto testnet support * [*] fixed chapel allocs * [-] removed 6 mil block limit for headers sync * Fix hardforks on chapel and other testnets * [*] fixed header sync issue after merge * [*] tiny code cleanup * [-] removed some comments * [*] increased mdbx map size to 4 TB * [*] increased max chaindata size to 6 tb * [*] bring more compatibility with origin erigon and some code cleanup * [+] added support of validator mode for BSC chain * [*] enable private key load for bsc, rialto and chapel chains * [*] fixed running BSC validator node * Fix the branch list * [*] tiny fixes for linter * [*] formatted imports for core and parlia packages * [*] fixed import rules in other files * Revert "[*] formatted imports for core and parlia packages" This reverts commit c764b58b34fedc2b14d69458583ba0dad114f227. * [*] changed import rules in more packages * [*] fixed type mismatch in hack command * [*] fixed crash on new epoch, enabled bootstrap flags * [*] fixed linter errors * [*] fixed missing err check for syscalls * [*] now BSC implementation is fully compatible with erigon original sources * Revert "Add chain config and CLI changes for Binance Smart Chain support (#3131)" This reverts commit 3d048b7f1a5e74ca318af96268472e2fb0262d3b. * Revert "Add Parlia consensus engine for Binance Smart Chain support (#3086)" This reverts commit ee99f17fbe0889483004f0ee113e37ad0c5c8283. * [*] fixed several issues after merge * [*] fixed integration compilation * Revert "Fix the branch list" This reverts commit 8150ca57e5f2707a84a9f6a1c5b809b7cc84547b. * [-] removed receipt repair migration * [*] fixed parlia fork numbers output * [*] bring more devel compatibility, fixed bsc address list for access list calculation * [*] fixed bug with commiting state transition for bad blocks in BSC * [*] fixed bsc changes apply for integration command and updated config print for parlia * [*] fixed bug with applying bsc forks for chapel and rialto testnet chains [*] let's use finalize and assemble for mining to let consensus know for what it's finalizing block * Fix compilation errors in hack.go * Fix lint * reset changes in erigon-snapshots to devel * Remove unrelated changes * Fix embed * Remove more unrelated changes * Remove more unrelated changes * Restore clique and aura miner config * Refactor interfaces not to use slice pointers * Refactor parlia functions to return tx and receipt instead of dealing with slices * Fix for header panic * Fix lint, restore system contract addresses * Remove more unrelated changes, unify GatherForks Co-authored-by: Dmitry Ivanov <convexman18@gmail.com> Co-authored-by: j75689 <j75689@gmail.com> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-01-14 22:06:35 +03:00
Alloc: readPrealloc("allocs/bsc.json"),
Number: 0x00,
GasUsed: 0x00,
}
}
Merging Turbo bor into devel (#3372) * implemented bor consensus * add bor flags to default * change bucket into snapshot to clique * enable stateSync * bypass reciept checks * fix receipt calculation and bor logs * fix: contract call wrt bor * Update mumbai config * Add: bor-mainnet flag and config * Add bor consensus to integration * use header coinbase in block context * london fork mumbai changes * fix genesis error * Jaipur fork for mumbai * add sysCall to verifyHeader * added bor related rpc method implementation * added bor specific rpc extensions * fixes in snapshot implementation, major refactor for bor rpc * modify consensus specific db path for bor * fix: remove parallel compute for get root hash rpc method * Added bor-receipt flow * Use turbo-bor-lib and bor tables * Use bor table in RPC snapshot * Update README.md * Update README.md * Update README.md * Update README.md * update rpc readme * link rpc docs in readme * Update Readme * Update Readme * move erigon namespace rpc methods to eth * rm: erigon namespace * rm: erigon namespace, update list of available rpc methods, add example * fix: binary name in rpc readme * fix: max db size * Add london to bor-mainnet * updated node.go * add system req to readme * golang version fix readme * added networknames in correct place * nil * ran gofmt * erigon * fixed fake.go * dont need turbor-lib * old readme * fixing readme * half * other half * changed return * fixing return * fixed return * fixed flags * gofmt * merge with devel * latest erigon-lib * fixed context.coinbase * took out syscall * fixed params in hash * bor type now is consensus.Engine * parlia is consensus.Engine * missing arg and repeated importation * repeated importation * fixed eth_receipts.go * deleted duplicate issuance * part of consensus.Engine type * added eth_api issuance * networkname * added erigon_system file * fork struct taken out * added erigon block * getLogByHash for erigonImpl * gofmt * fixed lint * ops * gofmt * gofmt * added APIImple functions * fixed clique test * took out print * fixed state added balance * fixed README * fixed rpcDaemon README * fixed integration README * updated blockchain.go * lint * added bor back into blockchain.go * took out comment * lint * updated daemon * updated wtb * removed duplicate * removed VerifyHeaders * prevent use of wrong Transfer * fixed state_processor.go * fixed state_transition.go * fixed headers * returning err * error handling in bor read tx look up * put for txLookUp * dealing with error * lint * traces * more traces * fixed receipt in execution * getTrasanction receipt for bor or others * nil * lint * ops * deleted syscall * took out else * Merge branch 'devel * tests syscalls * changed borReceipt to receipt * reset header algos * arguments fix * took out prefixes * lint * erigon-named * borReceiptKey = blocknumber * reverts e3b60c2e159d03efcb855f7ab3da5a098dd60c33. * correct hashing tx * dont need it here * lint * added txlookup for bor * change to uint256 * outputs for isBor * wrapper * added isBor and isParlia * isBor * fixed BorTransfer * not readBody * correct prefix * added blockNum * added readStorageBody * readStorageBody * lint * got rid of unnecessary bor_receipt func * onlny if bor * use clone * append * writeToSlice * added isBor flag * fixed writeToSlice * normal sorting * lint * Reset erigon-snapshots * Move bor prefix into if Co-authored-by: Krishna Upadhyaya <krishnau1604@gmail.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Uttam Singh <uttamkhanduja@yahoo.in> Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-02-08 00:30:46 +03:00
func DefaultMumbaiGenesisBlock() *Genesis {
return &Genesis{
Config: params.MumbaiChainConfig,
Nonce: 0,
Timestamp: 1558348305,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
Merging Turbo bor into devel (#3372) * implemented bor consensus * add bor flags to default * change bucket into snapshot to clique * enable stateSync * bypass reciept checks * fix receipt calculation and bor logs * fix: contract call wrt bor * Update mumbai config * Add: bor-mainnet flag and config * Add bor consensus to integration * use header coinbase in block context * london fork mumbai changes * fix genesis error * Jaipur fork for mumbai * add sysCall to verifyHeader * added bor related rpc method implementation * added bor specific rpc extensions * fixes in snapshot implementation, major refactor for bor rpc * modify consensus specific db path for bor * fix: remove parallel compute for get root hash rpc method * Added bor-receipt flow * Use turbo-bor-lib and bor tables * Use bor table in RPC snapshot * Update README.md * Update README.md * Update README.md * Update README.md * update rpc readme * link rpc docs in readme * Update Readme * Update Readme * move erigon namespace rpc methods to eth * rm: erigon namespace * rm: erigon namespace, update list of available rpc methods, add example * fix: binary name in rpc readme * fix: max db size * Add london to bor-mainnet * updated node.go * add system req to readme * golang version fix readme * added networknames in correct place * nil * ran gofmt * erigon * fixed fake.go * dont need turbor-lib * old readme * fixing readme * half * other half * changed return * fixing return * fixed return * fixed flags * gofmt * merge with devel * latest erigon-lib * fixed context.coinbase * took out syscall * fixed params in hash * bor type now is consensus.Engine * parlia is consensus.Engine * missing arg and repeated importation * repeated importation * fixed eth_receipts.go * deleted duplicate issuance * part of consensus.Engine type * added eth_api issuance * networkname * added erigon_system file * fork struct taken out * added erigon block * getLogByHash for erigonImpl * gofmt * fixed lint * ops * gofmt * gofmt * added APIImple functions * fixed clique test * took out print * fixed state added balance * fixed README * fixed rpcDaemon README * fixed integration README * updated blockchain.go * lint * added bor back into blockchain.go * took out comment * lint * updated daemon * updated wtb * removed duplicate * removed VerifyHeaders * prevent use of wrong Transfer * fixed state_processor.go * fixed state_transition.go * fixed headers * returning err * error handling in bor read tx look up * put for txLookUp * dealing with error * lint * traces * more traces * fixed receipt in execution * getTrasanction receipt for bor or others * nil * lint * ops * deleted syscall * took out else * Merge branch 'devel * tests syscalls * changed borReceipt to receipt * reset header algos * arguments fix * took out prefixes * lint * erigon-named * borReceiptKey = blocknumber * reverts e3b60c2e159d03efcb855f7ab3da5a098dd60c33. * correct hashing tx * dont need it here * lint * added txlookup for bor * change to uint256 * outputs for isBor * wrapper * added isBor and isParlia * isBor * fixed BorTransfer * not readBody * correct prefix * added blockNum * added readStorageBody * readStorageBody * lint * got rid of unnecessary bor_receipt func * onlny if bor * use clone * append * writeToSlice * added isBor flag * fixed writeToSlice * normal sorting * lint * Reset erigon-snapshots * Move bor prefix into if Co-authored-by: Krishna Upadhyaya <krishnau1604@gmail.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Uttam Singh <uttamkhanduja@yahoo.in> Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-02-08 00:30:46 +03:00
Alloc: readPrealloc("allocs/mumbai.json"),
}
}
2022-08-10 19:04:13 +07:00
// DefaultBorMainnet returns the Bor Mainnet network gensis block.
Merging Turbo bor into devel (#3372) * implemented bor consensus * add bor flags to default * change bucket into snapshot to clique * enable stateSync * bypass reciept checks * fix receipt calculation and bor logs * fix: contract call wrt bor * Update mumbai config * Add: bor-mainnet flag and config * Add bor consensus to integration * use header coinbase in block context * london fork mumbai changes * fix genesis error * Jaipur fork for mumbai * add sysCall to verifyHeader * added bor related rpc method implementation * added bor specific rpc extensions * fixes in snapshot implementation, major refactor for bor rpc * modify consensus specific db path for bor * fix: remove parallel compute for get root hash rpc method * Added bor-receipt flow * Use turbo-bor-lib and bor tables * Use bor table in RPC snapshot * Update README.md * Update README.md * Update README.md * Update README.md * update rpc readme * link rpc docs in readme * Update Readme * Update Readme * move erigon namespace rpc methods to eth * rm: erigon namespace * rm: erigon namespace, update list of available rpc methods, add example * fix: binary name in rpc readme * fix: max db size * Add london to bor-mainnet * updated node.go * add system req to readme * golang version fix readme * added networknames in correct place * nil * ran gofmt * erigon * fixed fake.go * dont need turbor-lib * old readme * fixing readme * half * other half * changed return * fixing return * fixed return * fixed flags * gofmt * merge with devel * latest erigon-lib * fixed context.coinbase * took out syscall * fixed params in hash * bor type now is consensus.Engine * parlia is consensus.Engine * missing arg and repeated importation * repeated importation * fixed eth_receipts.go * deleted duplicate issuance * part of consensus.Engine type * added eth_api issuance * networkname * added erigon_system file * fork struct taken out * added erigon block * getLogByHash for erigonImpl * gofmt * fixed lint * ops * gofmt * gofmt * added APIImple functions * fixed clique test * took out print * fixed state added balance * fixed README * fixed rpcDaemon README * fixed integration README * updated blockchain.go * lint * added bor back into blockchain.go * took out comment * lint * updated daemon * updated wtb * removed duplicate * removed VerifyHeaders * prevent use of wrong Transfer * fixed state_processor.go * fixed state_transition.go * fixed headers * returning err * error handling in bor read tx look up * put for txLookUp * dealing with error * lint * traces * more traces * fixed receipt in execution * getTrasanction receipt for bor or others * nil * lint * ops * deleted syscall * took out else * Merge branch 'devel * tests syscalls * changed borReceipt to receipt * reset header algos * arguments fix * took out prefixes * lint * erigon-named * borReceiptKey = blocknumber * reverts e3b60c2e159d03efcb855f7ab3da5a098dd60c33. * correct hashing tx * dont need it here * lint * added txlookup for bor * change to uint256 * outputs for isBor * wrapper * added isBor and isParlia * isBor * fixed BorTransfer * not readBody * correct prefix * added blockNum * added readStorageBody * readStorageBody * lint * got rid of unnecessary bor_receipt func * onlny if bor * use clone * append * writeToSlice * added isBor flag * fixed writeToSlice * normal sorting * lint * Reset erigon-snapshots * Move bor prefix into if Co-authored-by: Krishna Upadhyaya <krishnau1604@gmail.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Uttam Singh <uttamkhanduja@yahoo.in> Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-02-08 00:30:46 +03:00
func DefaultBorMainnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.BorMainnetChainConfig,
Nonce: 0,
Timestamp: 1590824836,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
Merging Turbo bor into devel (#3372) * implemented bor consensus * add bor flags to default * change bucket into snapshot to clique * enable stateSync * bypass reciept checks * fix receipt calculation and bor logs * fix: contract call wrt bor * Update mumbai config * Add: bor-mainnet flag and config * Add bor consensus to integration * use header coinbase in block context * london fork mumbai changes * fix genesis error * Jaipur fork for mumbai * add sysCall to verifyHeader * added bor related rpc method implementation * added bor specific rpc extensions * fixes in snapshot implementation, major refactor for bor rpc * modify consensus specific db path for bor * fix: remove parallel compute for get root hash rpc method * Added bor-receipt flow * Use turbo-bor-lib and bor tables * Use bor table in RPC snapshot * Update README.md * Update README.md * Update README.md * Update README.md * update rpc readme * link rpc docs in readme * Update Readme * Update Readme * move erigon namespace rpc methods to eth * rm: erigon namespace * rm: erigon namespace, update list of available rpc methods, add example * fix: binary name in rpc readme * fix: max db size * Add london to bor-mainnet * updated node.go * add system req to readme * golang version fix readme * added networknames in correct place * nil * ran gofmt * erigon * fixed fake.go * dont need turbor-lib * old readme * fixing readme * half * other half * changed return * fixing return * fixed return * fixed flags * gofmt * merge with devel * latest erigon-lib * fixed context.coinbase * took out syscall * fixed params in hash * bor type now is consensus.Engine * parlia is consensus.Engine * missing arg and repeated importation * repeated importation * fixed eth_receipts.go * deleted duplicate issuance * part of consensus.Engine type * added eth_api issuance * networkname * added erigon_system file * fork struct taken out * added erigon block * getLogByHash for erigonImpl * gofmt * fixed lint * ops * gofmt * gofmt * added APIImple functions * fixed clique test * took out print * fixed state added balance * fixed README * fixed rpcDaemon README * fixed integration README * updated blockchain.go * lint * added bor back into blockchain.go * took out comment * lint * updated daemon * updated wtb * removed duplicate * removed VerifyHeaders * prevent use of wrong Transfer * fixed state_processor.go * fixed state_transition.go * fixed headers * returning err * error handling in bor read tx look up * put for txLookUp * dealing with error * lint * traces * more traces * fixed receipt in execution * getTrasanction receipt for bor or others * nil * lint * ops * deleted syscall * took out else * Merge branch 'devel * tests syscalls * changed borReceipt to receipt * reset header algos * arguments fix * took out prefixes * lint * erigon-named * borReceiptKey = blocknumber * reverts e3b60c2e159d03efcb855f7ab3da5a098dd60c33. * correct hashing tx * dont need it here * lint * added txlookup for bor * change to uint256 * outputs for isBor * wrapper * added isBor and isParlia * isBor * fixed BorTransfer * not readBody * correct prefix * added blockNum * added readStorageBody * readStorageBody * lint * got rid of unnecessary bor_receipt func * onlny if bor * use clone * append * writeToSlice * added isBor flag * fixed writeToSlice * normal sorting * lint * Reset erigon-snapshots * Move bor prefix into if Co-authored-by: Krishna Upadhyaya <krishnau1604@gmail.com> Co-authored-by: Manav Darji <manavdarji.india@gmail.com> Co-authored-by: Uttam Singh <uttamkhanduja@yahoo.in> Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-02-08 00:30:46 +03:00
Alloc: readPrealloc("allocs/bor_mainnet.json"),
}
}
func DefaultBorDevnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.BorDevnetChainConfig,
Nonce: 0,
Timestamp: 1558348305,
GasLimit: 10000000,
Difficulty: big.NewInt(1),
Mixhash: libcommon.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Coinbase: libcommon.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/bor_devnet.json"),
}
}
func DefaultGnosisGenesisBlock() *Genesis {
return &Genesis{
Config: params.GnosisChainConfig,
Timestamp: 0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/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 12:54:18 +01:00
func DefaultChiadoGenesisBlock() *Genesis {
return &Genesis{
Config: params.ChiadoChainConfig,
Timestamp: 0,
AuRaSeal: common.FromHex("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 0x989680,
Difficulty: big.NewInt(0x20000),
Alloc: readPrealloc("allocs/chiado.json"),
}
}
func DefaultPulsechainGenesisBlock() *Genesis {
return &Genesis{
Config: params.PulsechainChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
GasLimit: 5000,
Difficulty: big.NewInt(17179869184),
Alloc: readPrealloc("allocs/mainnet.json"),
}
}
2023-03-23 16:00:27 -05:00
func DefaultPulsechainTestnetV3GenesisBlock() *Genesis {
return &Genesis{
2023-03-23 16:00:27 -05:00
Config: params.PulsechainTestnetV3ChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
GasLimit: 5000,
Difficulty: big.NewInt(17179869184),
Alloc: readPrealloc("allocs/mainnet.json"),
}
}
2023-02-26 13:52:40 -06:00
func DefaultPulsechainDevnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.PulsechainDevnetChainConfig,
ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000123463a4B065722E99115D6c222f267d9cABb5240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 30000000,
Difficulty: big.NewInt(131072),
Alloc: readPrealloc("allocs/pulsechain-devnet.json"),
}
}
2021-09-08 11:00:06 +07:00
// Pre-calculated version of:
2022-08-10 19:04:13 +07:00
//
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
2021-09-08 11:00:06 +07:00
var DevnetSignPrivateKey, _ = crypto.HexToECDSA("26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48")
var DevnetEtherbase = libcommon.HexToAddress("67b1d87101671b127f5f8714789c7192f7ad340e")
2021-09-07 16:12:49 +07:00
2019-12-10 11:50:16 +01:00
// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
func DeveloperGenesisBlock(period uint64, faucet libcommon.Address) *Genesis {
// 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
return &Genesis{
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 11500000,
Difficulty: big.NewInt(1),
Alloc: readPrealloc("allocs/dev.json"),
2016-11-20 22:32:31 +01:00
}
}
func readPrealloc(filename string) GenesisAlloc {
f, err := allocs.Open(filename)
if err != nil {
panic(fmt.Sprintf("Could not open genesis preallocation for %s: %v", filename, err))
}
defer f.Close()
decoder := json.NewDecoder(f)
ga := make(GenesisAlloc)
err = decoder.Decode(&ga)
if err != nil {
panic(fmt.Sprintf("Could not parse genesis preallocation for %s: %v", filename, err))
}
return ga
}
func DefaultGenesisBlockByChainName(chain string) *Genesis {
switch chain {
case networkname.MainnetChainName:
return DefaultGenesisBlock()
case networkname.SepoliaChainName:
return DefaultSepoliaGenesisBlock()
case networkname.RinkebyChainName:
return DefaultRinkebyGenesisBlock()
case networkname.GoerliChainName:
return DefaultGoerliGenesisBlock()
case networkname.SokolChainName:
return DefaultSokolGenesisBlock()
case networkname.BSCChainName:
return DefaultBSCGenesisBlock()
case networkname.ChapelChainName:
return DefaultChapelGenesisBlock()
case networkname.RialtoChainName:
return DefaultRialtoGenesisBlock()
case networkname.MumbaiChainName:
return DefaultMumbaiGenesisBlock()
case networkname.BorMainnetChainName:
return DefaultBorMainnetGenesisBlock()
case networkname.BorDevnetChainName:
return DefaultBorDevnetGenesisBlock()
case networkname.GnosisChainName:
return DefaultGnosisGenesisBlock()
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 12:54:18 +01:00
case networkname.ChiadoChainName:
return DefaultChiadoGenesisBlock()
case networkname.PulsechainChainName:
return DefaultPulsechainGenesisBlock()
2023-02-26 13:52:40 -06:00
case networkname.PulsechainDevnetChainName:
return DefaultPulsechainDevnetGenesisBlock()
2023-03-23 16:00:27 -05:00
case networkname.PulsechainTestnetV3ChainName:
return DefaultPulsechainTestnetV3GenesisBlock()
default:
return nil
}
}