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

build statically-linked sui-node for testing on glibc-based hosts #18611

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

jnaulty
Copy link
Contributor

@jnaulty jnaulty commented Jul 11, 2024

Description

Update Deterministic Sui Build to compile a statically-linked binary.
StageX uses musl for compiling sui-node.

In order for this to run the sui-node binary directly on glibc-based linux macines, it must be statically linked.

Test plan

Cherry-pick commit to testnet branch and test on a private testnet.

  • build docker image
  • extract sui-node binary
  • confirm statically linked (run file on mac, ldd on linux)
  • upload to baremetal test server + run
  • check build is still deterministic from github action build, linux machine, macOS machine

Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Jul 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Jul 11, 2024 3:51pm
sui-kiosk ⬜️ Ignored (Inspect) Jul 11, 2024 3:51pm
sui-typescript-docs ⬜️ Ignored (Inspect) Jul 11, 2024 3:51pm

ENV GIT_REVISION=${GIT_REVISION}
ENV PROFILE=${PROFILE}

RUN --network=none cargo build --frozen --profile ${PROFILE} --bin sui-node
RUN --network=none cargo build --target x86_64-unknown-linux-musl --frozen --profile ${PROFILE} --bin sui-node
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this part needed? or is the fixing of the rust flags enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it actually is needed:

 => CACHED [build 7/8] COPY --from=linux-headers . /                                                                                                                                            0.0s
=> ERROR [build 8/8] RUN --network=none cargo build --frozen --profile release --bin sui-node                                                                                                  5.1s
------
> [build 8/8] RUN --network=none cargo build --frozen --profile release --bin sui-node:
5.010 error: cannot produce proc-macro for `ark-ff-asm v0.4.2` as the target `x86_64-unknown-linux-musl` does not support these crate types
------
Dockerfile:67
--------------------
 65 |     ENV PROFILE=${PROFILE}
 66 |     
 67 | >>> RUN --network=none cargo build --frozen --profile ${PROFILE} --bin sui-node
 68 |     
 69 |     FROM scratch AS install
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo build --frozen --profile ${PROFILE} --bin sui-node" did not complete successfully: exit code: 101

(other references to this issue of needing to specify --target

rust-lang/rust#78210 (comment)

https://msfjarvis.dev/posts/building-static-rust-binaries-for-linux/

The reason behind this seems to be a bug with cargo, where the RUSTFLAGS are applied to the target platform only when --target is explicitly provided

@jnaulty jnaulty merged commit e48c9c4 into main Jul 12, 2024
51 checks passed
@jnaulty jnaulty deleted the jnaulty/deterministic-sui-node-static-linked branch July 12, 2024 02:02
@jnaulty
Copy link
Contributor Author

jnaulty commented Jul 12, 2024

relates to: #13476

tx-tomcat pushed a commit to tx-tomcat/sui-network that referenced this pull request Jul 29, 2024
…stenLabs#18611)

## Description 

Update Deterministic Sui Build to compile a statically-linked binary.
StageX uses `musl` for compiling `sui-node`. 

In order for this to run the `sui-node` binary directly on glibc-based
linux macines, it must be statically linked.

## Test plan 

Cherry-pick commit to `testnet` branch and test on a private testnet.

* build docker image
* extract `sui-node` binary
* confirm statically linked (run `file` on mac, `ldd` on linux)
* upload to baremetal test server + run
* check build is still deterministic from github action build, linux
machine, macOS machine

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
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.

2 participants