mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
Merge pull request #3 from teddy931130/devops_task
Add docker-compose for local development
This commit is contained in:
commit
ab3f41ad80
3 changed files with 121 additions and 69 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -47,3 +47,6 @@ tests/spec-tests/
|
|||
.terraform
|
||||
terraform.tfstate*
|
||||
.terraform.tfstate.lock.info
|
||||
|
||||
.env
|
||||
geth-data/
|
||||
|
|
|
|||
87
README.md
87
README.md
|
|
@ -1,16 +1,14 @@
|
|||
## Go Ethereum
|
||||
# Go Ethereum
|
||||
|
||||
Golang execution layer implementation of the Ethereum protocol.
|
||||
|
||||
[](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
|
||||
[](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
|
||||
[](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
|
||||
[](https://app.travis-ci.com/github/ethereum/go-ethereum)
|
||||
[](https://discord.gg/nthXNEv)
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ The go-ethereum project comes with several wrappers/executables found in the `cm
|
|||
directory.
|
||||
|
||||
| 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. |
|
||||
| `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. |
|
||||
|
|
@ -54,17 +52,17 @@ on how you can run your own `geth` instance.
|
|||
|
||||
Minimum:
|
||||
|
||||
* CPU with 4+ cores
|
||||
* 8GB RAM
|
||||
* 1TB free storage space to sync the Mainnet
|
||||
* 8 MBit/sec download Internet service
|
||||
- CPU with 4+ cores
|
||||
- 8GB RAM
|
||||
- 1TB free storage space to sync the Mainnet
|
||||
- 8 MBit/sec download Internet service
|
||||
|
||||
Recommended:
|
||||
|
||||
* Fast CPU with 8+ cores
|
||||
* 16GB+ RAM
|
||||
* High-performance SSD with at least 1TB of free space
|
||||
* 25+ MBit/sec download Internet service
|
||||
- Fast CPU with 8+ cores
|
||||
- 16GB+ RAM
|
||||
- High-performance SSD with at least 1TB of free space
|
||||
- 25+ MBit/sec download Internet service
|
||||
|
||||
### Full node on the main Ethereum network
|
||||
|
||||
|
|
@ -74,14 +72,15 @@ 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:
|
||||
|
||||
```shell
|
||||
$ geth console
|
||||
geth console
|
||||
```
|
||||
|
||||
This command will:
|
||||
* Start `geth` in snap sync mode (default, can be changed with the `--syncmode` flag),
|
||||
|
||||
- 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
|
||||
of the Ethereum network, which is very CPU intensive.
|
||||
* Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console),
|
||||
- Start the built-in interactive [JavaScript console](https://geth.ethereum.org/docs/interacting-with-geth/javascript-console),
|
||||
(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)
|
||||
(note: the `web3` version bundled within `geth` is very old, and not up to date with official docs),
|
||||
as well as `geth`'s own [management APIs](https://geth.ethereum.org/docs/interacting-with-geth/rpc).
|
||||
|
|
@ -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.
|
||||
|
||||
```shell
|
||||
$ geth --holesky console
|
||||
geth --holesky console
|
||||
```
|
||||
|
||||
The `console` subcommand has the same meaning as above and is equally
|
||||
|
|
@ -105,10 +104,10 @@ useful on the testnet too.
|
|||
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
@ -116,11 +115,11 @@ Specifying the `--holesky` flag, however, will reconfigure your `geth` instance
|
|||
`geth attach <datadir>/holesky/geth.ipc`. Windows users are not affected by
|
||||
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
|
||||
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 available between them.*
|
||||
accounts available between them._
|
||||
|
||||
### Configuration
|
||||
|
||||
|
|
@ -128,14 +127,14 @@ As an alternative to passing the numerous flags to the `geth` binary, you can al
|
|||
configuration file via:
|
||||
|
||||
```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
|
||||
export your existing configuration:
|
||||
|
||||
```shell
|
||||
$ geth --your-favourite-flags dumpconfig
|
||||
geth --your-favourite-flags dumpconfig
|
||||
```
|
||||
|
||||
#### Docker quick start
|
||||
|
|
@ -174,18 +173,18 @@ you'd expect.
|
|||
|
||||
HTTP based JSON-RPC API options:
|
||||
|
||||
* `--http` Enable the HTTP-RPC server
|
||||
* `--http.addr` HTTP-RPC server listening interface (default: `localhost`)
|
||||
* `--http.port` HTTP-RPC server listening port (default: `8545`)
|
||||
* `--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)
|
||||
* `--ws` Enable the WS-RPC server
|
||||
* `--ws.addr` WS-RPC server listening interface (default: `localhost`)
|
||||
* `--ws.port` WS-RPC server listening port (default: `8546`)
|
||||
* `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
|
||||
* `--ws.origins` Origins from which to accept WebSocket requests
|
||||
* `--ipcdisable` Disable the IPC-RPC server
|
||||
* `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
|
||||
- `--http` Enable the HTTP-RPC server
|
||||
- `--http.addr` HTTP-RPC server listening interface (default: `localhost`)
|
||||
- `--http.port` HTTP-RPC server listening port (default: `8545`)
|
||||
- `--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)
|
||||
- `--ws` Enable the WS-RPC server
|
||||
- `--ws.addr` WS-RPC server listening interface (default: `localhost`)
|
||||
- `--ws.port` WS-RPC server listening port (default: `8546`)
|
||||
- `--ws.api` API's offered over the WS-RPC interface (default: `eth,net,web3`)
|
||||
- `--ws.origins` Origins from which to accept WebSocket requests
|
||||
- `--ipcdisable` Disable the IPC-RPC server
|
||||
- `--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
|
||||
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:
|
||||
|
||||
* 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 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 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 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
|
||||
|
||||
|
|
@ -226,13 +225,13 @@ and merge procedures quick and simple.
|
|||
|
||||
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/)).
|
||||
* 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.
|
||||
* Pull requests need to be based on and opened against the `master` branch.
|
||||
* Commit messages should be prefixed with the package(s) they modify.
|
||||
* E.g. "eth, rpc: make trace configs optional"
|
||||
- Pull requests need to be based on and opened against the `master` branch.
|
||||
- Commit messages should be prefixed with the package(s) they modify.
|
||||
- E.g. "eth, rpc: make trace configs optional"
|
||||
|
||||
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
|
||||
|
|
|
|||
50
docker-compose.yml
Normal file
50
docker-compose.yml
Normal 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
|
||||
Loading…
Reference in a new issue