Giter Club home page Giter Club logo

madara's Introduction

⚡ Madara App Chain Stack

Welcome to Madara, the modular stack to build chains using Cairo and the Starknet technology. Apps like dYdX V3, Immutable and Sorare have been using StarkEx for scaling for a while and now with Madara, it's open source for everyone to use.

Madara is built on the Substrate framework which not only makes it modular but also gives it access to years of dev tooling, libraries and a strong developer community. It is specifically helpful if you want to own more of the stack and get more control over your chain.

📚 Documentation

Get started with our comprehensive documentation, which covers everything from project structure and architecture to benchmarking and running Madara:

📣 Building App Chains

For many use cases, you do not need to fork this repo to build your app chain. By adding changes using forking, you will have to periodically rebase (and solve conflicts) to remain updated with the latest version of Madara. Madara by default provides

  • pallet_starknet: Adds the CairoVM to Substrate which allows you to deploy and execute Cairo contracts.
  • Starknet RPC: Adds all the Starknet RPC calls to your chain so that it's compatible with all RPC tools like starknet-js, wallets, etc.
  • DA Interface: A general interface which allows you to use any DA layer like Avail, Celestia, Ethereum etc.
  • Proving: Running the Starknet OS which is the runtime logic in Cairo so that it can be proven on the L1.

So for many use cases where you want to change common things like

  • Configuration parameters for example block time, maximum steps etc.
  • DA layer
  • Genesis state
  • Add new off chain workers
  • Add new pallets

you don't need to fork the Madara repo. Instead, you can import the relevant code as crates/pallets. We have created an app-chain-template which imports Madara as a library to show an example and would recommend you start from here. For other more detailed use cases like

  • Adding a new syscall to the cairo VM
  • Changing the runtime logic to deviate from Starknet's logic

You should consider forking parts of Madara.

📣 Peripheral repositories

  • Madara Docsite: The source code of the Madara documentation website. Deployed on https://docs.madara.zone.
  • Stark Compass Explorer by the LambdaClass team : An open source block explorer for Starknet based chains.
  • Madara Infra: A collection of scripts and tools to deploy and manage Madara on different environments (e.g. AWS, docker, ansible, etc.). It also contains the Starknet Stack demo docker-compose file.
  • Madara Tsukuyomi: The source code of the Madara Desktop App. A friendly GUI to start a Madara node and interact with it.
  • App Chain Template: A ready to use template that allows you to easily start an app chain.

🌟 Features

  • Starknet sequencer 🐺
  • Built on Substrate 🌐
  • Rust-based for safety and performance 🏎️
  • Custom FRAME pallets for Starknet functionality 🔧
  • Comprehensive documentation 📚
  • Active development and community support 🤝

🏗️ Build & Run

Want to dive straight in? Check out our Getting Started Guide for instructions on how to build and run Madara on your local machine.

Benchmarking

Benchmarking is an essential process in our project development lifecycle, as it helps us to track the performance evolution of Madara over time. It provides us with valuable insights into how well Madara handles transaction throughput, and whether any recent changes have impacted performance.

You can follow the evolution of Madara's performance by visiting our Benchmark Page.

However, it's important to understand that the absolute numbers presented on this page should not be taken as the reference or target numbers for a production environment. The benchmarks are run on a self-hosted GitHub runner, which may not represent the most powerful machine configurations in real-world production scenarios.

Therefore, these numbers primarily serve as a tool to track the relative performance changes over time. They allow us to quickly identify and address any performance regressions, and continuously optimize the system's performance.

In other words, while the absolute throughput numbers may not be reflective of a production environment, the relative changes and trends over time are what we focus on. This way, we can ensure that Madara is always improving, and that we maintain a high standard of performance as the project evolves.

One can use flamegraph-rs to generate flamegraphs and look for the performance bottlenecks of the system by running the following :

./target/release/madara setup
flamegraph --root --open  -- ./target/release/madara --dev

In parallel to that, run some transactions against your node (you can use Gomu Gomu no Gatling benchmarker). Once you stop the node, the flamegraph will open in your browser.

🌐 Connect to the dev webapp

