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

chore(submitter): refactoring points #57

Merged
merged 8 commits into from
Sep 20, 2024
Merged

Conversation

Lazar955
Copy link
Member

@Lazar955 Lazar955 commented Sep 18, 2024

Code cleanup

References issue

@Lazar955 Lazar955 marked this pull request as ready for review September 19, 2024 10:35
return nil
}

func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error {
Copy link
Member

Choose a reason for hiding this comment

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

better to have a doc string to explain the idea of MaybeResubmitSecondCheckpointTx

rl.metrics.InvalidCheckpointCounter.Inc()
return nil
}

Copy link
Member

Choose a reason for hiding this comment

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

should we add a check that the epoch of the checkpoint equals that of the last submitted checkpoint?

submitter/relayer/relayer.go Outdated Show resolved Hide resolved
@Lazar955 Lazar955 requested a review from gitferry September 19, 2024 18:10
}

// No need to resend, transaction already confirmed
if !found {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way that the Tx could be dropped from the mempool and it is not confirmed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

if tx would have too low fee it is possible that it could be evicted from the mempool without inclusion in th ledger. Maybe it is worth adding the check if tx is is already in the ledger then ? In btc staker there is method - https://github.com/babylonchain/btc-staker/blob/main/walletcontroller/client.go#L243, which retrieves tx from node and marks wheter it is from the mempool or from the ledger. Maybe we can re-use it here ?

}

// MaybeResubmitSecondCheckpointTx based on the resend interval attempts to resubmit 2nd ckpt tx with a bumped fee
func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

only suggestion for naming

Suggested change
func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error {
func (rl *Relayer) ResubmitSecondCheckpointTxIfNeeded(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error {

return false, err
}

// the transaction is in the mempool
Copy link
Member

Choose a reason for hiding this comment

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

here indicates that either the tx is either in the mempool or on the chain. I think we only need to resend tx2 if it is in the mempool or it can't be found at all. Can we differentiate it?

@Lazar955 Lazar955 requested a review from gitferry September 20, 2024 12:49
Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 262 to 266
if status != btcclient.TxInMemPool && status != btcclient.TxNotFound {
rl.logger.Debugf("Transaction %v is already confirmed or has an unexpected state: %v",
rl.lastSubmittedCheckpoint.Tx2.TxId, status)
return nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if status != btcclient.TxInMemPool && status != btcclient.TxNotFound {
rl.logger.Debugf("Transaction %v is already confirmed or has an unexpected state: %v",
rl.lastSubmittedCheckpoint.Tx2.TxId, status)
return nil, nil
}
if status == btcclient.TxInChain {
rl.logger.Debugf("Transaction %v is already confirmed",
rl.lastSubmittedCheckpoint.Tx2.TxId)
return nil, nil
}

Seems TxInChain is the only possible option here

@Lazar955 Lazar955 merged commit 84f8e61 into main Sep 20, 2024
8 checks passed
@Lazar955 Lazar955 deleted the lazar/refactor-submitter branch September 20, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants