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

Remove useless bootstrapping metric #2858

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions snow/engine/avalanche/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ func (b *bootstrapper) Start(ctx context.Context, startReqID uint32) error {
if err := b.VtxBlocked.SetParser(ctx, &vtxParser{
log: b.Ctx.Log,
numAccepted: b.numAcceptedVts,
numDropped: b.numDroppedVts,
manager: b.Manager,
}); err != nil {
return err
Expand All @@ -334,7 +333,6 @@ func (b *bootstrapper) Start(ctx context.Context, startReqID uint32) error {
if err := b.TxBlocked.SetParser(&txParser{
log: b.Ctx.Log,
numAccepted: b.numAcceptedTxs,
numDropped: b.numDroppedTxs,
vm: b.VM,
}); err != nil {
return err
Expand Down Expand Up @@ -475,7 +473,6 @@ func (b *bootstrapper) process(ctx context.Context, vtxs ...avalanche.Vertex) er
pushed, err := b.VtxBlocked.Push(ctx, &vertexJob{
log: b.Ctx.Log,
numAccepted: b.numAcceptedVts,
numDropped: b.numDroppedVts,
vtx: vtx,
})
if err != nil {
Expand All @@ -497,7 +494,6 @@ func (b *bootstrapper) process(ctx context.Context, vtxs ...avalanche.Vertex) er
pushed, err := b.TxBlocked.Push(ctx, &txJob{
log: b.Ctx.Log,
numAccepted: b.numAcceptedTxs,
numDropped: b.numDroppedTxs,
tx: tx,
})
if err != nil {
Expand Down
16 changes: 2 additions & 14 deletions snow/engine/avalanche/bootstrap/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

type metrics struct {
numFetchedVts, numDroppedVts, numAcceptedVts,
numFetchedTxs, numDroppedTxs, numAcceptedTxs prometheus.Counter
numFetchedVts, numAcceptedVts,
numFetchedTxs, numAcceptedTxs prometheus.Counter
}

func (m *metrics) Initialize(
Expand All @@ -23,11 +23,6 @@ func (m *metrics) Initialize(
Name: "fetched_vts",
Help: "Number of vertices fetched during bootstrapping",
})
m.numDroppedVts = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "dropped_vts",
Help: "Number of vertices dropped during bootstrapping",
})
m.numAcceptedVts = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted_vts",
Expand All @@ -39,11 +34,6 @@ func (m *metrics) Initialize(
Name: "fetched_txs",
Help: "Number of transactions fetched during bootstrapping",
})
m.numDroppedTxs = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "dropped_txs",
Help: "Number of transactions dropped during bootstrapping",
})
m.numAcceptedTxs = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted_txs",
Expand All @@ -52,10 +42,8 @@ func (m *metrics) Initialize(

return utils.Err(
registerer.Register(m.numFetchedVts),
registerer.Register(m.numDroppedVts),
registerer.Register(m.numAcceptedVts),
registerer.Register(m.numFetchedTxs),
registerer.Register(m.numDroppedTxs),
registerer.Register(m.numAcceptedTxs),
)
}
15 changes: 6 additions & 9 deletions snow/engine/avalanche/bootstrap/tx_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
var errMissingTxDependenciesOnAccept = errors.New("attempting to accept a transaction with missing dependencies")

type txParser struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
vm vertex.LinearizableVM
log logging.Logger
numAccepted prometheus.Counter
vm vertex.LinearizableVM
}

func (p *txParser) Parse(ctx context.Context, txBytes []byte) (queue.Job, error) {
Expand All @@ -36,15 +36,14 @@ func (p *txParser) Parse(ctx context.Context, txBytes []byte) (queue.Job, error)
return &txJob{
log: p.log,
numAccepted: p.numAccepted,
numDropped: p.numDropped,
tx: tx,
}, nil
}

type txJob struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
tx snowstorm.Tx
log logging.Logger
numAccepted prometheus.Counter
tx snowstorm.Tx
}

func (t *txJob) ID() ids.ID {
Expand All @@ -67,14 +66,12 @@ func (t *txJob) Execute(ctx context.Context) error {
return err
}
if hasMissingDeps {
t.numDropped.Inc()
return errMissingTxDependenciesOnAccept
}

status := t.tx.Status()
switch status {
case choices.Unknown, choices.Rejected:
t.numDropped.Inc()
return fmt.Errorf("attempting to execute transaction with status %s", status)
case choices.Processing:
txID := t.tx.ID()
Expand Down
24 changes: 11 additions & 13 deletions snow/engine/avalanche/bootstrap/vertex_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
)

var errMissingVtxDependenciesOnAccept = errors.New("attempting to execute blocked vertex")
var (
errMissingVtxDependenciesOnAccept = errors.New("attempting to execute blocked vertex")
errTxNotAcceptedInVtxOnAccept = errors.New("attempting to execute vertex with non-accepted transaction")
)

type vtxParser struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
manager vertex.Manager
log logging.Logger
numAccepted prometheus.Counter
manager vertex.Manager
}

