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

clocks: tagged deadlines #5649

Merged
merged 26 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0502b7c
tagged clock interface
yossigi Aug 9, 2023
b81bbd3
checkpoint: integrating the new clock
yossigi Aug 9, 2023
7ab2db7
checkpoint: integrating tagged timers
yossigi Aug 9, 2023
1fc2f90
fix failing tests
yossigi Aug 10, 2023
7e9f9fc
names refactor
yossigi Aug 10, 2023
b59136b
generic timeout type for timers.Clock
zeldovich Aug 10, 2023
db1386c
msgp for tagged deadline
yossigi Aug 10, 2023
2f4eee1
fix lint issues
yossigi Aug 10, 2023
3a5a1ed
+msgp_gen test
yossigi Aug 10, 2023
1379b72
Merge branch 'master' into yossi/taggedDeadlines
yossigi Aug 14, 2023
201dff2
remove agreement-related types from util/timeers, merge of zeldovich@…
yossigi Aug 14, 2023
4d811fb
no need for msgp in timers anymore
yossigi Aug 14, 2023
ebbd32b
remove uneeded files
yossigi Aug 14, 2023
be9acf6
one deadline for each type
yossigi Aug 15, 2023
e676f0a
comment explaining why we store the deadline type
yossigi Aug 15, 2023
272f0a6
add two fields for backwards compatibility
cce Aug 15, 2023
089f4cf
update comment, rerun msgp and add test
cce Aug 15, 2023
5dd8764
Merge pull request #5669 from cce/cce/taggedDeadlines-twofields
cce Aug 16, 2023
0a3fbea
don't choose OldDeadline at random, since the unmarshalling logic is …
yossigi Aug 16, 2023
bb94590
next receives Deadline-type timeouts
yossigi Aug 16, 2023
bf9a97c
add TODO
yossigi Aug 17, 2023
7744159
Update agreement/player.go
yossigi Aug 17, 2023
972046f
move type defs to agreement/types.go
yossigi Aug 17, 2023
571458e
Update agreement/types.go
cce Aug 17, 2023
de83831
shorter Deadline construction
yossigi Aug 17, 2023
dfac007
Merge branch 'yossi/taggedDeadlines' of github.com:algorand/go-algora…
yossigi Aug 17, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ALGOD_API_PACKAGES := $(sort $(shell GOPATH=$(GOPATH) && GO111MODULE=off && cd d

GOMOD_DIRS := ./tools/block-generator ./tools/x-repo-types

MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/merklearray ./crypto/merklesignature ./crypto/stateproof ./data/basics ./data/transactions ./data/stateproofmsg ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./network ./node ./ledger ./ledger/ledgercore ./ledger/store/trackerdb ./ledger/store/trackerdb/generickv ./ledger/encoded ./stateproof ./data/account ./daemon/algod/api/spec/v2
MSGP_GENERATE := ./protocol ./protocol/test ./crypto ./crypto/merklearray ./crypto/merklesignature ./crypto/stateproof ./data/basics ./data/transactions ./data/stateproofmsg ./data/committee ./data/bookkeeping ./data/hashable ./agreement ./rpcs ./network ./node ./ledger ./ledger/ledgercore ./ledger/store/trackerdb ./ledger/store/trackerdb/generickv ./ledger/encoded ./stateproof ./data/account ./daemon/algod/api/spec/v2 ./util/timers

default: build

Expand Down
5 changes: 2 additions & 3 deletions agreement/agreementtest/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/util/db"
"github.com/algorand/go-algorand/util/timers"
)
Expand Down Expand Up @@ -60,7 +59,7 @@ func (i *instant) Encode() []byte {
return nil
}

func (i *instant) TimeoutAt(d time.Duration) <-chan time.Time {
func (i *instant) TimeoutAt(d time.Duration, timeoutType timers.TimeoutType) <-chan time.Time {
ta := make(chan time.Time)
select {
case <-i.timeoutAtCalled:
Expand All @@ -69,7 +68,7 @@ func (i *instant) TimeoutAt(d time.Duration) <-chan time.Time {
return ta
}

if d == agreement.FilterTimeout(0, protocol.ConsensusCurrentVersion) && !i.HasPending("pseudonode") {
if timeoutType == timers.Filter && !i.HasPending("pseudonode") {
close(ta)
}
return ta
Expand Down
7 changes: 4 additions & 3 deletions agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/logging/logspec"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/util/timers"
)

const (
Expand Down Expand Up @@ -190,7 +191,7 @@ func (d *demux) verifyBundle(ctx context.Context, m message, r round, p period,
// next blocks until it observes an external input event of interest for the state machine.
//
// If ok is false, there are no more events so the agreement service should quit.
func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Duration, currentRound round) (e externalEvent, ok bool) {
func (d *demux) next(s *Service, deadline Deadline, fastDeadline time.Duration, currentRound round) (e externalEvent, ok bool) {
defer func() {
if !ok {
return
Expand Down Expand Up @@ -250,8 +251,8 @@ func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Durat
}

ledgerNextRoundCh := s.Ledger.Wait(nextRound)
deadlineCh := s.Clock.TimeoutAt(deadline)
fastDeadlineCh := s.Clock.TimeoutAt(fastDeadline)
deadlineCh := s.Clock.TimeoutAt(deadline.Duration, deadline.Type)
fastDeadlineCh := s.Clock.TimeoutAt(fastDeadline, timers.FastRecovery)

d.UpdateEventsQueue(eventQueueDemux, 0)
d.monitor.dec(demuxCoserviceType)
Expand Down
6 changes: 3 additions & 3 deletions agreement/demux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ func (t *demuxTester) Zero() timers.Clock {
}

// implement timers.Clock
func (t *demuxTester) TimeoutAt(delta time.Duration) <-chan time.Time {
if delta == fastTimeoutChTime {
func (t *demuxTester) TimeoutAt(delta time.Duration, timeoutType timers.TimeoutType) <-chan time.Time {
if timeoutType == timers.FastRecovery {
return nil
}

Expand Down Expand Up @@ -675,7 +675,7 @@ func (t *demuxTester) TestUsecase(testcase demuxTestUsecase) bool {
close(s.quit)
}

e, ok := dmx.next(s, time.Second, fastTimeoutChTime, 300)
e, ok := dmx.next(s, Deadline{Duration: time.Second, Type: timers.Deadline}, fastTimeoutChTime, 300)

if !assert.Equal(t, testcase.ok, ok) {
return false
Expand Down
2 changes: 1 addition & 1 deletion agreement/fuzzer/networkFacade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (n *NetworkFacade) Rezero() {
// Since implements the Clock interface.
func (n *NetworkFacade) Since() time.Duration { return 0 }

func (n *NetworkFacade) TimeoutAt(d time.Duration) <-chan time.Time {
func (n *NetworkFacade) TimeoutAt(d time.Duration, timeoutType timers.TimeoutType) <-chan time.Time {
defer n.timeoutAtInitOnce.Do(func() {
n.timeoutAtInitWait.Done()
})
Expand Down
Loading