Once your Madara node is up and running, you can connect to our Dev Frontend App to interact with your chain. Connect here!

🤝 Contribute

We're always looking for passionate developers to join our community and contribute to Madara. Check out our contributing guide for more information on how to get started.

📖 License

This project is licensed under the MIT license.

See LICENSE for more information.

Happy coding! 🎉

Contributors ✨

Thanks goes to these wonderful people (emoji key):

</tr>
Abdel @ StarkWare
Abdel @ StarkWare

💻
Timothée Delabrouille
Timothée Delabrouille

💻
0xevolve
0xevolve

💻
Lucas @ StarkWare
Lucas @ StarkWare

💻
Davide Silva
Davide Silva

💻
Finiam
Finiam

💻
Resende
Resende

💻
drspacemn
drspacemn

💻
Tarrence van As
Tarrence van As

💻
Siyuan Han
Siyuan Han

📖
Zé Diogo
Zé Diogo

💻
Matthias Monnier
Matthias Monnier

💻
glihm
glihm

💻
Antoine
Antoine

💻
Clément Walter
Clément Walter

💻
Elias Tazartes
Elias Tazartes

💻
Jonathan LEI
Jonathan LEI

💻
greged93
greged93

💻
Santiago Galván (Dub)
Santiago Galván (Dub)

💻
ftupas
ftupas

💻
Paul-Henry Kajfasz
Paul-Henry Kajfasz

💻
chirag-bgh
chirag-bgh

💻
danilowhk
danilowhk

💻
Harsh Bajpai
Harsh Bajpai

💻
amanusk
amanusk

💻
Damián Piñones
Damián Piñones

💻
marioiordanov
marioiordanov

💻
Daniel Bejarano
Daniel Bejarano

💻
sparqet
sparqet

💻
Robin Straub
Robin Straub

💻
tedison
tedison

💻
lanaivina
lanaivina

💻
Oak
Oak

💻
Pia
Pia

💻
apoorvsadana
apoorvsadana

💻
Francesco Ceccon
Francesco Ceccon

💻
ptisserand
ptisserand

💻
Zizou
Zizou

💻
V.O.T
V.O.T

💻
Abishek Bashyal
Abishek Bashyal

💻
Ammar Arif
Ammar Arif

💻
lambda-0x
lambda-0x

💻
exp_table
exp_table

💻
Pilou
Pilou

💻
hithem
hithem

💻
Chris Lexmond
Chris Lexmond

💻
Tidus91
Tidus91

💻
Veronika S
Veronika S

💻
Asten
Asten

💻
ben2077
ben2077

💻
Michael Zaikin
Michael Zaikin

💻
João Pereira
João Pereira

📖
kasteph
kasteph

💻
Ayush Tomar
Ayush Tomar

💻
tchataigner
tchataigner

💻
Alexander Kalankhodzhaev
Alexander Kalankhodzhaev

💻
antiyro
antiyro

💻
azurwastaken
azurwastaken

💻
azurwastaken
Mrisho Lukamba

💻
Tbelleng
Tbelleng

💻
hhamud
Hamza Hamud

💻
elielnfinic
Eliel Mathe

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

madara's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

madara's Issues

feat: Deploy

Feature Request

Describe the Feature Request

Implement Deploy Transaction

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

RUSTSEC-2021-0060: `aes-soft` has been merged into the `aes` crate

aes-soft has been merged into the aes crate

Details
Status unmaintained
Package aes-soft
Version 0.6.4
URL RustCrypto/block-ciphers#200
Date 2021-04-29

Please use the aes crate going forward. The new repository location is at:

<https://github.com/RustCrypto/block-ciphers/tree/master/aes>

AES-NI is now autodetected at runtime on i686/x86-64 platforms.
If AES-NI is not present, the aes crate will fallback to a constant-time
portable software implementation.

To force the use of a constant-time portable implementation on these platforms,
even if AES-NI is available, use the new force-soft feature of the aes
crate to disable autodetection.

See advisory page for additional details.

feat: Faucet

Feature Request

Describe the Feature Request

We want to have some kind of faucet extrinsic for an address to get some ETH.

Describe Preferred Solution

This should modify the StorageView starknet's pallet storage map.

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Enable offchain worker configuration.

Description

Offchain worker needs to access Ethereum data, hence it requires the address of an Ethereum RPC node. We want this address to be configurable.
We won't be able to have access to env variables or config file values from the outer node in the runtime or in the pallet.
We probably will need to use offchain storage to deal with configuration.

Start by implementing a single config variable: eth_execution_api_rpc_url.

Resources

Implement L1 => L2 messaging

Description

Starknet allows to send messages from Ethereum to Starknet. In order to do that a transaction has to be sent on Ethereum to a specific smart contract. Once the tx is final the sequencer consumes the message on Starknet and executes the transaction.

Acceptance criteria

  • The sequencer can pick up final messages
  • The sequencer can execute those messages

feat: Declare

Feature Request

Describe the Feature Request

Implement Declare Transactions

Describe Preferred Solution

Describe Alternatives

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Handle `$STRK` as the native asset.

Description

We need to handle $STRK token as the native asset of the chain. The particularity is that this token is actually an ERC20 token and not a native asset. Hence we need to determine the impact on substrate architecture. The main immediate impact is the handling of transaction fees.
We should also investigate how to handle some pallets that could require to manipulate the $STRK token, for example staking, governance pallets.

Acceptance criteria

  • The address of the $STRK token must be configurable at the pallet level.
  • Transaction fees must be paid in $STRK tokens

Resources

Prepare Starknet block header structure

Descripion

We need to change the default block header structure used in substrate and define one compatible with Starknet.
We will create a BlockHeader types in primitives/starknet and add some unused fields for now.

The structure of Starknet block header is defined here: https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/header/

Strategies

Inherent transactions

https://docs.substrate.io/fundamentals/transaction-types/

Inherent transactions—sometimes referred to as inherents—are a special type of unsigned transaction. With this type of transaction, block authoring nodes can add information directly to a block. Inherent transactions can only be inserted into a block by the block authoring node that calls them.

Pros

  • Seems to be quite easy and without a lof of implications

Cons

  • Performance overhead ?

Wrapper block

https://corepaper.org/substrate/wrapper/
https://substrate.stackexchange.com/a/2648

Pros

  • Seems to be the easiest approach, without changes to core substrate features

Cons

  • Performance overhead, would be cool to be able to estimate the overhead

Extend substrate primitives

Pros

  • Might be the most performant approach

Cons

  • Touches core substrate features and might have a lot of implications

Projects

Moonbeam

Moonbeam is using the wrapper block strategy

Image

RUSTSEC-2021-0059: `aesni` has been merged into the `aes` crate

aesni has been merged into the aes crate

Details
Status unmaintained
Package aesni
Version 0.10.0
URL RustCrypto/block-ciphers#200
Date 2021-04-29

Please use the aes crate going forward. The new repository location is at:

<https://github.com/RustCrypto/block-ciphers/tree/master/aes>

AES-NI is now autodetected at runtime on i686/x86-64 platforms.
If AES-NI is not present, the aes crate will fallback to a constant-time
portable software implementation.

To prevent this fallback (and have absence of AES-NI result in an illegal
instruction crash instead), continue to pass the same RUSTFLAGS which were
previously required for the aesni crate to compile:

RUSTFLAGS=-Ctarget-feature=+aes,+ssse3

See advisory page for additional details.

Reduce compile time

Description

Build is currently quite slow, mainly due because of a large number of dependencies.

We should investigate if we can improve build time. Some tips from this article can be applied.

RUSTSEC-2021-0139: ansi_term is Unmaintained

ansi_term is Unmaintained

Details
Status unmaintained
Package ansi_term
Version 0.12.1
URL ogham/rust-ansi-term#72
Date 2021-08-18

The maintainer has advised that this crate is deprecated and will not receive any maintenance.

The crate does not seem to have much dependencies and may or may not be ok to use as-is.

Last release seems to have been three years ago.

Possible Alternative(s)

The below list has not been vetted in any way and may or may not contain alternatives;

