filecoin-project / go-crypto

Other
3 stars 5 forks source link

Using go-ethereum module together with go-crypto in an application results in build errors #2

Closed jimpick closed 3 months ago

jimpick commented 6 months ago

Developers who are building applications in go that use both go-ethereum and go-crypto will encounter a build error that looks like this:

$ go build
# github.com/glifio/cli
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000058.o: in function `secp256k1GoPanicIllegal':
/tmp/go-build/_cgo_export.c:27: multiple definition of `secp256k1GoPanicIllegal'; /mnt/durable-disk/tmp/go-link-2271829685/000054.o:/tmp/go-build/_cgo_export.c:27: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000058.o: in function `secp256k1GoPanicError':
/tmp/go-build/_cgo_export.c:46: multiple definition of `secp256k1GoPanicError'; /mnt/durable-disk/tmp/go-link-2271829685/000054.o:/tmp/go-build/_cgo_export.c:46: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_create':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:58: multiple definition of `secp256k1_context_create'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:56: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_clone':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:83: multiple definition of `secp256k1_context_clone'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:81: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_destroy':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:92: multiple definition of `secp256k1_context_destroy'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:90: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_set_illegal_callback':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:101: multiple definition of `secp256k1_context_set_illegal_callback'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:99: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_set_error_callback':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:109: multiple definition of `secp256k1_context_set_error_callback'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:107: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_parse':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:150: multiple definition of `secp256k1_ec_pubkey_parse'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:148: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_serialize':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:165: multiple definition of `secp256k1_ec_pubkey_serialize'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:163: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_signature_parse_der':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:212: multiple definition of `secp256k1_ecdsa_signature_parse_der'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:210: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_signature_parse_compact':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:228: multiple definition of `secp256k1_ecdsa_signature_parse_compact'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:226: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_signature_serialize_der':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:249: multiple definition of `secp256k1_ecdsa_signature_serialize_der'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:247: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_signature_serialize_compact':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:261: multiple definition of `secp256k1_ecdsa_signature_serialize_compact'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:259: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_signature_normalize':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:274: multiple definition of `secp256k1_ecdsa_signature_normalize'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:272: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_verify':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:293: multiple definition of `secp256k1_ecdsa_verify'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:291: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_sign':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:345: multiple definition of `secp256k1_ecdsa_sign'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:343: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_seckey_verify':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:391: multiple definition of `secp256k1_ec_seckey_verify'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:389: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_create':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:404: multiple definition of `secp256k1_ec_pubkey_create'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:402: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_privkey_tweak_add':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:427: multiple definition of `secp256k1_ec_privkey_tweak_add'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:425: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_tweak_add':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:450: multiple definition of `secp256k1_ec_pubkey_tweak_add'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:448: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_privkey_tweak_mul':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:474: multiple definition of `secp256k1_ec_privkey_tweak_mul'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:472: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_tweak_mul':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:496: multiple definition of `secp256k1_ec_pubkey_tweak_mul'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:494: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_context_randomize':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:520: multiple definition of `secp256k1_context_randomize'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:518: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ec_pubkey_combine':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:527: multiple definition of `secp256k1_ec_pubkey_combine'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:525: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_recoverable_signature_parse_compact':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/modules/recovery/main_impl.h:38: multiple definition of `secp256k1_ecdsa_recoverable_signature_parse_compact'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/modules/recovery/main_impl.h:38: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_recoverable_signature_serialize_compact':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/modules/recovery/main_impl.h:60: multiple definition of `secp256k1_ecdsa_recoverable_signature_serialize_compact'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/modules/recovery/main_impl.h:60: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_recoverable_signature_convert':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/modules/recovery/main_impl.h:74: multiple definition of `secp256k1_ecdsa_recoverable_signature_convert'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/modules/recovery/main_impl.h:74: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_sign_recoverable':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/modules/recovery/main_impl.h:123: multiple definition of `secp256k1_ecdsa_sign_recoverable'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/modules/recovery/main_impl.h:123: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ecdsa_recover':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/modules/recovery/main_impl.h:170: multiple definition of `secp256k1_ecdsa_recover'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/modules/recovery/main_impl.h:170: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o: in function `secp256k1_ext_scalar_mul':
/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/ext.h:101: multiple definition of `secp256k1_ext_scalar_mul'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/ext.h:101: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o:/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:343: multiple definition of `secp256k1_nonce_function_default'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:341: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o:/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/secp256k1.c:342: multiple definition of `secp256k1_nonce_function_rfc6979'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/secp256k1.c:340: first defined here
/usr/bin/ld: /mnt/durable-disk/tmp/go-link-2271829685/000061.o:/home/jim/go/pkg/mod/github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52/./libsecp256k1/src/group_impl.h:71: multiple definition of `CURVE_B'; /mnt/durable-disk/tmp/go-link-2271829685/000057.o:/home/jim/go/pkg/mod/github.com/ethereum/go-ethereum@v1.12.0/crypto/secp256k1/./libsecp256k1/src/group_impl.h:71: first defined here
collect2: error: ld returned 1 exit status

This happens because go-crypto is using https://github.com/ipsn/go-secp256k1 .. which consists of a cgo based library extracted from go-ethereum.

So when go-crypto is used at the same time as go-ethereum in a binary, both cgo libraries get built, but both have the same symbol names, so it won't link.

For the glif binaries, we've developed a workaround using a replace directive in go.mod and a forked version of go-secp256k1:

This workaround only works if the replace directive is used in go.mod. Unfortunately that means that the glif cli can't be distributed using go install:

$ go install github.com/glifio/cli@latest
go: downloading github.com/glifio/cli v1.0.3
go: github.com/glifio/cli@latest (in github.com/glifio/cli@v1.0.3):
    The go.mod file for the module providing named packages contains one or
    more replace directives. It must not contain directives that would cause
    it to be interpreted differently than if it were the main module.
jimpick commented 6 months ago

@Stebalien suggested it might be possible to replace the cgo library with a pure go implementation (used by libp2p):

This shouldn't affect gas because "FVM uses https://github.com/paritytech/libsecp256k1 and message inclusion charges for storage, not signature verification"

ribasushi commented 6 months ago

Fwiw this same library has been used for over a year in https://pkg.go.dev/github.com/jsign/go-filsigner

Stebalien commented 6 months ago

Awesome! I looks like we may be able to borrow the glue code from that library as well (I'd depend on it directly, but that would introduce a cycle).

jimpick commented 5 months ago

If we want to eliminate the problematic ipsn/go-secp256k1 dependency from Lotus, the following modules would need to be updated to use the replacement implementation. (from go mod graph in Lotus)

github.com/ipsn/go-secp256k1@v0.0.0-20180726113642-9d62b9f0bc52
github.com/filecoin-project/go-address@v1.1.0
github.com/filecoin-project/filecoin-ffi@v0.30.4-0.20220519234331-bfd1f5f9fe38
github.com/filecoin-project/go-fil-markets@v1.28.3
github.com/filecoin-project/go-state-types@v0.13.1
github.com/filecoin-project/test-vectors/schema@v0.0.7
github.com/ipni/index-provider@v0.12.0
github.com/filecoin-project/go-state-types@v0.11.2-0.20230712101859-8f37624fa540
github.com/filecoin-project/filecoin-ffi@v0.30.4-0.20200910194244-f640612a1a1f
github.com/filecoin-project/go-commp-utils@v0.1.3
github.com/filecoin-project/go-commp-utils/nonffi@v0.0.0-20220905160352-62059082a837
github.com/filecoin-project/go-crypto@v0.0.1
github.com/filecoin-project/go-crypto@v0.0.0-20191218222705-effae4ea9f03
github.com/filecoin-project/go-address@v0.0.5
github.com/filecoin-project/specs-actors@v0.9.15
github.com/filecoin-project/specs-actors/v3@v3.1.2
github.com/filecoin-project/specs-actors/v4@v4.0.2
github.com/filecoin-project/specs-actors/v5@v5.0.6
github.com/filecoin-project/specs-actors/v6@v6.0.2
github.com/filecoin-project/specs-actors/v7@v7.0.1
github.com/filecoin-project/specs-actors/v8@v8.0.1
github.com/filecoin-project/go-state-types@v0.1.10
github.com/filecoin-project/go-state-types@v0.1.6
github.com/filecoin-project/specs-actors@v0.9.15-0.20220514164640-94e0d5e123bd
github.com/filecoin-project/go-address@v0.0.3
github.com/filecoin-project/specs-actors/v2@v2.3.6
github.com/filecoin-project/go-state-types@v0.0.0-20201102161440-c8033295a1fc
github.com/filecoin-project/specs-actors@v0.9.13
github.com/filecoin-project/go-state-types@v0.1.0
github.com/filecoin-project/go-state-types@v0.0.0-20200928172055-2df22083d8ab

(parsing script)

jimpick commented 5 months ago

It was easier to fork go-ethereum and rename the symbols there. I experimented with that approach here, and it worked:

Because there is no longer a replace directive in go.mod, we can now use go install:

$ go install github.com/glifio/cli@2c22d4e4f1164d9f3e2448f38828065ebdcd86c1
$ cli
Usage:
  glif [command]

Available Commands:
  agent         Commands for interacting with the Glif Agent
  completion    Generate the autocompletion script for the specified shell
  help          Help about any command
  ifil          Commands for interacting with the Infinity Pool Liquid Staking Token (iFIL)
  infinity-pool Commands for interacting with the Infinity Pool
  info          Prints information about the CLI
  pools         Commands for interacting with the GLIF Pools Protocol
  wallet        Manage Glif wallets
  wfil          Commands for interacting with Wrapped Filecoin tokens

Flags:
      --config-dir string   config directory
  -h, --help                help for glif
  -t, --toggle              Help message for toggle

Use "glif [command] --help" for more information about a command.

The downside to this approach is that you have to use the forked go-ethereum, which is probably a turn-off for most developers.

Stebalien commented 5 months ago

If we want to eliminate the problematic ipsn/go-secp256k1 dependency from Lotus, the following modules would need to be updated to use the replacement implementation. (from go mod graph in Lotus)

Those are transitive dependencies through go-crypto (with maybe a few exceptions).

Stebalien commented 5 months ago

I.e., updating go-crypto in the root module to a version that doesn't depend on the ipni package should be sufficient.

jimpick commented 5 months ago

That sounds great. I didn't understand that go modules would work that way.

I did make a jimpick/go-crypto package here that uses glifio/go-secp256k1 instead of ipsn/go-secp256k1: https://github.com/jimpick/go-crypto/tree/glifio_secp256k1

It's still the same native library, just with renamed symbols.

Without using a replace directive, I can't really test it as a replacement for the filecoin-project/go-crypto package ... as I don't have the ability to write to that repo.

Schwartz10 commented 5 months ago

The Jon branch in this repository will fix this issue