Merge pull request #3 from teddy931130/devops_task

Add docker-compose for local development
This commit is contained in:
Teodor Daskalov 2025-01-16 00:20:13 +02:00 committed by GitHub
commit ab3f41ad80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 121 additions and 69 deletions

3
.gitignore vendored
View file

@ -47,3 +47,6 @@ tests/spec-tests/
.terraform .terraform
terraform.tfstate* terraform.tfstate*
.terraform.tfstate.lock.info .terraform.tfstate.lock.info
.env
geth-data/

135
README.md
View file

@ -1,16 +1,14 @@
## Go Ethereum # Go Ethereum
Golang execution layer implementation of the Ethereum protocol. Golang execution layer implementation of the Ethereum protocol.
[![API Reference]( [![API Reference](https://pkg.go.dev/badge/github.com/ethereum/go-ethereum)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/ethereum/go-ethereum)](https://goreportcard.com/report/github.com/ethereum/go-ethereum) [![Go Report Card](https://goreportcard.com/badge/github.com/ethereum/go-ethereum)](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
[![Travis](https://app.travis-ci.com/ethereum/go-ethereum.svg?branch=master)](https://app.travis-ci.com/github/ethereum/go-ethereum) [![Travis](https://app.travis-ci.com/ethereum/go-ethereum.svg?branch=master)](https://app.travis-ci.com/github/ethereum/go-ethereum)
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/nthXNEv) [![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.gg/nthXNEv)
Automated builds are available for stable releases and the unstable master branch. Binary Automated builds are available for stable releases and the unstable master branch. Binary
archives are published at https://geth.ethereum.org/downloads/. archives are published at <https://geth.ethereum.org/downloads/>.
## Building the source ## Building the source
@ -34,14 +32,14 @@ make all
The go-ethereum project comes with several wrappers/executables found in the `cmd` The go-ethereum project comes with several wrappers/executables found in the `cmd`
directory. directory.
| Command | Description | | Command | Description |
| :--------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :--------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI page](https://geth.ethereum.org/docs/fundamentals/command-line-options) for command line options. | | **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default), archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI page](https://geth.ethereum.org/docs/fundamentals/command-line-options) for command line options. |
| `clef` | Stand-alone signing tool, which can be used as a backend signer for `geth`. | | `clef` | Stand-alone signing tool, which can be used as a backend signer for `geth`. |
| `devp2p` | Utilities to interact with nodes on the networking layer, without running a full blockchain. | | `devp2p` | Utilities to interact with nodes on the networking layer, without running a full blockchain. |
| `abigen` | Source code generator to convert Ethereum contract definitions into easy-to-use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings) page for details. | | `abigen` | Source code generator to convert Ethereum contract definitions into easy-to-use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://docs.soliditylang.org/en/develop/abi-spec.html) with expanded functionality if the contract bytecode is also available. However, it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings) page for details. |
| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). | | `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug run`). |
| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). | | `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user-friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
## Running `geth` ## Running `geth`
@ -54,17 +52,17 @@ on how you can run your own `geth` instance.
Minimum: Minimum:
* CPU with 4+ cores - CPU with 4+ cores
* 8GB RAM - 8GB RAM
* 1TB free storage space to sync the Mainnet - 1TB free storage space to sync the Mainnet
* 8 MBit/sec download Internet service - 8 MBit/sec download Internet service
Recommended: Recommended:
* Fast CPU with 8+ cores - Fast CPU with 8+ cores
* 16GB+ RAM - 16GB+ RAM
* High-performance SSD with at least 1TB of free space - High-performance SSD with at least 1TB of free space
* 25+ MBit/sec download Internet service - 25+ MBit/sec download Internet service
### Full node on the main Ethereum network ### Full node on the main Ethereum network
@ -74,19 +72,20 @@ particular use case, the user doesn't care about years-old historical data, so w
sync quickly to the current state of the network. To do so: sync quickly to the current state of the network. To do so:
```shell ```shell
$ geth console geth console
``` ```
This command will: This command will:
* Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
causing it to download more data in exchange for avoiding processing the entire history - Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
of the Ethereum network, which is very CPU intensive. causing it to download more data in exchange for avoiding processing the entire history
* Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console), of the Ethereum network, which is very CPU intensive.
(via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md) - Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console),
(note: the `web3` version bundled within `geth` is very old, and not up to date with official docs), (via the trailing `console` subcommand) through which you can interact using [`web3` methods](https://github.com/ChainSafe/web3.js/blob/0.20.7/DOCUMENTATION.md)
as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc). (note: the `web3` version bundled within `geth` is very old, and not up to date with official docs),
This tool is optional and if you leave it out you can always attach it to an already running as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc).
`geth` instance with `geth attach`. This tool is optional and if you leave it out you can always attach it to an already running
`geth` instance with `geth attach`.
### A Full node on the Holesky test network ### A Full node on the Holesky test network
@ -97,7 +96,7 @@ network, you want to join the **test** network with your node, which is fully eq
the main network, but with play-Ether only. the main network, but with play-Ether only.
```shell ```shell
$ geth --holesky console geth --holesky console
``` ```
The `console` subcommand has the same meaning as above and is equally The `console` subcommand has the same meaning as above and is equally
@ -105,22 +104,22 @@ useful on the testnet too.
Specifying the `--holesky` flag, however, will reconfigure your `geth` instance a bit: Specifying the `--holesky` flag, however, will reconfigure your `geth` instance a bit:
* Instead of connecting to the main Ethereum network, the client will connect to the Holesky - Instead of connecting to the main Ethereum network, the client will connect to the Holesky
test network, which uses different P2P bootnodes, different network IDs and genesis test network, which uses different P2P bootnodes, different network IDs and genesis
states. states.
* Instead of using the default data directory (`~/.ethereum` on Linux for example), `geth` - Instead of using the default data directory (`~/.ethereum` on Linux for example), `geth`
will nest itself one level deeper into a `holesky` subfolder (`~/.ethereum/holesky` on will nest itself one level deeper into a `holesky` subfolder (`~/.ethereum/holesky` on
Linux). Note, on OSX and Linux this also means that attaching to a running testnet node Linux). Note, on OSX and Linux this also means that attaching to a running testnet node
requires the use of a custom endpoint since `geth attach` will try to attach to a requires the use of a custom endpoint since `geth attach` will try to attach to a
production node endpoint by default, e.g., production node endpoint by default, e.g.,
`geth attach <datadir>/holesky/geth.ipc`. Windows users are not affected by `geth attach <datadir>/holesky/geth.ipc`. Windows users are not affected by
this. this.
*Note: Although some internal protective measures prevent transactions from _Note: Although some internal protective measures prevent transactions from
crossing over between the main network and test network, you should always crossing over between the main network and test network, you should always
use separate accounts for play and real money. Unless you manually move use separate accounts for play and real money. Unless you manually move
accounts, `geth` will by default correctly separate the two networks and will not make any accounts, `geth` will by default correctly separate the two networks and will not make any
accounts available between them.* accounts available between them._
### Configuration ### Configuration
@ -128,14 +127,14 @@ As an alternative to passing the numerous flags to the `geth` binary, you can al
configuration file via: configuration file via:
```shell ```shell
$ geth --config /path/to/your_config.toml geth --config /path/to/your_config.toml
``` ```
To get an idea of how the file should look like you can use the `dumpconfig` subcommand to To get an idea of how the file should look like you can use the `dumpconfig` subcommand to
export your existing configuration: export your existing configuration:
```shell ```shell
$ geth --your-favourite-flags dumpconfig geth --your-favourite-flags dumpconfig
``` ```
#### Docker quick start #### Docker quick start
@ -150,7 +149,7 @@ docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
``` ```
This will start `geth` in snap-sync mode with a DB memory allowance of 1GB, as the This will start `geth` in snap-sync mode with a DB memory allowance of 1GB, as the
above command does. It will also create a persistent volume in your home directory for above command does. It will also create a persistent volume in your home directory for
saving your blockchain as well as map the default ports. There is also an `alpine` tag saving your blockchain as well as map the default ports. There is also an `alpine` tag
available for a slim version of the image. available for a slim version of the image.
@ -174,18 +173,18 @@ you'd expect.
HTTP based JSON-RPC API options: HTTP based JSON-RPC API options:
* `--http` Enable the HTTP-RPC server - `--http` Enable the HTTP-RPC server
* `--http.addr` HTTP-RPC server listening interface (default: `localhost`) - `--http.addr` HTTP-RPC server listening interface (default: `localhost`)
* `--http.port` HTTP-RPC server listening port (default: `8545`) - `--http.port` HTTP-RPC server listening port (default: `8545`)
* `--http.api` API's offered over the HTTP-RPC interface (default: `eth,net,web3`) - `--http.api` API's offered over the HTTP-RPC interface (default: `eth,net,web3`)
* `--http.corsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced) - `--http.corsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
* `--ws` Enable the WS-RPC server - `--ws` Enable the WS-RPC server
* `--ws.addr` WS-RPC server listening interface (default: `localhost`) - `--ws.addr` WS-RPC server listening interface (default: `localhost`)
* `--ws.port` WS-RPC server listening port (default: `8546`) - `--ws.port` WS-RPC server listening port (default: `8546`)
* `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`) - `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
* `--ws.origins` Origins from which to accept WebSocket requests - `--ws.origins` Origins from which to accept WebSocket requests
* `--ipcdisable` Disable the IPC-RPC server - `--ipcdisable` Disable the IPC-RPC server
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it) - `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
You'll need to use your own programming environments' capabilities (libraries, tools, etc) to You'll need to use your own programming environments' capabilities (libraries, tools, etc) to
connect via HTTP, WS or IPC to a `geth` node configured with the above flags and you'll connect via HTTP, WS or IPC to a `geth` node configured with the above flags and you'll
@ -208,9 +207,9 @@ to easily set up a network of geth nodes without also setting up a corresponding
There are three different solutions depending on your use case: There are three different solutions depending on your use case:
* If you are looking for a simple way to test smart contracts from go in your CI, you can use the [Simulated Backend](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings#blockchain-simulator). - If you are looking for a simple way to test smart contracts from go in your CI, you can use the [Simulated Backend](https://geth.ethereum.org/docs/developers/dapp-developer/native-bindings#blockchain-simulator).
* If you want a convenient single node environment for testing, you can use our [Dev Mode](https://geth.ethereum.org/docs/developers/dapp-developer/dev-mode). - If you want a convenient single node environment for testing, you can use our [Dev Mode](https://geth.ethereum.org/docs/developers/dapp-developer/dev-mode).
* If you are looking for a multiple node test network, you can set one up quite easily with [Kurtosis](https://geth.ethereum.org/docs/fundamentals/kurtosis). - If you are looking for a multiple node test network, you can set one up quite easily with [Kurtosis](https://geth.ethereum.org/docs/fundamentals/kurtosis).
## Contribution ## Contribution
@ -226,13 +225,13 @@ and merge procedures quick and simple.
Please make sure your contributions adhere to our coding guidelines: Please make sure your contributions adhere to our coding guidelines:
* Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) - Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting)
guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)). guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
* Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) - Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary)
guidelines. guidelines.
* Pull requests need to be based on and opened against the `master` branch. - Pull requests need to be based on and opened against the `master` branch.
* Commit messages should be prefixed with the package(s) they modify. - Commit messages should be prefixed with the package(s) they modify.
* E.g. "eth, rpc: make trace configs optional" - E.g. "eth, rpc: make trace configs optional"
Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/geth-developer/dev-guide) Please see the [Developers' Guide](https://geth.ethereum.org/docs/developers/geth-developer/dev-guide)
for more details on configuring your environment, managing project dependencies, and for more details on configuring your environment, managing project dependencies, and

50
docker-compose.yml Normal file
View file

@ -0,0 +1,50 @@
name: limechain-devops-task
services:
go-ethereum:
container_name: "go-ethereum"
image: "861276097334.dkr.ecr.eu-central-1.amazonaws.com/limechain-devops-task/go-ethereum:1"
### keep if testing build locally
# build:
# dockerfile: Dockerfile
# context: .
### override default 'geth' entrypoint to use a local devnet
### with persistent blockchain and account data (--datadir flag)
entrypoint: "geth --dev --datadir /root/.ethereum --http --http.api eth,web3,net --http.addr 0.0.0.0 --http.corsdomain 'https://remix.ethereum.org'"
volumes:
- "./geth-data:/root/.ethereum"
### keep to pass any env vars if necessary
# env_file:
# - ".env"
ports:
- "8545:8545"
- "8546:8546"
- "30303:30303"
- "30303:30303/udp"
networks:
go-ethereum:
ipv4_address: 172.25.0.2
healthcheck:
### test whether a tcp connection on the RPC port is successful
test: ["CMD-SHELL", "nc -w 1 -v localhost 8545 || exit 1"]
interval: 30s
timeout: 5s
retries: 3
deploy:
resources:
reservations:
cpus: "1"
memory: "1G"
limits:
cpus: "2"
memory: "2G"
restart: "on-failure:3"
networks:
go-ethereum:
driver: bridge
ipam:
config:
- subnet: 172.25.0.0/24