Skip to content

Conversation

theuni
Copy link
Member

@theuni theuni commented Jan 5, 2024

This library has existed for nearly 10 years with very little known uptake or impact. It has become a maintenance burden. In several cases it dictates our code/library structure (for example necessitating LIBBITCOIN_CRYPTO_BASE), as well as build-system procedures (building multiple copies of object files especially for the lib).

Several discussions have arisen wrt migrating it to CMake and it has become difficult to justify adding more complexity for a library that is virtually unused anyway.

See for example the discussions:
hebasto#41
#29123

And here: #29180
Where it is pointed out that the libbitcoinconsensus functions are slower than those the internal bitcoind equivalents due to the missing sha2 implementations.

Instead, we (fanquake, hebasto, TheCharlatan, and I) propose simply not migrating it to CMake and letting it end with v27. Any remaining use-cases could be handled in the future by libbitcoinkernel.

If there are any users currently using libbitcoinconsensus, please chime in with your use-case!

Edit: Corrected final release to be v27.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 5, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, fanquake
Concept NACK luke-jr
Concept ACK stickies-v, jamesob, sanket1729, ajtowns, BrandonOdiwuor, jaonoctus, vasild, brunoerg
Stale ACK jonatack, hebasto

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@TheCharlatan
Copy link
Contributor

Concept ACK

@theuni theuni force-pushed the deprecate-libconsensus branch from 5545ee2 to a6745f8 Compare January 5, 2024 17:00
@hebasto
Copy link
Member

hebasto commented Jan 5, 2024

Concept ACK.

@dongcarl
Copy link
Contributor

dongcarl commented Jan 5, 2024

Might still be used here: https://github.com/rust-bitcoin/rust-bitcoinconsensus

Ping @apoelstra @tcharding

@1thales
Copy link

1thales commented Jan 5, 2024

Ping @Davidson-Souza

@stickies-v
Copy link
Contributor

Concept ACK

@Davidson-Souza
Copy link

Thank you, @1thales, for the ping.

I'm building a lightweight Bitcoin full node called Floresta, and I'm using libbitcoinconsensus through rust-bitcoinconsensus. I would rather not reimplement the entire script interpreter logic, given the complexity of keeping this code consensus-compatible with core. I did reimplement some consensus logic, but tx validation and script interpreter are the hardest ones to. libbitcoinconsensus has some issues, for example libbitcoinconsensus doesn't validate relative locktimes like CSV. I would prefer validating everything, including those.

Furthermore, I've exchanged some emails with @TheCharlatan about libbitcoinkernel, which is a great project. However, as it is, can't be used by Floresta because it relies on core's block-storage and leveldb. Since floresta is built using utreexo, we can't need those.

If libbitcoinkernel exposes stateless block/tx validation, that is, I give the transaction[s], the inputs and some context like block hash and MTP, and it spits out a "valid" or "not valid because X"; I would start using it as replacement without problems.

@jamesob
Copy link
Contributor

jamesob commented Jan 5, 2024

Concept ACK

If libbitcoinkernel exposes stateless block/tx validation, that is, I give the transaction[s], the inputs and some context like block hash and MTP, and it spits out a "valid" or "not valid because X"; I would start using it as replacement without problems.

Sounds pretty achievable in the short-term, and something that should be exposed for cross-implementation testing anyway?

@tcharding
Copy link
Contributor

Might still be used here: https://github.com/rust-bitcoin/rust-bitcoinconsensus

Ping @apoelstra @tcharding

rust-bitcoinconsensus can just do a "final" release using v27 and keep existing if folk want to use it, its trivial to maintain.

@sanket1729
Copy link
Contributor

concept ACK. cc @danielabrozzoni @notmandatory (BDK group)

This is the list of dependencies that rely on libbitcoinconsensus.

I believe most of them use libbitcoinconsensus for testing script execution, with the only exception of floresta? While I found it beneficial for cross-testing complex scripts, the absence of core policy rule checking became a notable drawback.

