-
Notifications
You must be signed in to change notification settings - Fork 18
Add TransactionLifecycleID #396
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
Changes from all commits
8a0cfba
b5f7f01
16775bb
e877780
d9b80dd
32a7fdb
4272a55
23622b1
49a6329
5f49972
9810ef8
d762a11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,7 @@ func (t *Txm) HealthReport() map[string]error { | |
| func (t *Txm) CreateTransaction(ctx context.Context, txRequest *types.TxRequest) (tx *types.Transaction, err error) { | ||
| tx, err = t.txStore.CreateTransaction(ctx, txRequest) | ||
| if err == nil { | ||
| t.lggr.Infow("Created transaction", "tx", tx) | ||
| t.lggr.Infow("Created transaction", "txID", tx.ID, "tx", tx, "transactionLifecycleID", tx.GetTransactionLifecycleID(t.lggr)) | ||
| } | ||
| return | ||
| } | ||
|
|
@@ -188,7 +188,10 @@ func (t *Txm) Trigger(address common.Address) { | |
| if !exists { | ||
| return | ||
| } | ||
| triggerCh <- struct{}{} | ||
| select { | ||
| case triggerCh <- struct{}{}: | ||
| default: | ||
| } | ||
|
Comment on lines
+191
to
+194
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't fully oversee the consequences of this change, can you explain this a bit?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is the default way in go to not block the caller and just fill the channel and exit. Before we would (mistakenly) block after the buffer was filled. The old way may impact throughput on some rare cases, hence the change. |
||
| }) { | ||
| t.lggr.Error("Txm unstarted") | ||
| } | ||
|
|
@@ -333,7 +336,7 @@ func (t *Txm) sendTransactionWithError(ctx context.Context, tx *types.Transactio | |
| } | ||
| start := time.Now() | ||
| txErr := t.client.SendTransaction(ctx, tx, attempt) | ||
| t.lggr.Infow("Broadcasted attempt", "tx", tx, "attempt", attempt, "duration", time.Since(start), "txErr: ", txErr) | ||
| t.lggr.Infow("Broadcasted attempt", "tx", tx, "attempt", attempt, "transactionLifecycleID", tx.GetTransactionLifecycleID(t.lggr), "duration", time.Since(start), "txErr", txErr) | ||
|
||
| if txErr != nil && t.errorHandler != nil { | ||
| if err = t.errorHandler.HandleError(ctx, tx, txErr, t.txStore, t.SetNonce, false); err != nil { | ||
| return | ||
|
|
@@ -440,6 +443,7 @@ func (t *Txm) extractMetrics(ctx context.Context, txs []*types.Transaction) []ui | |
| if tx.InitialBroadcastAt != nil { | ||
| t.Metrics.RecordTimeUntilTxConfirmed(ctx, float64(time.Since(*tx.InitialBroadcastAt))) | ||
| } | ||
| t.lggr.Infow("Confirmed transaction", "txID", tx.ID, "transactionLifecycleID", tx.GetTransactionLifecycleID(t.lggr)) | ||
| } | ||
| return confirmedTxIDs | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ import ( | |
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
|
|
||
| "github.com/smartcontractkit/chainlink-common/pkg/logger" | ||
| "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" | ||
| clnull "github.com/smartcontractkit/chainlink-common/pkg/utils/null" | ||
|
|
||
|
|
@@ -106,6 +107,18 @@ func (t *Transaction) GetMeta() (*TxMeta, error) { | |
| return &m, nil | ||
| } | ||
|
|
||
| func (t *Transaction) GetTransactionLifecycleID(lggr logger.SugaredLogger) string { | ||
| meta, err := t.GetMeta() | ||
| if err != nil { | ||
| lggr.Errorw("failed to get meta of the transaction", "err", err) | ||
| return "" | ||
| } | ||
| if meta != nil && meta.TransactionLifecycleID != nil { | ||
| return *meta.TransactionLifecycleID | ||
| } | ||
| return "" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think unknown is consistent. I'd rather have it empty, or probably not log the field at all if it's nil in a future PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair, I do think it would be nice to differentiate between the unknown/unset situation and the error situation though
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but we shouldn't relay an error in an unrelated log field just because the underlying method happened to fail. That was the intention of the error log above. Each time you'll make the call you'll see the empty field but you'll also see the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not completely following this. Let's say we grep the logs for broadcasted transactions by querying e.g. However, if tracing ID is empty, then we don't know what happened: is it actually not set or were we unable to retrieve Meta? We won't see the Anyway, I'm fine leaving it like this since there's a very low chance GetMeta() returns an error, this would only happen on malformed json.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, if you filter specifically with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also this might be eventually split up to individual fields i.e.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true. Ok let's leave it like this |
||
| } | ||
|
|
||
| type Attempt struct { | ||
| ID uint64 | ||
| TxID uint64 | ||
|
|
@@ -184,6 +197,9 @@ type TxMeta struct { | |
| // Dual Broadcast | ||
| DualBroadcast *bool `json:"DualBroadcast,omitempty"` | ||
| DualBroadcastParams *string `json:"DualBroadcastParams,omitempty"` | ||
|
|
||
| // TransactionLifecycleID is used for tracing the entire lifecycle of a transaction from OCR Transmit to confirmation on-chain. | ||
| TransactionLifecycleID *string `json:"TransactionLifecycleID,omitempty"` | ||
| } | ||
|
|
||
| type QueueingTxStrategy struct { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the config digest captures the aggregator address right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly, but it's encapsulated.