mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 01:27:38 +00:00
Bor devnet option (#4428)
* bor mining testing * Implemented bor-devent network * Minor fixes * use signer as validator * remove unused spaces * fix typo
This commit is contained in:
parent
059e5d1ea5
commit
1e3c90ba80
@ -941,7 +941,7 @@ func setEtherbase(ctx *cli.Context, cfg *ethconfig.Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.GlobalString(ChainFlag.Name) == networkname.DevChainName {
|
if ctx.GlobalString(ChainFlag.Name) == networkname.DevChainName || ctx.GlobalString(ChainFlag.Name) == networkname.BorDevnetChainName {
|
||||||
if etherbase == "" {
|
if etherbase == "" {
|
||||||
cfg.Miner.SigKey = core.DevnetSignPrivateKey
|
cfg.Miner.SigKey = core.DevnetSignPrivateKey
|
||||||
cfg.Miner.Etherbase = core.DevnetEtherbase
|
cfg.Miner.Etherbase = core.DevnetEtherbase
|
||||||
@ -1054,6 +1054,8 @@ func DataDirForNetwork(datadir string, network string) string {
|
|||||||
return filepath.Join(datadir, "mumbai")
|
return filepath.Join(datadir, "mumbai")
|
||||||
case networkname.BorMainnetChainName:
|
case networkname.BorMainnetChainName:
|
||||||
return filepath.Join(datadir, "bor-mainnet")
|
return filepath.Join(datadir, "bor-mainnet")
|
||||||
|
case networkname.BorDevnetChainName:
|
||||||
|
return filepath.Join(datadir, "bor-devnet")
|
||||||
case networkname.SepoliaChainName:
|
case networkname.SepoliaChainName:
|
||||||
return filepath.Join(datadir, "sepolia")
|
return filepath.Join(datadir, "sepolia")
|
||||||
default:
|
default:
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/ledgerwatch/erigon/core/types/accounts"
|
"github.com/ledgerwatch/erigon/core/types/accounts"
|
||||||
"github.com/ledgerwatch/erigon/crypto"
|
"github.com/ledgerwatch/erigon/crypto"
|
||||||
"github.com/ledgerwatch/erigon/params"
|
"github.com/ledgerwatch/erigon/params"
|
||||||
|
"github.com/ledgerwatch/erigon/params/networkname"
|
||||||
"github.com/ledgerwatch/erigon/rlp"
|
"github.com/ledgerwatch/erigon/rlp"
|
||||||
"github.com/ledgerwatch/erigon/rpc"
|
"github.com/ledgerwatch/erigon/rpc"
|
||||||
"github.com/ledgerwatch/log/v3"
|
"github.com/ledgerwatch/log/v3"
|
||||||
@ -981,6 +982,20 @@ func (c *Bor) GetCurrentSpan(header *types.Header, state *state.IntraBlockState,
|
|||||||
|
|
||||||
// GetCurrentValidators get current validators
|
// GetCurrentValidators get current validators
|
||||||
func (c *Bor) GetCurrentValidators(blockNumber uint64) ([]*Validator, error) {
|
func (c *Bor) GetCurrentValidators(blockNumber uint64) ([]*Validator, error) {
|
||||||
|
// Use signer as validator in case of bor devent
|
||||||
|
if c.chainConfig.ChainName == networkname.BorDevnetChainName {
|
||||||
|
validators := []*Validator{
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
Address: c.signer,
|
||||||
|
VotingPower: 1000,
|
||||||
|
ProposerPriority: 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return validators, nil
|
||||||
|
}
|
||||||
|
|
||||||
span, err := c.getSpanForBlock(blockNumber)
|
span, err := c.getSpanForBlock(blockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
48
core/allocs/bor_devnet.json
Normal file
48
core/allocs/bor_devnet.json
Normal file
File diff suppressed because one or more lines are too long
@ -704,6 +704,19 @@ func DefaultBorMainnetGenesisBlock() *Genesis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DefaultBorDevnetGenesisBlock() *Genesis {
|
||||||
|
return &Genesis{
|
||||||
|
Config: params.BorDevnetChainConfig,
|
||||||
|
Nonce: 0,
|
||||||
|
Timestamp: 1558348305,
|
||||||
|
GasLimit: 10000000,
|
||||||
|
Difficulty: big.NewInt(1),
|
||||||
|
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||||
|
Alloc: readPrealloc("allocs/bor_devnet.json"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Pre-calculated version of:
|
// Pre-calculated version of:
|
||||||
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
|
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
|
||||||
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
|
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
|
||||||
@ -780,6 +793,8 @@ func DefaultGenesisBlockByChainName(chain string) *Genesis {
|
|||||||
return DefaultMumbaiGenesisBlock()
|
return DefaultMumbaiGenesisBlock()
|
||||||
case networkname.BorMainnetChainName:
|
case networkname.BorMainnetChainName:
|
||||||
return DefaultBorMainnetGenesisBlock()
|
return DefaultBorMainnetGenesisBlock()
|
||||||
|
case networkname.BorDevnetChainName:
|
||||||
|
return DefaultBorDevnetGenesisBlock()
|
||||||
case networkname.KilnDevnetChainName:
|
case networkname.KilnDevnetChainName:
|
||||||
return DefaultKilnDevnetGenesisBlock()
|
return DefaultKilnDevnetGenesisBlock()
|
||||||
default:
|
default:
|
||||||
|
@ -653,6 +653,25 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var borcfg *bor.Bor
|
||||||
|
if b, ok := s.engine.(*bor.Bor); ok {
|
||||||
|
borcfg = b
|
||||||
|
} else if br, ok := s.engine.(*serenity.Serenity); ok {
|
||||||
|
if b, ok := br.InnerEngine().(*bor.Bor); ok {
|
||||||
|
borcfg = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if borcfg != nil {
|
||||||
|
if cfg.SigKey == nil {
|
||||||
|
log.Error("Etherbase account unavailable locally", "err", err)
|
||||||
|
return fmt.Errorf("signer missing: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
borcfg.Authorize(eb, func(_ common.Address, mimeType string, message []byte) ([]byte, error) {
|
||||||
|
return crypto.Sign(crypto.Keccak256(message), cfg.SigKey)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer debug.LogPanic()
|
defer debug.LogPanic()
|
||||||
defer close(s.waitForMiningStop)
|
defer close(s.waitForMiningStop)
|
||||||
|
43
params/chainspecs/bor-devnet.json
Normal file
43
params/chainspecs/bor-devnet.json
Normal file
File diff suppressed because one or more lines are too long
@ -73,6 +73,7 @@ var (
|
|||||||
RialtoGenesisHash = common.HexToHash("0xaabe549bfa85c84f7aee9da7010b97453ad686f2c2d8ce00503d1a00c72cad54")
|
RialtoGenesisHash = common.HexToHash("0xaabe549bfa85c84f7aee9da7010b97453ad686f2c2d8ce00503d1a00c72cad54")
|
||||||
MumbaiGenesisHash = common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
|
MumbaiGenesisHash = common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
|
||||||
BorMainnetGenesisHash = common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
|
BorMainnetGenesisHash = common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
|
||||||
|
BorDevnetGenesisHash = common.HexToHash("0x5a06b25b0c6530708ea0b98a3409290e39dce6be7f558493aeb6e4b99a172a87")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -162,6 +163,8 @@ var (
|
|||||||
|
|
||||||
BorMainnetChainConfig = readChainSpec("chainspecs/bor-mainnet.json")
|
BorMainnetChainConfig = readChainSpec("chainspecs/bor-mainnet.json")
|
||||||
|
|
||||||
|
BorDevnetChainConfig = readChainSpec("chainspecs/bor-devnet.json")
|
||||||
|
|
||||||
CliqueSnapshot = NewSnapshotConfig(10, 1024, 16384, true, "")
|
CliqueSnapshot = NewSnapshotConfig(10, 1024, 16384, true, "")
|
||||||
|
|
||||||
TestChainConfig = &ChainConfig{
|
TestChainConfig = &ChainConfig{
|
||||||
@ -770,6 +773,8 @@ func ChainConfigByChainName(chain string) *ChainConfig {
|
|||||||
return MumbaiChainConfig
|
return MumbaiChainConfig
|
||||||
case networkname.BorMainnetChainName:
|
case networkname.BorMainnetChainName:
|
||||||
return BorMainnetChainConfig
|
return BorMainnetChainConfig
|
||||||
|
case networkname.BorDevnetChainName:
|
||||||
|
return BorDevnetChainConfig
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -803,6 +808,8 @@ func GenesisHashByChainName(chain string) *common.Hash {
|
|||||||
return &MumbaiGenesisHash
|
return &MumbaiGenesisHash
|
||||||
case networkname.BorMainnetChainName:
|
case networkname.BorMainnetChainName:
|
||||||
return &BorMainnetGenesisHash
|
return &BorMainnetGenesisHash
|
||||||
|
case networkname.BorDevnetChainName:
|
||||||
|
return &BorDevnetGenesisHash
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ const (
|
|||||||
RialtoChainName = "rialto"
|
RialtoChainName = "rialto"
|
||||||
MumbaiChainName = "mumbai"
|
MumbaiChainName = "mumbai"
|
||||||
BorMainnetChainName = "bor-mainnet"
|
BorMainnetChainName = "bor-mainnet"
|
||||||
|
BorDevnetChainName = "bor-devnet"
|
||||||
)
|
)
|
||||||
|
|
||||||
var All = []string{
|
var All = []string{
|
||||||
@ -32,4 +33,5 @@ var All = []string{
|
|||||||
//RialtoChainName,
|
//RialtoChainName,
|
||||||
MumbaiChainName,
|
MumbaiChainName,
|
||||||
BorMainnetChainName,
|
BorMainnetChainName,
|
||||||
|
BorDevnetChainName,
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,12 @@ func NewNodConfigUrfave(ctx *cli.Context) *nodecfg.Config {
|
|||||||
log.Info("Starting Erigon on Chapel testnet...")
|
log.Info("Starting Erigon on Chapel testnet...")
|
||||||
case networkname.DevChainName:
|
case networkname.DevChainName:
|
||||||
log.Info("Starting Erigon in ephemeral dev mode...")
|
log.Info("Starting Erigon in ephemeral dev mode...")
|
||||||
|
case networkname.MumbaiChainName:
|
||||||
|
log.Info("Starting Erigon on Mumbai testnet...")
|
||||||
case networkname.BorMainnetChainName:
|
case networkname.BorMainnetChainName:
|
||||||
log.Info("Starting Erigon on Bor Mainnet")
|
log.Info("Starting Erigon on Bor Mainnet...")
|
||||||
|
case networkname.BorDevnetChainName:
|
||||||
|
log.Info("Starting Erigon on Bor Devnet...")
|
||||||
case "", networkname.MainnetChainName:
|
case "", networkname.MainnetChainName:
|
||||||
if !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) {
|
if !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) {
|
||||||
log.Info("Starting Erigon on Ethereum mainnet...")
|
log.Info("Starting Erigon on Ethereum mainnet...")
|
||||||
|
Loading…
Reference in New Issue
Block a user