-
Notifications
You must be signed in to change notification settings - Fork 106
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
Zcash-compatible Bitcoin script impl #180
Comments
Two options:
|
Another option is to build This would likely be a bit more work than wrapping the parity-zcash code, but you could probably provide the same API around both, and the license for |
Hmm, just to clarify, the suggestion is to extract the C++ consensus implementation from |
some helpful pointers from @prestwich:
|
relevant discord discussion: https://discordapp.com/channels/676527656170160146/716086297210650634/729816649242378261 |
@yaahc mind reposting some context for those of us following who aren't on discord? :) |
@preswich Not sure how well this will paste but here goes nothing Yaah (she/her)Yesterday at 2:50 PM zebra/zebra-chain/src/types.rs Line 99 in 8281b90
GitHub ZcashFoundation/zebra An ongoing Rust implementation of a Zcash node. 🦓. Contribute to ZcashFoundation/zebra development by creating an account on GitHub. str4dYesterday at 2:53 PM Hoo boy, not envying you implementing this durumcrustulumYesterday at 2:53 PM we aren't, we're pulling in a dep definitely uh, not trying to do that from scratch 😅 str4dYesterday at 2:53 PM Sentiment still applies durumcrustulumYesterday at 2:53 PM eeep str4dYesterday at 2:55 PM We don't have SegWit (or several other NOP changes) from upstream, and we stripped out FindAndDelete etc. before launch, so you likely can't just depend on a Bitcoin Rust dependency. durumcrustulumYesterday at 2:55 PM I think this is the one https://github.com/rust-bitcoin/rust-bitcoin/ GitHub rust-bitcoin/rust-bitcoin Rust Bitcoin library. Contribute to rust-bitcoin/rust-bitcoin development by creating an account on GitHub. hrmpph yeah str4dYesterday at 2:56 PM Using that as a starting point, and keeping close enough to pull in updates from them, makes sense. But I doubt that the delta can be easily applied as a purely functional wrapper (I'd be happy to be wrong!) Some things (like NOP changes) could be wrapped to hide the internal behaviour with an actual nop, but IDK enough about how that implementation is designed. The C++ impl certainly isn't amenable to that (it internally iterates over the script, and there's no modular "handle one opcode" point that is treated as an opaque handler within the script iteration, just a giant switch statement) Yaah (she/her)Yesterday at 3:06 PM
wheeeeww |
I think this is a really thorny issue as Zcash relies on an ancient fork of Script, and Script is full of terrible edge cases (like negative 0). If we use a Rust re-implementation we're more likely to cause consensus failures 🤔 |
not if zcashd adopts the same rust impl :D |
if moving to a new Script implementation entirely, it would be a good idea to patch up sighash a bit. ZIP-243 hasn't been updated for the recent BIP-143 value issues. Here's a list of changes in BIP-341. Numbers 2 and 3 are useful for Zcash:
|
That would have to wait until at least the Canopy network upgrade, which is in November. We would need some kind of script implementation before then, to validate Sapling to Heartwood. |
Good point. I think we will need to come up with two plans, one for short term and one for long term. Short Term
Long Term
The best option seems to be 3 for short term and then 1 for long term, that gives us a fully valid and reliable script implementation at all times. If we run into issues with ffi and c++ or if we really don't want to have any c++ dependencies then I feel like the second best option would be 2 which then grows into 1. And for 2 we could even use bits and pieces of |
Voice of a generation, I ams |
How do we validate pre-Canopy blocks? |
In general, it might help to look through the list of BIPs and ZIPs in #253 to find any script changes or restrictions. |
disclaimer: I'm not exactly an expert on the network upgrades or consensus, so this could easily be based on faulty assumptions. I assume the zebra-script impl would be well tested against all pre canopy blocks. If we're worried about some of the last pre Canopy blocks failing to validate causing problems with the network update we could do a transition period where as part of the Canopy upgrade we include both script validators and continue to use the c++ script validator for all old blocks and use the rust validator for all new blocks, then we could go back and make sure all existing pre-canopy blocks successfully validate with |
Using dual libraries works, as long as the new validator accepts all the old blocks. Here's how we would do that hard fork at Canopy activation:
That way, we support chain reorganisations across the activation height. If the old validator rejects some old blocks, then new zcashd nodes will reject those old blocks during the initial sync. There are workarounds, but they involve hard-coded exceptions for some blocks or block ranges. |
@str4d went and setup a version of libzcashconsensus that is refactored to be more self contained which we should use for any https://github.com/str4d/zcash/tree/proofverifier-refactor pull that branch from str4d's repo and then build just CONFIGURE_FLAGS="--with-libs" ./zcutil/build.sh -j$(nproc) |
You can disable more parts and build just
The static library ends up in |
extremely relevant reference impl for when someone wrapped the upstream version of https://github.com/rust-bitcoin/rust-bitcoinconsensus/blob/master/build.rs |
No description provided.
The text was updated successfully, but these errors were encountered: