Sharingan

Sharingan starter pack

Madara

Madara (opens in a new tab) is a Starknet sequencer. Written using rust and substrate (a SDK to build blockchain), Madara is a community driven sequencer supported by Starkware Keep-Starknet-Strange team which is expected to be one of the major sequencers participating in the Starknet decentralization.

If you don't know Madara, take a look at the repository and the contributor starter pack (opens in a new tab) to have an idea of how it is built.

However, if you just want to participate to Sharingan, you can continue reading this guide, which will guide you without previous Madara knowledge.

What is Sharingan

Sharingan is an ephemeral testnet for Starknet where all nodes participating in the network are Madara instances. In this testnet, Starknet is being tested decentralized, where the nodes work in consensus to determine which block is the next to be added to the chain.

But there are also nodes that are participating in the data storage only, without being involved in the consensus.

Even if Madara is called Starknet Sequencer, we distinguish two types of node in Sharingan:

  1. Madara as a sequencer, participating in the consensus.
  2. Madara as a fullnode, for the data persistence.

For the rest of the guide, sequencer will refer to a Madara instance participating to the consensus, and fullnode to a Madara instance used for data persistence.

The objective of Sharingan is to start testing Starknet being decentralized and also give an access to everybody to participate and test Starknet network.

To interact with the Starknet network, Starknet nodes expose a JSON RPC endpoint. This means that any Madara instance participating in the network will have an open port to allow external communication. More on this in the RPC dedicated section.

If you speak spanish, you surely want to check this version (opens in a new tab) of the guide, made by Nadai for StarknetES community.

Sharingan typology

As mentioned, Sharingan relies on sequencers to produce, validate and add block to the chain. As of today, Sharingan has the following known sequencers:

MaintainerIDKey aliasIPPeer IDRPC port
Starkware1alice52.7.206.20812D3KooWJytWW4wqhG1xp9ckLb7B15KqDU24Q8HHo8VfwXmFe5ZE9933
Starkware2bob44.195.161.8212D3KooWHocNfvLz6rgpb8wJsynSpMwkspkcRn6gmN5UiK1tTTeG9933
Cartridge3charlie208.67.222.22212D3KooWQe2ZtqiyC5CLJKZr9i9xTmEyiAikZcr5J18w3cG1dQAc9933
LambdaClass4dave65.109.91.2912D3KooWK8QhFjkGYGyMskDuCyaS1nrhfTfadMeRjJkox4SV32co9933
Pragma5eve13.39.22.8212D3KooWGMCGJ517tFor12U9n2v3ax5WNw1pXFdj48hSHYQe6oyJ9933
Kakarot6ferdie52.50.242.18212D3KooWHnQ8LC113DgB5cVVyx2mvTN7bBkm75zvzsndr2WhstEE9933

More technical details can be found in the discussion here (opens in a new tab).

As Madara is using substrate, there is an existing web application that allows you to monitor the Sharingan state. And to check the node typology, you can directly go here to the node info (opens in a new tab) tab.

Currently, sequencers are chosen by Starkware, and you can join as a fullnode only.

Participate to Sharingan as a fullnode

To participate to Sharingan, there are few considerations to have in mind:

  1. The Madara code you will be running will need to expose two ports: one for the peer-to-peer communication, which is currently 30333, and one for the RPC mentioned earlier which is usually 9933.

  2. Substrate is using chain specs to have all participating node being in sync on how to collaborate on the network. The chain specification is also special in substrate, as it includes what we call the runtime, where we define how transactions are processed within the nodes.

To participate to Sharingan as a fullnode, you have two options:

Easy way: docker image

There is a docker image built for Sharingan, which will be updated at each version of Sharingan. However, to ensure that you are using the correct chain specs, please proceed to the following:

  1. Download the source code (opens in a new tab) of the current version of Sharingan release (currently v0.1.0-testnet-sharingan-alpha.4).

  2. Extract the archive, to later access the file of interest which is madara/infra/chain-specs/testnet-sharingan-raw.json.

  3. Running the docker container, where we will use 2 volumes. One to access the chain specs file, and another one for the storage of the chain data.

sudo docker run -v /tmp:/data \
                -v /path/to/madara/infra/chain-specs/:/chain-specs \
                ghcr.io/keep-starknet-strange/madara:v0.1.0-testnet-sharingan-alpha.4 \
                --chain /chain-specs/testnet-sharingan-raw.json \
                --base-path /data/sharingan \
                --bootnodes /ip4/52.7.206.208/tcp/30333/p2p/12D3KooWJytWW4wqhG1xp9ckLb7B15KqDU24Q8HHo8VfwXmFe5ZE \
                --rpc-cors=all \
                --rpc-external \
                --rpc-methods=unsafe \
                --port 30333 \
                --rpc-port 9933

Consider running the node in detached mode using the -d option. But try first running without the -d option as it's easier to see what's happening if it's your first time using docker.

Dev way: cloning Madara repository

If you prefer having Madara compiled locally, you must:

  1. Clone Madara repository (opens in a new tab).
  2. Checkout on the tag v0.1.0-testnet-sharingan-alpha.4.
  3. cargo build --workspace --release (you can check this guide (opens in a new tab) with some info about compiling Madara).
  4. Run the fullnode (in a screen, or any other mean to keep it running) being at the root of Madara repository:
./target/release/madara \
--base-path /path/to/storage/sharingan \
--chain ./infra/chain-specs/testnet-sharingan-raw.json \
--bootnodes /ip4/52.7.206.208/tcp/30333/p2p/12D3KooWJytWW4wqhG1xp9ckLb7B15KqDU24Q8HHo8VfwXmFe5ZE \
--rpc-cors=all --rpc-external --rpc-methods=unsafe \
--port 30333 --rpc-port 9933

Once you have your node running, you can get your Peer ID running the following command:

curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
    "jsonrpc": "2.0",
    "method": "system_localPeerId",
    "params": [],
    "id": 1
}' \
http://your_ip:9933

You can then go to the node explorer (opens in a new tab) and check that your node is appearing and start synchronizing the blocks.

Welcome to Sharingan, you're in! :rocket:

For now, there are few transactions, and the storage for the 20,000+ blocks is less that 1GB. But this will vary in the future depending on the network activity.

Interact with Starknet using JSON RPC

To interact with Starknet using a node of Sharingan, you must use JSON RPC directly (with command like curl) or indirectly using Starknet CLI programs like starkli (opens in a new tab) (Some documentation coming soon for starkli).

Currently, Madara is still under active development and it's recommended to regularly check the Starknet features compatibility page of Madara (opens in a new tab).

In the current version, please don't use unsupported RPC endpoint as we are working on handling them.

Here are some examples of RPC using the sequencer-1 of Starkware:

Get the last block hash

starkli block-hash --rpc http://52.7.206.208:9933
curl --header "Content-Type: application/json" \
     --request POST \
     --data '{
     "jsonrpc": "2.0",
     "method": "starknet_blockHashAndNumber",
     "params": ["latest"],
     "id":1}' \
     http://52.7.206.208:9933

Sharingan substrate explorer

Here (opens in a new tab) is the web app to visualize Sharingan status.

As mentioned earlier, Madara is using substrate SDK. As a particularity of how Madara uses substrate, any Starknet block is produced and wrapped into a substrate block.

Substrate blocks are not using the same hashing method that Starknet uses. For this reason, the blocks visible in the explorer are not matching the blocks you can see in Starknet explorer like starkscan or voyager.

But this is a great tool to check Sharingan typology and block production.

What can I do on Sharingan

For now, Madara (and then Sharingan) is not supporting Cairo 1, this is coming soon!

The idea is to have lots of people using Sharingan as a testnet, deploying and using contracts sending transactions to Sharingan nodes.

This will be the most effective way to initiate Starknet decentralization.

For now you can take existing Cairo 0 contracts and play with them on Sharingan, but be prepared.. Quantum Leap is coming and Madara is not far behind...! :rocket:

Let's continue building and thank you for being part or having interest for Sharingan testnet!