Skip to content

Commit

Permalink
consortium: remove unused genesis in consensus engine
Browse files Browse the repository at this point in the history
  • Loading branch information
minh-bq committed May 21, 2024
1 parent 9e55df7 commit 3815939
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions consensus/consortium/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ type Consortium struct {
}

// New creates a Consortium proxy that decides what Consortium version will be called
func New(chainConfig *params.ChainConfig, db ethdb.Database, ee *ethapi.PublicBlockChainAPI, genesisHash common.Hash) *Consortium {
func New(chainConfig *params.ChainConfig, db ethdb.Database, ee *ethapi.PublicBlockChainAPI) *Consortium {
// Set any missing consensus parameters to their defaults
consortiumV1 := v1.New(chainConfig, db, ee)
consortiumV2 := v2.New(chainConfig, db, ee, genesisHash, consortiumV1)
consortiumV2 := v2.New(chainConfig, db, ee, consortiumV1)

return &Consortium{
chainConfig: chainConfig,
Expand Down
3 changes: 0 additions & 3 deletions consensus/consortium/v2/consortium.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ type Consortium struct {
chainConfig *params.ChainConfig
config *params.ConsortiumConfig // Consensus engine configuration parameters
forkedBlock uint64
genesisHash common.Hash
db ethdb.Database // Database to store and retrieve snapshot checkpoints

recents *lru.ARCCache // Snapshots for recent block to speed up reorgs
Expand All @@ -120,7 +119,6 @@ func New(
chainConfig *params.ChainConfig,
db ethdb.Database,
ethAPI *ethapi.PublicBlockChainAPI,
genesisHash common.Hash,
v1 consortiumCommon.ConsortiumAdapter,
) *Consortium {
consortiumConfig := chainConfig.Consortium
Expand All @@ -136,7 +134,6 @@ func New(
consortium := Consortium{
chainConfig: chainConfig,
config: consortiumConfig,
genesisHash: genesisHash,
db: db,
ethAPI: ethAPI,
recents: recents,
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
log.Info("Unprotected transactions allowed")
}
ethAPI := ethapi.NewPublicBlockChainAPI(eth.APIBackend)
eth.engine = ethconfig.CreateConsensusEngine(stack, chainConfig, &ethashConfig, config.Miner.Notify, config.Miner.Noverify, chainDb, ethAPI, genesisHash)
eth.engine = ethconfig.CreateConsensusEngine(stack, chainConfig, &ethashConfig, config.Miner.Notify, config.Miner.Noverify, chainDb, ethAPI)

bcVersion := rawdb.ReadDatabaseVersion(chainDb)
var dbVer = "<nil>"
Expand Down
12 changes: 10 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,21 @@ type Config struct {
}

// CreateConsensusEngine creates a consensus engine for the given chain configuration.
func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database, ee *ethapi.PublicBlockChainAPI, genesisHash common.Hash) consensus.Engine {
func CreateConsensusEngine(
stack *node.Node,
chainConfig *params.ChainConfig,
config *ethash.Config,
notify []string,
noverify bool,
db ethdb.Database,
ee *ethapi.PublicBlockChainAPI,
) consensus.Engine {
// If proof-of-authority is requested, set it up
if chainConfig.Clique != nil {
return clique.New(chainConfig.Clique, db)
}
if chainConfig.Consortium != nil {
return consortium.New(chainConfig, db, ee, genesisHash)
return consortium.New(chainConfig, db, ee)
}
// Otherwise assume proof-of-work
switch config.PowMode {
Expand Down
2 changes: 1 addition & 1 deletion les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
eventMux: stack.EventMux(),
reqDist: newRequestDistributor(peers, &mclock.System{}),
accountManager: stack.AccountManager(),
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &config.Ethash, nil, false, chainDb, nil, genesisHash),
engine: ethconfig.CreateConsensusEngine(stack, chainConfig, &config.Ethash, nil, false, chainDb, nil),
bloomRequests: make(chan chan *bloombits.Retrieval),
bloomIndexer: core.NewBloomIndexer(chainDb, params.BloomBitsBlocksClient, params.HelperTrieConfirmations),
p2pServer: stack.Server(),
Expand Down

0 comments on commit 3815939

Please sign in to comment.