From 0a5fc40fa5c7a78f6b66f736f15211e8ffb51769 Mon Sep 17 00:00:00 2001 From: yumiel Date: Thu, 19 Dec 2024 14:07:46 +0800 Subject: [PATCH] add TODO about createSnapshot * however, before TODO, keep creating istanbul snapshot --- blockchain/blockchain.go | 5 +++++ consensus/consensus.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index e18e8ae96..8975a8dbb 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -2151,6 +2151,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty } } + // update governance CurrentSet if it is at an epoch block + if bc.engine.CreateSnapshot(bc, block.NumberU64(), block.Hash(), nil) != nil { + return i, events, coalescedLogs, err + } + // update governance parameters if istanbul, ok := bc.engine.(consensus.Istanbul); ok { if err = istanbul.UpdateParam(block.NumberU64()); err != nil { diff --git a/consensus/consensus.go b/consensus/consensus.go index 27ac19b73..d2ceaf3af 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -127,6 +127,8 @@ type Engine interface { // Protocol returns the protocol for this consensus Protocol() Protocol + // TODO-kaiax-valset: delete CreateSnapshot which is called after post insert block + // e.g. insertChain, worker.wait, New() // CreateSnapshot does not return a snapshot but creates a new snapshot if not exists at a given point in time. CreateSnapshot(chain ChainReader, number uint64, hash common.Hash, parents []*types.Header) error