Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consortium/v2: copy justified block number and block hash in snapshot copy #329

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions consensus/consortium/v2/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ func (s *Snapshot) store(db ethdb.Database) error {
// copy creates a deep copy of the snapshot.
func (s *Snapshot) copy() *Snapshot {
cpy := &Snapshot{
chainConfig: s.chainConfig,
config: s.config,
ethAPI: s.ethAPI,
sigCache: s.sigCache,
Number: s.Number,
Hash: s.Hash,
Recents: make(map[uint64]common.Address),
chainConfig: s.chainConfig,
config: s.config,
ethAPI: s.ethAPI,
sigCache: s.sigCache,
Number: s.Number,
Hash: s.Hash,
Recents: make(map[uint64]common.Address),
JustifiedBlockNumber: s.JustifiedBlockNumber,
JustifiedBlockHash: s.JustifiedBlockHash,
}

if s.Validators != nil {
Expand Down Expand Up @@ -212,8 +214,8 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
// already and the impact is not high, we simply trust the finality vote
// here without verification.
if extraData.HasFinalityVote == 1 {
s.JustifiedBlockNumber = header.Number.Uint64() - 1
s.JustifiedBlockHash = header.ParentHash
snap.JustifiedBlockNumber = header.Number.Uint64() - 1
snap.JustifiedBlockHash = header.ParentHash
}
}

Expand Down