Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Replay feature by Kyrin #246

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADD . .
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm cdk-erigon
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm cdk-erigon integration

FROM docker.io/library/golang:1.21-alpine3.17 AS tools-builder
RUN apk --no-cache add build-base linux-headers git bash ca-certificates libstdc++
Expand Down Expand Up @@ -46,6 +46,7 @@ WORKDIR /home/erigon

## then give each binary its own layer
COPY --from=builder /app/build/bin/cdk-erigon /usr/local/bin/cdk-erigon
COPY --from=builder /app/build/bin/integration /usr/local/bin/integration

EXPOSE 8545 \
8551 \
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ var (
YieldSizeFlag = cli.Uint64Flag{
Name: "yieldsize",
Usage: "transaction count fetched from txpool each time",
Value: 1000,
Value: 30,
}
)

Expand Down Expand Up @@ -1945,7 +1945,7 @@ func setTxPool(ctx *cli.Context, fullCfg *ethconfig.Config) {

// For X Layer
setTxPoolXLayer(ctx, cfg)

purgeEvery := ctx.Duration(TxpoolPurgeEveryFlag.Name)
purgeDistance := ctx.Duration(TxpoolPurgeDistanceFlag.Name)

Expand Down
41 changes: 41 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,44 @@ test-1: stop all ## Runs group 1 e2e tests checking race conditions
sleep 3
docker ps -a
trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 600s ../ci/e2e-1/...

DOCKER_COMPOSE_LRP := docker compose -f docker-compose-lrp.yml
DOCKER_LRP_UNWIND := xlayer-lrp-unwind
DOCKER_LRP_RESEQUENCE := xlayer-lrp-resequence

RUN_DOCKER_LRP_STATELESS_EXECUTOR := $(DOCKER_COMPOSE_LRP) up -d $(DOCKER_STATELESS_EXECUTOR)
RUN_DOCKER_LRP_L1_NETWORK := $(DOCKER_COMPOSE_LRP) up -d $(DOCKER_L1_NETWORK)
RUN_DOCKER_LRP_UNWIND := $(DOCKER_COMPOSE_LRP) up -d $(DOCKER_LRP_UNWIND)
RUN_DOCKER_LRP_RESEQUENCE := $(DOCKER_COMPOSE_LRP) up -d $(DOCKER_LRP_RESEQUENCE)

STOP_LRP := $(DOCKER_COMPOSE_LRP) down --remove-orphans; sleep 3; rm -rf data

.PHONY: lrp-run
lrp-run: build-docker
$(RUN_DOCKER_LRP_L1_NETWORK)
$(RUN_DOCKER_LRP_STATELESS_EXECUTOR)
sleep 3
@read -p "Enter unwind to batch number: " UNWIND_BATCH_NO; \
if [ "$(shell uname)" = "Darwin" ]; then \
sed -i '' "s/--unwind-batch-no=[0-9]*/--unwind-batch-no=$$UNWIND_BATCH_NO/" docker-compose-lrp.yml; \
else \
sed -i "s/--unwind-batch-no=[0-9]*/--unwind-batch-no=$$UNWIND_BATCH_NO/" docker-compose-lrp.yml; \
fi
$(RUN_DOCKER_LRP_UNWIND)
sleep 20
$(RUN_DOCKER_LRP_RESEQUENCE)

.PHONY: lrp-stop
lrp-stop:
$(STOP_LRP)


TARGET_LOG_FILE := filtered.log

.PHONY: lrp-check
lrp-check: ## Filter logs for LRP & Compute TPS & Check stateroots (configure debugToolsConfig.yaml)
docker logs $(DOCKER_LRP_RESEQUENCE) 2>&1 | grep "\[5/13 Execution\]" > $(TARGET_LOG_FILE)
sleep 3
python process_log.py $(TARGET_LOG_FILE)
sleep 3
go run ../zk/debug_tools/rpc-blockhashes-compare/main.go
123 changes: 123 additions & 0 deletions test/docker-compose-lrp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
version: "3.5"
networks:
default:
name: erigon-lrp
services:
# xlayer-lrp-sequence:
# container_name: xlayer-lrp-sequence
# image: cdk-erigon
# environment:
# - CDK_ERIGON_SEQUENCER=1
# ports:
# - 6062:6060
# - 8126:8545
# - 6902:6900
# - 9093:9095
# volumes:
# - ./data/lrp/:/home/erigon/data/
# - ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
# - ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
# - ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
# - ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
# command: >
# cdk-erigon --zkevm.l1-cache-enabled=true --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-lrp:
container_name: xlayer-lrp
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=0
ports:
- 6062:6060
- 8126:8545
- 6902:6900
- 9093:9095
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.rpc.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-lrp-unwind:
container_name: xlayer-lrp-unwind
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=0
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.rpc.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: |
integration state_stages_zkevm \
--config=/usr/src/app/config.yaml \
--chain dynamic-mynetwork \
--datadir /home/erigon/data/ \
--unwind-batch-no=10

xlayer-lrp-resequence:
container_name: xlayer-lrp-resequence
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=1
ports:
- 6062:6060
- 8126:8545
- 6902:6900
- 9093:9095
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --zkevm.l1-cache-enabled=true --zkevm.sequencer-resequence=true --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-executor:
container_name: xlayer-executor
image: hermeznetwork/zkevm-prover:v9.0.0-RC1-fork.13
platform: linux/amd64
environment:
- EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
ports:
- 0.0.0.0:50061:50061 # MT
- 0.0.0.0:50071:50071 # Executor
volumes:
- ./config/test.stateless_executor.config.json:/usr/src/app/config.json
command: >
zkProver -c /usr/src/app/config.json

xlayer-mock-l1-network:
container_name: xlayer-mock-l1-network
image: zjg555543/geth:fork13-v0.0.3
ports:
- 8545:8545
- 8546:8546
command:
- "--http"
- "--http.api"
- "admin,eth,debug,miner,net,txpool,personal,web3"
- "--http.addr"
- "0.0.0.0"
- "--http.corsdomain"
- "*"
- "--http.vhosts"
- "*"
- "--ws"
- "--ws.origins"
- "*"
- "--ws.addr"
- "0.0.0.0"
- "--dev"
- "--dev.period"
- "1"
- "--datadir"
- "/geth_data"
- "--syncmode"
- "full"
- "--rpc.allow-unprotected-txs"
106 changes: 105 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,59 @@ services:
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml
cdk-erigon --zkevm.l1-cache-enabled=true --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-seq-resequence:
container_name: xlayer-seq-resequence
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=1
ports:
- 6060:6060
- 8123:8545
- 6900:6900
- 9092:9095
volumes:
- ./data/seq/:/home/erigon/data/
- ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --zkevm.l1-cache-enabled=true --zkevm.sequencer-resequence=true --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-seq-recover:
container_name: xlayer-seq-recover
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=1
ports:
- 6060:6060
- 8123:8545
- 6900:6900
- 9092:9095
volumes:
- ./data/seq/:/home/erigon/data/
- ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --zkevm.l1-cache-enabled=true --zkevm.l1-sync-start-block=353 --zkevm.da-url=http://xlayer-da:8444 --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-seq-unwind:
container_name: xlayer-seq-unwind
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=1
volumes:
- ./data/seq/:/home/erigon/data/
- ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
integration state_stages_zkevm --config=/usr/src/app/config.yaml --chain dynamic-mynetwork --datadir /home/erigon/data/ --unwind-batch-no=1

xlayer-rpc:
container_name: xlayer-rpc
Expand All @@ -133,6 +185,58 @@ services:
command: >
cdk-erigon --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-lrp:
container_name: xlayer-lrp
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=0
ports:
- 6062:6060
- 8126:8545
- 6902:6900
- 9093:9095
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.rpc.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-lrp-unwind:
container_name: xlayer-lrp-unwind
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=0
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.rpc.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
integration state_stages_zkevm --config=/usr/src/app/config.yaml --chain dynamic-mynetwork --datadir /home/erigon/data/ --unwind-batch-no=1

xlayer-lrp-resequence:
container_name: xlayer-lrp-resequence
image: cdk-erigon
environment:
- CDK_ERIGON_SEQUENCER=1
ports:
- 6062:6060
- 8126:8545
- 6902:6900
- 9093:9095
volumes:
- ./data/lrp/:/home/erigon/data/
- ./config/test.erigon.seq.config.yaml:/usr/src/app/config.yaml
- ./config/dynamic-mynetwork-allocs.json:/usr/src/app/dynamic-mynetwork-allocs.json
- ./config/dynamic-mynetwork-chainspec.json:/usr/src/app/dynamic-mynetwork-chainspec.json
- ./config/dynamic-mynetwork-conf.json:/usr/src/app/dynamic-mynetwork-conf.json
command: >
cdk-erigon --zkevm.l1-cache-enabled=true --zkevm.sequencer-resequence=true --http.vhosts=* --http.corsdomain=* --ws --config=/usr/src/app/config.yaml

xlayer-mock-l1-network:
container_name: xlayer-mock-l1-network
image: zjg555543/geth:fork13-v0.0.3
Expand Down
42 changes: 42 additions & 0 deletions test/fetch_blocks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# 检查是否提供了所有必要的参数
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then
echo "Usage: $0 --to <end_blocknumber> --rpc-url <url> [--from <start_blocknumber>] [-f <target_file>]"
exit 1
fi

# 设置默认目标文件名
START_BLOCKNUMBER=0
TARGET_FILE="blocks_info.txt"

# 读取参数
while [[ "$#" -gt 0 ]]; do
case $1 in
--from) START_BLOCKNUMBER="$2"; shift ;;
--to) END_BLOCKNUMBER="$2"; shift ;;
--rpc-url) RPC_URL="$2"; shift ;;
-f) TARGET_FILE="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

# 检查是否所有参数都已设置
if [ -z "$END_BLOCKNUMBER" ] || [ -z "$RPC_URL" ]; then
echo "Usage: $0 --to <end_blocknumber> --rpc-url <url> [--from <start_blocknumber>] [-f <target_file>]"
exit 1
fi

# 清空目标文件
> $TARGET_FILE

# 循环获取区块信息
for blocknumber in $(seq $START_BLOCKNUMBER $END_BLOCKNUMBER)
do
echo "Fetching block $blocknumber..."
cast block $blocknumber --rpc-url $RPC_URL >> $TARGET_FILE
echo "" >> $TARGET_FILE # 添加一个空行以分隔每个区块的信息
done

echo "All blocks fetched and saved to $TARGET_FILE"
Loading
Loading