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

fix: panic in SendCheckpointToBTC #138

Merged
merged 5 commits into from
Dec 11, 2024
Merged

Conversation

guoshijiang
Copy link
Contributor

resolve this issue: #137

Copy link
Member

@SebastianElvis SebastianElvis left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for the fix!

Probably @gitferry can take a look as well

@gitferry
Copy link
Member

gitferry commented Dec 10, 2024

Thanks for the report! I think the issue is valid. Basically, in the case of #137

  1. the submitter failed to submit the first tx of a checkpoint
  2. it fell into MaybeResubmitSecondCheckpointTx to try to re-submit the second tx of the lastSubmittedCheckpoint. Then the panic happened because the submitter was initiated with empty lastSubmittedCheckpoint
    • the check if durSeconds < rl.config.ResendIntervalSeconds can pass is because the submiter was initiated with empty lastSubmittedCheckpoint

Therefore, I think a proper fix is to continue the for loop if SendCheckpointToBTC returns error. This ensures that an empty lastSubmittedCheckpoint will not go to MaybeResubmitSecondCheckpointTx.

@Lazar955 wdyt?

@Lazar955
Copy link
Member

Thanks for the report! I think the issue is valid. Basically, in the case of #137

  1. the submitter failed to submit the first tx of a checkpoint

  2. it fell into MaybeResubmitSecondCheckpointTx to try to re-submit the second tx of the lastSubmittedCheckpoint. Then the panic happened because the submitter was initiated with empty lastSubmittedCheckpoint

    • the check if durSeconds < rl.config.ResendIntervalSeconds can pass is because the submiter was initiated with empty lastSubmittedCheckpoint

Therefore, I think a proper fix is to continue the for loop if SendCheckpointToBTC returns error. This ensures that an empty lastSubmittedCheckpoint will not go to MaybeResubmitSecondCheckpointTx.

@Lazar955 wdyt?

Agreed with @gitferry, err happened in SendCheckpointToBTC therefore we shouldn't execute MaybeResubmitSecondCheckpointTx but rather continue.

@guoshijiang can you amend your PR?

@Lazar955 Lazar955 changed the title [R4R]: Added the check if rl.lastSubmittedCheckpoint.Tx1 and rl.lastSubmittedCheckpoint.Tx2 are nil in relayer.go fix: panic in SendCheckpointToBTC Dec 10, 2024
@Lazar955 Lazar955 changed the title fix: panic in SendCheckpointToBTC fix: panic in SendCheckpointToBTC Dec 10, 2024
@guoshijiang
Copy link
Contributor Author

Thanks for the report! I think the issue is valid. Basically, in the case of #137

  1. the submitter failed to submit the first tx of a checkpoint

  2. it fell into MaybeResubmitSecondCheckpointTx to try to re-submit the second tx of the lastSubmittedCheckpoint. Then the panic happened because the submitter was initiated with empty lastSubmittedCheckpoint

    • the check if durSeconds < rl.config.ResendIntervalSeconds can pass is because the submiter was initiated with empty lastSubmittedCheckpoint

Therefore, I think a proper fix is to continue the for loop if SendCheckpointToBTC returns error. This ensures that an empty lastSubmittedCheckpoint will not go to MaybeResubmitSecondCheckpointTx.
@Lazar955 wdyt?

Agreed with @gitferry, err happened in SendCheckpointToBTC therefore we shouldn't execute MaybeResubmitSecondCheckpointTx but rather continue.

@guoshijiang can you amend your PR?

update

@Lazar955
Copy link
Member

Thanks for the report! I think the issue is valid. Basically, in the case of #137

  1. the submitter failed to submit the first tx of a checkpoint

  2. it fell into MaybeResubmitSecondCheckpointTx to try to re-submit the second tx of the lastSubmittedCheckpoint. Then the panic happened because the submitter was initiated with empty lastSubmittedCheckpoint

    • the check if durSeconds < rl.config.ResendIntervalSeconds can pass is because the submiter was initiated with empty lastSubmittedCheckpoint

Therefore, I think a proper fix is to continue the for loop if SendCheckpointToBTC returns error. This ensures that an empty lastSubmittedCheckpoint will not go to MaybeResubmitSecondCheckpointTx.
@Lazar955 wdyt?

Agreed with @gitferry, err happened in SendCheckpointToBTC therefore we shouldn't execute MaybeResubmitSecondCheckpointTx but rather continue.
@guoshijiang can you amend your PR?

update

Will approve once CI passes. Update the changelog file as well (see the previous updates)

Copy link
Member

@Lazar955 Lazar955 left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for your contribution

CHANGELOG.md Show resolved Hide resolved
@Lazar955 Lazar955 mentioned this pull request Dec 11, 2024
@Lazar955 Lazar955 merged commit 674853f into babylonlabs-io:main Dec 11, 2024
10 of 12 checks passed
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.

panic: runtime error: invalid memory address or nil pointer dereference
4 participants