diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 19bae76bf9..5fda0ca290 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -187,6 +187,10 @@ If you need to make a new go module, here are the steps to follow: For the most part, we follow the [uber style guide](https://github.com/uber-go/guide/blob/master/style.md). +### macOS and Docker-based Tools + +If you're using a Mac with Apple Silicon (M1/M2/M3), you might encounter issues with Docker-based tools that use AMD64 images. This is particularly relevant for tools like our `abigen` utility. Please see our [abigen README](./tools/abigen/README.md#note-on-macos-and-rosetta) for details on how to resolve Rosetta-related issues and our plans for future improvements. + ### Testing We often use the [testsuite](https://pkg.go.dev/github.com/synapsecns/sanguine/core/testsuite) lib to create a test suite. You don't need this, as it adds a lot of overhead, but if you need a context you should us it. This library contains two methods: diff --git a/tools/abigen/README.md b/tools/abigen/README.md index 625cf84304..642ce288f0 100644 --- a/tools/abigen/README.md +++ b/tools/abigen/README.md @@ -19,6 +19,8 @@ package generate ``` + + ### Note: Using abigen this way can occasionally cause you to run into the following error string: `missing go.sum entry for module providing package`. This is well documented in [several](https://github.com/99designs/gqlgen/issues/1483) projects made to be run from go-generate. If this is the case, you can create a package exclusively for updating the go.mod. @@ -123,3 +125,24 @@ func init() { 5. Golang native `sol-merger`. Currently, this package relies on [`sol-merger`](https://github.com/RyuuGan/sol-merger). This package handles C3 linearization (removing duplicate abstracts, etc) and dependency resolution in the way that go native solidity flatteners (e.g. [flattener](https://github.com/DaveAppleton/SolidityFlattery/blob/master/flat.go)) don't yet. It'd be nice to be able to do this in `abigen` so we could skip the merge step. 6. Consider generating a `doc.go` if one doesn't exist documenting the package 7. Better vyper support + +### Note on macOS and Rosetta + +If you are using a Mac with Apple Silicon, you might encounter issues running AMD64 Docker images due to the Rosetta translation layer. Rosetta is a dynamic binary translator that allows applications compiled for Intel processors to run on Apple Silicon. However, it may not always work seamlessly with Docker images designed for AMD64 architecture. + +To resolve this issue, you can: + +1. **Install Rosetta**: If not already installed, run the following command in your terminal: + ```shell + softwareupdate --install-rosetta + ``` + +2. **Update Docker**: Ensure your Docker Desktop is up-to-date by navigating to **Settings** > **Software Update** > **Check for Updates**. + +3. **Disable x86_64/amd64 Emulation**: In Docker Desktop, go to **General settings** and disable the x86_64/amd64 emulation using Rosetta. + +For a detailed guide on fixing this issue, refer to [this blog post](https://romanzipp.com/blog/maocs-sequoia-docker-resetta-is-only-intended-to-run-silicon). + +### Future Plans + +To mitigate these issues, we plan to implement a fallback mechanism that downloads `solc` directly, bypassing the need for Docker-based solutions on incompatible architectures. For more details on this planned improvement, see [issue #3366](https://github.com/synapsecns/sanguine/issues/3366). diff --git a/tools/abigen/internal/generate.go b/tools/abigen/internal/generate.go index 1ce183c2b3..a1015add72 100644 --- a/tools/abigen/internal/generate.go +++ b/tools/abigen/internal/generate.go @@ -211,7 +211,7 @@ func createRunFile(version string) (runFile *os.File, err error) { } // create a bash file that runs solidity with args passed to the run file - _, err = runFile.WriteString(fmt.Sprintf("#!/bin/bash -e \n$(which docker) run -v $(pwd):/solidity ethereum/solc:%s \"$@\"", version)) + _, err = runFile.WriteString(fmt.Sprintf("#!/bin/bash -e \n$(which docker) run --platform linux/amd64 -v $(pwd):/solidity ethereum/solc:%s \"$@\"", version)) if err != nil { return nil, fmt.Errorf("could not create temp file: %w", err) }