Skip to content

Commit

Permalink
abigen: osx rosetta fixes [SLT-452] (#3365)
Browse files Browse the repository at this point in the history
* platform bump [SLT-452]

* add contract

* Revert "add contract"

This reverts commit 91f8158.

* add docs around m1

* readme nit [ci skip]

---------

Co-authored-by: Trajan0x <[email protected]>
  • Loading branch information
trajan0x and trajan0x authored Nov 2, 2024
1 parent 496c228 commit bd67b1b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 23 additions & 0 deletions tools/abigen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).
2 changes: 1 addition & 1 deletion tools/abigen/internal/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit bd67b1b

Please sign in to comment.