Merge branch 'master' of github.com:primevprotocol/mev-commit-geth

This commit is contained in:
kant 2024-01-25 02:48:48 -08:00
commit 578e614738
5 changed files with 116 additions and 14 deletions

35
.github/workflows/goreleaser.yaml vendored Normal file
View file

@ -0,0 +1,35 @@
name: goreleaser
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: echo "flags=--snapshot" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.21
cache: true
- name: GHCR Docker Login
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean ${{ env.flags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

45
.goreleaser.yaml Normal file
View file

@ -0,0 +1,45 @@
version: 1
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
goarm:
- 7
ignore:
- goos: windows
goarch: arm64
main: ./cmd/geth
binary: geth
archives:
- format: tar.gz
# This name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# Use zip for windows archives.
format_overrides:
- goos: windows
format: zip
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

View file

@ -177,6 +177,8 @@ services:
networks: networks:
l1_net: l1_net:
ipv4_address: '172.14.0.2' ipv4_address: '172.14.0.2'
ports:
- 9545:8545 # Expose RPC port to host as 9545
volumes: volumes:
- geth-data-l1-bootnode:/data - geth-data-l1-bootnode:/data
profiles: profiles:

View file

@ -1,8 +1,9 @@
#!/bin/sh #!/bin/sh
set -exu set -exu
GETH_BIN_PATH=${GETH_BIN_PATH:-geth}
GENESIS_L1_PATH=${GENESIS_L1_PATH:-/genesis.json} GENESIS_L1_PATH=${GENESIS_L1_PATH:-/genesis.json}
VERBOSITY=3 VERBOSITY=${VERBOSITY:-3}
GETH_DATA_DIR=${GETH_DATA_DIR:-/data} GETH_DATA_DIR=${GETH_DATA_DIR:-/data}
GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata" GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata"
GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore" GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore"
@ -16,7 +17,7 @@ if [ ! -d "$GETH_KEYSTORE_DIR" ] && [ "$GETH_NODE_TYPE" = "signer" ]; then
echo "$GETH_KEYSTORE_DIR missing, running account import" echo "$GETH_KEYSTORE_DIR missing, running account import"
echo -n "pwd" > "$GETH_DATA_DIR"/password echo -n "pwd" > "$GETH_DATA_DIR"/password
echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key
geth --verbosity="$VERBOSITY" \ "$GETH_BIN_PATH" --verbosity="$VERBOSITY" \
--nousb \ --nousb \
account import \ account import \
--datadir="$GETH_DATA_DIR" \ --datadir="$GETH_DATA_DIR" \
@ -30,7 +31,7 @@ fi
if [ ! -d "$GETH_CHAINDATA_DIR" ]; then if [ ! -d "$GETH_CHAINDATA_DIR" ]; then
echo "$GETH_CHAINDATA_DIR missing, running init" echo "$GETH_CHAINDATA_DIR missing, running init"
echo "Initializing genesis." echo "Initializing genesis."
geth --verbosity="$VERBOSITY" \ "$GETH_BIN_PATH" --verbosity="$VERBOSITY" \
--nousb \ --nousb \
--state.scheme=path \ --state.scheme=path \
--db.engine=pebble \ --db.engine=pebble \
@ -42,6 +43,19 @@ fi
# Obtain assigned container IP for p2p # Obtain assigned container IP for p2p
NODE_IP=${NODE_IP:-$(hostname -i)} NODE_IP=${NODE_IP:-$(hostname -i)}
echo "NODE_IP is set to: $NODE_IP"
PUBLIC_NODE_IP=${PUBLIC_NODE_IP:-""}
echo "EXTERNAL_NODE_IP is set to: $PUBLIC_NODE_IP"
# Set NAT_FLAG based on whether PUBLIC_NODE_IP is empty or not
if [ -n "$PUBLIC_NODE_IP" ]; then
NAT_FLAG="--nat=extip:$PUBLIC_NODE_IP"
else
NAT_FLAG="--nat=none"
fi
# (Optional) Echo the values for verification
if [ "$GETH_NODE_TYPE" = "bootnode" ]; then if [ "$GETH_NODE_TYPE" = "bootnode" ]; then
echo "Starting bootnode" echo "Starting bootnode"
@ -49,7 +63,7 @@ if [ "$GETH_NODE_TYPE" = "bootnode" ]; then
# Generate boot.key # Generate boot.key
echo "$BOOT_KEY" > $GETH_DATA_DIR/boot.key echo "$BOOT_KEY" > $GETH_DATA_DIR/boot.key
exec geth \ exec "$GETH_BIN_PATH" \
--verbosity="$VERBOSITY" \ --verbosity="$VERBOSITY" \
--datadir="$GETH_DATA_DIR" \ --datadir="$GETH_DATA_DIR" \
--port 30301 \ --port 30301 \
@ -78,17 +92,19 @@ if [ "$GETH_NODE_TYPE" = "bootnode" ]; then
--pprof.port=60601 \ --pprof.port=60601 \
--nodekey $GETH_DATA_DIR/boot.key \ --nodekey $GETH_DATA_DIR/boot.key \
--netrestrict $NET_RESTRICT \ --netrestrict $NET_RESTRICT \
--nat extip:$NODE_IP \ "$NAT_FLAG" \
--txpool.accountqueue=512 \ --txpool.accountqueue=512 \
--rpc.allow-unprotected-txs --rpc.allow-unprotected-txs
elif [ "$GETH_NODE_TYPE" = "signer" ]; then elif [ "$GETH_NODE_TYPE" = "signer" ]; then
echo "Starting signer node" echo "Starting signer node"
echo "BOOTNODE_ENDPOINT is set to: $BOOTNODE_ENDPOINT"
GETH_PORT="${GETH_PORT:-30311}"
exec geth \ exec "$GETH_BIN_PATH" \
--verbosity="$VERBOSITY" \ --verbosity="$VERBOSITY" \
--datadir="$GETH_DATA_DIR" \ --datadir="$GETH_DATA_DIR" \
--port 30311 \ --port="$GETH_PORT" \
--syncmode=full \ --syncmode=full \
--gcmode=full \ --gcmode=full \
--state.scheme=path \ --state.scheme=path \
@ -124,15 +140,17 @@ elif [ "$GETH_NODE_TYPE" = "signer" ]; then
--authrpc.port="8551" \ --authrpc.port="8551" \
--authrpc.vhosts="*" \ --authrpc.vhosts="*" \
--txpool.accountqueue=512 \ --txpool.accountqueue=512 \
--nat extip:$NODE_IP "$NAT_FLAG"
elif [ "$GETH_NODE_TYPE" = "member" ]; then elif [ "$GETH_NODE_TYPE" = "member" ]; then
echo "Starting member node" echo "Starting member node"
echo "BOOTNODE_ENDPOINT is set to: $BOOTNODE_ENDPOINT"
GETH_PORT="${GETH_PORT:-30311}"
exec geth \ exec "$GETH_BIN_PATH" \
--verbosity="$VERBOSITY" \ --verbosity="$VERBOSITY" \
--datadir="$GETH_DATA_DIR" \ --datadir="$GETH_DATA_DIR" \
--port 30311 \ --port="$GETH_PORT" \
--syncmode=full \ --syncmode=full \
--gcmode=full \ --gcmode=full \
--state.scheme=path \ --state.scheme=path \
@ -162,7 +180,7 @@ elif [ "$GETH_NODE_TYPE" = "member" ]; then
--authrpc.port="8551" \ --authrpc.port="8551" \
--authrpc.vhosts="*" \ --authrpc.vhosts="*" \
--txpool.accountqueue=512 \ --txpool.accountqueue=512 \
--nat extip:$NODE_IP "$NAT_FLAG"
else else
echo "Invalid GETH_NODE_TYPE specified" echo "Invalid GETH_NODE_TYPE specified"
fi fi

View file

@ -4,11 +4,13 @@
set -e set -e
if [ -z "$1" ]; then # Use the first command line argument, if provided. Otherwise, use the environment variable.
echo "Usage: $0 <JSON_RPC_URL>" JSON_RPC="${1:-$JSON_RPC_URL}"
if [ -z "$JSON_RPC" ]; then
echo "Usage: $0 <JSON_RPC_URL> or set the JSON_RPC_URL environment variable."
exit 1 exit 1
fi fi
JSON_RPC="$1"
if ! [ -x "$(command -v curl)" ]; then if ! [ -x "$(command -v curl)" ]; then
echo "Curl must be installed to deploy the create2 proxy" >&2 echo "Curl must be installed to deploy the create2 proxy" >&2