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

Commit 3f36345

Browse files
authored
doc: improve docs (#1269)
1 parent a4f2b54 commit 3f36345

File tree

3 files changed

+101
-128
lines changed

3 files changed

+101
-128
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Next release
44

5+
- chore: update README.md and getting-started.md
56
- chore: remove crates that have been copy-pasted from plkdtSDK
67
- feat(rpc): return deployed contract address and actual fee in transaction
78
receipt

README.md

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,61 +35,86 @@
3535
</a>
3636
</div>
3737

38-
# ⚡ Madara: Starknet Sequencer 👉👈
38+
# ⚡ Madara App Chain Stack
3939

40-
Welcome to **Madara**, a blazing fast ⚡ [Starknet](https://www.starknet.io/)
41-
sequencer designed to make your projects soar!
40+
Welcome to **Madara**, the modular stack to build chains using
41+
[Cairo](https://book.cairo-lang.org/title-page.html) and the
42+
[Starknet](https://www.starknet.io/) technology. Apps like dYdX V3, Immutable
43+
and Sorare have been using StarkEx for scaling for a while and now with Madara,
44+
it's open source for everyone to use.
4245

43-
Built on the robust Substrate framework and fast, thanks to Rust 🦀, Madara
44-
delivers unmatched performance and scalability to power your Starknet-based
45-
Validity Rollup chain.
46+
Madara is built on the [Substrate](https://substrate.io/) framework which not
47+
only makes it modular but also gives it access to years of dev tooling,
48+
libraries and a strong developer community. It is specifically helpful if you
49+
want to own more of the stack and get more control over your chain.
4650

47-
Dive into the world of Madara and join our passionate community of contributors!
48-
Together, we're pushing the boundaries of what's possible within the Starknet
49-
ecosystem.
51+
## 📚 Documentation
5052

51-
🚀 Discover the unparalleled flexibility and might of Madara, your gateway to
52-
launching your very own Starknet appchain or L3. Harness the prowess of Cairo,
53-
while maintaining complete control over your custom appchain, tailored to your
54-
specific requirements. Madara is designed to empower a multitude of projects,
55-
fueling growth within the Starknet ecosystem.
53+
Get started with our comprehensive documentation, which covers everything from
54+
project structure and architecture to benchmarking and running Madara:
55+
56+
- [Getting Started Guide](./docs/getting-started.md)
57+
- [Architecture Overview](./docs/architecture.md)
58+
- [Chain Genesis Information](./docs/genesis.md)
59+
- [Project Structure](./docs/project-structure.md)
60+
- [Run benchmark yourself](./benchmarking/README.md)
61+
62+
## 📣 Building App Chains
63+
64+
For many use cases, you do not need to fork this repo to build your app chain.
65+
By adding changes using forking, you will have to periodically rebase (and solve
66+
conflicts) to remain updated with the latest version of Madara. Madara by
67+
default provides
68+
69+
- `pallet_starknet`: Adds the CairoVM to Substrate which allows you to deploy
70+
and execute Cairo contracts.
71+
- `Starknet RPC`: Adds all the Starknet RPC calls to your chain so that it's
72+
compatible with all RPC tools like starknet-js, wallets, etc.
73+
- `DA Interface`: A general interface which allows you to use any DA layer like
74+
`Avail`, `Celestia`, `Ethereum` etc.
75+
- `Proving`: Running the Starknet OS which is the runtime logic in Cairo so that
76+
it can be proven on the L1.
77+
78+
So for many use cases where you want to change common things like
79+
80+
- Configuration
81+
[parameters](https://github.com/keep-starknet-strange/madara/blob/d90cb1a3ce5389f5f530ee5eaf3c3d4c96561b12/crates/runtime/src/pallets.rs#L33)
82+
for example block time, maximum steps etc.
83+
- DA layer
84+
- Genesis state
85+
- Add new off chain workers
86+
- Add new pallets
87+
88+
you don't need to fork the Madara repo. Instead, you can import the relevant
89+
code as crates/pallets. We have created an
90+
[app-chain-template](https://github.com/keep-starknet-strange/madara-app-chain-template)
91+
which imports Madara as a library to show an example and would recommend you
92+
start from here. For other more detailed use cases like
93+
94+
- Adding a new syscall to the cairo VM
95+
- Changing the runtime logic to deviate from Starknet's logic
96+
97+
You should consider forking parts of Madara.
5698

5799
## 📣 Peripheral repositories
58100

59-
- [Madara Explorer](https://github.com/lambdaclass/madara_explorer) by the great
60-
[LambdaClass](https://lambdaclass.com/) team 🫶: A block explorer for Madara.
101+
- [Madara Docsite](https://github.com/keep-starknet-strange/madara-docs): The
102+
source code of the Madara documentation website. Deployed on
103+
`https://docs.madara.zone`.
104+
- [Stark Compass Explorer](https://github.com/lambdaclass/madara_explorer) by
105+
the [LambdaClass](https://lambdaclass.com/) team : An open source block
106+
explorer for Starknet based chains.
61107
- [Madara Infra](https://github.com/keep-starknet-strange/madara-infra): A
62108
collection of scripts and tools to deploy and manage Madara on different
63109
environments (e.g. AWS, docker, ansible, etc.). It also contains the
64110
[Starknet Stack](https://github.com/keep-starknet-strange/madara-infra/blob/main/starknet-stack/docker-compose.yml)
65111
demo `docker-compose` file.
66-
- [Madara Kit Application](https://github.com/keep-starknet-strange/madara-app):
67-
A simple application that demonstrates how to use Madara. Deployed on
68-
`https://app.madara.zone`.
69-
- [Madara Docsite](https://github.com/keep-starknet-strange/madara-docs): The
70-
source code of the Madara documentation website. Deployed on
71-
`https://docs.madara.zone`.
72112
- [Madara Tsukuyomi](https://github.com/keep-starknet-strange/madara-tsukuyomi):
73113
The source code of the Madara Desktop App. A friendly GUI to start a Madara
74114
node and interact with it.
75115
- [App Chain Template](<(https://github.com/keep-starknet-strange/madara-app-chain-template)>):
76116
A ready to use template that allows you to easily start an app chain.
77117

78-
## 📣 Building App Chains
79-
80-
> Do NOT fork this repo and build your app chain on top unless completely
81-
> necessary. By adding changes using forking, you will have to periodically
82-
> rebase (and solve conflicts) to remain updated with the latest version of
83-
> Madara.
84-
85-
One of the main features of Madara is to allow users to start their app chains
86-
that support Cairo contracts and Starknet like blocks. Hence, to make it easy
87-
for users to build a custom app chain, we have created an
88-
[app-chain-template](https://github.com/keep-starknet-strange/madara-app-chain-template)
89-
which imports Madara as a pallet. This removes all the boilerplate code and
90-
allows you to focus on code only relevant to your app chain. Moreover, updating
91-
Madara is as simple as updating the pallet version.
92-
93118
## 🌟 Features
94119

95120
- Starknet sequencer 🐺
@@ -99,17 +124,6 @@ Madara is as simple as updating the pallet version.
99124
- Comprehensive documentation 📚
100125
- Active development and community support 🤝
101126

102-
## 📚 Documentation
103-
104-
Get started with our comprehensive documentation, which covers everything from
105-
project structure and architecture to benchmarking and running Madara:
106-
107-
- [Architecture Overview](./docs/architecture.md)
108-
- [Chain Genesis Information](./docs/genesis.md)
109-
- [Project Structure](./docs/project-structure.md)
110-
- [Getting Started Guide](./docs/getting-started.md)
111-
- [Run benchmark yourself](./benchmarking/README.md)
112-
113127
## 🏗️ Build & Run
114128

115129
Want to dive straight in? Check out our

docs/getting-started.md

Lines changed: 38 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,64 @@ then run:
1111
rustup show
1212
```
1313

14-
### Cargo Run
14+
### Single-Node Development Chain
1515

1616
Use Rust's native `cargo` command to build and launch the template node:
1717

18+
You first need to setup up the node, which means you need to load the genesis
19+
state into your file system.
20+
1821
```sh
1922
cargo run --release -- setup --chain=dev --from-remote
20-
cargo run --release -- --dev
2123
```
2224

23-
The node also supports to use manual seal (to produce block manually through
24-
RPC). This is also used by the typescript tests:
25+
Now, you can start the node in development mode
2526

2627
```sh
27-
$ cargo run --release -- --dev --sealing=manual
28-
# Or
29-
$ cargo run --release -- --dev --sealing=instant
28+
cargo run --release -- --dev
3029
```
3130

32-
Log level can be specified with `-l` flag. For example, `-ldebug` will show
33-
debug logs. It can also be specified via the `RUST_LOG` environment variable.
34-
For example:
31+
### Interacting with the node
3532

36-
```sh
37-
RUSTLOG=runtime=info cargo run --release -- --dev
38-
```
33+
Madara is compatible with the Starknet
34+
[spec](https://github.com/starkware-libs/starknet-specs) which means all tooling
35+
around Starknet (starknet-js, starknet-rs, wallets, etc.) can be used out of the
36+
box by just changing the RPC url to point to your node. By default, this would
37+
be `http://localhost:9944`.
38+
39+
### Common chain flags
40+
41+
You can check all the available using the `--help` flag. Some common points to
42+
know about have been mentioned below.
43+
44+
Madara overrides the default `dev` flag in substrate to meet its requirements.
45+
The following flags are automatically enabled with the `--dev` argument:
46+
47+
`--chain=dev`, `--force-authoring`, `--alice`, `--tmp`, `--rpc-external`,
48+
`--rpc-methods=unsafe`
3949

40-
### Cargo Build
50+
The `--tmp` flag stores the chain database in a temporary folder. You can
51+
specify a custom folder to store the chain state by using the `--base-path`
52+
flag. You cannot combine the `base-path` command with `--dev` as `--dev`
53+
enforces `--tmp` which will store the db at a temporary folder. You can,
54+
however, manually specify all flags that the dev flag adds automatically. Keep
55+
in mind, the path must be the same as the one you used in the setup command.
4156

42-
The `cargo run` command will perform an initial build. Use the following command
43-
to build the node without launching it:
57+
The node also supports to use manual seal (to produce block manually through
58+
RPC).
4459

4560
```sh
46-
cargo build --release
61+
cargo run --release -- --dev --sealing=manual
62+
# Or
63+
cargo run --release -- --dev --sealing=instant
4764
```
4865

49-
You can optionally specify the compiler version for the build:
66+
Log level can be specified with `-l` flag. For example, `-ldebug` will show
67+
debug logs. It can also be specified via the `RUST_LOG` environment variable.
68+
For example:
5069

5170
```sh
52-
COMPILER_VERSION=0.12.0 cargo build --release
71+
RUSTLOG=runtime=info cargo run --release -- --dev
5372
```
5473

5574
### Using Nix (optional, only for degens)
@@ -69,67 +88,6 @@ all parameters and subcommands:
6988
./target/release/madara -h
7089
```
7190

72-
## Run
73-
74-
The provided `cargo run` command will launch a temporary node and its state will
75-
be discarded after you terminate the process. After the project has been built,
76-
there are other ways to launch the node.
77-
78-
### Single-Node Development Chain
79-
80-
This command will start the single-node development chain with non-persistent
81-
state:
82-
83-
```bash
84-
./target/release/madara setup --chain=dev --from-remote
85-
./target/release/madara --dev
86-
```
87-
88-
Purge the development chain's state:
89-
90-
```bash
91-
./target/release/madara purge-chain --dev
92-
```
93-
94-
Start the development chain with detailed logging:
95-
96-
```bash
97-
RUST_BACKTRACE=1 ./target/release/madara -ldebug --dev
98-
```
99-
100-
> Development chain means that the state of our chain will be in a tmp folder
101-
> while the nodes are running. Also, **alice** account will be authority and
102-
> sudo account as declared in the
103-
> [genesis state](https://github.com/substrate-developer-hub/substrate-madara/blob/main/node/src/chain_spec.rs#L49).
104-
> At the same time the following accounts will be pre-funded:
105-
>
106-
> - Alice
107-
> - Bob
108-
> - Alice//stash
109-
> - Bob//stash
110-
111-
In case of being interested in maintaining the chain' state between runs a base
112-
path must be added so the db can be stored in the provided folder instead of a
113-
temporal one. We could use this folder to store different chain databases, as a
114-
different folder will be created per different chain that is ran. The following
115-
commands shows how to use a newly created folder as our db base path.
116-
117-
```bash
118-
// Create a folder to use as the db base path
119-
$ mkdir my-chain-state
120-
121-
// Use of that folder to store the chain state
122-
$ ./target/release/madara --dev --base-path ./my-chain-state/
123-
124-
// Check the folder structure created inside the base path after running the chain
125-
$ ls ./my-chain-state
126-
chains
127-
$ ls ./my-chain-state/chains/
128-
dev
129-
$ ls ./my-chain-state/chains/dev
130-
db keystore network
131-
```
132-
13391
### Connect with Polkadot-JS Apps Front-end
13492

13593
Once the node template is running locally, you can connect it with **Polkadot-JS

0 commit comments

Comments
 (0)