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

fix(crypto): secp256k1 cgo duplicate symbols #18306

Closed
wants to merge 33 commits into from

Conversation

JulianToledano
Copy link
Contributor

@JulianToledano JulianToledano commented Oct 30, 2023

Description

Closes:
#18232

This PR rename all duplicate symbols that any project using the SDK alongside with go-ethereum could get


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Summary by CodeRabbit

Refactor:

  • The cryptographic library secp256k1 has been replaced with cosmos_secp256k1 across the codebase. This change is internal and should not affect the end-user experience.

Style:

  • Function and variable names related to the secp256k1 library have been updated to include the prefix "cosmos_". This change is part of the codebase's internal refactoring and does not impact the functionality from an end-user perspective.

Documentation:

  • Comments in the code have been updated to reflect the switch from secp256k1 to cosmos_secp256k1. This change is primarily for developers and does not affect end-users.

@JulianToledano JulianToledano requested a review from a team as a code owner October 30, 2023 16:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2023

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits Files that changed from the base of the PR and between d82503e and 44d0bdc.
Files selected for processing (26)
  • crypto/keys/secp256k1/internal/secp256k1/ext.h (5 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/lax_der_parsing.c (2 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/lax_der_parsing.h (1 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/lax_der_privatekey_parsing.c (4 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/secp256k1.h (27 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/secp256k1_recovery.h (5 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_ecdh.c (1 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_internal.c (1 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_recover.c (2 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_schnorr_verify.c (3 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_sign.c (2 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/bench_verify.c (4 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/group_impl.h (6 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/java/org/bitcoin/NativeSecp256k1.java (6 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.c (12 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/java/org_bitcoin_NativeSecp256k1.h (2 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/java/org_bitcoin_Secp256k1Context.c (1 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/tests_impl.h (4 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h (6 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/tests_impl.h (7 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/secp256k1.c (21 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/tests.c (28 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/tests_exhaustive.c (7 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/panic_cb.go (1 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go (2 hunks)
  • crypto/keys/secp256k1/internal/secp256k1/secp256.go (4 hunks)

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json

@julienrbrt julienrbrt changed the title Bug: secp256k1 cgo duplicate symbols fix(crypto): secp256k1 cgo duplicate symbols Oct 30, 2023
@julienrbrt julienrbrt linked an issue Oct 30, 2023 that may be closed by this pull request
1 task
@github-prbot github-prbot requested review from a team, tac0turtle and samricotta and removed request for a team October 30, 2023 17:14
@github-actions
Copy link
Contributor

@JulianToledano your pull request is missing a changelog!

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

is there any way to do this without changing the fork?

potentially creating another file that can be used when importing geth, different build tag. Preferably it would be good to not touch the fork as when we go to update it this will get reverted

@JulianToledano
Copy link
Contributor Author

I didn't find any other solution but renaming the duplicated symbols.

Problem is clang on mac does not allow the use of --allow-multiple-definition and using -zmuldefs doesn't solve it either.

@tac0turtle
Copy link
Member

tac0turtle commented Oct 31, 2023

--allow-multiple-definition

I didn't find any other solution but renaming the duplicated symbols.

Problem is clang on mac does not allow the use of --allow-multiple-definition and using -zmuldefs doesn't solve it either.

maybe that is fine, for linux we say use these flags if importing geth and for mac we say we dont support secp cgo while importing geth? this allows us to keep the fork untouched.

What are your thoughts on that?

@JulianToledano
Copy link
Contributor Author

JulianToledano commented Nov 1, 2023

--allow-multiple-definition

I didn't find any other solution but renaming the duplicated symbols.
Problem is clang on mac does not allow the use of --allow-multiple-definition and using -zmuldefs doesn't solve it either.

maybe that is fine, for linux we say use these flags if importing geth and for mac we say we dont support secp cgo while importing geth? this allows us to keep the fork untouched.

What are your thoughts on that?

I've been checking the history of the fork and had never been updated. There are also some commits (most of them about linting and typos) but also adding the dummy.go files.

I think the decision here is either:

  • don't allow mac users to work with cgo on projects that use both the SDK and go-ethereum
  • modify this files, knowing that if updated mac users won't be able to work or we'll need to redo this work.

@tac0turtle
Copy link
Member

im more in favor of not touching forks like this, i think documentation would help. If users would want to modify use it on mac they could do so within docker

@JulianToledano
Copy link
Contributor Author

Understood, I'll make a PR with the documentation

@JulianToledano JulianToledano deleted the julian/secp256k1-cgo-go-ethereum branch November 4, 2023 12:23
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.

[Bug]: use of cgo secp256k1 conflicts with geth imports
3 participants