Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions clients/ethrex-revm/ethrex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,25 @@ else
cat /genesis.json
fi

echo "Command flags till now:"
echo $FLAGS

# Initialize the local testchain with the genesis state
# echo "Initializing database with genesis state..."
# $ethrex init $FLAGS --chain /genesis.json
FLAGS="$FLAGS --network /genesis.json"

# Set syncmode
if [ "$HIVE_NODETYPE" == "full" ]; then
FLAGS="$FLAGS --syncmode full"
fi
if [ "$HIVE_NODETYPE" == "snap" ]; then
FLAGS="$FLAGS --syncmode snap"
fi
if [ "$HIVE_NODETYPE" == "" ]; then
FLAGS="$FLAGS --syncmode full"
fi

echo "Command flags till now:"
echo $FLAGS

# Don't immediately abort, some imports are meant to fail
set +ex

Expand Down Expand Up @@ -96,7 +107,7 @@ else
echo "Warning: HIVE_TERMINAL_TOTAL_DIFFICULTY not supported."
fi

FLAGS="$FLAGS $ETHREX_FLAGS"
FLAGS="$FLAGS $ETHREX_FLAGS"

# Launch the main client.
echo "Running ethrex with flags: $FLAGS"
Expand Down
28 changes: 28 additions & 0 deletions clients/ethrex-snap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG baseimage=ghcr.io/lambdaclass/ethrex
ARG tag=latest

FROM $baseimage:$tag as builder

# Install script tools.
RUN apt-get update -y
RUN apt-get install -y bash curl jq

# Add genesis mapper script.
ADD genesis.json /genesis.json
ADD mapper.jq /mapper.jq

# Add the startup script.
ADD ethrex.sh /ethrex.sh
RUN chmod +x /ethrex.sh

# Add the enode URL retriever script.
ADD enode.sh /hive-bin/enode.sh
RUN chmod +x /hive-bin/enode.sh

# Create version.txt
RUN ethrex --version | sed -e 's/ethrex \(.*\)/\1/' > /version.txt

# Export the usual networking ports to allow outside access to the node.
EXPOSE 8545 8546 30303 30303/udp

ENTRYPOINT ["/ethrex.sh"]
40 changes: 40 additions & 0 deletions clients/ethrex-snap/Dockerfile.git
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Pulls geth from a git repository and builds it from source.

FROM rust:latest as builder
ARG github=lambdaclass/ethrex
ARG tag=main

RUN \
apt-get update && \
apt-get install -y libclang-dev pkg-config build-essential && \
git clone --depth 1 --branch $tag https://github.com/$github
WORKDIR ethrex
RUN make build
RUN cp target/debug/ethrex /usr/local/bin/ethrex

FROM debian:latest
RUN apt-get update && apt-get install -y bash curl jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy compiled binary from builder
COPY --from=builder /usr/local/bin/ethrex .

# Add genesis mapper script.
ADD genesis.json /genesis.json
ADD mapper.jq /mapper.jq

# Add the startup script.
ADD ethrex.sh /ethrex.sh
RUN chmod +x /ethrex.sh

# Add the enode URL retriever script.
ADD enode.sh /hive-bin/enode.sh
RUN chmod +x /hive-bin/enode.sh

# Create version.txt
RUN ./ethrex --version | sed -e 's/ethrex \(.*\)/\1/' > /version.txt

# Export the usual networking ports to allow outside access to the node.
EXPOSE 8545 8546 30303 30303/udp

ENTRYPOINT ["/ethrex.sh"]
39 changes: 39 additions & 0 deletions clients/ethrex-snap/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Build geth from source from a local directory called ethrex.
FROM rust:latest as builder

# Default local client path: clients/ethrex/ethrex
ARG local_path=ethrex
COPY $local_path ethrex

WORKDIR ethrex
RUN apt-get update && \
apt-get install -y libclang-dev pkg-config build-essential
RUN make build
RUN cp target/debug/ethrex /usr/local/bin/ethrex

FROM debian:latest
RUN apt-get update && apt-get install -y bash curl jq \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy compiled binary from builder
COPY --from=builder /usr/local/bin/ethrex .

# Add genesis mapper script.
ADD genesis.json /genesis.json
ADD mapper.jq /mapper.jq

# Add the startup script.
ADD ethrex.sh /ethrex.sh
RUN chmod +x /ethrex.sh

# Add the enode URL retriever script.
ADD enode.sh /hive-bin/enode.sh
RUN chmod +x /hive-bin/enode.sh

# Create version.txt
RUN ./ethrex --version | sed -e 's/ethrex \(.*\)/\1/' > /version.txt

# Export the usual networking ports to allow outside access to the node.
EXPOSE 8545 8546 30303 30303/udp

ENTRYPOINT ["/ethrex.sh"]
14 changes: 14 additions & 0 deletions clients/ethrex-snap/enode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Script to retrieve the enode
#
# This is copied into the validator container by Hive
# and used to provide a client-specific enode id retriever
#

# Immediately abort the script on any error encountered
set -e
data='{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}'
TARGET_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" --data $data "localhost:8545" )
TARGET_ENODE=$(echo ${TARGET_RESPONSE}| jq -r '.result.enode')
echo "$TARGET_ENODE"
103 changes: 103 additions & 0 deletions clients/ethrex-snap/ethrex.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash

# Immediately abort the script on any error encountered
set -ex

# no ansi colors
export RUST_LOG_STYLE=never

ethrex=./ethrex
ETHREX_FLAGS="--syncmode snap"

# Configure the chain.
mv /genesis.json /genesis-input.json
jq -f /mapper.jq /genesis-input.json > /genesis.json

# Configure log level
LOG=info
case "$HIVE_LOGLEVEL" in
0|1) LOG=error ;;
2) LOG=warn ;;
3) LOG=info ;;
4) LOG=debug ;;
5) LOG=trace ;;
esac
FLAGS="$FLAGS --log.level=$LOG"

# Dump genesis.
if [ "$HIVE_LOGLEVEL" -lt 4 ]; then
echo "Supplied genesis state (trimmed, use --sim.loglevel 4 or 5 for full output):"
jq 'del(.alloc[] | select(.balance == "0x123450000000000000000"))' /genesis.json
else
echo "Supplied genesis state:"
cat /genesis.json
fi

# Initialize the local testchain with the genesis state
# echo "Initializing database with genesis state..."
# $ethrex init $FLAGS --chain /genesis.json
FLAGS="$FLAGS --network /genesis.json"

echo "Command flags till now:"
echo $FLAGS

# Don't immediately abort, some imports are meant to fail
set +ex

# Load the test chain if present
echo "Loading initial blockchain..."
if [ -f /chain.rlp ]; then
echo "Importing chain.rlp..."
$ethrex $FLAGS $ETHREX_FLAGS import /chain.rlp
else
echo "Warning: chain.rlp not found."
fi

# Load the remainder of the test chain
if [ -d /blocks ]; then
echo "Loading remaining individual blocks..."
$ethrex $FLAGS $ETHREX_FLAGS import /blocks
else
echo "Warning: blocks folder not found."
fi

# Only set boot nodes in online steps
# It doesn't make sense to dial out, use only a pre-set bootnode.
if [ "$HIVE_BOOTNODE" != "" ]; then
FLAGS="$FLAGS --bootnodes=$HIVE_BOOTNODE"
fi

# Configure any mining operation
if [ "$HIVE_MINER" != "" ]; then
echo "Warning: miner not supported."
exit 1
fi
if [ "$HIVE_MINER_EXTRA" != "" ]; then
echo "Warning: miner extra data not supported."
exit 1
fi

# Import clique signing key.
if [ "$HIVE_CLIQUE_PRIVATEKEY" != "" ]; then
echo "Warning: clique private key not supported."
exit 1
fi

# Configure RPC.
FLAGS="$FLAGS --http.addr=0.0.0.0 --authrpc.addr=0.0.0.0"

# We don't support pre merge
if [ "$HIVE_TERMINAL_TOTAL_DIFFICULTY" != "" ]; then
JWT_SECRET="7365637265747365637265747365637265747365637265747365637265747365"
echo -n $JWT_SECRET > /jwt.secret
FLAGS="$FLAGS --authrpc.jwtsecret=/jwt.secret"
else
# We dont exit because some tests require this
echo "Warning: HIVE_TERMINAL_TOTAL_DIFFICULTY not supported."
fi

FLAGS="$FLAGS $ETHREX_FLAGS"

