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

Add script to run localnet #21

Merged
merged 6 commits into from
Jun 14, 2024
Merged
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
103 changes: 103 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# syntax = docker/dockerfile:1.2
FROM docker.io/library/golang:1.20-alpine3.17 AS builder

RUN apk --no-cache add build-base linux-headers git bash ca-certificates libstdc++

WORKDIR /app
ADD go.mod go.mod
ADD go.sum go.sum

RUN go mod download
ADD . .

RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make all


FROM docker.io/library/golang:1.20-alpine3.17 AS tools-builder
RUN apk --no-cache add build-base linux-headers git bash ca-certificates libstdc++
WORKDIR /app

ADD Makefile Makefile
ADD tools.go tools.go
ADD go.mod go.mod
ADD go.sum go.sum

RUN mkdir -p /app/build/bin

RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make db-tools

FROM docker.io/library/alpine:3.17

# install required runtime libs, along with some helpers for debugging
RUN apk add --no-cache ca-certificates libstdc++ tzdata
RUN apk add --no-cache curl jq bind-tools

RUN mkdir -p ~/.local/share/erigon
WORKDIR /home/erigon

## add pre-defined run configs
ADD hermezconfig-mainnet.yaml.example mainnet.yaml
ADD hermezconfig-cardona.yaml.example cardona.yaml
ADD hermezconfig-bali.yaml.example bali.yaml

# copy compiled artifacts from builder
## first do the mdbx ones - since these wont change as often
COPY --from=tools-builder /app/build/bin/mdbx_chk /usr/local/bin/mdbx_chk
COPY --from=tools-builder /app/build/bin/mdbx_copy /usr/local/bin/mdbx_copy
COPY --from=tools-builder /app/build/bin/mdbx_drop /usr/local/bin/mdbx_drop
COPY --from=tools-builder /app/build/bin/mdbx_dump /usr/local/bin/mdbx_dump
COPY --from=tools-builder /app/build/bin/mdbx_load /usr/local/bin/mdbx_load
COPY --from=tools-builder /app/build/bin/mdbx_stat /usr/local/bin/mdbx_stat

## then give each binary its own layer
COPY --from=builder /app/build/bin/devnet /usr/local/bin/devnet
COPY --from=builder /app/build/bin/downloader /usr/local/bin/downloader
COPY --from=builder /app/build/bin/cdk-erigon /usr/local/bin/cdk-erigon
COPY --from=builder /app/build/bin/erigon-cl /usr/local/bin/erigon-cl
COPY --from=builder /app/build/bin/evm /usr/local/bin/evm
COPY --from=builder /app/build/bin/hack /usr/local/bin/hack
COPY --from=builder /app/build/bin/integration /usr/local/bin/integration
COPY --from=builder /app/build/bin/lightclient /usr/local/bin/lightclient
COPY --from=builder /app/build/bin/observer /usr/local/bin/observer
COPY --from=builder /app/build/bin/pics /usr/local/bin/pics
COPY --from=builder /app/build/bin/rpcdaemon /usr/local/bin/rpcdaemon
COPY --from=builder /app/build/bin/rpctest /usr/local/bin/rpctest
COPY --from=builder /app/build/bin/sentinel /usr/local/bin/sentinel
COPY --from=builder /app/build/bin/sentry /usr/local/bin/sentry
COPY --from=builder /app/build/bin/state /usr/local/bin/state
COPY --from=builder /app/build/bin/txpool /usr/local/bin/txpool
COPY --from=builder /app/build/bin/verkle /usr/local/bin/verkle



EXPOSE 8545 \
8551 \
8546 \
30303 \
30303/udp \
42069 \
42069/udp \
8080 \
9090 \
6060

# https://github.com/opencontainers/image-spec/blob/main/annotations.md
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Erigon ZKEVM Client" \
org.label-schema.name="ZKEVM Erigon" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://torquem.ch" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/0xPolygonHermez/cdk-erigon.git" \
org.label-schema.vendor="Torquem" \
org.label-schema.version=$VERSION

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,6 @@ protobuf:
## help: print commands help
help : Makefile
@sed -n 's/^##//p' $<

build-docker: ## Builds a docker image with the binary
docker build -t cdk-erigon -f ./Dockerfile.local .
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
)

var legacyExecutors []legacy_executor_verifier.ILegacyExecutor
if len(cfg.ExecutorUrls) > 0 && cfg.ExecutorUrls[0] != "" {
if len(cfg.ExecutorUrls) > 0 && cfg.ExecutorUrls[0] != "" && cfg.ExecutorStrictMode {
levCfg := legacy_executor_verifier.Config{
GrpcUrls: cfg.ExecutorUrls,
Timeout: cfg.ExecutorRequestTimeout,
Expand Down
52 changes: 52 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
DOCKER_COMPOSE := docker-compose -f docker-compose.yml
DOCKER_STATELESS_EXECUTOR := erigon-stateless-executor
DOCKER_STATE_DB := erigon-state-db
DOCKER_SEQ_SENDER := erigon-seqsender
DOCKER_AGGREGATOR := erigon-aggregator
DOCKER_AGGREGATOR_DB := erigon-aggregator-db
DOCKER_PROVER := erigon-prover
DOCKER_APPROVE := erigon-approve
DOCKER_SEQ := erigon-seq
DOCKER_L1_NETWORK := erigon-mock-l1-network

RUN_DOCKER_STATELESS_EXECUTOR := $(DOCKER_COMPOSE) up -d $(DOCKER_STATELESS_EXECUTOR)
RUN_DOCKER_STATE_DB := $(DOCKER_COMPOSE) up -d $(DOCKER_STATE_DB)
RUN_DOCKER_SEQ_SENDER := $(DOCKER_COMPOSE) up -d $(DOCKER_SEQ_SENDER)
RUN_DOCKER_AGGREGATOR := $(DOCKER_COMPOSE) up -d $(DOCKER_AGGREGATOR)
RUN_DOCKER_AGGREGATOR_DB := $(DOCKER_COMPOSE) up -d $(DOCKER_AGGREGATOR_DB)
RUN_DOCKER_PROVER := $(DOCKER_COMPOSE) up -d $(DOCKER_PROVER)
RUN_DOCKER_APPROVE := $(DOCKER_COMPOSE) up -d $(DOCKER_APPROVE)
RUN_DOCKER_SEQ := $(DOCKER_COMPOSE) up -d $(DOCKER_SEQ)
RUN_DOCKER_L1_NETWORK := $(DOCKER_COMPOSE) up -d $(DOCKER_L1_NETWORK)

STOP := $(DOCKER_COMPOSE) down --remove-orphans

.PHONY: run
run: ## Runs a full node
$(RUN_DOCKER_L1_NETWORK)
sleep 3
$(RUN_DOCKER_STATE_DB)
sleep 3
$(RUN_DOCKER_AGGREGATOR_DB)
sleep 3
$(RUN_DOCKER_STATELESS_EXECUTOR)
sleep 3
$(RUN_DOCKER_PROVER)
sleep 3
$(RUN_DOCKER_SEQ)
sleep 3
$(RUN_DOCKER_APPROVE)
sleep 3
$(RUN_DOCKER_SEQ_SENDER)
sleep 3
$(RUN_DOCKER_AGGREGATOR)

.PHONY: stop
stop: ## Stops all services
$(STOP)

.PHONY: min-run
min-run: ## Runs a minimal node
$(RUN_DOCKER_L1_NETWORK)
sleep 3
$(RUN_DOCKER_SEQ)
66 changes: 66 additions & 0 deletions test/config/aggregator.node.config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

[Aggregator]
Host = "0.0.0.0"
Port = 50081
RetryTime = "5s"
VerifyProofInterval = "10s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"
ProofStatePollingInterval = "5s"
SenderAddress = "0x70997970c51812dc3a010c7d01b50e0d17dc79c8"
CleanupLockedProofsInterval = "2m"
GeneratingProofCleanupThreshold = "10m"
ForkId = 9
WitnessURL = "http://erigon-seq:8545"
LERContract = "0xa40D5f56745a118D0906a34E69aeC8C0Db1cB8fA"
[Aggregator.DB]
Name = "aggregator_db"
User = "aggregator_user"
Password = "aggregator_password"
Host = "erigon-aggregator-db"
Port = "5432"
EnableLog = false
MaxConns = 200
[Aggregator.Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]
[Aggregator.StreamClient]
Server = "erigon-seq:6900"
[Aggregator.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
ConsolidationL1ConfirmationBlocks = 5
FinalizationL1ConfirmationBlocks = 10
WaitReceiptToBeGenerated = "8s"
PrivateKeys = [
{Path = "/pk/aggregator.keystore", Password = "testonly"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = "/ethtxmanager_aggregator.json"
[Aggregator.EthTxManager.Etherman]
URL = "http://erigon-mock-l1-network:8545"
L1ChainID = 1337
HTTPHeaders = []
[Aggregator.Synchronizer]
[Aggregator.Synchronizer.DB]
Name = "state_db"
User = "state_user"
Password = "state_password"
Host = "erigon-state-db"
Port = "5432"
EnableLog = false
MaxConns = 10
[Aggregator.Synchronizer.Synchronizer]
SyncInterval = "10s"
SyncChunkSize = 1000
GenesisBlockNumber = 136
[Aggregator.Synchronizer.Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[EventLog]
[EventLog.DB]
86 changes: 86 additions & 0 deletions test/config/dynamic-mynetwork-allocs.json

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions test/config/dynamic-mynetwork-chainspec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"ChainName": "dynamic-mynetwork",
"chainId": 1001,
"consensus": "ethash",
"homesteadBlock": 0,
"daoForkBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 9999999999999999999999999999999999999999999999999,
"arrowGlacierBlock": 9999999999999999999999999999999999999999999999999,
"grayGlacierBlock": 9999999999999999999999999999999999999999999999999,
"terminalTotalDifficulty": 58750000000000000000000,
"terminalTotalDifficultyPassed": false,
"shanghaiTime": 9999999999999999999999999999999999999999999999999,
"cancunTime": 9999999999999999999999999999999999999999999999999,
"pragueTime": 9999999999999999999999999999999999999999999999999,
"ethash": {}
}

6 changes: 6 additions & 0 deletions test/config/dynamic-mynetwork-conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "0x489e44072604e671274ea693d5309e797fb37a3e0d91e5b0f04639c251c05332",
"timestamp": 1712834884,
"gasLimit": 0,
"difficulty": 0
}
34 changes: 34 additions & 0 deletions test/config/seqsender.node.config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[Log]
Environment = "development" # "production" or "development"
Level = "info"
Outputs = ["stderr"]

[SequenceSender]
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
MaxTxSizeForL1 = 13107
L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"}
SequencesTxFileName = "sequencesender.json"
WaitPeriodPurgeTxFile = "60m"
MaxPendingTx = 1
[SequenceSender.StreamClient]
Server = "erigon-seq:6900"
[SequenceSender.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
ConsolidationL1ConfirmationBlocks = 5
FinalizationL1ConfirmationBlocks = 10
WaitReceiptToBeGenerated = "8s"
PrivateKeys = [
{Path = "/pk/sequencer.keystore", Password = "testonly"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = "ethtxmanager.json"
[SequenceSender.EthTxManager.Etherman]
URL = "http://erigon-mock-l1-network:8545"
MultiGasProvider = false
L1ChainID = 1337
HTTPHeaders = []
46 changes: 46 additions & 0 deletions test/config/test.erigon.seq.config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
datadir: /home/erigon/data/
chain: dynamic-mynetwork
http: true
private.api.addr: localhost:9091
zkevm.l2-chain-id: 1001
zkevm.l2-sequencer-rpc-url:
zkevm.l2-datastreamer-url:
zkevm.l1-chain-id: 1337
zkevm.l1-rpc-url: http://erigon-mock-l1-network:8545

zkevm.address-sequencer: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"
zkevm.address-zkevm: "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
zkevm.address-admin: "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
zkevm.address-rollup: "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
zkevm.address-ger-manager: "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"

zkevm.l1-rollup-id: 1
zkevm.l1-first-block: 136
zkevm.l1-block-range: 10
zkevm.l1-query-delay: 100
zkevm.rpc-ratelimit: 300
zkevm.datastream-version: 2

zkevm.executor-urls: erigon-stateless-executor:50071
zkevm.executor-strict: false
zkevm.witness-full: true

zkevm.sequencer-initial-fork-id: 9
zkevm.data-stream-host: "localhost"
zkevm.data-stream-port: 6900
zkevm.default-gas-price: 1000000000
zkevm.max-gas-price: 0
zkevm.gas-price-factor: 0.000001

externalcl: true
http.api: [eth, debug, net, trace, web3, erigon, txpool, zkevm]
http.addr: 0.0.0.0
http.port: 8545
http.vhosts: any
http.corsdomain: any
ws: true

db.read.concurrency: 20000
txpool.globalslots: 100000
txpool.globalbasefeeslots: 100000
txpool.globalqueue: 100000
Loading
Loading