-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
return nil | ||
} | ||
|
||
func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpointWithMetaResponse) 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.
better to have a doc string to explain the idea of MaybeResubmitSecondCheckpointTx
rl.metrics.InvalidCheckpointCounter.Inc() | ||
return nil | ||
} | ||
|
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.
should we add a check that the epoch of the checkpoint equals that of the last submitted checkpoint?
submitter/relayer/relayer.go
Outdated
} | ||
|
||
// No need to resend, transaction already confirmed | ||
if !found { |
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 there any way that the Tx could be dropped from the mempool and it is not confirmed?
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.
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 { |
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.
only suggestion for naming
func (rl *Relayer) MaybeResubmitSecondCheckpointTx(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error { | |
func (rl *Relayer) ResubmitSecondCheckpointTxIfNeeded(ckpt *ckpttypes.RawCheckpointWithMetaResponse) error { |
submitter/relayer/relayer.go
Outdated
return false, err | ||
} | ||
|
||
// the transaction is in the mempool |
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.
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?
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.
LGTM!
submitter/relayer/relayer.go
Outdated
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 | ||
} |
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.
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
Code cleanup
References issue