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

dynamic-lambda: continue tracking the best proposal even after freezing #5701

Merged
merged 275 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
275 commits
Select commit Hold shift + click to select a range
0b8e8a5
less logging, params in vfuture
yossigi Aug 10, 2023
75c8081
enough rounds to activate dynamic lambda
yossigi Aug 10, 2023
3a5a1ed
+msgp_gen test
yossigi Aug 10, 2023
32a30fa
Merge branch 'yossi/taggedDeadlines' into feature/dynamic-lambda
yossigi Aug 10, 2023
aa603c9
skip sdk comparison
yossigi Aug 11, 2023
cc5a872
rounds run faster now. Give the txn a little bit more time to live
yossigi Aug 11, 2023
69633c7
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 14, 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
c51731a
95th percentile deadline
yossigi Aug 15, 2023
e676f0a
comment explaining why we store the deadline type
yossigi Aug 15, 2023
9e0a3ff
grace
yossigi Aug 15, 2023
7d39273
add voteVerified ValidatedAt times
cce 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
1ace788
add readLowestEvent from 63c03b907764a583132c55e255d3816d2aad49f8 (or…
cce Aug 16, 2023
911979f
add readLowestVote
cce Aug 15, 2023
83489b5
update handleWinningPayloadArrival and hook up to player tests
cce Aug 16, 2023
93c6a49
rerun msgp
cce Aug 16, 2023
c7b9d96
Update proposalStore.go
cce Aug 16, 2023
951ecd0
Update events.go
cce Aug 16, 2023
905551b
doc new parameter
yossigi Aug 16, 2023
2778bdd
add TestPlayerRetainsReceivedValidatedAtAVPP and comments
cce Aug 16, 2023
d508405
remove readLowestValue and readLowestPayload
cce Aug 16, 2023
6a31232
rename to lowestCredentialArrivals
cce Aug 16, 2023
6a4ea85
fix fmt string
cce Aug 16, 2023
e178503
fix TestPlayerRetainsReceivedValidatedAt tests
cce Aug 16, 2023
bb94590
next receives Deadline-type timeouts
yossigi Aug 16, 2023
b161d7d
Merge pull request #5671 from cce/dynamic-lambda-vote-validatedAt
cce Aug 16, 2023
83bf00f
credential tracking
yossigi Aug 16, 2023
1404411
conflict fix from taggedDeadlines
yossigi Aug 16, 2023
3580617
address some of the comments
yossigi Aug 17, 2023
53838ab
history window tests
yossigi Aug 17, 2023
ea35ee3
nits
yossigi Aug 17, 2023
0bcdf19
typo
yossigi Aug 17, 2023
4cfb6aa
off switch in config
yossigi Aug 17, 2023
d459e78
checkpoint: positive test
yossigi Aug 17, 2023
bbfe2ae
fix testingClock.Since to give non zero measurements
yossigi Aug 18, 2023
b88eab3
add negative test: make sure we discard history window when going to …
yossigi Aug 18, 2023
d14bde2
tagged clock interface
yossigi Aug 9, 2023
b53d93e
checkpoint: integrating the new clock
yossigi Aug 9, 2023
85585bc
checkpoint: integrating tagged timers
yossigi Aug 9, 2023
5bce862
fix failing tests
yossigi Aug 10, 2023
786e779
names refactor
yossigi Aug 10, 2023
e02464f
add some pieces of dynamic lambda from feature/pipeline into agreement
cce Aug 2, 2023
b7feca1
add/adapt code from pipelinePlayer.resizeArrivals on feature/pipeline
cce Aug 3, 2023
b999bee
checkpoint: param cleanup
yossigi Aug 8, 2023
15eaa70
reset history on non-0 periods
yossigi Aug 8, 2023
358c0eb
test clock tweak
yossigi Aug 9, 2023
be5fe0f
avoid weird clock tweak
yossigi Aug 10, 2023
58ac6e8
msgp for tagged deadline
yossigi Aug 10, 2023
f679c57
fix lint issues
yossigi Aug 10, 2023
a8b9998
fix lint issues
yossigi Aug 10, 2023
05cbd97
parameter cleanup + logging
yossigi Aug 10, 2023
06b0acd
lint
yossigi Aug 10, 2023
32c9423
less logging, params in vfuture
yossigi Aug 10, 2023
5f049d7
enough rounds to activate dynamic lambda
yossigi Aug 10, 2023
85dba70
+msgp_gen test
yossigi Aug 10, 2023
4a258eb
skip sdk comparison
yossigi Aug 11, 2023
cbd2bbf
rounds run faster now. Give the txn a little bit more time to live
yossigi Aug 11, 2023
9c3c43b
95th percentile deadline
yossigi Aug 15, 2023
60e7bf3
grace
yossigi Aug 15, 2023
0d7ea4b
doc new parameter
yossigi Aug 16, 2023
c8b59c3
add voteVerified ValidatedAt times
cce Aug 15, 2023
1c60257
add readLowestEvent from 63c03b907764a583132c55e255d3816d2aad49f8 (or…
cce Aug 16, 2023
fbb4234
add readLowestVote
cce Aug 15, 2023
f3aa450
update handleWinningPayloadArrival and hook up to player tests
cce Aug 16, 2023
822e946
rerun msgp
cce Aug 16, 2023
a9e9bfc
Update proposalStore.go
cce Aug 16, 2023
97fcbc2
Update events.go
cce Aug 16, 2023
8681dca
add TestPlayerRetainsReceivedValidatedAtAVPP and comments
cce Aug 16, 2023
ffc75d2
remove readLowestValue and readLowestPayload
cce Aug 16, 2023
a3b1f48
rename to lowestCredentialArrivals
cce Aug 16, 2023
23941a2
fix fmt string
cce Aug 16, 2023
005dfbf
fix TestPlayerRetainsReceivedValidatedAt tests
cce Aug 16, 2023
8a89821
generic timeout type for timers.Clock
zeldovich Aug 10, 2023
f88b521
no need for msgp in timers anymore
yossigi Aug 14, 2023
8f884e8
remove uneeded files
yossigi Aug 14, 2023
cf06cad
one deadline for each type
yossigi Aug 15, 2023
3b61b8a
comment explaining why we store the deadline type
yossigi Aug 15, 2023
9ce34be
address some of the comments
yossigi Aug 17, 2023
1d7e6e4
history window tests
yossigi Aug 17, 2023
974a74b
nits
yossigi Aug 17, 2023
b9c9613
typo
yossigi Aug 17, 2023
effc907
off switch in config
yossigi Aug 17, 2023
52621f5
checkpoint: positive test
yossigi Aug 17, 2023
1962351
fix testingClock.Since to give non zero measurements
yossigi Aug 18, 2023
2d74e27
add negative test: make sure we discard history window when going to …
yossigi Aug 18, 2023
34d5f94
rebase on master
yossigi Aug 18, 2023
e5da589
merge
yossigi Aug 18, 2023
1c99da0
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 18, 2023
2aef8af
remove unused variable
yossigi Aug 18, 2023
4af3e2e
remove unneeded checks
yossigi Aug 18, 2023
7b0b9d2
shorter clamping
yossigi Aug 18, 2023
d47671e
handle unfilled votes
yossigi Aug 21, 2023
292284e
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 21, 2023
be77e7e
no printing
yossigi Aug 21, 2023
b84d3ab
logging the right timeout
yossigi Aug 21, 2023
fe288a3
fix
yossigi Aug 21, 2023
a9ef051
add voteValidatedAt to telemetry
cce Aug 21, 2023
d4604d1
Merge pull request #5691 from cce/dynamic-lambda-telemetry-voteValida…
yossigi Aug 22, 2023
950de96
add dynamicFilterTimeout to BlockAcceptedEvent
cce Aug 22, 2023
ba6a55a
rerun make msgp
cce Aug 22, 2023
23d26ac
Merge pull request #5698 from cce/dynamicFilterTimeout-telemetry
yossigi Aug 22, 2023
7016377
move dynamic filter timeout parameters to consts
yossigi Aug 22, 2023
50a9ac0
+license
yossigi Aug 22, 2023
21ecfec
document new event
yossigi Aug 22, 2023
4fc7304
continue tracking the best proposal even after freezing
yossigi Aug 22, 2023
e260bf7
use right cred
yossigi Aug 22, 2023
52d9647
checkpoint: more backward compatible change
yossigi Aug 23, 2023
0df7082
relay only behavior
yossigi Aug 23, 2023
8e83a2e
doc line
yossigi Aug 23, 2023
8b0984c
keep old routers for longer
yossigi Aug 23, 2023
df7f645
take credential arrival times from credentialRoundLag ago
yossigi Aug 23, 2023
8082f79
lint
yossigi Aug 23, 2023
aa341b2
proposalManager doesn't filter old votes + test
yossigi Aug 24, 2023
1b8f21d
nits
yossigi Aug 24, 2023
df15f6b
update comment
yossigi Aug 24, 2023
5c2ece2
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 24, 2023
e08143b
fixed tests
yossigi Aug 24, 2023
3e1592b
less conversions
yossigi Aug 24, 2023
128686e
off by 2
yossigi Aug 24, 2023
9a4dfea
var rename
yossigi Aug 25, 2023
4d72b15
credential propagation bound is 2SmallLambda
yossigi Aug 25, 2023
9413913
document parameters
yossigi Aug 26, 2023
bab29e7
test
yossigi Aug 26, 2023
17c48d1
circular history buffer
yossigi Aug 26, 2023
57c2e39
credential history tests
yossigi Aug 26, 2023
a5bb314
move logic to credentialhistory
yossigi Aug 26, 2023
7a24b27
efficiency remark
yossigi Aug 26, 2023
e32460b
fix off by 1 in test
yossigi Aug 26, 2023
d8438b7
sanity
yossigi Aug 26, 2023
7e51ae8
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 26, 2023
22b8c87
checkpoint
yossigi Aug 26, 2023
253ab05
fix unittest: now looking at specific rounds
yossigi Aug 26, 2023
04f607a
tighter checks
yossigi Aug 26, 2023
5e7ad38
tighter checks in tests
yossigi Aug 26, 2023
e01ffe6
msgp
yossigi Aug 26, 2023
bd007d2
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 26, 2023
6e676cf
partition test comments
yossigi Aug 27, 2023
20d3c2a
fix lint issues, push lowerbound to 1/2s
yossigi Aug 27, 2023
4d03bde
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 27, 2023
f2edc3f
store method documentation
yossigi Aug 28, 2023
5ca8a27
credentialArrivalHistory documentation
yossigi Aug 28, 2023
bd2c576
Update agreement/credentialArrivalHistory.go
yossigi Aug 28, 2023
4c1e706
addressing pr comments
yossigi Aug 28, 2023
a055334
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
f6979bc
comment about dynamic lambda
yossigi Aug 28, 2023
6a6eec0
1 line less
yossigi Aug 28, 2023
35de996
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
b1495d2
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 28, 2023
9af5a2b
Merge branch 'master' into yossi/credentialProp
yossigi Aug 28, 2023
7e9f8b5
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
98524f0
credential history be non pointer
yossigi Aug 28, 2023
0d72d56
more legible test
yossigi Aug 28, 2023
e924e7c
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
79e1904
partitiontest
yossigi Aug 28, 2023
3162243
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
40935ed
partitiontest
yossigi Aug 28, 2023
27af0b6
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
27f1374
remove redundant check
yossigi Aug 28, 2023
c1dea69
fix decoding
yossigi Aug 28, 2023
0ce9fea
allocate once at the end
yossigi Aug 28, 2023
a7b6d6f
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
7c1032d
partition test
yossigi Aug 28, 2023
ba1fc25
set player before passing to router
yossigi Aug 28, 2023
d23b1a3
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 28, 2023
b79b14c
use special consensus version for tests
yossigi Aug 29, 2023
529278a
revert e2e test changes
yossigi Aug 29, 2023
4fe6b66
commented out dynamic filter flag assignment
yossigi Aug 29, 2023
ecf406e
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 29, 2023
bfa4e01
historical clocks
yossigi Aug 30, 2023
6243be5
timestamp messages from future rounds at 0
yossigi Aug 30, 2023
869ee41
verified/unauthenticated vote
yossigi Aug 30, 2023
254f768
comment
yossigi Aug 30, 2023
ee9ebed
checkpoint: with historical clocks
yossigi Aug 30, 2023
929fa54
updated tests to match historical clocks state keeping
yossigi Aug 30, 2023
dc975c7
tests for late coming messages
yossigi Aug 30, 2023
ab7c83b
Merge branch 'master' into feature/dynamic-lambda
yossigi Aug 30, 2023
c33650e
Merge branch 'feature/dynamic-lambda' into yossi/credentialProp
yossigi Aug 30, 2023
3eeaebe
historical clocks cleanup
yossigi Aug 30, 2023
61d0aa0
more checks that service keeps the right clocks
yossigi Aug 31, 2023
9cc1caa
merge in master
yossigi Aug 31, 2023
56e5ca7
Merge branch 'master' into yossi/credentialProp
yossigi Aug 31, 2023
10c7f30
merge
yossigi Aug 31, 2023
e54e550
fix sdk comparison test
yossigi Aug 31, 2023
c490e92
Update agreement/proposalManager.go
yossigi Aug 31, 2023
82a659f
nits
yossigi Aug 31, 2023
9163199
fmt
yossigi Aug 31, 2023
ef88e2d
update TestProposalTrackerProposalSeeker
cce Sep 1, 2023
8d6a5f1
Update agreement/player.go
yossigi Sep 1, 2023
6d44753
Update agreement/proposalTracker.go
yossigi Sep 1, 2023
19f077c
add LowestAfterFreeze to readLowestEvent
cce Sep 1, 2023
36ce1cd
Merge remote-tracking branch 'upstream/yossi/credentialProp' into cre…
cce Sep 1, 2023
9ad9dbb
fix test off by 1
yossigi Sep 1, 2023
578ac8c
Merge pull request #5723 from cce/credentialProp-tweaks
yossigi Sep 1, 2023
4f17cfd
Update agreement/proposalTracker.go
cce Sep 1, 2023
890b9bc
fix fmt
cce Sep 1, 2023
ebbb6f6
gating relay policy change behind consensus upgrade
yossigi Sep 1, 2023
5b720e6
split proposalFresh and proposalUsedForCredentialHistory
cce Sep 1, 2023
2c6122b
Merge pull request #5724 from cce/credentialProp-change
yossigi Sep 1, 2023
59ecd4e
use named constant
yossigi Sep 1, 2023
b8b128a
relay vs ignore msg issue
yossigi Sep 2, 2023
f6ed967
checkpoint: relay rules
yossigi Sep 2, 2023
b3b07ff
relay action order
yossigi Sep 2, 2023
58db3f8
x
yossigi Sep 2, 2023
7038dfa
fix test by enabling dynamic filter timeout feature
yossigi Sep 2, 2023
44d862b
explicitly enable dyamic filter timeout for permutation test
yossigi Sep 2, 2023
7078340
code cleanup
yossigi Sep 2, 2023
291a48c
better comment
yossigi Sep 2, 2023
f2fcc97
switch to enum
yossigi Sep 3, 2023
8ff1607
msgp
yossigi Sep 3, 2023
f1c1b46
var name
yossigi Sep 3, 2023
fd83858
fix lint errors
yossigi Sep 3, 2023
418edcc
debug logging
yossigi Sep 3, 2023
6b2ca69
combine loops
yossigi Sep 5, 2023
50d7be4
simplify verifyPermutationExpectedActions
cce Sep 5, 2023
999ea5f
Apply suggestions from code review
yossigi Sep 5, 2023
a4ab04a
Update agreement/player_permutation_test.go
yossigi Sep 5, 2023
cf65c53
x
yossigi Sep 5, 2023
4ec269b
fix typos
cce Sep 5, 2023
1078864
rename and document CredentialTrackingNote enum values a little
cce Sep 5, 2023
5192344
new test for late arriviong credentials where the first credential is…
yossigi Sep 6, 2023
917e25f
check staging after updating credential tracking
yossigi Sep 6, 2023
704494b
Update agreement/proposalTracker.go
yossigi Sep 6, 2023
da6e736
add TestPlayerRetainsReceivedValidatedAtForHistoryWindowLateBetter an…
cce Sep 7, 2023
b3b6cb5
don't persist agreement state for old rounds
cce Sep 18, 2023
363f531
dynamic-lambda: improve handling of duplicate votes and update player…
cce Sep 29, 2023
0372df0
Update agreement/proposalManager.go
cce Oct 5, 2023
41bdce0
Update agreement/events.go
cce Oct 5, 2023
05db006
Update agreement/events.go
cce Oct 5, 2023
e6104d5
CR changes
cce Oct 5, 2023
f42cad3
rename LowestAfterFreeze => LowestIncludingLate
cce Oct 5, 2023
461ebc8
use switch in AttachReceivedAt
cce Oct 5, 2023
cc6d9fb
fix encode to not replace nil rr.Children maps with empty maps
cce Oct 5, 2023
dedcd0a
downgrade to nil in encoding rr.Children instead
cce Oct 5, 2023
a91d4e8
Merge remote-tracking branch 'upstream/master' into yossi/credentialProp
cce Oct 6, 2023
9d3613e
re-run make msgp with latest master
cce Oct 6, 2023
8c3da99
update CredentialTracking => LateCredentialTracking
cce Oct 6, 2023
b4f8598
Update agreement/player.go
cce Oct 11, 2023
aa952c0
add clockForRound to support AttachReceivedAt/AttachValidatedAt
cce Oct 11, 2023
81c4bc8
remove unused errProposalManagerPVFreshness and errProposalManagerPVD…
cce Oct 11, 2023
5923d76
rerun "make msgp"
cce Oct 12, 2023
b62d48d
rename roundZeroTimer => roundStartTimer and //msgp:ignore constantRo…
cce Oct 12, 2023
be63b9e
fix comment
cce Oct 12, 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
47 changes: 47 additions & 0 deletions agreement/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
do(context.Context, *Service)

String() string
ComparableStr() string
}

type nonpersistent struct{}
Expand All @@ -88,6 +89,8 @@
return a.t().String()
}

