mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-09 04:08:01 -05:00
feat: use already-built image in Dockerfile of l1-node-genesis-generator (#669)
* feat: use already-built image in Dockerfile of l1-node-genesis-generator * feat: get genesis time automatically in generate-genesis.sh and make L1_GENESIS_TIME optional * feat: make sed in-place command portable with both OS in generate-genesis.sh
This commit is contained in:
13
Makefile
13
Makefile
@@ -1,16 +1,5 @@
|
||||
include makefile-contracts.mk
|
||||
|
||||
define get_future_time
|
||||
$(shell \
|
||||
OS=$$(uname); \
|
||||
if [ "$$OS" = "Linux" ]; then \
|
||||
date -d '+3 seconds' +%s; \
|
||||
elif [ "$$OS" = "Darwin" ]; then \
|
||||
date -v +3S +%s; \
|
||||
fi \
|
||||
)
|
||||
endef
|
||||
|
||||
docker-pull-images-external-to-monorepo:
|
||||
docker compose -f docker/compose-tracing-v1-ci-extension.yml -f docker/compose-tracing-v2-ci-extension.yml --profile external-to-monorepo pull
|
||||
|
||||
@@ -42,7 +31,7 @@ start-env:
|
||||
echo "Starting stack reusing previous state"; \
|
||||
fi; \
|
||||
mkdir -p tmp/local; \
|
||||
L1_GENESIS_TIME=$(get_future_time) COMPOSE_PROFILES=$(COMPOSE_PROFILES) docker compose -f $(COMPOSE_FILE) up -d; \
|
||||
COMPOSE_PROFILES=$(COMPOSE_PROFILES) docker compose -f $(COMPOSE_FILE) up -d; \
|
||||
while [ "$$(docker compose -f $(COMPOSE_FILE) ps -q l1-el-node | xargs docker inspect -f '{{.State.Health.Status}}')" != "healthy" ] || \
|
||||
[ "$$(docker compose -f $(COMPOSE_FILE) ps -q sequencer | xargs docker inspect -f '{{.State.Health.Status}}')" != "healthy" ]; do \
|
||||
sleep 2; \
|
||||
|
||||
@@ -168,7 +168,6 @@ dockerCompose {
|
||||
// without cleaning the volumes
|
||||
noRecreate = true
|
||||
projectName = "docker"
|
||||
environment.put("L1_GENESIS_TIME", "${Instant.now().plusSeconds(3).getEpochSecond()}")
|
||||
}
|
||||
|
||||
localStackPostgresDbOnly {
|
||||
@@ -213,7 +212,6 @@ dockerCompose {
|
||||
// without cleaning the volumes
|
||||
noRecreate = true
|
||||
projectName = "docker"
|
||||
environment.put("L1_GENESIS_TIME", "${Instant.now().plusSeconds(3).getEpochSecond()}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ services:
|
||||
context: ./config/l1-node/
|
||||
profiles: [ "l1", "debug", "external-to-monorepo" ]
|
||||
command:
|
||||
--genesis-time ${L1_GENESIS_TIME}
|
||||
--genesis-time ${L1_GENESIS_TIME:-""}
|
||||
--current-time-delay-in-sec 3
|
||||
--l1-genesis /config/l1-genesis.json
|
||||
--network-config /config/network-config.yml
|
||||
--mnemonics /config/mnemonics.yaml
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
FROM golang:1.23-alpine as builder
|
||||
FROM ethpandaops/ethereum-genesis-generator:pk910-bash-el-genesis-generator
|
||||
|
||||
RUN apk add --no-cache git && git clone https://github.com/protolambda/eth2-testnet-genesis.git \
|
||||
&& cd eth2-testnet-genesis \
|
||||
&& go install .
|
||||
COPY ./generate-genesis.sh /config/generate-genesis.sh
|
||||
|
||||
COPY ./generate-genesis.sh /generate-genesis.sh
|
||||
|
||||
FROM alpine:3.20.3
|
||||
|
||||
RUN apk add --no-cache bash
|
||||
|
||||
COPY --from=builder /generate-genesis.sh /config/generate-genesis.sh
|
||||
COPY --from=builder /go/bin/eth2-testnet-genesis /usr/local/bin/
|
||||
|
||||
ENTRYPOINT [ "/bin/sh" , "/config/generate-genesis.sh" ]
|
||||
ENTRYPOINT [ "/bin/bash", "/config/generate-genesis.sh" ]
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
set -euo pipefail
|
||||
|
||||
genesis_time=""
|
||||
current_time_delay_in_sec=""
|
||||
l1_genesis=""
|
||||
network_config=""
|
||||
mnemonics=""
|
||||
output_dir=""
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 --genesis-time <timestamp> --l1-genesis <path to l1 genesis file> --network-config <path to network config file> --mnemonics <path to mnemonics file> --output-dir <output directory>"
|
||||
echo "Usage: $0 --genesis-time <timestamp> --current-time-delay-in-sec <seconds to delay current timestamp if genesis-time is not given> --l1-genesis <path to l1 genesis file> --network-config <path to network config file> --mnemonics <path to mnemonics file> --output-dir <output directory>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -18,6 +19,10 @@ while [[ $# -gt 0 ]]; do
|
||||
genesis_time="$2"
|
||||
shift 2
|
||||
;;
|
||||
--current-time-delay-in-sec)
|
||||
current_time_delay_in_sec="$2"
|
||||
shift 2
|
||||
;;
|
||||
--l1-genesis)
|
||||
l1_genesis="$2"
|
||||
shift 2
|
||||
@@ -41,18 +46,39 @@ while [[ $# -gt 0 ]]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$genesis_time" ] || [ -z "$l1_genesis" ] || [ -z "$network_config" ] || [ -z "$mnemonics" ] || [ -z "$output_dir" ]; then
|
||||
if [ -z "$l1_genesis" ] || [ -z "$network_config" ] || [ -z "$mnemonics" ] || [ -z "$output_dir" ]; then
|
||||
echo "Error: Missing required argument."
|
||||
usage
|
||||
fi
|
||||
|
||||
OS=$(uname);
|
||||
|
||||
if [ -z "$genesis_time" ]; then
|
||||
if [ -z "$current_time_delay_in_sec" ]; then
|
||||
current_time_delay_in_sec="3"
|
||||
fi
|
||||
genesis_time=$(
|
||||
if [ $OS = "Linux" ]; then
|
||||
date -d "+$current_time_delay_in_sec seconds" +%s;
|
||||
elif [ $OS = "Darwin" ]; then
|
||||
date -v +"$current_time_delay_in_sec"S +%s;
|
||||
fi
|
||||
)
|
||||
fi
|
||||
|
||||
echo "Genesis time set to: $genesis_time"
|
||||
|
||||
mkdir -p $output_dir
|
||||
cp $l1_genesis $output_dir/genesis.json
|
||||
cp $network_config $output_dir/$(basename -- $network_config)
|
||||
|
||||
sed -i -E 's/"timestamp": "[0-9]+"/"timestamp": "'"$genesis_time"'"/' $output_dir/genesis.json
|
||||
sed -i 's/\$GENESIS_TIME/'"$genesis_time"'/g' $output_dir/$(basename -- $network_config)
|
||||
# sed in-place command portable with both OS
|
||||
if [ $OS = "Linux" ]; then
|
||||
sed -i -E 's/"timestamp": "[0-9]+"/"timestamp": "'"$genesis_time"'"/' $output_dir/genesis.json
|
||||
sed -i 's/\$GENESIS_TIME/'"$genesis_time"'/g' $output_dir/$(basename -- $network_config)
|
||||
elif [ $OS = "Darwin" ]; then
|
||||
sed -i "" -E 's/"timestamp": "[0-9]+"/"timestamp": "'"$genesis_time"'"/' $output_dir/genesis.json
|
||||
sed -i "" 's/\$GENESIS_TIME/'"$genesis_time"'/g' $output_dir/$(basename -- $network_config)
|
||||
fi
|
||||
|
||||
/usr/local/bin/eth2-testnet-genesis deneb --config $output_dir/$(basename -- $network_config) --mnemonics $mnemonics --tranches-dir $output_dir/tranches --state-output $output_dir/genesis.ssz --eth1-config $output_dir/genesis.json
|
||||
|
||||
Reference in New Issue
Block a user