Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/zkevm' into zkevm-2.60
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls committed Aug 6, 2024
2 parents e734e51 + 870772c commit 7ae2c6d
Show file tree
Hide file tree
Showing 95 changed files with 3,272 additions and 1,469 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ cmd/prometheus
vendor

cache.db
.git
14 changes: 12 additions & 2 deletions .github/workflows/ci_zkevm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- reopened
- synchronize
- ready_for_review
workflow_dispatch:

concurrency:
group: ${{ github.ref }}
Expand Down Expand Up @@ -92,18 +93,27 @@ jobs:
working-directory: ./cdk-erigon
run: docker build -t cdk-erigon:local --file Dockerfile .

- name: Remove unused flags
working-directory: ./kurtosis-cdk
run: |
sed -i '/zkevm.sequencer-batch-seal-time:/d' templates/cdk-erigon/config.yml
- name: Configure Kurtosis CDK
working-directory: ./kurtosis-cdk
run: |
/usr/local/bin/yq -i '.args.data_availability_mode = "rollup"' cdk-erigon-sequencer-params.yml
/usr/local/bin/yq -i '.args.cdk_erigon_node_image = "cdk-erigon:local"' cdk-erigon-sequencer-params.yml
/usr/local/bin/yq -i '.args.zkevm_bridge_service_image = "hermeznetwork/zkevm-bridge-service:v0.5.0-RC8"' cdk-erigon-sequencer-params.yml
sed -i '/zkevm\.sequencer-initial-fork-id/d' ./templates/cdk-erigon/config-sequencer.yaml
- name: Deploy Kurtosis CDK package
working-directory: ./kurtosis-cdk
run: kurtosis run --enclave cdk-v1 --args-file cdk-erigon-sequencer-params.yml --image-download always .

- name: Override gas limit for test transactions
working-directory: ./kurtosis-cdk
run: |
sed -i 's/--gas-limit [0-9]*/--gas-limit 100000/gi' .github/actions/monitor-cdk-verified-batches/batch_verification_monitor.sh
- name: Monitor verified batches
working-directory: ./kurtosis-cdk
shell: bash
Expand Down Expand Up @@ -253,4 +263,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: logs_${{ github.run_id }}
path: ./kurtosis-cdk/ci_logs
path: ./kurtosis-cdk/ci_logs
8 changes: 4 additions & 4 deletions .github/workflows/nightly-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
strategy:
matrix:
include:
- name: "integration-5"
rpc_url: "http://34.175.214.161:8500"
eth_address: "0x41BB6960a5156aC29d6e9E04273837AD19d6691A"
secret_name: "NETWORK5_PRIVATE_KEY"
- name: "integration-8"
rpc_url: "http://34.175.214.161:18124"
eth_address: "0x126240A22FF66101131b0BcE1D6c27498ace7D41"
secret_name: "NETWORK5_PRIVATE_KEY_0X126"
- name: "cdk-1"
rpc_url: "http://34.175.214.161:8020"
eth_address: "0x673df8221611aD1f714053b82c4F9E2b0867CcC6"
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly-bridge-erc20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
strategy:
matrix:
include:
- profile_name: "network5"
- profile_name: "network8"
l1_ep: "https://rpc.eu-central-1.gateway.fm/v4/ethereum/non-archival/sepolia"
l2_ep: "http://34.175.214.161:8500"
bridge_ep: "http://34.175.214.161:8085"
l2_ep: "http://34.175.214.161:18124"
bridge_ep: "http://34.175.214.161:18080"
l1_pk_secret_name: "L1_SEPOLIA_FUNDED_PRIVATE_KEY"
l2_pk_secret_name: "NETWORK5_PRIVATE_KEY"
bridge_addr: "0xb566BE17B22404BD46F389030ec5592F8ffAde12"
l2_pk_secret_name: "NETWORK5_PRIVATE_KEY_0X126"
bridge_addr: "0x27DAeD0badd500740762d1792F3277a7F3DAdd79"

steps:
- name: Clone bridge repository
run: git clone --recurse-submodules -j8 https://github.com/0xPolygonHermez/zkevm-bridge-service.git -b feature/test_bridge_messages_real_network-v2 bridge
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly-bridge-msg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
strategy:
matrix:
include:
- profile_name: "network5"
- profile_name: "network8"
l1_ep: "https://rpc.eu-central-1.gateway.fm/v4/ethereum/non-archival/sepolia"
l2_ep: "http://34.175.214.161:8500"
bridge_ep: "http://34.175.214.161:8085"
l2_ep: "http://34.175.214.161:18124"
bridge_ep: "http://34.175.214.161:18080"
l1_pk_secret_name: "L1_SEPOLIA_FUNDED_PRIVATE_KEY"
l2_pk_secret_name: "NETWORK5_PRIVATE_KEY"
bridge_addr: "0xb566BE17B22404BD46F389030ec5592F8ffAde12"
l2_pk_secret_name: "NETWORK5_PRIVATE_KEY_0X126"
bridge_addr: "0x27DAeD0badd500740762d1792F3277a7F3DAdd79"

steps:
- name: Clone bridge repository
run: git clone --recurse-submodules -j8 https://github.com/0xPolygonHermez/zkevm-bridge-service.git -b develop bridge
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/nightly-eth-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
strategy:
matrix:
include:
- profile_name: "network5"
- profile_name: "network8"
l1_ep: "https://rpc.eu-central-1.gateway.fm/v4/ethereum/non-archival/sepolia"
l2_ep: "http://34.175.214.161:8500"
bridge_ep: "http://34.175.214.161:8085"
l2_ep: "http://34.175.214.161:18124"
bridge_ep: "http://34.175.214.161:18080"
l1_pk_secret_name: "L1_SEPOLIA_FUNDED_PRIVATE_KEY"
l2_pk_secret_name: "NETWORK5_PRIVATE_KEY_0X126"
bridge_addr: "0xb566BE17B22404BD46F389030ec5592F8ffAde12"
bridge_addr: "0x27DAeD0badd500740762d1792F3277a7F3DAdd79"

steps:
- name: Checkout current repository
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
--env PROFILE=${PROFILE} \
--workdir /app \
eth-bench-temp-${{ matrix.profile_name}} \
python bench.py -p "$PROFILE" -c 5 -t 12 --all --recover
python bench.py -p "$PROFILE" -c 5 -t 12 --confirmed --allconfirmed --unconfirmed --erc20 --uniswap --precompileds --pairings --eventminter --recover
docker run --rm \
--volume "$(pwd):/app" \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nightly-l1-recovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Run Docker Compose
- name: Run Network 8 Recovery
working-directory: ./zk/tests/nightly-l1-recovery
run: docker compose build --quiet && docker compose up --exit-code-from=block-checker
run: docker compose -f docker-compose-8.yml build --quiet && docker compose -f docker-compose-8.yml up --exit-code-from=block-checker
8 changes: 4 additions & 4 deletions .github/workflows/nightly-node-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
strategy:
matrix:
nodes:
- name: "Integration 5"
erigon: "http://34.175.214.161:8500"
zkevm: "http://34.175.214.161:8505"
sequencer: "http://34.175.214.161:8005"
- name: "Integration 8"
erigon: "http://34.175.214.161:18124"
zkevm: "http://34.175.214.161:18505"
sequencer: "http://34.175.214.161:18123"
compare-blocks: 1000
allowed-block-diff: 2000

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nightly-rpc-batch-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
- name: bali
legacy: "https://rpc.zkevm-internal.com"
erigon: "https://rpc.internal.zkevm-rpc.com"
- name: integration5
legacy: "http://34.175.214.161:8505"
erigon: "http://34.175.214.161:8500"
- name: integration8
legacy: "http://34.175.214.161:18505"
erigon: "http://34.175.214.161:18124"

steps:
- name: Checkout repository
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ profile.cov
# VS Code
.vscode

# PYTHON ENV
.python-env

# dashboard
/dashboard/assets/flow-typed
/dashboard/assets/node_modules
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ cdk-erigon is a fork of Erigon, currently in Alpha, optimized for syncing with t

***
## Release Roadmap
- **v0.9.x**: Support for Cardona testnet
- **v1.x.x**: Support for Mainnet
- **v1.1.x**: RPC (full support)
- **v2.x.x**: Sequencer (full support)
- **v3.x.x**: Erigon 3 based (snapshot support)

***

## Hardware requirements

* A Linux-based OS (e.g., Ubuntu Server 22.04 LTS).
* At least 32GB RAM with a 4-core CPU.
* Both Apple Silicon and AMD64 are supported.

## Chain/Fork Support
Current status of cdk-erigon's support for running various chains and fork ids:

- zkEVM Cardona testnet — beta support
- zkEVM Cardona testnet — full support
- zkEVM mainnet — beta support
- CDK Chains - beta support (forkid.9 and above)

Expand Down Expand Up @@ -58,6 +64,16 @@ In order to retrieve data from the L1, the L1 syncer must be configured to know

- `zkevm.l1-highest-block-type` which defaults to retrieving the 'finalized' block, however there are cases where you may wish to pass 'safe' or 'latest'.

### L1 Cache
The node can cache the L1 requests/responses to speed up the sync and enable quicker responses to RPC requests requiring for example OldAccInputHash from the L1. This is enabled by default,
but can be controlled via the following flags:

- `zkevm.l1-cache-enabled` - defaults to true, set to false to disable the cache
- `zkevm.l1-cache-port` - the port the cache server will run on, defaults to 6969

To transplant the cache between datadirs, the `l1cache` dir can be copied. To use an upstream cdk-erigon node's L1 cache, the zkevm.l1-cache-enabled can be set to false, and the node provided the endpoint of the cache,
instead of a regular L1 URL. e.g. `zkevm.l1-rpc-url=http://myerigonnode:6969?endpoint=http%3A%2F%2Fsepolia-rpc.com&chainid=2440`. NB: this node must be syncing the same network for any benefit!

## Sequencer (WIP)

Enable Sequencer: `CDK_ERIGON_SEQUENCER=1 ./build/bin/cdk-erigon <flags>`
Expand Down
87 changes: 87 additions & 0 deletions cmd/utils/customflags_zkevm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package utils

import (
"flag"
"fmt"

"github.com/c2h5oh/datasize"
"github.com/ledgerwatch/erigon/cmd/utils/flags"
"github.com/urfave/cli/v2"
)

// Custom cli.Flag type which expand the received string to an absolute path.
// e.g. ~/.ethereum -> /home/username/.ethereum
type DatasizeFlag struct {
Name string

Category string
DefaultText string
Usage string

Required bool
Hidden bool
HasBeenSet bool

Value datasizeFlagValue

Aliases []string
}

func (f *DatasizeFlag) Names() []string { return append([]string{f.Name}, f.Aliases...) }
func (f *DatasizeFlag) IsSet() bool { return f.HasBeenSet }
func (f *DatasizeFlag) String() string { return cli.FlagStringer(f) }

// called by cli library, grabs variable from environment (if in env)
// and adds variable to flag set for parsing.
func (f *DatasizeFlag) Apply(set *flag.FlagSet) error {
flags.EachName(f, func(name string) {
set.Var(&f.Value, f.Name, f.Usage)
})
return nil
}

func (f *DatasizeFlag) IsRequired() bool { return f.Required }

func (f *DatasizeFlag) IsVisible() bool { return !f.Hidden }

func (f *DatasizeFlag) GetCategory() string { return f.Category }

func (f *DatasizeFlag) TakesValue() bool { return true }
func (f *DatasizeFlag) GetUsage() string { return f.Usage }
func (f *DatasizeFlag) GetValue() string { return f.Value.String() }
func (f *DatasizeFlag) GetEnvVars() []string { return nil } // env not supported

func (f *DatasizeFlag) GetDefaultText() string {
if f.DefaultText != "" {
return f.DefaultText
}
return f.GetValue()
}

type datasizeFlagValue datasize.ByteSize

func (b *datasizeFlagValue) String() string {
if b == nil {
return ""
}
a := datasize.ByteSize(*b)
return a.String()
}

func (b *datasizeFlagValue) Set(s string) error {
val, err := datasize.ParseString(s)
if err != nil {
return fmt.Errorf("parse datasize: %v", err)
}
*b = datasizeFlagValue(val)
return nil
}

// DatasizeFlagValue returns the value of a DatasizeFlag from the flag set.
func DatasizeFlagValue(ctx *cli.Context, name string) *datasize.ByteSize {
val := ctx.Generic(name)
if val == nil {
return nil
}
return (*datasize.ByteSize)(val.(*datasizeFlagValue))
}
27 changes: 27 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,16 @@ var (
Usage: "Ethereum L1 RPC endpoint",
Value: "",
}
L1CacheEnabledFlag = cli.BoolFlag{
Name: "zkevm.l1-cache-enabled",
Usage: "Enable the L1 cache",
Value: true,
}
L1CachePortFlag = cli.UintFlag{
Name: "zkevm.l1-cache-port",
Usage: "The port used for the L1 cache",
Value: 6969,
}
AddressSequencerFlag = cli.StringFlag{
Name: "zkevm.address-sequencer",
Usage: "Sequencer address",
Expand Down Expand Up @@ -516,6 +526,11 @@ var (
Usage: "Batch seal time. Defaults to 3s",
Value: "3s",
}
SequencerHaltOnBatchNumber = cli.Uint64Flag{
Name: "zkevm.sequencer-halt-on-batch-number",
Usage: "Halt the sequencer on this batch number",
Value: 0,
}
ExecutorUrls = cli.StringFlag{
Name: "zkevm.executor-urls",
Usage: "A comma separated list of grpc addresses that host executors",
Expand All @@ -536,6 +551,12 @@ var (
Usage: "The timeout for the executor request",
Value: 500 * time.Millisecond,
}

WitnessMemdbSize = DatasizeFlag{
Name: "zkevm.witness-memdb-size",
Usage: "A size of the memdb used on witness generation in format \"2GB\". Might fail generation for older batches if not enough for the unwind.",
Value: datasizeFlagValue(2 * datasize.GB),
}
ExecutorMaxConcurrentRequests = cli.IntFlag{
Name: "zkevm.executor-max-concurrent-requests",
Usage: "The maximum number of concurrent requests to the executor",
Expand Down Expand Up @@ -1309,6 +1330,11 @@ var (
Usage: "Enable speed test",
Value: false,
}
YieldSizeFlag = cli.Uint64Flag{
Name: "yieldsize",
Usage: "transaction count fetched from txpool each time",
Value: 1000,
}
)

var MetricFlags = []cli.Flag{&MetricsEnabledFlag, &MetricsHTTPFlag, &MetricsPortFlag, &DiagDisabledFlag, &DiagEndpointAddrFlag, &DiagEndpointPortFlag, &DiagSpeedTestFlag}
Expand Down Expand Up @@ -2091,6 +2117,7 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
setTxPool(ctx, cfg)
cfg.TxPool = ethconfig.DefaultTxPool2Config(cfg)
cfg.TxPool.DBDir = nodeConfig.Dirs.TxPool
cfg.YieldSize = ctx.Uint64(YieldSizeFlag.Name)

setEthash(ctx, nodeConfig.Dirs.DataDir, cfg)
setClique(ctx, &cfg.Clique, nodeConfig.Dirs.DataDir)
Expand Down
Loading

0 comments on commit 7ae2c6d

Please sign in to comment.