func (a noopAction) ComparableStr() string { return a.String() }

Check warning on line 92 in agreement/actions.go

View check run for this annotation

Codecov / codecov/patch

agreement/actions.go#L92

Added line #L92 was not covered by tests

type networkAction struct {
nonpersistent

Expand Down Expand Up @@ -120,6 +123,13 @@
return fmt.Sprintf("%s: %2v", a.t().String(), a.Tag)
}

func (a networkAction) ComparableStr() string {
if a.Tag == protocol.AgreementVoteTag {
return fmt.Sprintf("%s: %2v: %3v-%2v-%2v", a.t().String(), a.Tag, a.UnauthenticatedVote.R.Round, a.UnauthenticatedVote.R.Period, a.UnauthenticatedVote.R.Step)
}
gmalouf marked this conversation as resolved.
Show resolved Hide resolved
return a.String()
}

func (a networkAction) do(ctx context.Context, s *Service) {
if a.T == broadcastVotes {
tag := protocol.AgreementVoteTag
Expand Down Expand Up @@ -192,6 +202,18 @@
return a.t().String()
}

func (a cryptoAction) ComparableStr() (s string) {
switch a.T {
case verifyVote:
s = fmt.Sprintf("%s: %3v-%2v TaskIndex %d", a.t().String(), a.Round, a.Period, a.TaskIndex)
case verifyPayload:
s = fmt.Sprintf("%s: %3v-%2v Pinned %v", a.t().String(), a.Round, a.Period, a.Pinned)
case verifyBundle:
s = fmt.Sprintf("%s: %3v-%2v-%2v", a.t().String(), a.Round, a.Period, a.Step)
gmalouf marked this conversation as resolved.
Show resolved Hide resolved
}
return
}

func (a cryptoAction) do(ctx context.Context, s *Service) {
switch a.T {
case verifyVote:
Expand Down Expand Up @@ -225,6 +247,8 @@
return fmt.Sprintf("%s: %.5s: %v, %v, %.5s", a.t().String(), a.Payload.Digest().String(), a.Certificate.Round, a.Certificate.Period, a.Certificate.Proposal.BlockDigest.String())
}

func (a ensureAction) ComparableStr() string { return a.String() }

func (a ensureAction) do(ctx context.Context, s *Service) {
logEvent := logspec.AgreementEvent{
Hash: a.Certificate.Proposal.BlockDigest.String(),
Expand Down Expand Up @@ -288,6 +312,8 @@
return fmt.Sprintf("%s: %.5s. %v. %v", a.t().String(), a.Certificate.Proposal.BlockDigest.String(), a.Certificate.Round, a.Certificate.Period)
}

func (a stageDigestAction) ComparableStr() string { return a.String() }

func (a stageDigestAction) do(ctx context.Context, service *Service) {
logEvent := logspec.AgreementEvent{
Hash: a.Certificate.Proposal.BlockDigest.String(),
Expand All @@ -314,8 +340,25 @@
return a.t().String()
}

func (a rezeroAction) ComparableStr() string {
return fmt.Sprintf("%s: %d", a.t().String(), a.Round)
}

func (a rezeroAction) do(ctx context.Context, s *Service) {
s.Clock = s.Clock.Zero()
// Preserve the zero time of the new round a.Round (for
// period 0) for future use if a late proposal-vote arrives,
// for late credential tracking.
if _, ok := s.historicalClocks[a.Round]; !ok {
s.historicalClocks[a.Round] = s.Clock
}
jannotti marked this conversation as resolved.
Show resolved Hide resolved

// Garbage collect clocks that are too old
for rnd := range s.historicalClocks {
if a.Round > rnd+credentialRoundLag {
delete(s.historicalClocks, rnd)

Check warning on line 359 in agreement/actions.go

View check run for this annotation

Codecov / codecov/patch

agreement/actions.go#L359

Added line #L359 was not covered by tests
yossigi marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

type pseudonodeAction struct {
Expand All @@ -336,6 +379,8 @@
return fmt.Sprintf("%v %3v-%2v-%2v: %.5v", a.t().String(), a.Round, a.Period, a.Step, a.Proposal.BlockDigest.String())
}

func (a pseudonodeAction) ComparableStr() string { return a.String() }

func (a pseudonodeAction) persistent() bool {
return a.T == attest
}
Expand Down Expand Up @@ -528,3 +573,5 @@
func (c checkpointAction) String() string {
return c.t().String()
}

func (c checkpointAction) ComparableStr() string { return c.String() }

Check warning on line 577 in agreement/actions.go

View check run for this annotation

Codecov / codecov/patch

agreement/actions.go#L577

Added line #L577 was not covered by tests
6 changes: 3 additions & 3 deletions agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ func (d *demux) next(s *Service, deadline Deadline, fastDeadline Deadline, curre

switch e.t() {
case payloadVerified:
e = e.(messageEvent).AttachValidatedAt(s.Clock.Since(), currentRound)
e = e.(messageEvent).AttachValidatedAt(clockForRound(currentRound, s.Clock, s.historicalClocks))
case payloadPresent, votePresent:
e = e.(messageEvent).AttachReceivedAt(s.Clock.Since(), currentRound)
e = e.(messageEvent).AttachReceivedAt(clockForRound(currentRound, s.Clock, s.historicalClocks))
case voteVerified:
// if this is a proposal vote (step 0), record the validatedAt time on the vote
if e.(messageEvent).Input.Vote.R.Step == 0 {
e = e.(messageEvent).AttachValidatedAt(s.Clock.Since(), currentRound)
e = e.(messageEvent).AttachValidatedAt(clockForRound(currentRound, s.Clock, s.historicalClocks))
}
}
}()
Expand Down
95 changes: 68 additions & 27 deletions agreement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (e messageEvent) String() string {
}

func (e messageEvent) ComparableStr() string {
return e.T.String()
return fmt.Sprintf("{T:%s %d Err:%v}", e.t().String(), e.ConsensusRound(), e.Err)
}

func (e messageEvent) ConsensusRound() round {
Expand Down Expand Up @@ -424,9 +424,14 @@ type readLowestEvent struct {

// Vote holds the lowest-credential vote.
Vote vote
// LowestIncludingLate holds the lowest-credential vote that was received, including
// after Vote has been frozen.
LowestIncludingLate vote

// Filled indicates whether the Vote field is filled
Filled bool
// Filled and HasLowestIncludingLate indicates whether the Vote or LowestIncludingLate
// fields are filled, respectively.
Filled bool
HasLowestIncludingLate bool
}

func (e readLowestEvent) t() eventType {
Expand Down Expand Up @@ -591,10 +596,36 @@ func (e payloadProcessedEvent) ComparableStr() string {
return fmt.Sprintf("%v: %.5v", e.t().String(), e.Proposal.BlockDigest.String())
}

// LateCredentialTrackingEffect indicates the impact of a vote that was filtered (due to age)
// on the credential tracking system (in credentialArrivalHistory), for the purpose of tracking
// the time it took the best credential to arrive, even if it was late.
type LateCredentialTrackingEffect uint8

const (
// NoLateCredentialTrackingImpact indicates the filtered event would have no impact on
// the credential tracking mechanism.
NoLateCredentialTrackingImpact LateCredentialTrackingEffect = iota

// UnverifiedLateCredentialForTracking indicates the filtered event could impact
// the credential tracking mechanism and more processing (validation) may be required.
// It may be set by proposalManager when handling votePresent events.
UnverifiedLateCredentialForTracking

// VerifiedBetterLateCredentialForTracking indicates that the filtered event provides a new best
// credential for its round.
// It may be set by proposalManager when handling voteVerified events.
VerifiedBetterLateCredentialForTracking
)

type filteredEvent struct {
// {proposal,vote,bundle}{Filtered,Malformed}
T eventType

// LateCredentialTrackingNote indicates the impact of the filtered event on the
// credential tracking machinery used for dynamically setting the filter
// timeout.
LateCredentialTrackingNote LateCredentialTrackingEffect

// Err is the reason cryptographic verification failed and is set for
// events {proposal,vote,bundle}Malformed.
Err *serializableError
Expand Down Expand Up @@ -975,50 +1006,60 @@ func (e checkpointEvent) AttachConsensusVersion(v ConsensusVersionView) external
return e
}

// This timestamp is assigned to messages that arrive for round R+1 while the current player
// is still waiting for quorum on R.
const pipelinedMessageTimestamp = time.Nanosecond

//msgp:ignore constantRoundStartTimer
type constantRoundStartTimer time.Duration

func (c constantRoundStartTimer) Since() time.Duration { return time.Duration(c) }

// clockForRound retrieves the roundStartTimer used for AttachValidatedAt and AttachReceivedAt.
func clockForRound(currentRound round, currentClock roundStartTimer, historicalClocks map[round]roundStartTimer) func(round) roundStartTimer {
return func(eventRound round) roundStartTimer {
if eventRound > currentRound {
return constantRoundStartTimer(pipelinedMessageTimestamp)
}
if eventRound == currentRound {
return currentClock
}
if clock, ok := historicalClocks[eventRound]; ok {
return clock
}
return constantRoundStartTimer(0)
}
}

// AttachValidatedAt looks for a validated proposal or vote inside a
// payloadVerified or voteVerified messageEvent, and attaches the given time to
// the proposal's validatedAt field.
func (e messageEvent) AttachValidatedAt(d time.Duration, currentRound round) messageEvent {
func (e messageEvent) AttachValidatedAt(getClock func(eventRound round) roundStartTimer) messageEvent {
switch e.T {
case payloadVerified:
if e.Input.Proposal.Round() > currentRound {
e.Input.Proposal.validatedAt = 1
} else {
e.Input.Proposal.validatedAt = d
}
e.Input.Proposal.validatedAt = getClock(e.Input.Proposal.Round()).Since()
case voteVerified:
if e.Input.Vote.R.Round > currentRound {
e.Input.Vote.validatedAt = 1
} else {
e.Input.Vote.validatedAt = d
}
e.Input.Vote.validatedAt = getClock(e.Input.Vote.R.Round).Since()
}
return e
}

// AttachReceivedAt looks for an unauthenticatedProposal inside a
// payloadPresent or votePresent messageEvent, and attaches the given
// time to the proposal's receivedAt field.
func (e messageEvent) AttachReceivedAt(d time.Duration, currentRound round) messageEvent {
if e.T == payloadPresent {
if e.Input.UnauthenticatedProposal.Round() > currentRound {
e.Input.UnauthenticatedProposal.receivedAt = 1
} else {
e.Input.UnauthenticatedProposal.receivedAt = d
}
} else if e.T == votePresent {
func (e messageEvent) AttachReceivedAt(getClock func(eventRound round) roundStartTimer) messageEvent {
switch e.T {
case payloadPresent:
e.Input.UnauthenticatedProposal.receivedAt = getClock(e.Input.UnauthenticatedProposal.Round()).Since()
case votePresent:
// Check for non-nil Tail, indicating this votePresent event
// contains a synthetic payloadPresent event that was attached
// to it by setupCompoundMessage.
if e.Tail != nil && e.Tail.T == payloadPresent {
// The tail event is payloadPresent, serialized together
// with the proposal vote as a single CompoundMessage
// using a protocol.ProposalPayloadTag network message.
if e.Tail.Input.UnauthenticatedProposal.Round() > currentRound {
e.Tail.Input.UnauthenticatedProposal.receivedAt = 1
} else {
e.Tail.Input.UnauthenticatedProposal.receivedAt = d
}
e.Tail.Input.UnauthenticatedProposal.receivedAt = getClock(e.Tail.Input.UnauthenticatedProposal.Round()).Since()
}
}
return e
Expand Down
70 changes: 70 additions & 0 deletions agreement/msgp_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions agreement/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ func persistent(as []action) bool {
// encode serializes the current state into a byte array.
func encode(t timers.Clock[TimeoutType], rr rootRouter, p player, a []action, reflect bool) (raw []byte) {
var s diskState

// Don't persist state for old rounds
// rootRouter.update() may preserve roundRouters from credentialRoundLag rounds ago
jannotti marked this conversation as resolved.
Show resolved Hide resolved
children := make(map[round]*roundRouter)
for rnd, rndRouter := range rr.Children {
if rnd >= p.Round {
children[rnd] = rndRouter
}
}
if len(children) == 0 {
rr.Children = nil
} else {
rr.Children = children
}

if reflect {
s.Router = protocol.EncodeReflect(rr)
s.Player = protocol.EncodeReflect(p)
Expand Down
Loading