Giter Site home page Giter Site logo

ftheirs / madara Goto Github PK

View Code? Open in Web Editor NEW

This project forked from madara-alliance/madara

0.0 0.0 0.0 280.42 MB

Madara is a powerful hybrid Starknet client written in Rust.

Home Page: https://madara.zone

License: Apache License 2.0

Shell 3.06% Rust 96.37% Nix 0.19% Dockerfile 0.38%

madara's Introduction

๐Ÿฅท Madara: Starknet client

Madara is a powerfull Starknet hybrid client written in Rust.

Table of Contents

โฌ‡๏ธ Installation

Run from Source

  1. Install dependencies

    Ensure you have the necessary dependencies:

    sudo apt-get update && sudo apt-get install -y \
      clang \
      protobuf-compiler \
      build-essential

    Install Rust:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s

    Clone the Madara repository:

    cd <your-destination-path>
    git clone https://github.com/KasarLabs/madara .
  2. Run Madara

    Start the Madara client with synchronization to Starknet mainnet:

    cargo run --release -- \
      --name madara \
      --base-path ../madara-db \
      --network main \
      --l1-endpoint ${ETHEREUM_API_URL} \

Run with Docker

1 Run docker image

To run Madara with Docker, use the following command:

docker run -d \
    --name madara \
    -p 9944:9944 \
    -v /var/lib/madara:/var/lib/madara \
    madara:latest \
    --base-path ../madara-db \
    --network main \
    --l1-endpoint <rpc key> \

Check the logs of the running Madara service:

docker logs -f madara

Run with Docker Compose

  1. Ensure environment variable

    Set the necessary environment variable:

    export ETHEREUM_API_URL="your-ethereum-api-url"

    Or create a .env file in the same directory as your docker-compose.yml file:

    ETHEREUM_API_URL=your-ethereum-api-url
  2. Build and Run the Container

    Navigate to the directory with your docker-compose.yml file and run:

    docker-compose up -d

    Check the logs of the running Madara service:

    docker-compose logs -f madara

โš™๏ธ Configuration

Configuring your Madara node properly ensures it meets your specific needs

Basic Command-Line Options

Here are the recommended options for a quick and simple configuration of your Madara full node:

  • --name <NAME>: The human-readable name for this node. It's used as the network node name.
  • --base-path <PATH>: Set the directory for Starknet data (default is /tmp/madara).
  • --network <NETWORK>: The network type to connect to (main, test, or integration).
  • --l1-endpoint <URL>: Specify the Layer 1 endpoint the node will verify its state from.
  • --rpc-port <PORT>: Specify the JSON-RPC server TCP port.
  • --rpc-cors <ORIGINS>: Specify browser origins allowed to access the HTTP & WS RPC servers.
  • --rpc-external: Listen to all RPC interfaces. Default is local.
  • --snap <BLOCK_NUMBER>: Start syncing from the closest snapshot available for the desired block (default is highest).

Advanced Command-Line Options

Here are more advanced command-line options, organized by namespace, for running and development purposes:

Network
  • -n, --network <NETWORK>: The network type to connect to (default: integration).
  • --port <PORT>: Set the network listening port.
  • --l1-endpoint <URL>: Specify the Layer 1 endpoint the node will verify its state from.
  • --gateway-key <GATEWAY_KEY>: Gateway API key to avoid rate limiting (optional).
  • --sync-polling-interval <SECONDS>: Polling interval in seconds (default: 2).
  • --no-sync-polling: Stop sync polling.
  • --n-blocks-to-sync <NUMBER>: Number of blocks to sync.
  • --starting-block <BLOCK>: The block to start syncing from (make sure to set --disable-root).
RPC
  • --rpc-external: Listen to all RPC interfaces. Note: not all RPC methods are safe to be exposed publicly. Use an RPC proxy server to filter out dangerous methods.
  • --rpc-methods <METHOD_SET>: RPC methods to expose (auto, safe, unsafe).
  • --rpc-max-request-size <SIZE>: Set the maximum RPC request payload size in megabytes (default: 15).
  • --rpc-max-response-size <SIZE>: Set the maximum RPC response payload size in megabytes (default: 15).
  • --rpc-max-subscriptions-per-connection <NUMBER>: Set the maximum concurrent subscriptions per connection (default: 1024).
  • --rpc-port <PORT>: Specify JSON-RPC server TCP port.
  • --rpc-max-connections <NUMBER>: Maximum number of RPC server connections (default: 100).
  • --rpc-cors <ORIGINS>: Specify browser origins allowed to access the HTTP & WS RPC servers.
