Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
14 changes: 8 additions & 6 deletions agreement/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,21 @@ func (a ensureAction) do(ctx context.Context, s *Service) {
logEvent.Type = logspec.RoundConcluded
s.log.with(logEvent).Infof("committed round %d with pre-validated block %v", a.Certificate.Round, a.Certificate.Proposal)
s.log.EventWithDetails(telemetryspec.Agreement, telemetryspec.BlockAcceptedEvent, telemetryspec.BlockAcceptedEventDetails{
Address: a.Certificate.Proposal.OriginalProposer.String(),
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
Address: a.Certificate.Proposal.OriginalProposer.String(),
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add to the telemetryspec.BlockAcceptedEventDetails another field to indicate whether it's a prevalidated block or not ?
( i.e. so that this branching would be visible on the telemetry ? )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, that would be interesting to know, sure

})
s.Ledger.EnsureValidatedBlock(a.Payload.ve, a.Certificate)
} else {
block := a.Payload.Block
logEvent.Type = logspec.RoundConcluded
s.log.with(logEvent).Infof("committed round %d with block %v", a.Certificate.Round, a.Certificate.Proposal)
s.log.EventWithDetails(telemetryspec.Agreement, telemetryspec.BlockAcceptedEvent, telemetryspec.BlockAcceptedEventDetails{
Address: a.Certificate.Proposal.OriginalProposer.String(),
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
Address: a.Certificate.Proposal.OriginalProposer.String(),
Hash: a.Certificate.Proposal.BlockDigest.String(),
Round: uint64(a.Certificate.Round),
ValidatedAt: a.Payload.validatedAt,
})
s.Ledger.EnsureBlock(block, a.Certificate)
}
Expand Down
4 changes: 4 additions & 0 deletions agreement/agreementtest/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (i *instant) Zero() timers.Clock {
return i
}

func (i *instant) Since() time.Duration {
return 0
}

func (i *instant) runRound(r basics.Round) {
<-i.Z1 // wait until Zero is called
<-i.timeoutAtCalled
Expand Down
4 changes: 4 additions & 0 deletions agreement/demux.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func (d *demux) next(s *Service, deadline time.Duration, fastDeadline time.Durat
}
proto, err := d.ledger.ConsensusVersion(ParamsRound(e.ConsensusRound()))
e = e.AttachConsensusVersion(ConsensusVersionView{Err: makeSerErr(err), Version: proto})

if e.t() == payloadVerified {
e = e.(messageEvent).AttachValidatedAt(s.Clock.Since())
}
}()

var pseudonodeEvents <-chan externalEvent
Expand Down
5 changes: 5 additions & 0 deletions agreement/demux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ func (t *demuxTester) Decode([]byte) (timers.Clock, error) {
return t, nil
}

// implement timers.Clock
func (t *demuxTester) Since() time.Duration {
return 0
}

// implement Ledger
func (t *demuxTester) NextRound() basics.Round {
return 1234
Expand Down
6 changes: 6 additions & 0 deletions agreement/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package agreement

import (
"fmt"
"time"

"github.com/algorand/go-algorand/logging"
"github.com/algorand/go-algorand/protocol"
Expand Down Expand Up @@ -932,3 +933,8 @@ func (e checkpointEvent) ConsensusRound() round {
func (e checkpointEvent) AttachConsensusVersion(v ConsensusVersionView) externalEvent {
return e
}

func (e messageEvent) AttachValidatedAt(d time.Duration) messageEvent {
e.Input.Proposal.validatedAt = d
return e
}
2 changes: 1 addition & 1 deletion agreement/msgp_gen.go

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

6 changes: 6 additions & 0 deletions agreement/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package agreement
import (
"context"
"fmt"
"time"

"github.com/algorand/go-algorand/crypto"
"github.com/algorand/go-algorand/data/basics"
Expand Down Expand Up @@ -88,6 +89,11 @@ type proposal struct {
// to disk, so after a crash, we will fall back to applying the
// raw Block to the ledger (and re-computing the state delta).
ve ValidatedBlock

// validatedAt indicates the time at which this proposal was
// validated (and thus was ready to be delivered to the state
// machine), relative to the zero of that round.
validatedAt time.Duration
}

func makeProposal(ve ValidatedBlock, pf crypto.VrfProof, origPer period, origProp basics.Address) proposal {
Expand Down
4 changes: 4 additions & 0 deletions agreement/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func (c *testingClock) Zero() timers.Clock {
return c
}

func (c *testingClock) Since() time.Duration {
return 0
}

func (c *testingClock) TimeoutAt(d time.Duration) <-chan time.Time {
c.mu.Lock()
defer c.mu.Unlock()
Expand Down
7 changes: 4 additions & 3 deletions logging/telemetryspec/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ const BlockAcceptedEvent Event = "BlockAccepted"

// BlockAcceptedEventDetails contains details for the BlockAcceptedEvent
type BlockAcceptedEventDetails struct {
Address string
Hash string
Round uint64
Address string
Hash string
Round uint64
ValidatedAt time.Duration
}

// TopAccountsEvent event
Expand Down
5 changes: 5 additions & 0 deletions util/timers/frozen.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ func (m *Frozen) Decode([]byte) (Clock, error) {
func (m *Frozen) String() string {
return ""
}

// Since implements the Clock interface.
func (m *Frozen) Since() time.Duration {
return 0
}
4 changes: 4 additions & 0 deletions util/timers/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type Clock interface {
// at which Zero was called as their reference point.
Zero() Clock

// Since returns the time spent between the last time the clock was zeroed out and the current
// wall clock time.
Since() time.Duration

// TimeoutAt returns a channel that fires delta time after Zero was called.
// If delta has already passed, it returns a closed channel.
//
Expand Down
5 changes: 5 additions & 0 deletions util/timers/monotonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,8 @@ func (m *Monotonic) Decode(data []byte) (Clock, error) {
func (m *Monotonic) String() string {
return time.Time(m.zero).String()
}

// Since returns the time that has passed between the time the clock was last zeroed out and now
func (m *Monotonic) Since() time.Duration {
return time.Since(m.zero)
}