Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Latest commit

 

History

History
320 lines (250 loc) · 11.5 KB

sharingan-starter-pack.md

File metadata and controls

320 lines (250 loc) · 11.5 KB

Sharingan starter pack

Network information

Madara

Madara 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 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 access to everybody to participate and test the 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 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:

Maintainer ID Key alias IP Peer ID RPC port
Starkware 1 alice 52.7.206.208 12D3KooWK26CZBpWtwMaVQ6nXHrrXBkdXXx6CrBAU2KgLTqDNL6o 9944
Starkware 2 bob 44.195.161.82 12D3KooWMyrW5SvZ1WpcMLi7QdjXRQ36mUBg6RoaoABtPNMGVqXr 9944
Cartridge 3 charlie 208.67.222.222 -- 9944
LambdaClass 4 dave 65.108.65.148 12D3KooWG29EKQvNoUHRWXwdNQ7LiEFG8wGS86CKyohe16sqYUM2 9944
Pragma 5 eve 13.39.22.82 12D3KooWMyJvL4qJZz9kTcD7xP2vBMqM9SMMFdJvD3tS9KEoMJCw 9944
Kakarot 6 ferdie 52.50.242.182 12D3KooWMzm38Uw32PS4aUxykX9vHWkG4TqKtYY6gqKSt6dwgmk3 9944

More technical details can be found in the discussion here.

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 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 9944.

  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.

  3. Resources: to participate to Sharingan testnet as a fullnode, the hardware requirements are low and it will depend on how much you will query your fullnode.

    But basically, you can spin up a node with 2 vCPU and 2GB RAM, and Madara will run smoothly. We recommend 4GB RAM as the initial synchronization of the blocks is more intensive, and can almost reach 2GB RAM. Also if you have your node running a large amount of time the RAM will grow. A restart refreshes the RAM usage to ~500MB.

    When Madara is on idle state, synchronizing the blocks at the head of the chain, it uses around 500MB/700MB RAM and very few CPUs.

    Tested with AMD EPYC 7000 series ~2.1GHz and Intel Xeon 3.3GHz, with 2 vCPU for the minimum configuration.

    If you are on AWS, t2.medium is a very good setup for a regular use if the instance is dedicated to Sharingan.

  4. Telemetry: Madara has now a telemetry feature for a real time monitoring of the nodes. You can find the dashboard here. It's time to add your node on this map! image

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. Create a docker volume used for sharingan:

    docker volume create sharingan-volume

    When a hard reset of the network is required, simply delete the volume with docker volume rm sharingan-volume.

    If you need a backup from the current state of your node, you can find the exact location of your volume using docker volume inspect sharingan-volume.

  2. Running the docker container.

    docker run --rm -d \
     -p 9944:9944 -p 30333:30333 \
     --name sharingan-fullnode \
     -v sharingan-volume:/root/.madara \
     ghcr.io/keep-starknet-strange/madara:v0.1.0-testnet-sharingan-beta.7.1 \
     --testnet sharingan \
     --telemetry-url 'wss://telemetry.madara.zone/submit 0'

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. Alternatively, you can also run docker logs -f sharingan-fullnode to see the logs when the container run in detached mode.

The --rm option is used to remove the container when it's stopped. The volume is not deleted, no data are lost. This is a convenient way to not accumulate the stopped containers.

Dev way: cloning Madara repository

If you prefer having Madara compiled locally, you must:

  1. Clone Madara repository.
  2. Checkout on the tag v0.1.0-testnet-sharingan-beta.7.1.
  3. cargo build --workspace --release (you can check this guide 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 setup
./target/release/madara --testnet sharingan --telemetry-url 'wss://telemetry.madara.zone/submit 0'

This will store the data into $HOME/.madara.

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://127.0.0.1:9944

You can then go to the node explorer and check that your node is appearing and start synchronizing the blocks.

Welcome to Sharingan, you're in! 🚀

For now, there are few transactions, and the storage for the 20,000+ blocks is less than 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 (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.

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:9944
curl --header "Content-Type: application/json" \
     --request POST \
     --data '{
     "jsonrpc": "2.0",
     "method": "starknet_blockHashAndNumber",
     "params": ["latest"],
     "id":1}' \
     http://52.7.206.208:9944

Sharingan substrate explorer

Here 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!