Dependency Specific Migration(s)

See advisory page for additional details.

Setup testnet infrastructure.

Description

Setup a complete testnet infrastructure including:

  • configuration & deployment scripts (terraform, kubernetes)
  • comprehensive documentation and instructions on how to join the testnet

Execute deployed cairo programs instead of hardcoded

Description

Currently, hardcoded Cairo program is run when execute_cairo_assembly_program extrinsic is triggered.

We need to execute actual deployed Cairo program.

Need to think about how to pass the entrypoint (user input ?).

Run the `__validate__` entrypoint before accepting a tx in the mempool

Description

We don't want to discover that a tx doesn't pass the validation step when we're construction the block it's an unnecessary waste of time and resources so we need to verify that a tx is valid when adding it to the mempool.

Acceptance criteria

  • Invalid (__validate__ fails) transactions are not added in the mempool

RUSTSEC-2020-0168: mach is unmaintained

mach is unmaintained

Details
Status unmaintained
Package mach
Version 0.3.2
URL fitzgen/mach#63
Date 2020-07-14

Last release was almost 4 years ago.

Maintainer(s) seem to be completely unreachable.

Possible Alternative(s)

These may or may not be suitable alternatives and have not been vetted in any way;

See advisory page for additional details.

Investigate if we could use some governance features from substrate governance.

Description

Starknet is decentralizing both the network and the governance of the protocol.

We should investigate if we could use some advanced governance features (like OpenGov, Pallet democracy) from substrate to achieve this.

We need to sync with the governance committee (@Manorsw @devenmatthews @s0lness) and with @bbrandtom about the plans and what features could be useful for them and the governance of Starknet.

Resources

Implement Starknet pallet hooks

Description

Implement the required substrate pallet hooks for Starknet pallet.

The list of possible hooks are defined here.

We need to identify which ones we have to implement.

feat: Apply State Diff ✨

Feature Request

Describe the Feature Request

We should compute the state diff after invoke and deploy transactions.
The state trie should also be updated after declare and deploy transactions.

Describe Preferred Solution

  • This involves writing wrappers for some starknet-api structs.
  • Then the StorageView mapping in the starknet pallet should be adequately updated.

Related Code

https://github.com/starkware-libs/starknet-api/blob/main/src/state.rs#L21

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No

Remove patched crates when `rocksdb` is compatible with `cranelift`

A patch was summited for librocksdb-sys to enable rustc_codegen_cranelift compilation.
However the version used as a dependency on this project is older so we created a new fork of the specific version needed with the cranelift patch in this repo.
When the rocksdb version that is compatible with rustc_codegen_cranelift is being used by default we can remove the patch version from the Cargo file.

RUSTSEC-2020-0071: Potential segfault in the time crate

Potential segfault in the time crate

Details
Package time
Version 0.1.45
URL time-rs/time#293
Date 2020-11-18
Patched versions >=0.2.23
Unaffected versions =0.2.0,=0.2.1,=0.2.2,=0.2.3,=0.2.4,=0.2.5,=0.2.6

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

The affected functions from time 0.2.7 through 0.2.22 are:

  • time::UtcOffset::local_offset_at
  • time::UtcOffset::try_local_offset_at
  • time::UtcOffset::current_local_offset
  • time::UtcOffset::try_current_local_offset
  • time::OffsetDateTime::now_local
  • time::OffsetDateTime::try_now_local

The affected functions in time 0.1 (all versions) are:

  • at
  • at_utc
  • now

Non-Unix targets (including Windows and wasm) are unaffected.

Patches

Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.

Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.

Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3 series.

Workarounds

A possible workaround for crates affected through the transitive dependency in chrono, is to avoid using the default oldtime feature dependency of the chrono crate by disabling its default-features and manually specifying the required features instead.

Examples:

Cargo.toml:

chrono = { version = &quot;0.4&quot;, default-features = false, features = [&quot;serde&quot;] }
chrono = { version = &quot;0.4.22&quot;, default-features = false, features = [&quot;clock&quot;] }

Commandline:

cargo add chrono --no-default-features -F clock

Sources:

See advisory page for additional details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.