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

SPIKE: HMW build guardiand on an ARM mac M1 machine? #58

Closed
jonathanpberger opened this issue Jul 19, 2024 · 3 comments
Closed

SPIKE: HMW build guardiand on an ARM mac M1 machine? #58

jonathanpberger opened this issue Jul 19, 2024 · 3 comments
Assignees

Comments

@jonathanpberger
Copy link

No description provided.

@jonathanpberger
Copy link
Author

@mdulin2 has some ideas

@mdulin2
Copy link
Collaborator

mdulin2 commented Jul 19, 2024

Installing all of the dependencies for the Guardian to run locally is annoying because of Wormchain and CosmWasm. So, the Guardian is usually built within a [Docker](https://github.com/wormhole-foundation/wormhole/blob/main/node/Dockerfile) container.

For development purposes, this container sucks though. A sub container is created to save space but since it has no tools (including ls) it’s virtually impossible to work with. Additionally, this Dockerfile only works on amd64 computers, even though most people at AR have Macbooks.

Here’s a mod to the Dockerfile that works on arm Macbooks.

# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM --platform=linux/arm64 docker.io/golang:1.21.9-bullseye@sha256:311468bffa9fa4747a334b94e6ce3681b564126d653675a6adc46698b2b88d35 AS build
# libwasmvm.so is not compatible with arm

WORKDIR /app

COPY node/tools tools

RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
  cd tools/ && go build -mod=readonly -o /dlv github.com/go-delve/delve/cmd/dlv

COPY node node
COPY sdk sdk
COPY wormchain wormchain

ARG GO_BUILD_ARGS=-race

RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
  export CGO_ENABLED=1 && \
  cd node && \
  go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /guardiand github.com/certusone/wormhole/node && \
  go get github.com/CosmWasm/wasmvm@v1.1.1 && \
  cp /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.1.1/internal/api/libwasmvm.aarch64.so /usr/lib/

ENTRYPOINT ["/bin/bash"]

To build the container run docker build --tag guardian_node -f ./node/Dockerfile . from the top level directory of Wormhole. This is because the Guardian needs some things from the Wormchain directory.

To run the container, use docker run --privileged -i -t guardian_node to get a shell inside of it. After that, it’s a little playground to run the Guardian with. The command below starts it (unsuccessfully because the nodes aren’t up of course):

/guardiand node --unsafeDevMode --guardianKey /tmp/bridge.key --publicRPC [::]:7070 --publicWeb [::]:7071 --adminSocket /tmp/admin.sock --publicGRPCSocket /tmp/publicrpc.sock --dataDir /tmp/data --publicRpcLogDetail full --ccqEnabled=true --ccqAllowedRequesters=beFA429d57cD18b7F8A4d91A2da9AB4AF05d0FBe,25021A4FCAf61F2EADC8202D3833Df48B2Fa0D54 --ccqAllowedPeers=12D3KooWSnju8zhywCYVi2JwTqky1sySPnmtYLsHHzc4WerMnDQH,12D3KooWM6WqedfR6ehtTd1y6rJu3ZUrEkTjcJJnJZYesjd89zj8 --logLevel=info --bscRPC ws://eth-devnet2:8545 --chainGovernorEnabled --ethRPC ws://eth-devnet2:8545

If you want to get further into the execution process, you may need to modify hostname.go in order to remove the hostname check for testnet.

Run all Guardian tests that are run on the Github repo:

go test -v -timeout 5m -race -ldflags '-extldflags "-Wl,--allow-multiple-definition" ' ./...

@kakucodes
Copy link

created an issue in the upstream wormhole repo wormhole-foundation#4031

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

No branches or pull requests

3 participants