-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
BCFR-934/remove-finality-depth-as-default-value-for-minConfirmation-and-fix-inconsistency #14509
Changes from all commits
089be68
2b9a263
184be32
9c9678a
871214a
3b899db
64873df
16078c2
6312f63
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
Remove finality depth as the default value for minConfirmation for tx jobs. | ||
Update the sql query for fetching pending callback transactions: | ||
if minConfirmation is not null, we check difference if the current block - tx block > minConfirmation | ||
else we check if the tx block is <= finalizedBlock | ||
#updated |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,11 +64,11 @@ func (t *ETHTxTask) getEvmChainID() string { | |
return t.EVMChainID | ||
} | ||
|
||
func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inputs []Result) (result Result, runInfo RunInfo) { | ||
func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inputs []Result) (Result, RunInfo) { | ||
var chainID StringParam | ||
err := errors.Wrap(ResolveParam(&chainID, From(VarExpr(t.getEvmChainID(), vars), NonemptyString(t.getEvmChainID()), "")), "evmChainID") | ||
if err != nil { | ||
return Result{Error: err}, runInfo | ||
return Result{Error: err}, RunInfo{} | ||
} | ||
|
||
chain, err := t.legacyChains.Get(string(chainID)) | ||
|
@@ -81,7 +81,7 @@ func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inpu | |
txManager := chain.TxManager() | ||
_, err = CheckInputs(inputs, -1, -1, 0) | ||
if err != nil { | ||
return Result{Error: errors.Wrap(err, "task inputs")}, runInfo | ||
return Result{Error: errors.Wrap(err, "task inputs")}, RunInfo{} | ||
} | ||
|
||
maximumGasLimit := SelectGasLimit(cfg.GasEstimator(), t.jobType, t.specGasLimit) | ||
|
@@ -107,25 +107,20 @@ func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inpu | |
errors.Wrap(ResolveParam(&failOnRevert, From(NonemptyString(t.FailOnRevert), false)), "failOnRevert"), | ||
) | ||
if err != nil { | ||
return Result{Error: err}, runInfo | ||
} | ||
var minOutgoingConfirmations uint64 | ||
if min, isSet := maybeMinConfirmations.Uint64(); isSet { | ||
minOutgoingConfirmations = min | ||
} else { | ||
minOutgoingConfirmations = uint64(cfg.FinalityDepth()) | ||
return Result{Error: err}, RunInfo{} | ||
} | ||
minOutgoingConfirmations, isMinConfirmationSet := maybeMinConfirmations.Uint64() | ||
|
||
txMeta, err := decodeMeta(txMetaMap) | ||
if err != nil { | ||
return Result{Error: err}, runInfo | ||
return Result{Error: err}, RunInfo{} | ||
} | ||
txMeta.FailOnRevert = null.BoolFrom(bool(failOnRevert)) | ||
setJobIDOnMeta(lggr, vars, txMeta) | ||
|
||
transmitChecker, err := decodeTransmitChecker(transmitCheckerMap) | ||
if err != nil { | ||
return Result{Error: err}, runInfo | ||
return Result{Error: err}, RunInfo{} | ||
} | ||
|
||
fromAddr, err := t.keyStore.GetRoundRobinAddress(ctx, chain.ID(), fromAddrs...) | ||
|
@@ -159,8 +154,11 @@ func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inpu | |
SignalCallback: true, | ||
} | ||
|
||
if minOutgoingConfirmations > 0 { | ||
// Store the task run ID, so we can resume the pipeline when tx is confirmed | ||
if !isMinConfirmationSet { | ||
// Store the task run ID, so we can resume the pipeline when tx is finalized | ||
txRequest.PipelineTaskRunID = &t.uuid | ||
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. @jmank88 is 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
What do you mean that it "gets executed"? AFAIK this parameter only affects the callback behavior, not confirmation. 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 referring to a scenario where |
||
} else if minOutgoingConfirmations > 0 { | ||
// Store the task run ID, so we can resume the pipeline after minOutgoingConfirmations | ||
txRequest.PipelineTaskRunID = &t.uuid | ||
txRequest.MinConfirmations = clnull.Uint32From(uint32(minOutgoingConfirmations)) | ||
} | ||
|
@@ -170,11 +168,11 @@ func (t *ETHTxTask) Run(ctx context.Context, lggr logger.Logger, vars Vars, inpu | |
return Result{Error: errors.Wrapf(ErrTaskRunFailed, "while creating transaction: %v", err)}, retryableRunInfo() | ||
} | ||
|
||
if minOutgoingConfirmations > 0 { | ||
return Result{}, pendingRunInfo() | ||
if txRequest.PipelineTaskRunID != nil { | ||
return Result{}, RunInfo{IsPending: true} | ||
} | ||
|
||
return Result{Value: nil}, runInfo | ||
return Result{}, RunInfo{} | ||
} | ||
|
||
func decodeMeta(metaMap MapParam) (*txmgr.TxMeta, error) { | ||
|
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.
This is now passing existing tests, but I think we are missing some coverage. Consider if a user does not set a value. In the old path, a value would be obtained that may or may not be zero, which determines whether we wait for a callback or not. In the new path, we never wait for callback. It would seem that we need a means of getting a callback after finalization (regardless of the particular depth or tags being used).
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.
Is it valid to set only
txRequest.PipelineTaskRunID
withouttxRequest.MinConfirmations
, to get a callback based on the configured finality? If that doesn't work already, it seems like a logical way to support this.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.
Implemented. Now the only change in behavior should be the unnoticeable implementation detail of an "immediate" callback in the case of omitting a value for a chain with "instant" finality. So just a bit of latency in the worst case.