func (p *vtxParser) Parse(ctx context.Context, vtxBytes []byte) (queue.Job, error) {
Expand All @@ -36,15 +39,14 @@ func (p *vtxParser) Parse(ctx context.Context, vtxBytes []byte) (queue.Job, erro
return &vertexJob{
log: p.log,
numAccepted: p.numAccepted,
numDropped: p.numDropped,
vtx: vtx,
}, nil
}

type vertexJob struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
vtx avalanche.Vertex
log logging.Logger
numAccepted prometheus.Counter
vtx avalanche.Vertex
}

func (v *vertexJob) ID() ids.ID {
Expand Down Expand Up @@ -85,7 +87,6 @@ func (v *vertexJob) Execute(ctx context.Context) error {
return err
}
if hasMissingDependencies {
v.numDropped.Inc()
return errMissingVtxDependenciesOnAccept
}
txs, err := v.vtx.Txs(ctx)
Expand All @@ -94,15 +95,12 @@ func (v *vertexJob) Execute(ctx context.Context) error {
}
for _, tx := range txs {
if tx.Status() != choices.Accepted {
v.numDropped.Inc()
v.log.Warn("attempting to execute vertex with non-accepted transactions")
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now require this to never happen.

return errTxNotAcceptedInVtxOnAccept
}
}
status := v.vtx.Status()
switch status {
case choices.Unknown, choices.Rejected:
v.numDropped.Inc()
return fmt.Errorf("attempting to execute vertex with status %s", status)
case choices.Processing:
v.numAccepted.Inc()
Expand Down
17 changes: 7 additions & 10 deletions snow/engine/snowman/bootstrap/block_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
var errMissingDependenciesOnAccept = errors.New("attempting to accept a block with missing dependencies")

type parser struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
vm block.ChainVM
log logging.Logger
numAccepted prometheus.Counter
vm block.ChainVM
}

func (p *parser) Parse(ctx context.Context, blkBytes []byte) (queue.Job, error) {
Expand All @@ -36,17 +36,16 @@ func (p *parser) Parse(ctx context.Context, blkBytes []byte) (queue.Job, error)
return &blockJob{
log: p.log,
numAccepted: p.numAccepted,
numDropped: p.numDropped,
blk: blk,
vm: p.vm,
}, nil
}

type blockJob struct {
log logging.Logger
numAccepted, numDropped prometheus.Counter
blk snowman.Block
vm block.Getter
log logging.Logger
numAccepted prometheus.Counter
blk snowman.Block
vm block.Getter
}

func (b *blockJob) ID() ids.ID {
Expand Down Expand Up @@ -76,13 +75,11 @@ func (b *blockJob) Execute(ctx context.Context) error {
return err
}
if hasMissingDeps {
b.numDropped.Inc()
return errMissingDependenciesOnAccept
}
status := b.blk.Status()
switch status {
case choices.Unknown, choices.Rejected:
b.numDropped.Inc()
return fmt.Errorf("attempting to execute block with status %s", status)
case choices.Processing:
blkID := b.blk.ID()
Expand Down
2 changes: 0 additions & 2 deletions snow/engine/snowman/bootstrap/bootstrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ func (b *Bootstrapper) Start(ctx context.Context, startReqID uint32) error {
b.parser = &parser{
log: b.Ctx.Log,
numAccepted: b.numAccepted,
numDropped: b.numDropped,
vm: b.VM,
}
if err := b.Blocked.SetParser(ctx, b.parser); err != nil {
Expand Down Expand Up @@ -616,7 +615,6 @@ func (b *Bootstrapper) process(ctx context.Context, blk snowman.Block, processin
pushed, err := b.Blocked.Push(ctx, &blockJob{
log: b.Ctx.Log,
numAccepted: b.numAccepted,
numDropped: b.numDropped,
blk: blk,
vm: b.VM,
})
Expand Down
1 change: 0 additions & 1 deletion snow/engine/snowman/bootstrap/bootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,6 @@ func TestBootstrapNoParseOnNew(t *testing.T) {
pushed, err := blocker.Push(context.Background(), &blockJob{
log: logging.NoLog{},
numAccepted: prometheus.NewCounter(prometheus.CounterOpts{}),
numDropped: prometheus.NewCounter(prometheus.CounterOpts{}),
blk: blk1,
vm: vm,
})
Expand Down
10 changes: 2 additions & 8 deletions snow/engine/snowman/bootstrap/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

type metrics struct {
numFetched, numDropped, numAccepted prometheus.Counter
fetchETA prometheus.Gauge
numFetched, numAccepted prometheus.Counter
fetchETA prometheus.Gauge
}

func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, error) {
Expand All @@ -21,11 +21,6 @@ func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, e
Name: "fetched",
Help: "Number of blocks fetched during bootstrapping",
}),
numDropped: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "dropped",
Help: "Number of blocks dropped during bootstrapping",
}),
numAccepted: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted",
Expand All @@ -40,7 +35,6 @@ func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, e

err := utils.Err(
registerer.Register(m.numFetched),
registerer.Register(m.numDropped),
registerer.Register(m.numAccepted),
registerer.Register(m.fetchETA),
)
Expand Down
Loading