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

Investigate dependencies of Rust code in go packages #2084

Open
kirugan opened this issue Aug 22, 2024 · 5 comments
Open

Investigate dependencies of Rust code in go packages #2084

kirugan opened this issue Aug 22, 2024 · 5 comments
Assignees
Labels

Comments

@kirugan
Copy link
Contributor

kirugan commented Aug 22, 2024

Context: the Starknet P2P explorer uses Juno as an external library for some of its features, but it's not as simple as doing go get, as it's required to compile the Rust dependencies.

For example, here's a snippet of the build process if Juno is used as a library (without the additional Rust compilation):

...
26.31 /usr/bin/ld: cannot find -ljuno_starknet_compiler_rs: No such file or directory
26.31 /usr/bin/ld: cannot find -ljuno_starknet_core_rs: No such file or directory
26.31 /usr/bin/ld: /tmp/go-link-3421764336/000026.o: in function `mygetgrouplist':
26.31 /_/GOROOT/src/os/user/getgrouplist_unix.go:15: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
26.31 /usr/bin/ld: /tmp/go-link-3421764336/000025.o: in function `mygetgrgid_r':
26.31 /_/GOROOT/src/os/user/cgo_lookup_cgo.go:45: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
...

List of packages that is used right now:

github.com/NethermindEth/juno/utils
github.com/NethermindEth/juno/clients/feeder
github.com/NethermindEth/juno/starknetdata/feeder

These packages shouldn't require rust code at all (especially utils package). We need to investigate what's going on

@ShantelPeters
Copy link

Can I work on this ?

Copy link

onlydustapp bot commented Aug 23, 2024

Hey @ShantelPeters!
Thanks for showing interest.
We've created an application for you to contribute to Juno.
Go check it out on OnlyDust!

@weiihann
Copy link
Contributor

weiihann commented Aug 23, 2024

Did some investigations:

github.com/NethermindEth/juno/clients/feeder

  • Depends on github.com/NethermindEth/juno/starknet
  • Indirectly depends on core, core/crypto (via starknet)

That's why the following errors occur:

26.31 /usr/bin/ld: cannot find -ljuno_starknet_compiler_rs: No such file or directory
26.31 /usr/bin/ld: cannot find -ljuno_starknet_core_rs: No such file or directory

So compilation is needed for packages core and starknet, which require Rust dependencies.

Some solutions in mind:

  1. Move the Rust code to its own packages for core and starknet
  • starknet contains the Compile function, in which only rpc and adapters/p2p2core are using it, we can move it to a separate package (i.e. compiler) without much issues
  • core contains cairo0classHash function, in which Cairo0Class from core is using it. It's slightly tricky, but I think we can move Cairo0Class to a separate package.

I'm not sure if this is the most elegant solution, as that means we have to be more careful about the dependencies of the packages. Perhaps I'll attempt to implement the solution and raise a PR.

wojciechos added a commit to NethermindEth/starknet-p2p-tests that referenced this issue Aug 28, 2024
Can't use the package directly right now due to dependencies issue in Juno.
Refer to: NethermindEth/juno#2084
wojciechos added a commit to NethermindEth/starknet-p2p-tests that referenced this issue Aug 28, 2024
Can't use the package directly right now due to dependencies issue in Juno.
Refer to: NethermindEth/juno#2084
wojciechos added a commit to NethermindEth/starknet-p2p-tests that referenced this issue Sep 13, 2024
… request (#1)

Please **ignore the /protocols/ directory.** It's copied directly from
Juno with minor changes. Temporarly I couldn't import the package
because of many not needed, heavy Rust deps. For more details, see:
[NethermindEth/juno#2084](NethermindEth/juno#2084).

PR added demo p2p tests for starkness network, including:
1. Conformance test for verifying block header
2. Performance test for block header
3. Peer discovery
@weiihann weiihann self-assigned this Sep 16, 2024
@derrix060
Copy link
Contributor

Being worked on in #2111

@Magicking
Copy link

« These packages shouldn't require rust code at all [...] »

As a 3-year-old Golang implementation of the Starknet protocol dubbed « the Starknet Golang client », no parts of this project should rely on any Rust code.

I would suggest to list, benchmark and track all the external functions used within these files:

./starknet/compiler/rust/src/lib.rs
./vm/rust/src/jsonrpc.rs
./vm/rust/src/juno_state_reader.rs
./vm/rust/src/versioned_constants.rs
./vm/rust/src/lib.rs

( ./core/rust/src/lib.rs is removed by #2111 )

To help the task of removing Rust code from the Golang client in order to be well integrated within the Golang ecosystem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants