-
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
[BCI-3730] - Remove dependence on MinConfirmations in EVM TXM code #13973
base: develop
Are you sure you want to change the base?
Changes from 50 commits
fcc4ef5
18665f5
c7f79c6
d56cafc
2df05f7
df0eeef
2ae25fa
eec4380
82156bf
92b5974
9c28bbb
cdb12d3
d30eb3a
fe3eb8b
8b34faa
ab755c1
c32d061
be447e8
e9f5874
c9033db
a4557a4
2a0c8f7
1370e51
77d5a55
424253b
0783aab
3c9b965
5818d5c
df44a3a
daab2d6
76a9510
913533c
ca6a2d4
9d3f425
943224d
09bf8ca
2799272
995636a
67a5f8a
7091ba8
cdcbb99
82fde8d
acc3a8a
e0573cb
c24408b
bc148c9
2b195c7
755593c
f8463ac
e2332fb
b45fb5d
07f5cc3
8b45996
ae734e9
f025054
be13b71
85d8a92
f5094bd
2fdff68
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,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
Remove dependency of MinConfirmations in EVM TXM code #update #deprecation_notice |
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 |
---|---|---|
|
@@ -76,6 +76,7 @@ type TestEvmTxStore interface { | |
GetAllTxAttempts(ctx context.Context) (attempts []TxAttempt, err error) | ||
CountTxesByStateAndSubject(ctx context.Context, state txmgrtypes.TxState, subject uuid.UUID) (count int, err error) | ||
FindTxesByFromAddressAndState(ctx context.Context, fromAddress common.Address, state string) (txes []*Tx, err error) | ||
FindTxesByFromAddressAndNonce(ctx context.Context, fromAddress common.Address, nonce int64) (txes []*Tx, err error) | ||
UpdateTxAttemptBroadcastBeforeBlockNum(ctx context.Context, id int64, blockNum uint) error | ||
} | ||
|
||
|
@@ -216,7 +217,6 @@ func (db *DbEthTx) FromTx(tx *Tx) { | |
db.Meta = tx.Meta | ||
db.Subject = tx.Subject | ||
db.PipelineTaskRunID = tx.PipelineTaskRunID | ||
db.MinConfirmations = tx.MinConfirmations | ||
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 think we either need to drop these fields if they are unused, or continue to set them from old data if they are still used. Having them around but unset will just be misleading. |
||
db.TransmitChecker = tx.TransmitChecker | ||
db.InitialBroadcastAt = tx.InitialBroadcastAt | ||
db.SignalCallback = tx.SignalCallback | ||
|
@@ -250,7 +250,6 @@ func (db DbEthTx) ToTx(tx *Tx) { | |
tx.Meta = db.Meta | ||
tx.Subject = db.Subject | ||
tx.PipelineTaskRunID = db.PipelineTaskRunID | ||
tx.MinConfirmations = db.MinConfirmations | ||
tx.ChainID = db.EVMChainID.ToInt() | ||
tx.TransmitChecker = db.TransmitChecker | ||
tx.InitialBroadcastAt = db.InitialBroadcastAt | ||
|
@@ -1017,19 +1016,20 @@ WHERE evm.tx_attempts.state = 'in_progress' AND evm.txes.from_address = $1 AND e | |
} | ||
|
||
// Find confirmed txes requiring callback but have not yet been signaled | ||
func (o *evmTxStore) FindTxesPendingCallback(ctx context.Context, blockNum int64, chainID *big.Int) (receiptsPlus []ReceiptPlus, err error) { | ||
func (o *evmTxStore) FindTxesPendingCallback(ctx context.Context, chainID *big.Int) (receiptsPlus []ReceiptPlus, err error) { | ||
var rs []dbReceiptPlus | ||
|
||
var cancel context.CancelFunc | ||
ctx, cancel = o.stopCh.Ctx(ctx) | ||
defer cancel() | ||
|
||
err = o.q.SelectContext(ctx, &rs, ` | ||
SELECT evm.txes.pipeline_task_run_id, evm.receipts.receipt, COALESCE((evm.txes.meta->>'FailOnRevert')::boolean, false) "FailOnRevert" FROM evm.txes | ||
INNER JOIN evm.tx_attempts ON evm.txes.id = evm.tx_attempts.eth_tx_id | ||
INNER JOIN evm.receipts ON evm.tx_attempts.hash = evm.receipts.tx_hash | ||
WHERE evm.txes.pipeline_task_run_id IS NOT NULL AND evm.txes.signal_callback = TRUE AND evm.txes.callback_completed = FALSE | ||
AND evm.receipts.block_number <= ($1 - evm.txes.min_confirmations) AND evm.txes.evm_chain_id = $2 | ||
`, blockNum, chainID.String()) | ||
AND evm.txes.state = 'finalized' AND evm.txes.evm_chain_id = $1 | ||
`, chainID.String()) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to retrieve transactions pending pipeline resume callback: %w", err) | ||
} | ||
|
@@ -1816,10 +1816,10 @@ func (o *evmTxStore) CreateTransaction(ctx context.Context, txRequest TxRequest, | |
err = orm.q.GetContext(ctx, &dbEtx, ` | ||
INSERT INTO evm.txes (from_address, to_address, encoded_payload, value, gas_limit, state, created_at, meta, subject, evm_chain_id, min_confirmations, pipeline_task_run_id, transmit_checker, idempotency_key, signal_callback) | ||
VALUES ( | ||
$1,$2,$3,$4,$5,'unstarted',NOW(),$6,$7,$8,$9,$10,$11,$12,$13 | ||
$1,$2,$3,$4,$5,'unstarted',NOW(),$6,$7,$8,NULL,$9,$10,$11,$12 | ||
) | ||
RETURNING "txes".* | ||
`, txRequest.FromAddress, txRequest.ToAddress, txRequest.EncodedPayload, assets.Eth(txRequest.Value), txRequest.FeeLimit, txRequest.Meta, txRequest.Strategy.Subject(), chainID.String(), txRequest.MinConfirmations, txRequest.PipelineTaskRunID, txRequest.Checker, txRequest.IdempotencyKey, txRequest.SignalCallback) | ||
`, txRequest.FromAddress, txRequest.ToAddress, txRequest.EncodedPayload, assets.Eth(txRequest.Value), txRequest.FeeLimit, txRequest.Meta, txRequest.Strategy.Subject(), chainID.String(), txRequest.PipelineTaskRunID, txRequest.Checker, txRequest.IdempotencyKey, txRequest.SignalCallback) | ||
if err != nil { | ||
return pkgerrors.Wrap(err, "CreateEthTransaction failed to insert evm tx") | ||
} | ||
|
@@ -2064,6 +2064,18 @@ func (o *evmTxStore) FindTxesByFromAddressAndState(ctx context.Context, fromAddr | |
return txes, err | ||
} | ||
|
||
func (o *evmTxStore) FindTxesByFromAddressAndNonce(ctx context.Context, fromAddress common.Address, nonce int64) (txes []*Tx, err error) { | ||
var cancel context.CancelFunc | ||
ctx, cancel = o.stopCh.Ctx(ctx) | ||
defer cancel() | ||
sql := "SELECT * FROM evm.txes WHERE from_address = $1 AND nonce = $2" | ||
var dbEtxs []DbEthTx | ||
err = o.q.SelectContext(ctx, &dbEtxs, sql, fromAddress, nonce) | ||
txes = make([]*Tx, len(dbEtxs)) | ||
dbEthTxsToEvmEthTxPtrs(dbEtxs, txes) | ||
return txes, err | ||
} | ||
|
||
func (o *evmTxStore) UpdateTxAttemptBroadcastBeforeBlockNum(ctx context.Context, id int64, blockNum uint) error { | ||
var cancel context.CancelFunc | ||
ctx, cancel = o.stopCh.Ctx(ctx) | ||
|
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.
Why was this changed?
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.
Due to the new logic in confirmer, we only fetch finalized tx for callback ,
FindTxWithSequence
doesn't work anymore because it returns only thestate IN ('confirmed', 'confirmed_missing_receipt', 'unconfirmed')