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

chainntnfs+lntest: fix TestInterfaces #8923

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

yyforyongyu
Copy link
Collaborator

This flake has popped up multiple times,

2024/07/18 08:06:20 Running ChainNotifier interface tests for: btcd
--- FAIL: TestInterfaces (67.92s)
    --- FAIL: TestInterfaces/btcd_historical_spend_dispatch (30.06s)
        test_interface.go:872: spend ntfn never received
FAIL
FAIL	github.com/lightningnetwork/lnd/chainntnfs/test/btcd	67.937s
FAIL

Turns out it's failing here, where we rescan blocks to find the relevant spending tx,

lnd/chainntnfs/txnotifier.go

Lines 1310 to 1315 in 6dea864

if !details.HasSpenderWitness() {
Log.Criticalf("Found spending tx for outpoint=%v, but the "+
"transaction %v does not have witness",
spendRequest.OutPoint, details.SpendingTx.TxHash())
return ErrEmptyWitnessStack

It's also easy to reproduce - need to run it multiple times tho,

case=TestInterfaces/btcd_historical_spend_dispatch_with_script_dispatch
pkg=chainntnfs/test/btcd
go clean -testcache | make unit-debug log="stdlog trace" pkg=$pkg case=$case timeout=10s

And the relevant logs,

2024-06-28 06:10:19.764 [CRT] NTFN: Found spending tx for outpoint=0000000000000000000000000000000000000000000000000000000000000000:0, but the transaction f78dafeb14b356ae7f2aefacc725b8700b6e9b206fdaa1d43d52d4a26a5cde63 does not have witness
2024-06-28 06:10:19.764 [ERR] NTFN: Unable to process transaction f78dafeb14b356ae7f2aefacc725b8700b6e9b206fdaa1d43d52d4a26a5cde63: witness stack is empty

Since we don't ever allow pre-segwit utxos to be used, we now update the tests to always create segwit v0 txns.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice, LGTM 🎉

@@ -59,6 +59,12 @@ func NewMiner(t *testing.T, netParams *chaincfg.Params, extraArgs []string,
t.Fatalf("unable to set up backend node: %v", err)
}

// Next mine enough blocks in order for segwit and the CSV package
// soft-fork to activate.
numBlocks := netParams.MinerConfirmationWindow*2 + 17
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where did these numbers come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

partially from the itest where we mine blocks to activate it - then it's retry -> fail cycle to find the minimal blocks. Since it's not used anywhere else so I didn't make it into a constant.

@guggero
Copy link
Collaborator

guggero commented Jul 24, 2024

Hmm, I wonder if we need to increase some timeouts in other tests that use the lntest/unittest code?
I see the routing/chainview and chainntnfs/bitcoindnotify packages becoming a bit more flakey.

Here's an example:

 --- FAIL: TestHistoricalConfDetailsNoTxIndex (0.00s)
    --- FAIL: TestHistoricalConfDetailsNoTxIndex/rpc_polling_disabled (11.58s)
        bitcoind_test.go:241: timed out in syncNotifierWithMiner, got err=<nil>, minerHeight=430, bitcoindHeight=0

This commit upgrades the test to always use a segwit v0 witness program
when creating testing txns.
@yyforyongyu
Copy link
Collaborator Author

Since it says bitcoindHeight=0, I think maybe the notifier is not even started in this case. Pushed a commit to add debug logs. Will find out more in the CI.

@guggero
Copy link
Collaborator

guggero commented Jul 24, 2024

Since it says bitcoindHeight=0, I think maybe the notifier is not even started in this case. Pushed a commit to add debug logs. Will find out more in the CI.

Thanks! But of course the tests don't fail anymore now 🙈 Should I re-trigger the CI to run the unit tests again?
Or should we just merge and look into the new flakes in a new PR?

@yyforyongyu
Copy link
Collaborator Author

Or should we just merge and look into the new flakes in a new PR?

Cool I'd prefer we merge this and investigate it in a new PR - have a trivial PR cooking locally to update the github action versions, we can then figure it out there, or whenever we see the flakes again in other PRs.

@guggero guggero merged commit b10ebb2 into lightningnetwork:master Jul 24, 2024
23 of 32 checks passed
@yyforyongyu yyforyongyu deleted the fix-test-interface branch July 24, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants