From 3964663eba754329e6d91bcb7e207fab89b14e81 Mon Sep 17 00:00:00 2001 From: Andy Tudhope <13001517+andytudhope@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:14:58 +0200 Subject: [PATCH] Hack fixes (#28) * Adjust precompiles guide * attends to feedback from circumventing --- docs/how-to/create-precompiles.mdx | 10 +++-- docs/how-to/run-suave.mdx | 64 +++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 10 deletions(-) diff --git a/docs/how-to/create-precompiles.mdx b/docs/how-to/create-precompiles.mdx index 6a1935a7..d3be225e 100644 --- a/docs/how-to/create-precompiles.mdx +++ b/docs/how-to/create-precompiles.mdx @@ -58,7 +58,7 @@ functions: type: Bid ``` -There are three to-level objects: `types`, `structs` and `functions`. In this guide, we will focus on the `functions`, as adding a new precompile will most often entail writing a new function. +There are three top-level objects: `types`, `structs` and `functions`. In this guide, we will focus on the `functions`, as adding a new precompile will most often entail writing a new function. If you can specify the function's name, the address its logic is deployed at on SUAVE, and what form you expect the inputs and output to take, then our codegen tool will automatically generate both the Solidity and Go bindings required to make your precompile work. @@ -107,9 +107,9 @@ Then, run our code generator: $ go run suave/gen/main.go --write ``` -If your `yaml` additions have no errors and the `--write` flag is set, the bindings will be regenerated [here](https://github.com/flashbots/suave-geth/blob/main/suave/sol/libraries/Suave.sol) and [here](https://github.com/flashbots/suave-geth/blob/main/core/vm/contracts_suave_runtime_adapter.go). +If your `yaml` additions have no errors and the `--write` flag is set, the bindings will be (re)generated [here](https://github.com/flashbots/suave-geth/blob/main/suave/sol/libraries/Suave.sol) and [here](https://github.com/flashbots/suave-geth/blob/main/core/vm/contracts_suave_runtime_adapter.go). -A new `Add` function will have been created will have been created in the interface, which looks like: +A new `Add` function will have been created in the interface, which looks like: ```go type SuaveRuntime interface { @@ -119,7 +119,9 @@ type SuaveRuntime interface { } ``` -You will now need to write the logic required for your precompile to work as expected based on this generated skeleton. You can do this in the specific `suaveRuntime` struct generated in the same `contracts_suave_runtime_adapter.go` file. In our case, the logic is very simple: just a straightforward addition of the values passed in as inputs. Your implementation may be arbitrarily more complex based on what you want the precompile to achieve. +You will now need to write the logic required for your precompile to work as expected based on this generated skeleton. + +You can do this in `contracts_suave.go`. In our case, the logic is very simple: just a straightforward addition of the values passed in as inputs. Your implementation may be arbitrarily more complex based on what you want the precompile to achieve. ````go func (b *suaveRuntime) Add(a uint64, b uint64) (uint64, error) { diff --git a/docs/how-to/run-suave.mdx b/docs/how-to/run-suave.mdx index f6039e60..28fe6e1d 100644 --- a/docs/how-to/run-suave.mdx +++ b/docs/how-to/run-suave.mdx @@ -34,11 +34,29 @@ git clone https://github.com/flashbots/suave-geth.git ```bash cd suave-geth/ ``` -3. Run SUAVE (depending on your docker setup, you may need to run this as `sudo`): +3. Run SUAVE: ```bash make devnet-up ``` +
+ 1. Docker permission errors +
+
+
+ It is likely best to create a new user group for Docker, rather than run the above command as sudo. You can do by running:

+ + sudo usermod -aG docker $USER +
+ + newgrp docker + +
+
+
+
+ + ### Optional testing 4. Test your node by deploying a contract and sending it some transactions: @@ -69,10 +87,40 @@ You can also navigate to [http://localhost:8080](http://localhost:8080) in your make devnet-down ``` -### Common problems +### Troubleshooting
- 1. Docker not running + 1. Go permission errors +
+
+
+ If you are seeing:
+ + "cp: cannot create regular file '/bin/suave': Permission denied" +

+ it is most likely because you have not set your GOPATH correctly. You can do so by running:

+ + export GOPATH=$HOME/go + +
+
+
+
+
+ 2. Missing packages +
+
+
+ If you have set up a new machine to run through this, you'll also need to install Make and Go:
+ + sudo apt install make golang-go + +
+
+
+
+
+ 2. Docker not running
@@ -83,13 +131,17 @@ make devnet-down You can check the current status with:
sudo systemctl status docker +

+ If you installed Docker and still run into issues wit docker-compose, you can try:
+ + sudo apt install docker-compose
- 2. Unsupported version + 3. Unsupported version
@@ -97,7 +149,7 @@ make devnet-down ERROR: Version in "././suave/devenv/docker-compose.yml" is unsupported.

- Simply go to the file in /suave/devenv/docker-compose.yml and change the first line to use 3.3 rather than 3.8. + Go to the file in /suave/devenv/docker-compose.yml and change the first line to use 3.3 rather than 3.8.
@@ -147,7 +199,7 @@ If the `--datadir` flag is not set, a geth client stores data in the `$HOME/.eth You can attach to the usual Geth javascript console to get any interactive data you need with: ```bash -./build/bin/suave attach ./suave/geth.ipc +./build/bin/suave attach /tmp/geth.ipc ``` From within the console, you can run: