Skip to content

Commit

Permalink
improve geth action
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaying-peng committed Oct 20, 2022
1 parent 576defd commit 2e88aa9
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 9 deletions.
16 changes: 14 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ outputs:
rpc_url:
description: "url of JSON RPC"
value: http://localhost:8546
address:
description: "account of address"
value: "0x622fbe99b3a378fac736bf29d7e23b85e18816eb"
private_key:
description: "account of private key"
value: "0xde665c1c4bb8a5b74386dd8fb17dd2ba9a59db6cc11aea4d27ebdc5ecf46c13c"
password:
description: "account of passowrd"
value: "password"
network_id:
description: "network id"
value: "10412"
value: "12345"
chain_id:
description: "chain id"
value: "10412"
value: "12345"
runs:
using: "composite"
steps:
- id: init
run: cd ${{ github.action_path }}; docker-compose run --rm geth ./scripts/init.sh
shell: bash
- id: run
run: cd ${{ github.action_path }}; docker-compose up -d
shell: bash
15 changes: 8 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
version: '3'

services:
geth-ethereum-mainnet:
geth:
image: ethereum/client-go:v1.10.23
environment:
- DEVMODE=true
command: [ "--dev", "--dev.period", "0",
"--http", "--http.api",
"personal,eth,net,web3,debug",
"--http.addr", "0.0.0.0",
"--datadir", "./data", "--http.vhosts=*"]
volumes:
- ".docker/geth:/root"
- "./.ethereum:/root/.ethereum"
- "./geth/config:/root/config"
- "./geth/scripts:/root/scripts"
working_dir: /root
entrypoint: sh
ports:
- "8546:8545"
command: ./scripts/run.sh

26 changes: 26 additions & 0 deletions geth/config/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"config": {
"chainId": 12345,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"clique": {
"period": 0,
"epoch": 30000
}
},
"difficulty": "1",
"gasLimit": "8000000",
"extradata": "0x00000000000000000000000000000000000000000000000000000000000000004cdbd835fe18bd93cca39a262cff72dbac99e24f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"alloc": {
"622fbe99b3a378fac736bf29d7e23b85e18816eb": { "balance": "888888888888888888888888" },
"4cdbd835fe18bd93cca39a262cff72dbac99e24f": { "balance": "888888888888888888888888" }
}
}

1 change: 1 addition & 0 deletions geth/config/password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
password
1 change: 1 addition & 0 deletions geth/config/private-key1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f78955a540221936a4eba0edd96547fc400d44f7f2107be4c7e72f6076a649d1
1 change: 1 addition & 0 deletions geth/config/private-key2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de665c1c4bb8a5b74386dd8fb17dd2ba9a59db6cc11aea4d27ebdc5ecf46c13c
8 changes: 8 additions & 0 deletions geth/scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -eu

geth init /root/config/genesis.json
geth --password /root/config/password.txt account import /root/config/private-key1.txt
geth --password /root/config/password.txt account import /root/config/private-key2.txt

22 changes: 22 additions & 0 deletions geth/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

set -eu

geth \
--verbosity 5 \
--nodiscover \
--syncmode 'full' \
--nat none \
--port 30310 \
--http \
--http.addr '0.0.0.0' \
--http.port 8545 \
--http.vhosts '*' \
--http.api 'personal,eth,net,web3,txpool,miner,debug' \
--networkid '12345' \
--mine \
--miner.etherbase '0x4cdBd835fE18BD93ccA39A262Cff72dbAC99E24F' \
--miner.gasprice 0 \
--unlock "0,1" \
--password /root/config/password.txt \
--allow-insecure-unlock

0 comments on commit 2e88aa9

Please sign in to comment.