mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
Integration: configure correct consensus engine (#6492)
This commit is contained in:
parent
d595accc63
commit
a4006ad2af
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -25,7 +24,6 @@ import (
|
|||||||
"github.com/ledgerwatch/erigon/cmd/hack/tool/fromdb"
|
"github.com/ledgerwatch/erigon/cmd/hack/tool/fromdb"
|
||||||
"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
|
"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
|
||||||
"github.com/ledgerwatch/erigon/consensus"
|
"github.com/ledgerwatch/erigon/consensus"
|
||||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
|
||||||
"github.com/ledgerwatch/erigon/core"
|
"github.com/ledgerwatch/erigon/core"
|
||||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||||
reset2 "github.com/ledgerwatch/erigon/core/rawdb/rawdbreset"
|
reset2 "github.com/ledgerwatch/erigon/core/rawdb/rawdbreset"
|
||||||
@ -1314,24 +1312,19 @@ func initConsensusEngine(cc *params.ChainConfig, datadir string, db kv.RwDB) (en
|
|||||||
snapshots, _ := allSnapshots(context.Background(), db)
|
snapshots, _ := allSnapshots(context.Background(), db)
|
||||||
config := ethconfig.Defaults
|
config := ethconfig.Defaults
|
||||||
|
|
||||||
switch {
|
var consensusConfig interface{}
|
||||||
case cc.Clique != nil:
|
|
||||||
c := params.CliqueSnapshot
|
if cc.Clique != nil {
|
||||||
c.DBPath = filepath.Join(datadir, "clique", "db")
|
consensusConfig = params.CliqueSnapshot
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(cc, l, c, config.Miner.Notify, config.Miner.Noverify, "", true, datadir, snapshots, db.ReadOnly(), db)
|
} else if cc.Aura != nil {
|
||||||
case cc.Aura != nil:
|
config.Aura.Etherbase = config.Miner.Etherbase
|
||||||
consensusConfig := ¶ms.AuRaConfig{DBPath: filepath.Join(datadir, "aura")}
|
consensusConfig = &config.Aura
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, "", true, datadir, snapshots, db.ReadOnly(), db)
|
} else if cc.Parlia != nil {
|
||||||
case cc.Parlia != nil:
|
consensusConfig = &config.Parlia
|
||||||
// Apply special hacks for BSC params
|
} else if cc.Bor != nil {
|
||||||
params.ApplyBinanceSmartChainParams()
|
consensusConfig = &config.Bor
|
||||||
consensusConfig := ¶ms.ParliaConfig{DBPath: filepath.Join(datadir, "parlia")}
|
} else {
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, "", true, datadir, snapshots, db.ReadOnly(), db)
|
consensusConfig = &config.Ethash
|
||||||
case cc.Bor != nil:
|
|
||||||
consensusConfig := &config.Bor
|
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, HeimdallURL, false, datadir, snapshots, db.ReadOnly(), db)
|
|
||||||
default: //ethash
|
|
||||||
engine = ethash.NewFaker()
|
|
||||||
}
|
}
|
||||||
return
|
return ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallURL, config.WithoutHeimdall, datadir, snapshots, false /* readonly */, db)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import (
|
|||||||
|
|
||||||
"github.com/ledgerwatch/erigon/common"
|
"github.com/ledgerwatch/erigon/common"
|
||||||
"github.com/ledgerwatch/erigon/consensus"
|
"github.com/ledgerwatch/erigon/consensus"
|
||||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
|
||||||
"github.com/ledgerwatch/erigon/consensus/misc"
|
"github.com/ledgerwatch/erigon/consensus/misc"
|
||||||
"github.com/ledgerwatch/erigon/core"
|
"github.com/ledgerwatch/erigon/core"
|
||||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||||
@ -624,29 +623,23 @@ func (ww *WriterWrapper) CreateContract(address common.Address) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func initConsensusEngine(chainConfig *params.ChainConfig, snapshots *snapshotsync.RoSnapshots) (engine consensus.Engine) {
|
func initConsensusEngine(cc *params.ChainConfig, snapshots *snapshotsync.RoSnapshots) (engine consensus.Engine) {
|
||||||
l := log.New()
|
l := log.New()
|
||||||
config := ethconfig.Defaults
|
config := ethconfig.Defaults
|
||||||
|
|
||||||
switch {
|
var consensusConfig interface{}
|
||||||
case chainConfig.Clique != nil:
|
|
||||||
c := params.CliqueSnapshot
|
|
||||||
c.DBPath = filepath.Join(datadirCli, "clique", "db")
|
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, l, c, config.Miner.Notify, config.Miner.Noverify, "", true, datadirCli, snapshots, true /* readonly */)
|
|
||||||
case chainConfig.Aura != nil:
|
|
||||||
consensusConfig := ¶ms.AuRaConfig{DBPath: filepath.Join(datadirCli, "aura")}
|
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, "", true, datadirCli, snapshots, true /* readonly */)
|
|
||||||
case chainConfig.Parlia != nil:
|
|
||||||
// Apply special hacks for BSC params
|
|
||||||
params.ApplyBinanceSmartChainParams()
|
|
||||||
consensusConfig := ¶ms.ParliaConfig{DBPath: filepath.Join(datadirCli, "parlia")}
|
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, "", true, datadirCli, snapshots, true /* readonly */)
|
|
||||||
case chainConfig.Bor != nil:
|
|
||||||
consensusConfig := &config.Bor
|
|
||||||
engine = ethconsensusconfig.CreateConsensusEngine(chainConfig, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallURL, false, datadirCli, snapshots, true /* readonly */)
|
|
||||||
default: //ethash
|
|
||||||
engine = ethash.NewFaker()
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
if cc.Clique != nil {
|
||||||
|
consensusConfig = params.CliqueSnapshot
|
||||||
|
} else if cc.Aura != nil {
|
||||||
|
config.Aura.Etherbase = config.Miner.Etherbase
|
||||||
|
consensusConfig = &config.Aura
|
||||||
|
} else if cc.Parlia != nil {
|
||||||
|
consensusConfig = &config.Parlia
|
||||||
|
} else if cc.Bor != nil {
|
||||||
|
consensusConfig = &config.Bor
|
||||||
|
} else {
|
||||||
|
consensusConfig = &config.Ethash
|
||||||
|
}
|
||||||
|
return ethconsensusconfig.CreateConsensusEngine(cc, l, consensusConfig, config.Miner.Notify, config.Miner.Noverify, config.HeimdallURL, config.WithoutHeimdall, datadirCli, snapshots, true /* readonly */)
|
||||||
}
|
}
|
||||||
|
@ -47,10 +47,16 @@ func CreateConsensusEngine(chainConfig *params.ChainConfig, logger log.Logger, c
|
|||||||
}
|
}
|
||||||
case *params.ConsensusSnapshotConfig:
|
case *params.ConsensusSnapshotConfig:
|
||||||
if chainConfig.Clique != nil {
|
if chainConfig.Clique != nil {
|
||||||
|
if consensusCfg.DBPath == "" {
|
||||||
|
consensusCfg.DBPath = filepath.Join(datadir, "clique", "db")
|
||||||
|
}
|
||||||
eng = clique.New(chainConfig, consensusCfg, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly))
|
eng = clique.New(chainConfig, consensusCfg, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly))
|
||||||
}
|
}
|
||||||
case *params.AuRaConfig:
|
case *params.AuRaConfig:
|
||||||
if chainConfig.Aura != nil {
|
if chainConfig.Aura != nil {
|
||||||
|
if consensusCfg.DBPath == "" {
|
||||||
|
consensusCfg.DBPath = filepath.Join(datadir, "aura")
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
eng, err = aura.NewAuRa(chainConfig.Aura, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly), chainConfig.Aura.Etherbase, consensusconfig.GetConfigByChain(chainConfig.ChainName))
|
eng, err = aura.NewAuRa(chainConfig.Aura, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly), chainConfig.Aura.Etherbase, consensusconfig.GetConfigByChain(chainConfig.ChainName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -59,6 +65,9 @@ func CreateConsensusEngine(chainConfig *params.ChainConfig, logger log.Logger, c
|
|||||||
}
|
}
|
||||||
case *params.ParliaConfig:
|
case *params.ParliaConfig:
|
||||||
if chainConfig.Parlia != nil {
|
if chainConfig.Parlia != nil {
|
||||||
|
if consensusCfg.DBPath == "" {
|
||||||
|
consensusCfg.DBPath = filepath.Join(datadir, "parlia")
|
||||||
|
}
|
||||||
eng = parlia.New(chainConfig, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly), snapshots, chainDb[0])
|
eng = parlia.New(chainConfig, db.OpenDatabase(consensusCfg.DBPath, logger, consensusCfg.InMemory, readonly), snapshots, chainDb[0])
|
||||||
}
|
}
|
||||||
case *params.BorConfig:
|
case *params.BorConfig:
|
||||||
|
Loading…
Reference in New Issue
Block a user