On Sequencers, nodes, and everything you were afraid to ask about them in Starknet.
Starknet has many moving parts (and some are still in development) which could potentially cause confusion… So, anon - let’s take a bit of a closer look!
In short, we will take a look at these topics, from lower to higher levels:
The Cairo VM is concerned with the Cairo programming language execution logic. Currently, there are 2 implementations of the VM:
The pythonic VM is slower, so soon it will be replaced by the Rust version.
Cairo is actually a general-purpose programming language, which means it’s not specifically limited to smart contracts. It can be used for any computation that would benefit from being proved on one computer and verified on other machines with lower hardware requirements. For a deeper look into the Cairo language, we recommend you check out this awesome Cairo book!
Note: One important thing to note here is that you cannot write smart contracts as you would be used to on this level. For smart contracts support, we have to go one level up in the architecture - the blockifier.
These components are basically the Rust implementation of the Starknet blockchain!
The Blockifier is built by Starkware and Starknet_in_rust is built by Lambda Class. They both incorporate (wrap) the Cairo VM, build on top of it to provide support for smart contracts (system calls), block execution logic, and create state diffs.
The goal for the Blockifier is to extend it into a full StarkNet sequencer, written in Rust, replacing the one currently in use.
Full nodes track StarkNet’s state 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:
For our architectural purpose of the story, we could say: if on top of the Blockifier you now add networking, RPC entry points, and a database - you get a full node!
At last, if on top of our full nodes, we add ordering of blocks and producing blocks recognized by the sharp prover, we now have a sequencer!
The Sequencer is a crucial part of the Starknet ecosystem, as it receives, batches, and executes transactions. It has http API endpoints that are called by nodes (Pathfinder, Juno, Papyrus), CLI tools (starknet, Starknet.js…) for interacting with Starknet.
As of May 5, 2023 the Sequencer is being developed and maintained by Starkware, in the Python language. It is not open sourced, and is centralized.
The direct Http endpoints to the Sequencer will be deprecated and only RPC calls to nodes will work. But this will change pretty soon! In the near future, the plan is to optimize the Sequencer with a rewrite to the Rust language, and later on to add decentralization capabilities to the network. To emphasize, the sequencer will also be (eventually) decentralized as part of the decentralization roadmap.
We must also mention the Madara project - an open-source work-in-progress sequencer based on Substrate. On testing, it achieved 100ms block time with a whopping 250 TPS!!
For additional learning, here is a list of more in-depth resources about Starknet:
* This article is also available on SpaceShard Medium.