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

TXMv2 broadcast transactions #15709

Closed
wants to merge 12 commits into from
5 changes: 5 additions & 0 deletions .changeset/young-buses-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Add beholder metric to monitor TXMv2 transactions
27 changes: 27 additions & 0 deletions core/chains/evm/txm/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"go.opentelemetry.io/otel/metric"
"google.golang.org/protobuf/proto"

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
"github.com/smartcontractkit/chainlink-common/pkg/metrics"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txm/pb"
)

var (
Expand Down Expand Up @@ -91,3 +94,27 @@ func (m *txmMetrics) RecordTimeUntilTxConfirmed(ctx context.Context, duration fl
promTimeUntilTxConfirmed.WithLabelValues(m.chainID.String()).Observe(duration)
m.timeUntilTxConfirmed.Record(ctx, duration)
}

func (m *txmMetrics) EmitTxMessage(ctx context.Context, tx common.Hash, fromAddress common.Address, toAddress common.Address, nonce uint64) error {
message := &pb.TxMessage{
Hash: tx.String(),
FromAddress: fromAddress.String(),
ToAddress: toAddress.String(),
Nonce: nonce,
}

messageBytes, err := proto.Marshal(message)
if err != nil {
return err
}

err = beholder.GetEmitter().Emit(
ctx,
messageBytes,
"beholder_domain", "svr",
"beholder_entity", "pb.TxMessage",
"beholder_data_schema", "/beholder-tx-message/versions/1",
)

return err
}
159 changes: 159 additions & 0 deletions core/chains/evm/txm/pb/beholder-tx-message.pb.go

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

12 changes: 12 additions & 0 deletions core/chains/evm/txm/pb/beholder-tx-message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";

option go_package = "github.com/smartcontractkit/chainlink-common/pkg/beholder/pb";

package pb;

message TxMessage {
string Hash = 1;
string FromAddress = 2;
string ToAddress = 3;
uint64 Nonce = 4;
}
4 changes: 4 additions & 0 deletions core/chains/evm/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ func (t *Txm) sendTransactionWithError(ctx context.Context, tx *types.Transactio
}

t.metrics.IncrementNumBroadcastedTxs(ctx)
if err = t.metrics.EmitTxMessage(ctx, attempt.Hash, address, tx.ToAddress, *tx.Nonce); err != nil {
t.lggr.Errorw("Beholder error emitting tx message", "err", err)
}

return t.txStore.UpdateTransactionBroadcast(ctx, attempt.TxID, *tx.Nonce, attempt.Hash, address)
}

Expand Down
Loading