Skip to content
Closed
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
19 changes: 18 additions & 1 deletion pkg/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
sequenceDiagram "github.com/smartcontractkit/chainlink-ton/pkg/ton/codec/debug/visualizations/sequence"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tracetracking"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/offramp"
)

type TxManager interface {
Expand Down Expand Up @@ -251,6 +252,21 @@ func (t *Txm) broadcastLoop() {
}
}

// We consider succesful a transaction that reaches CCIPReceive, so we stop tracing after that.
// TODO: We should be able to trace up to CCIPReceive, ignore the result of the CCIPReceive message, and then trace
// either the confirmation or failure path back through the CCIP contracts.
var stopAtCCIPReceiveCondition tracetracking.StopCondition = func (_, m *tracetracking.ReceivedMessage) (bool, error) {
opcode, err := tvm.ExtractOpcode(m.InternalMsg.Body)
if err != nil {
return true, (fmt.Errorf("failed to extract opcode from message in the trace: %w", err))
}
//Stop tracing on CCIPReceive message delivery
if uint64(opcode) == offramp.OpcodeCCIPReceive {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we make this part of SubmitTransaction or determine somehow based on the input? Placing this straight into the txm makes this generic component CCIP 1.6 specific and will break on future versions/other products

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This would also require us to verify the contract address or we're vulnerable to spoofing if someone else deliberately uses this opcode downstream in the receiver

return true, nil
}
return false, nil
}

// broadcastWithRetry Attempts to broadcast a transaction with retries on failure. We only retry if there was a
// failure to send the transaction, not if the transaction was broadcast but failed to execute (non-zero exit code).
func (t *Txm) broadcastWithRetry(ctx context.Context, tx *Tx, msg *wallet.Message, txID string) error {
Expand Down Expand Up @@ -483,7 +499,8 @@ func (t *Txm) checkUnconfirmed(ctx context.Context) {
t.logger.Errorw("failed to get outcome exit code", "LT", unconfirmedTx.LT, "error", err)
continue
}
traceSucceeded := receivedMessage.TraceSucceeded()

traceSucceeded, _ := receivedMessage.TraceSucceededWith(stopAtCCIPReceiveCondition)

if err := txStore.MarkFinalized(unconfirmedTx.LT, traceSucceeded, exitCode); err != nil {
t.logger.Errorw("failed to mark tx as finalized in TxStore", "LT", unconfirmedTx.LT, "error", err)
Expand Down
Loading