Skip to content

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented Aug 15, 2025

Fixes #2404.
If different versions of bitcoind return different error strings, we need a way to match those as well.

@guggero guggero requested a review from yyforyongyu August 15, 2025 06:41
@coveralls
Copy link

coveralls commented Aug 15, 2025

Pull Request Test Coverage Report for Build 17062080212

Details

  • 4 of 6 (66.67%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 54.804%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rpcclient/errors.go 4 6 66.67%
Files with Coverage Reduction New Missed Lines %
database/ffldb/blockio.go 4 88.81%
Totals Coverage Status
Change from base Build 16582220057: 0.01%
Covered Lines: 31099
Relevant Lines: 56746

💛 - Coveralls

Copy link
Collaborator

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM🙏

@yyforyongyu
Copy link
Collaborator

@ziggie1984 maybe you could take a look?

Copy link
Contributor

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

Thank you for monitoring the core lib, wondering if we just define these 2 new errors instead of mapping ?

// The error message was changed in
// https://github.com/bitcoin/bitcoin/pull/33050 which will be included
// in bitcoind v30.0 and beyond.
"mempool script verify flag failed": ErrNonMandatoryScriptVerifyFlag,
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also add: block-script-verify-flag-failed see https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes-33183.md ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yes. Added.

// version dependent (e.g. versions up to v29 return the error as specified in
// `Error()` above, while versions v30 and beyond return the error as mapped
// here.
var BitcoindErrMap = map[string]error{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we just introduce 2 new errors instead of mapping it to the old one ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because the errors were simply renamed, I wanted to keep the same semantic meaning (e.g. the same error constant) in case we matched on them anywhere. We currently don't, so we could've added new errors. But I still find it slightly better in terms of understanding what's going on. Added some additional context to the comment of the new map, why we use it and when we should create new constants.
I hope that makes sense to you?

Fixes btcsuite#2404.
If different versions of bitcoind return different error strings, we
need a way to match those as well.
@guggero guggero force-pushed the bitcoind-v30-error branch from 1435f8c to ffcda0f Compare August 19, 2025 07:00
@guggero guggero requested a review from ziggie1984 August 19, 2025 07:01
Copy link
Contributor

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

Thank you

@guggero
Copy link
Collaborator Author

guggero commented Aug 19, 2025

@Roasbeef requesting merge override.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🎽

This works for now, but ideally we'd be able to just check against error codes instead of strings....

@Roasbeef Roasbeef merged commit ce72d63 into btcsuite:master Aug 20, 2025
3 checks passed
@guggero guggero deleted the bitcoind-v30-error branch August 20, 2025 06:28
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.

string-matching will break in bitcoind v30.0
5 participants