-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Bugfix: Workaround UniValue push_back(bool) limitation with push_back(UniValue(bool)) #22412
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
Conversation
…(UniValue(bool)) UniValue doesn't define push_back(bool), so C++ silently converts the bool to int and we end up with a Number of 0/1 instead Explicitly passing a bool UniValue, however, works fine.
Thank you for your contribution. However we do not accept patches that are only meant for downstream projects that are shipping modified versions of Bitcoin Core. This project's goal is to maintain the vanilla version of Bitcoin Core. |
Happy to reopen for more feedback |
Agree that this needs tests if it is decided that the workaround should be applied. Also the minimum dependency version should be properly documented in https://github.com/bitcoin/bitcoin/blob/master/doc/dependencies.md#dependencies to have an objective criteria to decide on what workarounds are acceptable and which ones are not. Currently it is not documented and I (incorrectly?) assumed that only the bundled univalue is supported. The lack of clarification will lead to subjective disagreement about what versions are supported. Finally, the patch seems incomplete anyway. It is a workaround for the fix for arrays I submitted in bitcoin-core/univalue-subtree@98fadc0, however it doesn't seem to address the same issue that was fixed for dictionaries in bitcoin-core/univalue-subtree@51d3ab3 |
To reply to my own comment: The minimum required univalue version is hidden in the configure.ac. The last time it was bumped was #12666 to require the bool dictionary fix. So Concept NACK on this pull. I'd prefer to bump the minimum univalue dependency to require the bool array fix. This is a reliable fix for the bug (unlike this pull request) that also prevents the bug from silently appearing again. |
@@ -606,8 +606,9 @@ void RPCHelpMan::AppendArgMap(UniValue& arr) const | |||
map.push_back(m_name); | |||
map.push_back(i); | |||
map.push_back(arg_name); | |||
map.push_back(arg.m_type == RPCArg::Type::STR || | |||
arg.m_type == RPCArg::Type::STR_HEX); | |||
// NOTE: push_back(bool) converts the bool to Number, so explicitly make a boolean UniValue first |
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.
This note is only true for broken versions of univalue. push_back in our tree works just fine.
Many changes that benefit other projects (eg, Liquid) have been accepted into Core. This particular fix, however, affects Core itself, without modifications.
It would be good to get one of the CI tasks using official UniValue, yes. That would have caught this. However, many of our tests don't differentiate between Number and boolean JSON return values, and would have ignored the issue if the bug hadn't been in the test itself. Personally, I have modified my UniValue to give a deprecation warning when push_back(bool) is used. That could be put in our UniValue fork - or perhaps there's a way to make it stronger (ie, an error)?
Done
For that approach, the fix needs to be released upstream first. AFAIK, you have never submitted it upstream (despite me bringing it to your attention previously), so that hasn't even begun... Until that happens, this fix is needed. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Assuming others are obliged to do something is not how open source dev works. Regardless, I just looked into this and it seems this issue is fixed in the latest release? At least the code where the patch could be applied is removed. |
I didn't assume that. It's simply what would be necessary to avoid this workaround.
It's still an issue in the latest stable 1.0.5, and 1.1.1 (a development release, possibly with a new API) can't be used to build Core at all (jgarzik/univalue#76) |
In my view there are two options:
|
IMO this is the ideal approach to take.
It is unclear if this is going to happen before 22.0. |
To get the ball rolling on eventually not needing this, I opened jgarzik/univalue#83 |
Strong concept ACK. The upstream https://github.com/jgarzik/univalue/ project is barely maintained. |
Strong concept NACK. It appears to be maintained just fine. The only reason this has broken is because @MarcoFalke has gone out of his way to create a divergent fork in the Core subtree for no benefit. Ideally, we should just drop the subtree entirely, but at the very least, continuing to support building with official UniValue releases is a bare minimum level of competence we should keep. |
This is false; I did not create the repo that feeds the subtree. Also, it is irrelevant who created the repo, it was created so that bugfixes can be merged faster into the subtree. In fact, as you can see from all the cross-merge commits, I was putting effort into keeping them in sync. |
Related discussion about this happened in at least: Re-hashing the same topic every year isn't going to help this project. |
What I see, is that you made an incompatible API change, ignored efforts to reconcile the official UniValue tree, rudely insta-closed this PR to fix compatibility, and when pushed here, you created a PR for it with 15 unrelated commits that you know you would never merge to Core.
So don't rehash it. We had something that worked. You're the one who apparently wants to change that. |
Sorry @luke-jr, but this is ridiculous. Upstream is obviously unmaintained. It seems the maintainer has not had any comments/commits or other activity in over two years, while there have been PRs opened and commented on on a semi-regular basis. Bitcoin Core has had its own fork for a while, because the maintenance situation was sporadic before for time before already, but at this point there is no reason to keep treating that repo as upstream - it's dead. And the fact that it works without maintenance is not a reason why improvements to our fork can't be made. So I think we should simply start treating the https://github.com/bitcoin-core/univalue repository as upstream. You can't go call clear improvements to the codebase "going out of your way to create a divergent fork" when upstream isn't accepting any changes at all. |
@sipa There has been nothing to merge during that time. I glanced at the PRs. Some are enhancements tagged for a future release. None are merged in the Core subtree (aside from the ones just opened yesterday), so if upstream is unmaintained, so is Core's fork.
IF upstream is in fact unmaintained, that would seem like a good alternative solution. However, as things stand, that repo breaks compatibility by removing the Edit: We should probably also merge in the bugfix(es) in upstream that Core's fork is still missing... (ironic to complain upstream hasn't acted in 1 day, when we're missing at least one 2+ year old bugfix)
That isn't established yet. Upstream hasn't had more than 1 day to triage the push_back change. |
I assumed you were talking about earlier changes when making that accusation. If that's not the case, I take my words back on that aspect. I still disagree that there aren't any useful improvements PRed (e.g. jgarzik/univalue#70 or jgarzik/univalue#79), or that "it's maintained" - there has been no activity at all. |
This is also false. Both the forks did merge PRs with "unrelated commits":
Merging one branch into another (with all commits) is one way to keep them in sync.
It might be good to explain which fixes you are referring to.
There is no maintained version of Bitcoin Core that uses |
|
Mr. Garzik advises that he still maintains UniValue and will make a new stable release (presumably with the fix) this month. Perhaps the best approach at this time, is to simply bump the minimum version required to 1.0.6 assuming it will be available by the time 22.0 is final? |
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
It's now essentially the end of the month, and I can't yet see any new activity in https://github.com/jgarzik/univalue. |
In this case we should remove |
Or just fix the bug in Core. Upstream not agreeing to your API change is not an excuse to break compatibility. If you want to become upstream, fine, but don't be a jerk to everyone who wishes to use proper shared libraries. NACK to removing UniValue support and creating divergent vendor-only forks for no reason. |
Concept NACK. I agree with the discussion here, in regards to why this is not something we want to, or should have to do. I've summarized my thoughts in #22646, which removes support for system univalue.
Also
Another month has passed and there's neither release activity, not commentary on any of the new PRs by Bitcoin Core contributors in the https://github.com/jgarzik/univalue/ repo. |
…tem-univalue` 0f95247 Integrate univalue into our buildsystem (Cory Fields) 9b49ed6 Squashed 'src/univalue/' changes from 98fadc0909..a44caf65fe (fanquake) Pull request description: This PR more tightly integrates building Univalue into our build system. This follows the same approach we use for [LevelDB](https://github.com/bitcoin-core/leveldb/), ([`Makefile.leveldb.include`](https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.leveldb.include)), and [CRC32C](https://github.com/bitcoin-core/crc32c) ([`Makefile.crc32c.include`](https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include)), and will be the same approach we use for [minisketch](https://github.com/sipa/minisketch); see #23114. This approach yields a number of benefits, including: * Faster configuration due to one less subconfigure being run during `./configure` i.e 22s with this PR vs 26s * Faster autoconf i.e 13s with this PR vs 17s * Improved caching * No more issues with compiler flags i.e #12467 * More direct control means we can build exactly the objects we want There might be one argument against making this change, which is that builders should have the option to use "proper shared/system libraries". However, I think that falls down for a few reasons. The first being that we already don't support building with a number of system libraries (secp256k1, leveldb, crc32c); some for good reason. Univalue is really the odd one out at the moment. Note that the only fork of Core I'm aware of, that actively patches in support for using system libs, also explicitly marks them as ["DANGEROUS"](https://github.com/bitcoinknots/bitcoin/blob/a886811721ce66eb586871706b3f5dd27518ac3e/configure.ac#L1430) and ["NOT SUPPORTED"](https://github.com/bitcoinknots/bitcoin/blob/a886811721ce66eb586871706b3f5dd27518ac3e/configure.ac#L1312). So it would seem they exist more to satisfy a distro requirement, as opposed to something that anyone should, or would actually use in practice. PRs like #22412 highlight the "issue" with us operating with our own Univalue fork, where we actively fix bugs, and make improvements, when upstream (https://github.com/jgarzik/univalue) may not be taking those improvements, and by all accounts, is not currently actively maintained. Bitcoin Core should not be hamstrung into not being able to fix bugs in a library, and/or have to litter our source with "workarounds", i.e #22412, for bugs we've already fixed, based on the fact that an upstream project is not actively being maintained. Allowing builders to use system libs is really only exacerbating this problem, with little benefit to our project. Bitcoin Core is not quite like your average piece of distro packaged software. There is the potential for us to give the same treatment to libsecp256k1, however it seems doing that is currently less straightforward. ACKs for top commit: dongcarl: ACK 0f95247 less my comment above, always nice to have an include-able `sources.mk` which makes integration easier. theuni: ACK 0f95247. Thanks fanquake for keeping this going. Tree-SHA512: a7f2e41ee7cba06ae72388638e86b264eca1b9a8b81c15d1d7b45df960c88c3b91578b4ade020f8cc61d75cf8d16914575f9a78fa4cef9c12be63504ed804b99
…ith-system-univalue` 0f95247 Integrate univalue into our buildsystem (Cory Fields) 9b49ed6 Squashed 'src/univalue/' changes from 98fadc0909..a44caf65fe (fanquake) Pull request description: This PR more tightly integrates building Univalue into our build system. This follows the same approach we use for [LevelDB](https://github.com/bitcoin-core/leveldb/), ([`Makefile.leveldb.include`](https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.leveldb.include)), and [CRC32C](https://github.com/bitcoin-core/crc32c) ([`Makefile.crc32c.include`](https://github.com/bitcoin/bitcoin/blob/master/src/Makefile.crc32c.include)), and will be the same approach we use for [minisketch](https://github.com/sipa/minisketch); see bitcoin#23114. This approach yields a number of benefits, including: * Faster configuration due to one less subconfigure being run during `./configure` i.e 22s with this PR vs 26s * Faster autoconf i.e 13s with this PR vs 17s * Improved caching * No more issues with compiler flags i.e bitcoin#12467 * More direct control means we can build exactly the objects we want There might be one argument against making this change, which is that builders should have the option to use "proper shared/system libraries". However, I think that falls down for a few reasons. The first being that we already don't support building with a number of system libraries (secp256k1, leveldb, crc32c); some for good reason. Univalue is really the odd one out at the moment. Note that the only fork of Core I'm aware of, that actively patches in support for using system libs, also explicitly marks them as ["DANGEROUS"](https://github.com/bitcoinknots/bitcoin/blob/a886811721ce66eb586871706b3f5dd27518ac3e/configure.ac#L1430) and ["NOT SUPPORTED"](https://github.com/bitcoinknots/bitcoin/blob/a886811721ce66eb586871706b3f5dd27518ac3e/configure.ac#L1312). So it would seem they exist more to satisfy a distro requirement, as opposed to something that anyone should, or would actually use in practice. PRs like bitcoin#22412 highlight the "issue" with us operating with our own Univalue fork, where we actively fix bugs, and make improvements, when upstream (https://github.com/jgarzik/univalue) may not be taking those improvements, and by all accounts, is not currently actively maintained. Bitcoin Core should not be hamstrung into not being able to fix bugs in a library, and/or have to litter our source with "workarounds", i.e bitcoin#22412, for bugs we've already fixed, based on the fact that an upstream project is not actively being maintained. Allowing builders to use system libs is really only exacerbating this problem, with little benefit to our project. Bitcoin Core is not quite like your average piece of distro packaged software. There is the potential for us to give the same treatment to libsecp256k1, however it seems doing that is currently less straightforward. ACKs for top commit: dongcarl: ACK 0f95247 less my comment above, always nice to have an include-able `sources.mk` which makes integration easier. theuni: ACK 0f95247. Thanks fanquake for keeping this going. Tree-SHA512: a7f2e41ee7cba06ae72388638e86b264eca1b9a8b81c15d1d7b45df960c88c3b91578b4ade020f8cc61d75cf8d16914575f9a78fa4cef9c12be63504ed804b99
UniValue doesn't define push_back(bool), so C++ silently converts the bool to int and we end up with a Number of 0/1 instead
Explicitly passing a bool UniValue, however, works fine.
Fixes regressions introduced by #20012 and #21302