chg: no verify without engine

This commit is contained in:
Jaynti Kanani 2020-11-14 14:53:23 +05:30
parent 7319922ad5
commit 82246a5e94
No known key found for this signature in database
GPG key ID: 4396982C976BAE5E
3 changed files with 15 additions and 9 deletions

View file

@ -52,29 +52,30 @@ func getGenesis(genesisPath string) (*core.Genesis, error) {
return genesis, nil
}
func createBorEthereum(cfg *eth.Config) *eth.Ethereum {
// CreateBorEthereum Creates bor ethereum object from eth.Config
func CreateBorEthereum(cfg *eth.Config) *eth.Ethereum {
workspace, err := ioutil.TempDir("", "bor-command-node-")
if err != nil {
Fatalf("failed to create temporary keystore: %v", err)
Fatalf("Failed to create temporary keystore: %v", err)
}
// Create a networkless protocol stack and start an Ethereum service within
stack, err := node.New(&node.Config{DataDir: workspace, UseLightweightKDF: true, Name: "bor-command-node"})
if err != nil {
Fatalf("failed to create node: %v", err)
Fatalf("Failed to create node: %v", err)
}
ethereum, err := eth.New(stack, cfg)
if err != nil {
Fatalf("failed to register Ethereum protocol: %v", err)
Fatalf("Failed to register Ethereum protocol: %v", err)
}
// Start the node and assemble the JavaScript console around it
if err = stack.Start(); err != nil {
Fatalf("failed to start test stack: %v", err)
Fatalf("Failed to start stack: %v", err)
}
_, err = stack.Attach()
if err != nil {
Fatalf("failed to attach to node: %v", err)
Fatalf("Failed to attach to node: %v", err)
}
return ethereum

View file

@ -1813,14 +1813,16 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readOnly bool) (chain *core.B
Fatalf("%v", err)
}
var engine consensus.Engine
var ethereum *eth.Ethereum
if config.Clique != nil {
engine = clique.New(config.Clique, chainDb)
} else if config.Bor != nil {
engine = createBorEthereum(&eth.Config{
ethereum = CreateBorEthereum(&eth.Config{
Genesis: genesis,
HeimdallURL: ctx.GlobalString(HeimdallURLFlag.Name),
WithoutHeimdall: ctx.GlobalBool(WithoutHeimdallFlag.Name),
}).Engine()
})
engine = ethereum.Engine()
} else {
engine = ethash.NewFaker()
if !ctx.GlobalBool(FakePoWFlag.Name) {
@ -1866,6 +1868,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readOnly bool) (chain *core.B
if err != nil {
Fatalf("Can't create BlockChain: %v", err)
}
if ethereum != nil {
ethereum.SetBlockchain(chain)
}
return chain, chainDb
}

View file

@ -320,7 +320,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
// The first thing the node will do is reconstruct the verification data for
// the head block (ethash cache or clique voting snapshot). Might as well do
// it in advance.
bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true)
// bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true)
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
for hash := range BadHashes {