We've transitioned our projects to utilize the bitcoind crate, incorporating integration tests akin to BitcoinTestFramework in the core. Though the setup might be a bit clunky, I believe(as of now) there is no substitute to running core node to check if a transaction satisfies core policy rules.

@apoelstra
Copy link
Contributor

Thanks for the ping. (a) agreed that rust-bitcoinconsensus can just do a "final" release and this wouldn't be a problem for us, and (b) if there were a blackbox script validator somewhere else, we'd happily use that. Especially if it were a more maintained/supported part of Core rather than something hanging off the side.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK a6745f8 pending the actions above

Could probably squash. IIUC closes #29123.

@ajtowns
Copy link
Contributor

ajtowns commented Jan 8, 2024

I believe most of them use libbitcoinconsensus for testing script execution, with the only exception of floresta? While I found it beneficial for cross-testing complex scripts, the absence of core policy rule checking became a notable drawback.

Would something along the lines of https://github.com/ajtowns/bitcoin/commits/202309-evalscript/ be an interesting alternative?

$ ./bitcoin-util -script_flags=STANDARD evalscript '515193'
{
  "script": {
    "asm": "1 1 OP_ADD",
    "hex": "515193",
    "type": "nonstandard"
  },
  "sigversion": "witness_v0",
  "script_flags": "CHECKLOCKTIMEVERIFY,CHECKSEQUENCEVERIFY,CLEANSTACK,CONST_SCRIPTCODE,DERSIG,DISCOURAGE_OP_SUCCESS,DISCOURAGE_UPGRADABLE_NOPS,DISCOURAGE_UPGRADABLE_PUBKEYTYPE,DISCOURAGE_UPGRADABLE_TAPROOT_VERSION,DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM,LOW_S,MINIMALDATA,MINIMALIF,NULLDUMMY,NULLFAIL,P2SH,STRICTENC,TAPROOT,WITNESS,WITNESS_PUBKEYTYPE",
  "stack-after": [
    "02"
  ],
  "sigop-count": 0,
  "success": true
}

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

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

Concept ACK

@apoelstra
Copy link
Contributor

Would something along the lines of https://github.com/ajtowns/bitcoin/commits/202309-evalscript/ be an interesting alternative?

For my part I would rather have a library function than a CLI tool.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK a6745f8, the diff is correct.

@Sjors
Copy link
Member

Sjors commented Feb 5, 2024

This library has existed for nearly 10 years with very little known uptake or impact. It has become a maintenance burden. In several cases it dictates our code/library structure (for example necessitating LIBBITCOIN_CRYPTO_BASE), as well as build-system procedures (building multiple copies of object files especially for the lib).

What is the status of LIBBITCOIN_CRYPTO_BASE? Is it kept around or moved into libbitcoin_common?

@Sjors
Copy link
Member

Sjors commented Feb 5, 2024

I see it's mentioned here: #29180 (comment) - would be useful to also add a note to libraries.md

@Kixunil
Copy link

Kixunil commented Feb 15, 2024

Hey, I had a use case: create a chain of transactions in WASM (browser) in a multiparty protocol where the child transaction must be verified before signing their parents. The inputs of the parent are controlled by the verifying user so there's no "you need a full node anyway" argument. Thus libbitcoinkernel is not the solution. Now in my case the template is simple enough to not need libbitcoinconsensus - it's fine to just verify the signatures. But being able to just run the same code as Core would be very reassuring that there isn't an attack vector where the counterparty could produce invalid transaction that the client thinks is valid and I wonder if there is any other project that would need more complex verification.

There's another similar idea I had a long time ago: when ordering a node-in-a-box one could pre-open the channels during payment in the browser (same transaction) so one doesn't need to wait for channel opens after the node arrives and saves fees. However I'm not familiar with LN inner workings enough to tell whether libbitcoinconsensus would be needed for this. If the LN people could clarify this it'd be nice.

