mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
beacon/light: fix lock after lock deadlock
This commit is contained in:
parent
8e2107dc39
commit
445867e23a
1 changed files with 11 additions and 5 deletions
|
|
@ -182,6 +182,12 @@ func (s *CommitteeChain) Reset() {
|
||||||
s.chainmu.Lock()
|
s.chainmu.Lock()
|
||||||
defer s.chainmu.Unlock()
|
defer s.chainmu.Unlock()
|
||||||
|
|
||||||
|
s.resetLocked()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetLocked resets the committee chain without locking. The caller should hold
|
||||||
|
// the chainmu lock.
|
||||||
|
func (s *CommitteeChain) resetLocked() {
|
||||||
if err := s.rollback(0); err != nil {
|
if err := s.rollback(0); err != nil {
|
||||||
log.Error("Error writing batch into chain database", "error", err)
|
log.Error("Error writing batch into chain database", "error", err)
|
||||||
}
|
}
|
||||||
|
|
@ -201,22 +207,22 @@ func (s *CommitteeChain) CheckpointInit(bootstrap types.BootstrapData) error {
|
||||||
}
|
}
|
||||||
period := bootstrap.Header.SyncPeriod()
|
period := bootstrap.Header.SyncPeriod()
|
||||||
if err := s.deleteFixedCommitteeRootsFrom(period + 2); err != nil {
|
if err := s.deleteFixedCommitteeRootsFrom(period + 2); err != nil {
|
||||||
s.Reset()
|
s.resetLocked()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot) != nil {
|
if s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot) != nil {
|
||||||
s.Reset()
|
s.resetLocked()
|
||||||
if err := s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot); err != nil {
|
if err := s.addFixedCommitteeRoot(period, bootstrap.CommitteeRoot); err != nil {
|
||||||
s.Reset()
|
s.resetLocked()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := s.addFixedCommitteeRoot(period+1, common.Hash(bootstrap.CommitteeBranch[0])); err != nil {
|
if err := s.addFixedCommitteeRoot(period+1, common.Hash(bootstrap.CommitteeBranch[0])); err != nil {
|
||||||
s.Reset()
|
s.resetLocked()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.addCommittee(period, bootstrap.Committee); err != nil {
|
if err := s.addCommittee(period, bootstrap.Committee); err != nil {
|
||||||
s.Reset()
|
s.resetLocked()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
s.changeCounter++
|
s.changeCounter++
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue