Skip to content
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

Update vendored libsecp to 0.4.0 #652

Closed

Conversation

tcharding
Copy link
Member

This replaces #645 and includes patches from that PR as well as two additional patches to update to v0.4.0

FTR I always forget how to do this and just hack my way around, what I did was:

  1. Check out libsecp tag v0.4.0
  2. Work out why the patch wasn't applying (one function no longer exists)
  3. Manually create a patch file using diff and copies of the original and modified util.h
  4. cp the patch file to this repo, commit it and run the verdor script using the commit hash of the tagged commit

Question please: is there a way to do (3) using git?

upstream libsecp now has a CMakeLists.txt file. Many years ago we added
some things to .gitignore which appear to be local developers committing
the names of their own stray files, and now this is causing the
revendoring script to lose track of vendored files.
This is just a bad test. It constructs a preallocated context object by
starting from a non-preallocated context object, in a way that can't be
done by users (since it directly constructs a `Secp256k1` struct) and a
way that is very difficult to unwind, because you wind up with two
pointers to the same underlying context object, one a "preallocated" one
and one a normal one.

If you then drop the preallocated one, it will call
`secp256k1_context_destroy`, forcing you to manually deallocate the
other one. If you drop the normally-allocated one, you need to
mem::forget the preallocated one to avoid calling
`secp256k1_context_destroy` twice. The whole thing is pretty fragile.

There is another unit test, `test_raw_ctx`, which gets into the same
situation but using the public API, and demonstrates a few ways to get
out of it.
I'm not sure how these came to be committed, but they shouldn't be.
Running the vendoring script results in them being deleted.
Update the `util.h.patch` file in preparation for running the vendor
script. Done by guess work.
@tcharding
Copy link
Member Author

tcharding commented Sep 12, 2023

@apoelstra want to put me out of my misery please and tell me whats going on here? Running cargo test on this branch gives linker errors. Don't bother digging too deep but if you can take a guess off the top of your head I'll have another go. Thanks

@apoelstra
Copy link
Member

Nothing off the top of my head, sorry.

@tcharding
Copy link
Member Author

No sweat, thanks for checking.

@tcharding
Copy link
Member Author

Gee wiz, @Davidson-Souza already di this in #627, very unobservant of me.

@tcharding tcharding closed this Sep 18, 2023
apoelstra added a commit that referenced this pull request Sep 30, 2023
80b2a8d Update vendored libsecp to v0.4.0 (Davidson Souza)
d2285c9 ci: Remove MIPS* from CI (Davidson Souza)
0d58f50 ci: generalize grp in "illegal callback" test (Andrew Poelstra)
acf9ac1 delete `test_manual_create_destroy` test (Andrew Poelstra)
04ce508 lib: fix bad unit test (Andrew Poelstra)
e4cca90 gitignore: remove things that shouldn't be there (Andrew Poelstra)

Pull request description:

  Replaces  #645 and #652. Precedes #627.

  I'm basically using #652 but resolving the linking problems,

  My local CI is erring on windows cross-test, but I can compile without issue with `cargo build --target x86_64-pc-windows-gnu`. Some MIPS jobs failed before even installing cross, I think those aren't really related to this PR. Any ideas on what can be happening?

ACKs for top commit:
  apoelstra:
    ACK 80b2a8d

Tree-SHA512: 62c2e04348110e3995111fa666f10dcc403b963770d047361f9209cf45b45db8744a7eb6d9ee3278d18007412dab5131ac3e1dd3e3d704963c6a6f232d57199a
@tcharding tcharding deleted the 09-12-update-libsecp-0.4.0 branch October 9, 2023 22:09
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.

None yet

2 participants