Also please note that I find the announcement period super short. This wasn't loudly communicated and if I wasn't a co-maintainer of rust-bitcoin I wouldn't have known. And even then I'm already writing this post-merge. I'd really appreciate if there was more time given and louder announcements for breaking changes in the future.

@Sjors
Copy link
Member

Sjors commented Feb 16, 2024

Also please note that I find the announcement period super short.

Removal happens at some unknown time after deprecation, but from what I can tell, not before the 28.0 release (~November 2024). The upcoming v27.* releases will be maintained for a while longer too: https://bitcoincore.org/en/lifecycle/

the child transaction must be verified before signing their parents

What exactly do you mean by "verified"? Are you checking proof-of-work from the headers? The signature?

I'm not familiar enough with what functions the kernel library exposes, to know if you can already do that. Otherwise perhaps more functions should be exposed, in order to be able to perform a subset of validation.

@fanquake
Copy link
Member

Removal happens at some unknown time after deprecation,

No, removal is going to happen pretty immediately after the 27.x branch off.

@Kixunil
Copy link

Kixunil commented Feb 16, 2024

Removal happens at some unknown time after deprecation

That doesn't help people who really needed the library. Yeah, they will get screwed later but still they are getting screwed. I meant period to voice opposition to this change. Unless you're open to un-deprecating of course.

What exactly do you mean by "verified"?

It must be possible to include it in a block at some later time when the parent is confirmed and time locks are satisfied. Basically the same requirement as LN force close transaction just different conditions in scripts.

what functions the kernel library exposes

The information I found is that it performs IO and launches threads - both of those are impossible in WASM, so no functions can help unless it can conditionally not compile syscall-performing stuff. (Though even if it can I expect it will be a hell to integrate into other languages properly.)

@maflcko
Copy link
Member

maflcko commented Feb 28, 2024

That doesn't help people who really needed the library. Yeah, they will get screwed later but still they are getting screwed.

Is there a reason you can't stay on the lib of the 27.x or 26.x release?

fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 13, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 13, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
@luke-jr
Copy link
Member

luke-jr commented Mar 14, 2024

27.x obviously won't be supported indefinitely

@maflcko
Copy link
Member

maflcko commented Mar 15, 2024

27.x obviously won't be supported indefinitely

Why not? I don't recall the last reported bug in libconsensus, but even if there was one in the future, the 27.x branch could be kept around idle, so that unlikely bugfixes could be applied.

fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 18, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 18, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 18, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
fanquake added a commit to fanquake/bitcoin that referenced this pull request Mar 18, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
fanquake added a commit that referenced this pull request Apr 1, 2024
80f8b92 remove libbitcoinconsensus (fanquake)

Pull request description:

  This was deprecated in `v27.0`, for removal in `v28.0`. See discussion in PR #29189.

ACKs for top commit:
  theuni:
    Concept ACK and light review ACK 80f8b92. My only hesitation here is that (afaics?) there's now nothing keeping undesired features like threading or globals from working their way into the interpreter in future commits.
  m3dwards:
    Concept ACK 80f8b92
  TheCharlatan:
    ACK 80f8b92
  hebasto:
    ACK 80f8b92, I have reviewed the code and it looks OK.

Tree-SHA512: 17a62118aeb088f2695c892bb32794dfea3061e3cb7d9e8e9f1c06c3ff6f63a7587fa532e37edbb91fbc5a19b12c9a0f8e05fa9e8864aa07f92665375d847e80
ajtowns pushed a commit to ajtowns/bitcoin that referenced this pull request May 6, 2024
This was deprecated in v27.0, for removal in v28.0.
See discussion in PR bitcoin#29189.
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Feb 22, 2025
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Feb 24, 2025
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Feb 26, 2025
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Feb 28, 2025
luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Mar 5, 2025
@bitcoin bitcoin locked and limited conversation to collaborators Mar 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.