-
Notifications
You must be signed in to change notification settings - Fork 16
update libsimplicity to cad9a63292ea8fdd5c1615e0322986f6f996d42f #296
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
base: master
Are you sure you want to change the base?
Conversation
1940dab
to
ad7a60b
Compare
The clippy CI failure is expected and is because we're running clippy on an unpinned stable version. I will fix this in a followup commit (but I need to do this one first because my nix-based test infrastructure is not working, because I updated nixpkgs to no longer contain the Haskell deps for the old version of upstream, and I need those in order to build upstream to check that the vendored files are checked in correctly). No other CI failures are expected (if you see any you can wait til I fix them). |
I will need a couple of hours -- the current failures are because our fuzztests now use multiple incompatible versions of simplicity-sys, and we haven't separated their symbol names properly. |
There are actually only two changes here: * In vendor-simplicity.sh I added a couple `sed` lines to search-and-replace simplicity_ symbols with rustsimplicity_X_y_ ones, then re-ran the script. * In src/tests/ffi.rs I added a bunch of #[link_name] attributes to compensate. One way to test this is to rename all the 0_4s to 0_3s e.g. with find . -exec sed -i s/_0_4_/_0_3_/g {} \; Then re-run vendor-simplicity.sh and see that your `git diff` has become empty.
ad7a60b
to
ff51b90
Compare
Will open a separate PR with the first several commits of this. But want to get CI passing here first. |
e6cff83
to
f6a8a32
Compare
The process here was: * Manually replace c_X with c_v0_3_X everywhere (actually only in two files, wrapper.h and jets_ffi.rs) * Run update_jets.sh and make sure it changes all the 0_3s to 0_4s. Note that now both update_jets.sh and vendor-simplicity.sh update wrapper.h. This is fine since the change is idempotent. But we really should clean up and combine these two scripts one of these days.. The 0_3 test is easy to do during review, though if you are on NixOS then replace the cabal build/exec lines by first nix-building the `haskell` target in Simplicity and then directly calling result/bin/GenRustJets in there.
As before, I first manually added _0_3_ version numbers, modified the vendoring script, ran it, and made sure that the resulting diff added 0_4s and worked.
This field tells Cargo what library we're linking in, and helps it provide sane error messages (rather than linker spew) when somebody tries to compile multiple versions of the library that link the same thing. When we provide a links field we should also provide a build field. This is set to build.rs by default, but crate2nix seems to get confused when one is present but not the other.
Here I did the bare minimum renaming in the rest of the library to get things to compile. This was in three files: * in simplicity-sys/build.rs I had to tweak some paths * In simplicity-sys/depend/jets_wrapper.c I had to tweak a path * In simplicity-sys/depend/env.c tweaked some paths, added typedefs, and updated the signature of c_set_txEnv based on the same function in env.c from Haskell/cbits in libsimpliciity. THEN in order for the tests to pass and not segfault, I had to implement three API changes in simplicity-sys/src/tests/ffi.rs (and update the call sites in simplicity-sys/src/tests/mod.rs): * simplicity_decodeMallocDag now takes a callback * simplicity_mallocTypeInference now takes a callback (and defining this callback required adding bindings for a bunch of aux types, annoyingly) * SimplicityErr adds a new OVERWEIGHT variant (and extends the unit tests to hit this) Rust being extremely agressive about UB in unsafe code, by dropping any of the three of these you can get very weird-looking segfaults (e.g. an immediate jump to a null address with no backtrace, for the missing enum variant but a unit test that creates in from C code). Anyway, I tried to minimize this diff but wasn't totally successful. The next commits do the "rest" of the upgrade work, which consists of a bunch of mechanical renaming.
We leave txEnv alone because that's what's done in Haskell/cbits. When we add the 'bitcoin' feature we will figure out exactly what we're supposed to do here.
f6a8a32
to
421d47d
Compare
Blocked on BlockstreamResearch/simplicity#304 |
Updates libsimplicity for the recent refactorings for the elements/bitcoin split, and also to a commit that uses the new Haskell deps so that I can run my local CI on it.