Deoxys Documentation

Deoxys Last updated: 2019-06-01

Introduction

Deoxys is a Starknet full node client implementation based on Substrate and powered by Rust. It unlocks the full potential of full nodes on Starknet. It's goal is to substantially decrease synchronization time for Starknet full nodes.

Welcome to Deoxys

As we usher in the era of the decentralized web, the role of advanced blockchain technology has become increasingly critical. Starknet, a decentralized, permissionless, and scalable ZK-Rollup, represents a significant step forward in this field. It has proven itself as a standout in the L2 landscape and is significantly distinguished today. But every hero needs a trusted companion, and for Starknet, this ally emerges as Deoxys. Built on the robust Substrate framework and powered by the reliable might of Rust, Deoxys is the most powerful Starknet full node implementation. In this documentation, we will learn more about its architecture, its attributes, its specifics, and of course, how to launch your own Deoxys and benefit from its powers. But before we dive into that, I would like to say a few words about the technical prerequisites related to full nodes on Starknet and the tools that we are going to use.

Prerequisites

Full Nodes

Full nodes track the state of Starknet as it evolves over time and allow users and developers to query and change this state via Starknet's JSON RPC. An important thing to note - full nodes don't change the state themselves. Currently, they forward the requests to the sequencer and pull state updates from it to reach the latest block.

Right now on Starknet we have different full-node implementations:

Full nodes are like guardians of the Starknet state, they track and store a record of it. Sequencers themselves have full nodes.

Substrate

Substrate is a flexible, open-source framework developed by Parity Technologies for creating robust blockchains. It offers essential infrastructure through its Substrate Core and a range of pre-built modules via the Substrate Runtime Module Library (SRML). By using Substrate, Deoxys is able to concentrate on building unique features of a StarkNet full node without having to create standard blockchain functions from the ground up. Substrate's modularity also allows easy network upgrades, changes, and the addition of new features. Furthermore, its extensibility ensures scalability and interoperability, both key aspects in the evolution of the Starknet ecosystem.

Rust

Rust is a systems programming language that emphasizes safety, speed, and concurrency. It is known for its powerful type system, memory safety guarantees, and minimal runtime. Rust's design prevents many common programming errors, like null pointer dereferencing and data races, which makes it an ideal choice for building reliable, high-performance systems.

In the context of Deoxys, Rust provides a number of benefits:

  • Memory Safety: Rust's ownership model guarantees memory safety without needing a garbage collector, which can be a bottleneck in high-performance systems.
  • Concurrency: Rust has first-class support for concurrent and distributed systems, making it perfect for a distributed, concurrent environment like a blockchain.
  • Interoperability: Rust has excellent interoperability with other languages, which can be useful in a multi-language, open-source project.
  • Performance: Rust is designed to perform nearly as well as C++, making it suitable for a high-throughput system like a blockchain network.
  • Community and Ecosystem: Rust has a strong and growing community of developers, and its package ecosystem, Crates.io, provides a wealth of libraries that can help speed up the development process.

Given these benefits, Rust is well-suited for implementing a Starknet full node. It allows Deoxys to achieve high performance and reliability, while its strong memory safety guarantees help ensure the node operates as expected. Moreover, Rust's advanced concurrency features enable Deoxys to efficiently process multiple transactions and requests concurrently, enhancing its ability to manage the Starknet state.

Architecture

Global Operation

Here's a straightforward schematic representation of Deoxys, showcasing its dual role as a guardian of the Starknet state and its peer-to-peer state communication functionality. This feature reduces the reliance on requests to the sequencer and minimizes interactions between full node clients and the Starknet network sequencer.

architecture

Step 1: Synchronizing the Deoxys Boot-node with Starknet's current state

The initial stage of the process involves running a Deoxys boot-node with AUTHORITY status, establishing direct communication with the sequencer gateway. This gateway continuously retrieves blocks starting from the genesis block and stores subsequent states in its database. Once it reaches the latest block issued by the sequencer, it can efficiently query the sequencer as new blocks are produced.


Step 2: Cross-chain verification

The validity of the blocks received is checked by means of a cross-chain verification on the Ethereum chain. This ensures that network nodes are not subsequently informed of a false status (in progress).


Step 3: P2p synchronization of Deoxys nodes from the Deoxys Boot-node

Once a boot-node is operational and its ports are open, an unlimited number of Deoxys clients can be initiated. These clients function similarly to the boot-node but with a distinction that they no longer communicate with the sequencer. Instead, they solely interact with one another. Each client continuously acquires the state by requesting it from its peers while also responding to queries from other nodes within the network.



The Deoxys Runtime


1) The Starknet pallet

The core component of Deoxys is the starknet pallet. It provides a Starknet compatibility layer for Substrate. This pallet, in addition to the RPC module, validates starknet-encoded transactions and makes it possible to re-execute them and store the successive states.


2) Wrapper block strategy

You might be asking, how are we able to map Substrate blocks to Starknet blocks? Well, we use the wrapper block method first used by Parity in frontier, the EVM compatibility layer for Substrate.

"Wrapper block is a strategy in Substrate to allow the processing of blocks that were not originally designed with Substrate in mind."

It does add a slight performance overhead but it's negligible compared to other components of the runtime. Substrate blocks are translated to Starknet blocks in the 'Deoxys' module, and then executed by the Starknet pallet.


3) Execution

The execution layer defines the way blocks are executed and state diffs are produced. With Deoxys, blocks are executed and state diffs are produced using the blockifier by Starkware.

Vertical Stepper

Setup Deoxys

In this section, we will guide you through the build and run process so that you can run your own Deoxys client, and query the Starknet blockchain as smoothly as possible.


Get Started

  1. 1. Install dependencies

    We first need to make sure you have everything needed to complete this tutorial.

    Dependency Version Installation
    Rust rustc 1.69.0-nightly curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup toolchain install nightly
    nvm latest curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
    Cairo 1.0 curl -L https://github.com/franalgaba/cairo-installer/raw/main/bin/cairo-installer | bash
  2. 2. Run your own node

    Fetch the code from the Official Deoxys repository in the folder of your choice.

    cd <your-folder>
    git clone https://github.com/KasarLabs/deoxys
    

    Then let's build the dependencies in release mode

    cd deoxys
    cargo build --release

    Single-node Development Chain.

    This command will start the Deoxys client which will begin the synchronization with the Starknet network automatically:

    cargo run --release -- --dev --sealing=manual
    Kasar-GUI-2

    The terminal should display output similar to this

    If everything works correctly, we can go to the next step and create our peer to peer network!

  3. 3. Sync deoxys

    cargo run -- \
      --madara-path /tmp/boot \
      --validator \
      --rpc-cors=all \
      --rpc-external \
      --rpc-methods=unsafe \
      --port 30333 \
      --rpc-port 9944 \
      --name deoxys-boot \
      --telemetry-url "wss://deoxys.kasar.io/submit/ 0" \
      --dev \
      --sealing manual
    

    This command synchronizes Starknet from block 0

    Kasar-GUI-2

    The terminal should display output similar to this

  4. Let's break down the command

    • --madara-path /tmp/boot \: The filesystem path.
    • --validator \: The type of node you are running, a validator (or authority node) establishes direct communication with the sequencer. If this command is removed, you will run a standard Deoxys full node.
    • --rpc-cors=all \: The node's Remote Procedure Call (RPC) configuration, set to 'all' allowing any website or service from any domain to interact with the node's RPC.
    • --rpc-external \: The RPC interface of the node listens for connections not just from the local machine.
    • --rpc-methods=unsafe \: Here you provide broader access to the functionality of your node over the RPC interface. This can be useful for development, debugging, or administration purposes, where you might need more control over the node.
    • --port 30333 \: The network port on which the node will listen for peer-to-peer connections. Deoxys inherits Substrate mechanism, making '30333' the default P2P port.
    • --rpc-port 9944 \: The port number for the node's RPC interface. We used '--rpc-external', meaning that the RPC interface can be accessed from outside the local machine, then external clients will connect to the node's RPC interface using this port (9944 in this case). Port 9944 is a personal port.
    • --name deoxys-boot \: The name of the node. You can pick any name, for example --name Ultimate-Mewtwo \.
    • --telemetry-url "wss://deoxys.kasar.io/submit/ 0" \: This command specifies the endpoint to which the node will send its telemetry data. 'wss://deoxys.kasar.io/submit/ 0' is the specific URL and endpoint to which the telemetry data will be sent.
    • --sealing manual: The process of finalizing a block so that it can be added to the blockchain. The command will not be used in the long-term.

  5. 4. Launch the desktop app

    Next, clone this repo into the file you just used above

    
    cd your folder
    git clone https://github.com/KasarLabs/deoxys-app
    				

    Now we run npm

    
    npm install
    npm run start
    									

Use Deoxys

This section explains how to interact with the Deoxys-app.


Get Started

  1. 1. Run the app and pick your Deoxys

    After running npm the Deoxys desktop app will launch. You have the choice of running 3 types of Deoxys nodes

    1. Authority node: also called the Deoxys boot-node, this node retrieves blocks from the Starknet sequencer starting from the genesis block. Hence, synchronization is estimated at 24 hours
    2. Full node: these nodes connect to the authority node and import the synched data. Synchronization is estimated at 5 minutes
    3. Light node: this node doesn't keep a complete copy of Starknet. Instead, it only synchronizes with blocks from the point of its activation onward, disregarding any blocks prior to its launch
    Kasar-GUI-2

    Selecting your Deoxys node

  2. 2. Features on Deoxys

    1. See the logs of the node in realtime
    2. Install dockerized/binary apps that allow you to interact with your node.
    3. Kasar-GUI-2

      Selecting your Deoxys node


The benefits of the Deoxys architecture

The Deoxys architecture offers several significant benefits for the Starknet:

  1. Efficient Query Mechanism: Once Deoxys is updated to the latest block issued by the sequencer, it can efficiently query the sequencer for new blocks. This ensures real-time updates and reduced lag.
  2. Double Verification for Accuracy: With the L1 verification, Ethereum is responsible for validating Starknet transactions. Deoxys then cross-checks these transactions to ensure the L2 state is valid. This dual verification process guarantees the accuracy of the network's state, ensuring that nodes aren't misinformed about the network's status.
  3. P2P Synchronization: The Peer-to-Peer (P2P) network is a powerful feature within Deoxys. In this network, all nodes are equal, allowing them to function both as servers and clients. This means every node can request and supply services to others.
  4. Rapid Full Node Syncing: Introducing a P2P network to Starknet has revolutionized its syncing speed. Since full nodes are constantly communicating and sharing state information, synchronization time is vastly reduced. This ensures that if you operate a full node, you can synchronize rapidly due to nearby nodes already having synced data from the boot node.
  5. Innovative P2P Implementation: The full node P2P network is a groundbreaking addition to Starknet, marking a stride towards a consensus implementation.
  6. Impressive Synchronization Times: The synchronization time between the sequencer and the boot node with Deoxys is less than 25 hours, and even more impressively, the synchronization between full nodes and boot nodes takes less than 5 minutes.

Configuration

In this section, we will look at the different parameters you can tweak as a runtime engineer for your blockchain to be perfectly tailored to your needs.

Configuration

Parameter Location Interpretation Default
MILLISECS_PER_BLOCK crates/runtime/src/config.rs Average expected block time targeted. 6000 (ms)
BlockHashCount crates/runtime/src/config.rs Maximum number of block number to block hash mappings to keep (oldest pruned first). 2400

The core component of Deoxys is a custom substrate pallet named starknet which you can find under crates/pallets/starknet.

Let's take a closer look at the types and their default values in Deoxys's configuration.

// `crates/runtime/src/pallets.rs`
						
	// ...
	
	/// Configure the Starknet pallet in pallets/starknet.
	impl pallet_starknet::Config for Runtime {
	type RuntimeEvent = RuntimeEvent;
	type StateRoot = pallet_starknet::state_root::IntermediateStateRoot<Self>
	type SystemHash = mp_starknet::crypto::hash::pedersen::PedersenHasher;
	type TimestampProvider = Timestamp;
	type UnsignedPriority = UnsignedPriority;
	}
Type Interpretation Default
RuntimeEvent Event type that will be emitted on extrinsics' execution. Substrate RuntimeEvent
StateRoot Defines how the timestamp is retrieved (used for block timestamp) Starknet State Root
SystemHash Hashing function used to compute commitments. Pedersen
TimestampProvider Defines how the timestamp is retrieved (used for block timestamp) Timestamp Pallet

Starknet

StarkNet Features Compatibility

Block

Feature State
Parent block hash
Block number
Global State Root
Sequencer Address
Block timestamp
Transaction Count
Transaction Commitment
Event Count
Event Commitment
Protocol Version
Extra data

Transaction

Feature State
Declare
Deploy
Invoke
L1 handler 🚧

RPC

Feature State
starknet_getBlockWithTxHashes
starknet_getBlockWithTxs
starknet_getStateUpdate 🚧
starknet_getStorageAt 🚧
starknet_getTransactionByHash 🚧
starknet_getTransactionByBlockIdAndIndex 🚧
starknet_getTransactionReceipt 🚧
starknet_getClass 🚧
starknet_getClassHashAt 🚧
starknet_getClassAt 🚧
starknet_getBlockTransactionCount
starknet_call 🚧
starknet_estimateFee 🚧
starknet_blockNumber
starknet_blockHashAndNumber
starknet_chainId 🚧
starknet_pendingTransactions
starknet_syncing
starknet_getEvents 🚧
starknet_getNonce 🚧
starknet_traceTransaction 🚧
starknet_simulateTransaction 🚧
starknet_traceBlockTransactions 🚧
starknet_addInvokeTransaction
starknet_addDeclareTransaction
starknet_addDeployAccountTransaction

Decentralisation

Feature State
Single node
Small pool of nodes (POA) 🚧
Large pool of nodes (Base consensus) 🚧
Large pool of nodes (Custom consensus) 🚧

Optimisation

Feature State
Commitments 🚧
Transaction validity before mempool 🚧

Starknet API

Ethereum comparison

Ethereum Method StarkNet Method Differences From Ethereum
eth_blockNumber starknet_blockNumber Will return only the block number
eth_chainId starknet_chainId
eth_getBlockByNumber starknet_getBlockByNumber
  • Doesn't have the include transactions input.
  • The result key is “result”.
eth_getBlockTransactionCountByHash starknet_getBlockTransactionCountByHash
  • Supports also “latest” block tag as input.
  • The result is always an integer.
  • The response key is “result”.
  • May return an error for invalid block hash.
eth_getBlockTransactionCountByNumber starknet_getBlockTransactionCountByNumber
  • Block number input is given as a decimal integer.
  • The result key is “result”.
  • May return an error for invalid block number.
eth_getTransactionByBlockHashAndIndex starknet_getTransactionByBlockHashAndIndex The Index is given as a decimal integer.
eth_getTransactionByBlockNumberAndIndex starknet_getTransactionByBlockNumberAndIndex The index is given as a decimal integer.
eth_pendingTransactions starknet_pendingTransactions
  • The result key is “result”.
  • Will not return market fee parameters.
eth_getBlockByHash starknet_getBlockByHash
  • Doesn't have the include transactions input.
  • The result key is “result”.
eth_protocolVersion starknet_protocolVersion
eth_syncing starknet_syncing The result will not include known and pulled states
eth_getStorageAt starknet_getStorageAt
  • Accepts a block hash instead of a block number
  • The result key is “result”.
  • The result type is a field element.
  • Will return errors for invalid contract or storage keys.
eth_getTransactionByHash starknet_getTransactionByHash
  • Input key is “transaction_hash”.
  • The result key is “result”.
  • Will not return null.
  • Will return an error for an invalid transaction hash.
eth_getTransactionReceipt starknet_getTransactionReceipt
  • Input key is “transaction_hash”.
  • The result key is “result”.
  • Will not return null.
  • Will return an error for an invalid transaction hash.
eth_getCode starknet_getCode
  • The input key is “contract_address”.
  • Does not accept a block number.
  • Will return byte code (field elements) and ABI.
  • Will return an error for an invalid contract address.
eth_call starknet_call
  • Input transaction is different.
  • Input block designated by hash.
  • Will return errors for invalid contract address.

Contribute

Contribute to Deoxys

Deoxys has been built from the day 1 in the most open-source way possible, and will always follow the principles that drive the Starknet ecosystem since day 1. Anyone is free to join the KasarLabs telegram group here, come chat, ask for help, discuss anything!

Tip

Have an idea of an ambitious hack related to one module of the client? Such as an optimization update or a fixing issue? Go ahead and create a discussion on the GitHub repo, if all good you'll be invited to present it at one community call and then start implementing it.


Developers

Deoxys contributions are rewarded through OnlyDust. What does that mean? It means that you as a developer are free to pick any open issue and submit a PR. Once the PR is merged you will be paid according to the time/difficulty of the PR. For now, the Deoxys team does not look for new contributors, but this could change in the future. If you are interested in joining the team, please reach out to us on Telegram.


Bug Hunting

Found a bug? Please submit an issue on GitHub so any open-source contributor can look at it and fix it (you can too!).


Documentation

Missing anything in these docs? Spotted a typo? Please submit a PR or create an issue on GitHub. As with everything we do, we grow together and the more eyes we have looking at it, the better it will be.

FAQ

The road towards production

Deoxys is still at the development stage. So be cautious about going to production with such a system; thorough audits are highly recommended.

Deoxys aims to stand out as the fastest and most widely adopted client on Starknet. Thanks to its innovative approach, Deoxys considerably lightens the network, optimizes performance, and delivers a seamless user experience. When you choose Deoxys, you benefit from a state-of-the-art solution designed to unleash the full potential of the Starknet network and facilitate the development of high-performance, scalable decentralized applications.

Starknode

👽 x 💾

In the near future, we'd like to enable Starknode purchasers to run Deoxys clients on their boards. In particular, this would enable faster synchronization with the current state, and lighten the network thanks to peer-to-peer communication between Starknodes.

Ecosystem

In this section you'll find a curation of existing developments around Deoxys and the clever ways in which it can be used.

Media


Starknet infrastructure powered by Substrate | Antiyro

Here is a video tutorial of how Deoxys and Substrate work, by Antiyro at the 2023 Starknet Summit




How Deoxys works, but you're 5 years old

Here is a high-level overview of how the Deoxys architecture looks like, done by Starkience from Kasarlabs