Skip to content

Commit

Permalink
chore: rollback modifications to auth set changes
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Apr 26, 2023
1 parent 3eba164 commit f1eb6d6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
9 changes: 0 additions & 9 deletions dot/state/grandpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func (s *GrandpaState) HandleGRANDPADigest(header *types.Header, digest scale.Va
case types.GrandpaScheduledChange:
return s.addScheduledChange(header, val)
case types.GrandpaForcedChange:
fmt.Printf("adding a forced change\n")
return s.addForcedChange(header, val)
case types.GrandpaOnDisabled:
return nil
Expand Down Expand Up @@ -125,7 +124,6 @@ func (s *GrandpaState) addForcedChange(header *types.Header, fc types.GrandpaFor
return fmt.Errorf("cannot import forced change: %w", err)
}

fmt.Printf("there are now %d possible forced changes\n", s.forcedChanges.Len())
logger.Debugf("there are now %d possible forced changes", s.forcedChanges.Len())
return nil
}
Expand Down Expand Up @@ -259,13 +257,6 @@ func (s *GrandpaState) ApplyForcedChanges(importedBlockHeader *types.Header) err
return fmt.Errorf("cannot set change set id at block")
}

logger.Debug("reseting scheduled changes and forced changes")
s.scheduledChangeRoots.reset()
s.forcedChanges.reset()

logger.Debugf("Applying authority set forced change on block #%d made at block #%d",
importedBlockHeader.Number, forcedChange.announcingHeader.Number)

return nil
}

Expand Down
11 changes: 1 addition & 10 deletions dot/state/grandpa_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ func (oc *orderedPendingChanges) pruneChanges(hash common.Hash, isDescendantOf i
return nil
}

func (oc *orderedPendingChanges) reset() {
*oc = make([]pendingChange, 0)
}

type pendingChangeNode struct {
change *pendingChange
nodes []*pendingChangeNode
Expand Down Expand Up @@ -289,8 +285,7 @@ func (ct changeTree) findApplicableChange(hash common.Hash, number uint,
}

if child.change.announcingHeader.Number <= number && isDescendant {
return false, fmt.Errorf("%w: %s (%d)", errUnfinalizedAncestor,
child.change.announcingHeader.Hash(), child.change.announcingHeader.Number)
return false, errUnfinalizedAncestor
}
}

Expand Down Expand Up @@ -319,7 +314,3 @@ func (ct *changeTree) pruneChanges(hash common.Hash, isDescendantOf isDescendant
*ct = onBranchChanges
return nil
}

func (ct *changeTree) reset() {
*ct = []*pendingChangeNode{}
}

0 comments on commit f1eb6d6

Please sign in to comment.