# Launch the main client.
echo "Running ethrex with flags: $FLAGS"
$ethrex $FLAGS
15 changes: 15 additions & 0 deletions clients/ethrex-snap/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"mixHash" : "0x2c85bcbce56429100b2108254bb56906257582aeafcbd682bc9af67a9f5aee46",
"nonce" : "0x78cc16f7b4f65485",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x54c98c81",
"alloc" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance" : "0x09184e72a000"
}
}
}
75 changes: 75 additions & 0 deletions clients/ethrex-snap/mapper.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Removes all empty keys and values in input.
def remove_empty:
. | walk(
if type == "object" then
with_entries(
select(
.value != null and
.value != "" and
.value != [] and
.key != null and
.key != ""
)
)
else .
end
)
;

# Converts decimal string to number.
def to_int:
if . == null then . else .|tonumber end
;

# Converts "1" / "0" to boolean.
def to_bool:
if . == null then . else
if . == "1" then true else false end
end
;

# Replace config in input.
. + {
"config": {
"ethash": (if env.HIVE_CLIQUE_PERIOD then null else {} end),
"clique": (if env.HIVE_CLIQUE_PERIOD == null then null else {
"period": env.HIVE_CLIQUE_PERIOD|to_int,
} end),
"chainId": (if env.HIVE_CHAIN_ID == null then 1 else env.HIVE_CHAIN_ID|to_int end),
"homesteadBlock": env.HIVE_FORK_HOMESTEAD|to_int,
"daoForkBlock": env.HIVE_FORK_DAO_BLOCK|to_int,
"daoForkSupport": env.HIVE_FORK_DAO_VOTE|to_bool,
"eip150Block": env.HIVE_FORK_TANGERINE|to_int,
"eip150Hash": env.HIVE_FORK_TANGERINE_HASH,
"eip155Block": env.HIVE_FORK_SPURIOUS|to_int,
"eip158Block": env.HIVE_FORK_SPURIOUS|to_int,
"byzantiumBlock": env.HIVE_FORK_BYZANTIUM|to_int,
"constantinopleBlock": env.HIVE_FORK_CONSTANTINOPLE|to_int,
"petersburgBlock": env.HIVE_FORK_PETERSBURG|to_int,
"istanbulBlock": env.HIVE_FORK_ISTANBUL|to_int,
"muirGlacierBlock": env.HIVE_FORK_MUIR_GLACIER|to_int,
"berlinBlock": env.HIVE_FORK_BERLIN|to_int,
"londonBlock": env.HIVE_FORK_LONDON|to_int,
"arrowGlacierBlock": env.HIVE_FORK_ARROW_GLACIER|to_int,
"grayGlacierBlock": env.HIVE_FORK_GRAY_GLACIER|to_int,
"mergeNetsplitBlock": env.HIVE_MERGE_BLOCK_ID|to_int,
"terminalTotalDifficulty": env.HIVE_TERMINAL_TOTAL_DIFFICULTY|to_int,
"terminalTotalDifficultyPassed": env.HIVE_TERMINAL_TOTAL_DIFFICULTY_PASSED|to_bool,
"shanghaiTime": env.HIVE_SHANGHAI_TIMESTAMP|to_int,
"cancunTime": env.HIVE_CANCUN_TIMESTAMP|to_int,
"pragueTime": env.HIVE_PRAGUE_TIMESTAMP|to_int,
"blobSchedule": {
"cancun": {
"target": (if env.HIVE_CANCUN_BLOB_TARGET then env.HIVE_CANCUN_BLOB_TARGET|to_int else 3 end),
"max": (if env.HIVE_CANCUN_BLOB_MAX then env.HIVE_CANCUN_BLOB_MAX|to_int else 6 end),
"baseFeeUpdateFraction": (if env.HIVE_CANCUN_BLOB_BASE_FEE_UPDATE_FRACTION then env.HIVE_CANCUN_BLOB_BASE_FEE_UPDATE_FRACTION|to_int else 3338477 end)
},
"prague": {
"target": (if env.HIVE_PRAGUE_BLOB_TARGET then env.HIVE_PRAGUE_BLOB_TARGET|to_int else 6 end),
"max": (if env.HIVE_PRAGUE_BLOB_MAX then env.HIVE_PRAGUE_BLOB_MAX|to_int else 9 end),
"baseFeeUpdateFraction": (if env.HIVE_PRAGUE_BLOB_BASE_FEE_UPDATE_FRACTION then env.HIVE_PRAGUE_BLOB_BASE_FEE_UPDATE_FRACTION|to_int else 5007716 end)
}
},
"depositContractAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa"
}|remove_empty
}
Loading