Skip to content

KasarLabs/deoxys

Repository files navigation

πŸ₯· 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 trought 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.

About

Madara (prev: Deoxys) is a powerful hybrid Starknet client written in Rust.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages