Skip to content

Commit 73ebfbc

Browse files
authored
Merge pull request #6998 from onflow/petera/monotonous-monotonic
Rename MonotonousCounter to MonotonicCounter
2 parents 8b1120d + 53d629f commit 73ebfbc

File tree

29 files changed

+70
-70
lines changed

29 files changed

+70
-70
lines changed

access/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ func (h *Handler) SendAndSubscribeTransactionStatuses(
14271427

14281428
sub := h.api.SendAndSubscribeTransactionStatuses(ctx, &tx, request.GetEventEncodingVersion())
14291429

1430-
messageIndex := counters.NewMonotonousCounter(0)
1430+
messageIndex := counters.NewMonotonicCounter(0)
14311431
return subscription.HandleRPCSubscription(sub, func(txResults []*TransactionResult) error {
14321432
for i := range txResults {
14331433
index := messageIndex.Value()

consensus/hotstuff/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ The event handler is designed to be executed single-threaded.
173173
To separate general graph-theoretical concepts from the concrete blockchain application, `LevelledForest` refers to blocks as graph `vertices`
174174
and to a block's view number as `level`.
175175
* `Validator` validates the HotStuff-relevant aspects of
176-
- QC: total weight of all signers is more than 2/3 of committee weight, validity of signatures, view number is strictly monotonously increasing;
176+
- QC: total weight of all signers is more than 2/3 of committee weight, validity of signatures, view number is strictly monotonicly increasing;
177177
- TC: total weight of all signers is more than 2/3 of committee weight, validity of signatures, proof for entering view;
178178
- block proposal: from designated primary for the block's respective view, contains proposer's vote for its own block, QC in block is valid,
179179
a valid TC for the previous view is included if and only if the QC is not for the previous view;

consensus/hotstuff/integration/instance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func NewInstance(t *testing.T, options ...Option) *Instance {
451451
// mock signature aggregator which doesn't perform any crypto operations and just tracks total weight
452452
aggregator := &mocks.TimeoutSignatureAggregator{}
453453
totalWeight := atomic.NewUint64(0)
454-
newestView := counters.NewMonotonousCounter(0)
454+
newestView := counters.NewMonotonicCounter(0)
455455
aggregator.On("View").Return(view).Maybe()
456456
aggregator.On("TotalWeight").Return(func() uint64 {
457457
return totalWeight.Load()

consensus/hotstuff/pacemaker/view_tracker.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ func (vt *viewTracker) ProcessTC(tc *flow.TimeoutCertificate) (uint64, error) {
118118
}
119119

120120
// updateLivenessData updates the current view, qc, tc. We want to avoid unnecessary data-base
121-
// writes, which we enforce by requiring that the view number is STRICTLY monotonously increasing.
121+
// writes, which we enforce by requiring that the view number is STRICTLY monotonicly increasing.
122122
// Otherwise, an exception is returned. No errors are expected, any error should be treated as exception.
123123
func (vt *viewTracker) updateLivenessData(newView uint64, qc *flow.QuorumCertificate, tc *flow.TimeoutCertificate) error {
124124
if newView <= vt.livenessData.CurrentView {
125125
// This should never happen: in the current implementation, it is trivially apparent that
126126
// newView is _always_ larger than currentView. This check is to protect the code from
127127
// future modifications that violate the necessary condition for
128-
// STRICTLY monotonously increasing view numbers.
129-
return fmt.Errorf("cannot move from view %d to %d: currentView must be strictly monotonously increasing",
128+
// STRICTLY monotonicly increasing view numbers.
129+
return fmt.Errorf("cannot move from view %d to %d: currentView must be strictly monotonicly increasing",
130130
vt.livenessData.CurrentView, newView)
131131
}
132132

consensus/hotstuff/safetyrules/safety_rules_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func (s *SafetyRulesTestSuite) TestProduceVote_UpdateLockedOneChainView() {
196196
// TestProduceVote_InvalidCurrentView tests that no vote is created if `curView` has invalid values.
197197
// In particular, `SafetyRules` requires that:
198198
// - the block's view matches `curView`
199-
// - that values for `curView` are monotonously increasing
199+
// - that values for `curView` are monotonicly increasing
200200
//
201201
// Failing any of these conditions is a symptom of an internal bug; hence `SafetyRules` should
202202
// _not_ return a `NoVoteError`.
@@ -208,7 +208,7 @@ func (s *SafetyRulesTestSuite) TestProduceVote_InvalidCurrentView() {
208208
require.Error(s.T(), err)
209209
require.False(s.T(), model.IsNoVoteError(err))
210210
})
211-
s.Run("view-not-monotonously-increasing", func() {
211+
s.Run("view-not-monotonicly-increasing", func() {
212212
// create block with view < HighestAcknowledgedView
213213
proposal := helper.MakeSignedProposal(helper.WithProposal(helper.MakeProposal(
214214
helper.WithBlock(
@@ -450,7 +450,7 @@ func (s *SafetyRulesTestSuite) TestProduceVote_VotingOnInvalidProposals() {
450450
// TestProduceVote_VoteEquivocation tests scenario when we try to vote twice in same view. We require that replica
451451
// follows next rules:
452452
// - replica votes once per view
453-
// - replica votes in monotonously increasing views
453+
// - replica votes in monotonicly increasing views
454454
//
455455
// Voting twice per round on equivocating proposals is considered a byzantine behavior.
456456
// Expect a `model.NoVoteError` sentinel in such scenario.

consensus/hotstuff/timeoutaggregator/timeout_aggregator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type TimeoutAggregator struct {
3535
log zerolog.Logger
3636
hotstuffMetrics module.HotstuffMetrics
3737
engineMetrics module.EngineMetrics
38-
lowestRetainedView counters.StrictMonotonousCounter // lowest view, for which we still process timeouts
38+
lowestRetainedView counters.StrictMonotonicCounter // lowest view, for which we still process timeouts
3939
collectors hotstuff.TimeoutCollectors
4040
queuedTimeoutsNotifier engine.Notifier
4141
enteringViewNotifier engine.Notifier
@@ -64,7 +64,7 @@ func NewTimeoutAggregator(log zerolog.Logger,
6464
log: log.With().Str("component", "hotstuff.timeout_aggregator").Logger(),
6565
hotstuffMetrics: hotstuffMetrics,
6666
engineMetrics: engineMetrics,
67-
lowestRetainedView: counters.NewMonotonousCounter(lowestRetainedView),
67+
lowestRetainedView: counters.NewMonotonicCounter(lowestRetainedView),
6868
collectors: collectors,
6969
queuedTimeoutsNotifier: engine.NewNotifier(),
7070
enteringViewNotifier: engine.NewNotifier(),

consensus/hotstuff/timeoutcollector/timeout_collector.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type TimeoutCollector struct {
2020
timeoutsCache *TimeoutObjectsCache // cache for tracking double timeout and timeout equivocation
2121
notifier hotstuff.TimeoutAggregationConsumer
2222
processor hotstuff.TimeoutProcessor
23-
newestReportedQC counters.StrictMonotonousCounter // view of newest QC that was reported
24-
newestReportedTC counters.StrictMonotonousCounter // view of newest TC that was reported
23+
newestReportedQC counters.StrictMonotonicCounter // view of newest QC that was reported
24+
newestReportedTC counters.StrictMonotonicCounter // view of newest TC that was reported
2525
}
2626

2727
var _ hotstuff.TimeoutCollector = (*TimeoutCollector)(nil)
@@ -40,8 +40,8 @@ func NewTimeoutCollector(log zerolog.Logger,
4040
notifier: notifier,
4141
timeoutsCache: NewTimeoutObjectsCache(view),
4242
processor: processor,
43-
newestReportedQC: counters.NewMonotonousCounter(0),
44-
newestReportedTC: counters.NewMonotonousCounter(0),
43+
newestReportedQC: counters.NewMonotonicCounter(0),
44+
newestReportedTC: counters.NewMonotonicCounter(0),
4545
}
4646
}
4747

@@ -96,7 +96,7 @@ func (c *TimeoutCollector) processTimeout(timeout *model.TimeoutObject) error {
9696
// * Over larger time scales, the emitted events are for statistically increasing views.
9797
// * However, on short time scales there are _no_ monotonicity guarantees w.r.t. the views.
9898
// Explanation:
99-
// While only QCs with strict monotonously increasing views pass the
99+
// While only QCs with strict monotonicly increasing views pass the
100100
// `if c.newestReportedQC.Set(timeout.NewestQC.View)` statement, we emit the notification in a separate
101101
// step. Therefore, emitting the notifications is subject to races, where on very short time-scales
102102
// the notifications can be out of order.

consensus/hotstuff/voteaggregator/vote_aggregator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ type VoteAggregator struct {
3838
hotstuffMetrics module.HotstuffMetrics
3939
engineMetrics module.EngineMetrics
4040
notifier hotstuff.VoteAggregationViolationConsumer
41-
lowestRetainedView counters.StrictMonotonousCounter // lowest view, for which we still process votes
41+
lowestRetainedView counters.StrictMonotonicCounter // lowest view, for which we still process votes
4242
collectors hotstuff.VoteCollectors
4343
queuedMessagesNotifier engine.Notifier
4444
finalizationEventsNotifier engine.Notifier
45-
finalizedView counters.StrictMonotonousCounter // cache the last finalized view to queue up the pruning work, and unblock the caller who's delivering the finalization event.
45+
finalizedView counters.StrictMonotonicCounter // cache the last finalized view to queue up the pruning work, and unblock the caller who's delivering the finalization event.
4646
queuedVotes *fifoqueue.FifoQueue
4747
queuedBlocks *fifoqueue.FifoQueue
4848
}
@@ -79,8 +79,8 @@ func NewVoteAggregator(
7979
hotstuffMetrics: hotstuffMetrics,
8080
engineMetrics: engineMetrics,
8181
notifier: notifier,
82-
lowestRetainedView: counters.NewMonotonousCounter(lowestRetainedView),
83-
finalizedView: counters.NewMonotonousCounter(lowestRetainedView),
82+
lowestRetainedView: counters.NewMonotonicCounter(lowestRetainedView),
83+
finalizedView: counters.NewMonotonicCounter(lowestRetainedView),
8484
collectors: collectors,
8585
queuedVotes: queuedVotes,
8686
queuedBlocks: queuedBlocks,

engine/access/rest/websockets/data_providers/account_statuses_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (p *AccountStatusesDataProvider) createSubscription(ctx context.Context, ar
100100
// No errors are expected during normal operations.
101101
func (p *AccountStatusesDataProvider) handleResponse() func(accountStatusesResponse *backend.AccountStatusesResponse) error {
102102
blocksSinceLastMessage := uint64(0)
103-
messageIndex := counters.NewMonotonousCounter(0)
103+
messageIndex := counters.NewMonotonicCounter(0)
104104

105105
return func(accountStatusesResponse *backend.AccountStatusesResponse) error {
106106
// check if there are any events in the response. if not, do not send a message unless the last

engine/access/rest/websockets/data_providers/events_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (p *EventsDataProvider) Run() error {
8686
// No errors are expected during normal operations.
8787
func (p *EventsDataProvider) handleResponse() func(eventsResponse *backend.EventsResponse) error {
8888
blocksSinceLastMessage := uint64(0)
89-
messageIndex := counters.NewMonotonousCounter(0)
89+
messageIndex := counters.NewMonotonicCounter(0)
9090

9191
return func(eventsResponse *backend.EventsResponse) error {
9292
// check if there are any events in the response. if not, do not send a message unless the last

0 commit comments

Comments
 (0)