Giter Club home page Giter Club logo

kurtosis-cdk-erigon-node's Introduction

Kurtosis CDK-Erigon Node

This is a Kurtosis package that will spin up a CDK-Erigon node, optimized for syncing with any Polygon Hermez zkEVM network. The package is designed to be used for testing, validation and development of the cdk-erigon client. It is not intended for production use.

Table of Contents

Quickstart

๐Ÿšจ Make sure you have Docker and Kurtosis installed.

Deploy a Node

# Deploy a local CDK-Erigon mainnet node.
$ kurtosis run --enclave cdk-erigon github.com/leovct/kurtosis-cdk-erigon-node
# Equivalent to: kurtosis run --enclave cdk-erigon github.com/leovct/kurtosis-cdk-erigon-node '{chain: mainnet}'

# Alternatively, deploy nodes for other networks.
$ kurtosis run --enclave cdk-erigon github.com/leovct/kurtosis-cdk-erigon-node '{chain: cardona}'
$ kurtosis run --enclave cdk-erigon github.com/leovct/kurtosis-cdk-erigon-node '{chain: bali}'

The list of networks currently supported is available here.

Once the command is executed, observe the output, especially the exposed port (here, 50169), which corresponds to the HTTP-RPC server of the CDK-Erigon node.

...
Starlark code successfully run. No output was returned.

Made with Kurtosis - https://kurtosis.com
INFO[2024-03-05T11:42:06+01:00] ===================================================
INFO[2024-03-05T11:42:06+01:00] ||          Created enclave: cdk-erigon          ||
INFO[2024-03-05T11:42:06+01:00] ===================================================
Name:            cdk-erigon
UUID:            86dd2080720e
Status:          RUNNING
Creation Time:   Tue, 05 Mar 2024 11:42:00 CET
Flags:

========================================= Files Artifacts =========================================
UUID   Name

========================================== User Services ==========================================
UUID           Name              Ports                                          Status
6252397ca95a   cdk-erigon-node   http_rpc: 8545/tcp -> http://127.0.0.1:50169   RUNNING

Explore logs with:

$ kurtosis service logs cdk-erigon cdk-erigon-node --all --follow

Connect to the node:

$ kurtosis service shell cdk-erigon cdk-erigon-node

Finally, to monitor the node, you can use polycli.

$ polycli monitor --rpc-url http://127.0.0.1:50169

Node Integrity Check

Here are quick steps to ensure your node is synced and working correctly. For this example, we will sync against the Bali Testnet.

First, verify your node sync status.

$ curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:50169
{"jsonrpc":"2.0","id":1,"result":false}

Second, retrieve the latest block number (e.g. from the local node).

$ cast bn --rpc-url http://127.0.0.1:50169
1285203

Third and finally, compare state roots of local node RPC and sequencer RPC URLs for the latest block. They should match!

$ cast block 1285203 --rpc-url http://127.0.0.1:50169 --json | jq -r .stateRoot
0x54ee9fed29133351f1f49259ab47021fd06816210e1b16d0402de042ffb16e50

$ cast block 1285203 --rpc-url https://rpc.internal.zkevm-rpc.com --json | jq -r .stateRoot
0x54ee9fed29133351f1f49259ab47021fd06816210e1b16d0402de042ffb16e50

Configure your Node

To tailor your CDK-Erigon node according to your specific needs, explore and adjust the default configuration file (config.yaml). This file encompasses crucial parameters such as the target blockchain, zkEVM configurations, and L1 query parameters like block range, query delay, and the initial block for L1 synchronization. Feel free to customize these values and initiate your personalized node.

Here's a step-by-step guide:

  1. Clone the repository.
$ git clone https://github.com/leovct/kurtosis-cdk-erigon-node.git
$ cd kurtosis-cdk-erigon-node
  1. Edit the configuration.
$ vi config.yaml
  1. Start the node with your custom parameters.
$ kurtosis run --enclave cdk-erigon --args-file config.yaml .

Note: The current version of the CDK-Erigon node is based on the zkevm branch. As soon as Kurtosis supports build-time variables in the Dockerfile (refer to this issue), we will be able to pass the CDK-Erigon node version as a configuration parameter in config.yaml. This enhancement will provide greater flexibility and ease of configuration for testing CDK-Erigon node versions.

Add a New Network

Enhance the versatility of this Kurtosis package by seamlessly integrating a new network.

  1. Navigate to the config/network directory.
$ cd config/networks
  1. Add your own network configuration. For instance, refer to the existing mainnet configuration file (config/networks/mainnet.yaml) as a template.
$ vi my-network.yaml

Note that certain parameters are shared among all CDK-Erigon nodes and are stored in a separate file (config/common.yaml). This modular approach ensures the simplicity and readability of configurations.

  1. Adjust the chain parameter, in the configuration file (config.yaml), to match your network file name (here, it would be my-network).

  2. Start the node for your new network.

$ kurtosis run --enclave cdk-erigon --args-file config.yaml .

Supported Networks

Here is the list of networks currently supported. If you wish to add a new one, visit this section.

Network Rootchain Configuration File
zkEVM Mainnet Ethereum Mainnet config/networks/mainnet.yaml
zkEVM Etrog Testnet Ethereum Sepolia Testnet config/networks/etrog.yaml
zkEVM Cardona Testnet Ethereum Sepolia Testnet config/networks/cardona.yaml
zkEVM Bali Testnet Ethereum Sepolia Testnet config/networks/bali.yaml
X1 Testnet Ethereum Sepolia Testnet config/networks/x1-testnet.yaml

kurtosis-cdk-erigon-node's People

Contributors

leovct avatar

Watchers

 avatar

kurtosis-cdk-erigon-node's Issues

Provide CDK-Erigon node version as a configuration parameter

We would like to be able to test different versions of the CDK-Erigon node easily. We could achieve this by adding a new cdk_erigon_version parameter once Dockerfile build-time variables are supported in Kurtosis ImageBuildSpec. By default, we would build the node from the most recent commit.

Implementation

def run(
     ...,
     cdk_erigon_node_version="zkevm",
     go_version="1.19"
):
    config = create_cdk_erigon_node_config(...)
    start_cdk_erigon_node(plan, cdk_erigon_node_version, go_version, config)

def start_cdk_erigon_node(plan, cdk_erigon_node_version, go_version, config):
    plan.add_service(
        name="cdk-erigon-node",
        config=ServiceConfig(
            image=ImageBuildSpec(
                image_name="cdk-erigon",
                build_context_dir=".",
                build_args={
                        "CDK_ERIGON_NODE_VERSION": cdk_erigon_node_version,
                        "GO_VERSION": go_version,
                }
            ),
            files={"/etc/cdk-erigon": config},
            ports={"http_rpc": PortSpec(8545, application_protocol="http")},
            cmd=["--config=/etc/cdk-erigon/config.yaml", "--maxpeers=0"],
        ),
    )
 
# https://github.com/0xPolygonHermez/cdk-erigon/blob/zkevm/go.mod#L3
ARG GO_VERSION=1.19
FROM golang:${GO_VERSION} as builder
...

# https://github.com/0xPolygonHermez/cdk-erigon/releases
ARG CDK_ERIGON_NODE_VERSION=zkevm
RUN git clone --branch ${CDK_ERIGON_NODE_VERSION} https://github.com/0xPolygonHermez/cdk-erigon . \
  && make cdk-erigon

...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.