8000 feat: Instrument VoteExtension status [BLO-792] by nivasan1 · Pull Request #41 · skip-mev/connect · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

feat: Instrument VoteExtension status [BLO-792] #41

Merged
merged 13 commits into from
Jan 26, 2024
Merged
23 changes: 2 additions & 21 deletions abci/proposals/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,7 @@ func (h *ProposalHandler) PrepareProposalHandler() sdk.PrepareProposalHandler {
"slinky prepare proposal latency", (totalLatency - wrappedPrepareProposalLatency).Seconds(),
)

// record latency
h.metrics.ObserveABCIMethodLatency(servicemetrics.PrepareProposal, totalLatency-wrappedPrepareProposalLatency)

// record success/failure
var label servicemetrics.Labeller
if err != nil {
label, _ = err.(servicemetrics.Labeller)
} else {
label = servicemetrics.Success{}
}
h.metrics.AddABCIRequest(servicemetrics.PrepareProposal, label)
types.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedPrepareProposalLatency, err, servicemetrics.PrepareProposal)
}()

if req == nil {
Expand Down Expand Up @@ -261,16 +251,7 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
"wrapped prepare proposal latency", wrappedProcessProposalLatency.Seconds(),
"slinky prepare proposal latency", (totalLatency - wrappedProcessProposalLatency).Seconds(),
)
h.metrics.ObserveABCIMethodLatency(servicemetrics.ProcessProposal, totalLatency-wrappedProcessProposalLatency)

// record success/failure
var label servicemetrics.Labeller
if err != nil {
label, _ = err.(servicemetrics.Labeller)
} else {
label = servicemetrics.Success{}
}
h.metrics.AddABCIRequest(servicemetrics.ProcessProposal, label)
types.RecordLatencyAndStatus(h.metrics, totalLatency-wrappedProcessProposalLatency, err, servicemetrics.ProcessProposal)
}()

// this should never happen, but just in case
Expand Down
2 changes: 0 additions & 2 deletions abci/proposals/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ func (s *ProposalsTestSuite) TestProposalLatency() {
s.Require().True(latency >= 100*time.Millisecond) // shld have included validate vote extensions latency
s.Require().True(latency < 300*time.Millisecond) // shld have ignored the wrapped processProposal latency
}).Once()

metricsmocks.On("AddABCIRequest", servicemetrics.ProcessProposal, servicemetrics.Success{}).Once()
_, err = propHandler.ProcessProposalHandler()(s.ctx, req)
s.Require().NoError(err)
Expand Down Expand Up @@ -1075,7 +1074,6 @@ func (s *ProposalsTestSuite) TestPrepareProposalStatus() {
metricsMocks.On("AddABCIRequest", servicemetrics.PrepareProposal, expErr).Once()

metricsMocks.On("ObserveABCIMethodLatency", servicemetrics.PrepareProposal, mock.Anything).Return()

// make vote-extensions not enabled to skip validate vote extensions
s.ctx = s.ctx.WithBlockHeight(1)
s.ctx = testutils.UpdateContextWithVEHeight(s.ctx, 3)
Expand Down
5 changes: 5 additions & 0 deletions abci/strategies/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var (
)

// VoteExtensionCodec is the interface for encoding / decoding vote extensions.
//
//go:generate mockery --name VoteExtensionCodec --filename vote_extension_codec.go
type VoteExtensionCodec interface {
// Encode encodes the vote extension into a byte array.
Encode(ve vetypes.OracleVoteExtension) ([]byte, error)
Expand All @@ -26,6 +28,8 @@ type VoteExtensionCodec interface {
}

// ExtendedCommitCodec is the interface for encoding / decoding extended commit info.
//
//go:generate mockery --name ExtendedCommitCodec --filename extended_commit_codec.go
type ExtendedCommitCodec interface {
// Encode encodes the extended commit info into a byte array.
Encode(cometabci.ExtendedCommitInfo) ([]byte, error)
Expand All @@ -35,6 +39,7 @@ type ExtendedCommitCodec interface {
}

// NewDefaultVoteExtensionCodec returns a new DefaultVoteExtensionCodec.

func NewDefaultVoteExtensionCodec() *DefaultVoteExtensionCodec {
return &DefaultVoteExtensionCodec{}
}
Expand Down
78 changes: 78 additions & 0 deletions abci/strategies/codec/mocks/extended_commit_codec.go

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

78 changes: 78 additions & 0 deletions abci/strategies/codec/mocks/vote_extension_codec.go

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

25 changes: 25 additions & 0 deletions abci/types/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package types

import (
"time"

servicemetrics "github.com/skip-mev/slinky/service/metrics"
)

// RecordLatencyAndStatus is used by the ABCI handlers to record their e2e latency, and the status of the request
// to their corresponding metrics objects.
func RecordLatencyAndStatus(
metrics servicemetrics.Metrics, latency time.Duration, err error, method servicemetrics.ABCIMethod,
) {
Comment on lines +11 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this just be a method on servicemetrics.Metrics ?

// observe latency
metrics.ObserveABCIMethodLatency(method, latency)

// increment the number of extend vote requests
var label servicemetrics.Labeller
if err != nil {
label, _ = err.(servicemetrics.Labeller)
} else {
label = servicemetrics.Success{}
}
metrics.AddABCIRequest(method, label)
}
71 changes: 71 additions & 0 deletions abci/ve/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package ve

import (
"fmt"
)

// PreBlockError is an error that is returned when the pre-block simulation fails.
type PreBlockError struct {
Err error
}

func (e PreBlockError) Error() string {
return fmt.Sprintf("finalize block error: %s", e.Err.Error())
}

func (e PreBlockError) Label() string {
return "PreBlockError"
}

// Panic is an error that is returned when a panic occurs in the ABCI handler.
type Panic struct {
Err error
}

func (e Panic) Error() string {
return fmt.Sprintf("panic: %s", e.Err.Error())
}

func (e Panic) Label() string {
return "Panic"
}

// OracleClientError is an error that is returned when the oracle client's response is invalid.
type OracleClientError struct {
Err error
}

func (e OracleClientError) Error() string {
return fmt.Sprintf("oracle client error: %s", e.Err.Error())
}

func (e OracleClientError) Label() string {
return "OracleClientError"
}

// TransformPricesError is an error that is returned when there is a failure in attempting to transform the prices returned
// from the oracle server to the format expected by the validator set.
type TransformPricesError struct {
Err error
}

func (e TransformPricesError) Error() string {
return fmt.Sprintf("prices transform error: %s", e.Err.Error())
}

func (e TransformPricesError) Label() string {
return "TransformPricesError"
}

// ValidateVoteExtensionError is an error that is returned when there is a failure in validating a vote extension.
type ValidateVoteExtensionError struct {
Err error
}

func (e ValidateVoteExtensionError) Error() string {
return fmt.Sprintf("validate vote extension error: %s", e.Err.Error())
}

func (e ValidateVoteExtensionError) Label() string {
return "ValidateVoteExtensionError"
}
Loading
0