Database
  • --base-path <PATH>: Specify custom base path (default: /tmp/madara).
  • --snap <BLOCK_NUMBER>: Start syncing from the closest snapshot available for the desired block.
  • --tmp: Run a temporary node. A temporary directory will be created and deleted at the end of the process.
  • --cache: Enable caching of blocks and transactions to improve response times.
  • --db-cache <MiB>: Limit the memory the database cache can use.
  • --trie-cache-size <Bytes>: Specify the state cache size (default: 67108864).
  • --backup-every-n-blocks <NUMBER>: Specify the number of blocks after which a backup should be created.
  • --backup-dir <DIR>: Specify the directory where backups should be stored.
  • --restore-from-latest-backup: Restore the database from the latest backup available.

โ„น๏ธ Info: Note that not all parameters may be referenced here. Please refer to the cargo run -- --help command for the full list of parameters.

๐Ÿ“ธ Snapshots

Snapshots are under developpement and will be available through the --snap <block_number> parameter.

๐ŸŒ Interactions

Madara fully supports all the JSON-RPC methods as specified in the Starknet mainnet official JSON-RPC specs. These methods can be categorized into three main types: Read-Only Access Methods, Trace Generation Methods, and Write Methods.

Supported JSON-RPC Methods

Here is a list of all the supported methods with their current status:

Read Methods
Status Method
โœ… starknet_specVersion
โœ… starknet_getBlockWithTxHashes
โœ… starknet_getBlockWithReceipts
โœ… starknet_getBlockWithTxs
โœ… starknet_getStateUpdate
โœ… starknet_getStorageAt
โœ… starknet_getTransactionStatus
โœ… starknet_getTransactionByHash
โœ… starknet_getTransactionByBlockIdAndIndex
โœ… starknet_getTransactionReceipt
โœ… starknet_getClass
โœ… starknet_getClassHashAt
โœ… starknet_getClassAt
โœ… starknet_getBlockTransactionCount
โœ… starknet_call
โœ… starknet_estimateFee
โœ… starknet_estimateMessageFee
โœ… starknet_blockNumber
โœ… starknet_blockHashAndNumber
โœ… starknet_chainId
โœ… starknet_syncing
โœ… starknet_getEvents
โœ… starknet_getNonce
Trace Methods
Status Method
โœ… starknet_traceTransaction
โœ… starknet_simulateTransactions
โœ… starknet_traceBlockTransactions
Write Methods
Status Method
โœ… starknet_addInvokeTransaction
โœ… starknet_addDeclareTransaction
โœ… starknet_addDeployAccountTransaction

โ„น๏ธ Info: Madara currently supports latest JSON-RPC specs specs up to version v0.7.1

Example of Calling a JSON-RPC Method

Here is an example of how to call a JSON-RPC method using Madara:

{
  "jsonrpc": "2.0",
  "method": "starknet_getBlockWithTxHashes",
  "params": {
    "block_id": "latest"
  },
  "id": 1
}

You can use any JSON-RPC client to interact with the Madara node, such as curl, httpie, or a custom client in your preferred programming language. For more detailed information and examples on each method, please refer to the Starknet JSON-RPC specs.

โš ๏ธ Warning: Write methods are forwarded to the Sequencer for execution. Ensure you handle errors appropriately as per the JSON-RPC schema.

โœ” Supported Features

Madara offers numerous features and is constantly improving to stay at the cutting edge of Starknet technology.

  • Starknet Version: v0.13.1
  • JSON-RPC Version: v0.7.1
  • Feeder-Gateway State Synchronization
  • State Commitment Computation
  • L1 State Verification
  • Handling L1 and L2 Reorgs

Each feature is designed to ensure optimal performance and seamless integration with the Starknet ecosystem.

๐Ÿ‘ Contribute

๐Ÿค Partnerships

To establish a partnership with the Kasar team, or if you have any suggestion or special request, feel free to reach us on telegram.

โš ๏ธ License

Copyright (c) 2022-present, with the following contributors.

Madara is open-source software licensed under the Apache-2.0 License.

madara's People

Contributors

antiyro avatar abdelstark avatar jbcaron avatar 0xlucqs avatar evolveart avatar dependabot[bot] avatar tdelabro avatar tbelleng avatar d-roak avatar cchudant avatar apoorvsadana avatar clementwalter avatar greged93 avatar nils-mathieu avatar lambda-0x avatar sparqet avatar lana-shanghai avatar dbejarano820 avatar hel-kame avatar drspacemn avatar glihm avatar noamoulin avatar bajpai244 avatar chirag-bgh avatar zarboq avatar lucienfer avatar davidesilva avatar trantorian1 avatar fishseabowl avatar mdteach avatar

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.