Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Genesis3800 authored Dec 19, 2023
2 parents 575c963 + 9c5619c commit bcfbf4d
Show file tree
Hide file tree
Showing 20 changed files with 289 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Below is a curated list of GitHub repositories that are actively tracking the va
| | [Substrate](https://github.com/availproject/substrate) | Fork of Substrate for Avail. |
| **Explorations** | [Avail Explorations](https://github.com/availproject/avail-explorations) | Experimental features and research. |
| | [Avail Sovereign DA Adapter](https://github.com/availproject/avail-sovereign-da-adapter) | Data availability adapter for Sovereign Rollups. |
| **Tooling** | [Availup](https://github.com/availproject/availup) | CLI tool for Avail. |
| **Tooling** | [CLI](https://github.com/availproject/cli) | CLI tool for Avail. |
| | [Avail JS](https://github.com/availproject/avail-js) | JavaScript library for Avail; Fork of PolkadotJS |
| **Contracts and Proofs** | [Op EVM Contracts](https://github.com/availproject/op-evm-contracts) | EVM contracts for Avail. |
| | [Poly Multiproof](https://github.com/availproject/poly-multiproof) | Multiproof contracts for Avail. |
Expand Down
6 changes: 2 additions & 4 deletions docs/about/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ Avail JS aims to offer functionalities similar to those found in the [<ins>Polka

Before creating an account, it's essential to understand [<ins>seed phrases</ins>](https://en.wikipedia.org/wiki/Cryptocurrency_wallet). During the account creation process, you'll receive a seed phrase—a series of words that can be used to recover your account.

:::warning Seed Phrase Security
> Seed Phrase Security
NEVER share your seed phrase with anyone and keep it in a secure and offline location. Anyone with access to your seed phrase can gain control of your account.
:::

## Creating an Account on the Goldberg Testnet

Expand Down Expand Up @@ -71,9 +70,8 @@ Upon completion, a JSON file containing your account information will be downloa

The JSON file serves as a backup for your account and contains all the necessary information to recover it. It is encrypted with a password that you set during the account creation process.

:::caution Backup and Recovery
> Backup and Recovery
Always keep your JSON file in a secure and offline location. Losing this file and your password could result in the loss of your assets.
:::

## Next Steps

Expand Down
6 changes: 1 addition & 5 deletions docs/about/faucet.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ testnet.
Your address will be deposited 5 AVL token once the status changes to
`Complete`. You may request AVL every 3 hours.

:::note

The verification step is required, and you can only use the command
> The verification step is required, and you can only use the command
once every few minutes. The faucet is not meant for obtaining large
amounts of AVL (e.g. for validator bonding).

:::
14 changes: 8 additions & 6 deletions docs/about/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ ZK Rollups require upfront cryptographic proofs of transaction validity, focusin
3. **Assumption of Validity**: Proof of validity is demanded upfront, unlike Optimistic Rollups.
4. **Data Availability**: While validity proofs are independent of data availability, the chain's security heavily depends on it.
5. **Implications of Data Unavailability**:
- **State Recreation**: Users can recreate the state using main chain data.
- **Sequencer Intervention**: Other sequencers can step in to restore state and continue operations.
- **State Recreation**: Users can not recreate the state if data is not available.
- **Sequencer Intervention**: Other sequencers can step in to restore the state and continue operations.

Still, there are constraints with data availability.

Expand Down Expand Up @@ -238,16 +238,18 @@ The journey culminates with light clients performing proof verification. This pr

With your foundational understanding of Avail, if you're new to the ecosystem, be sure to visit the [<ins>Getting Started</ins>](/category/get-started/) section.

Additionally, consider experimenting with a light client. For this, the [<ins>Quickstart guide</ins>](/build/quickstart/) is great resource. To run an Avail light client, all you need to do is run one of the following commands:
Additionally, consider experimenting with a light client. For this, the [<ins>Quickstart guide</ins>](/build/quickstart/) is great resource. To run an Avail light client, all you need to do is install and use the Avail CLI.

To install the CLI from `npm`, run the following command:

```bash
curl -sL1 avail.sh | sh
npm i -g @availproject/cli
```

or, with wget:
Then run:

```bash
wget --https-only --secure-protocol=TLSv1_2 --quiet -O - avail.sh | sh
avail lc up
```

That's it!
Expand Down
12 changes: 3 additions & 9 deletions docs/about/introduction/light-clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ Light client functionality is separated into two logical parts - the _light clie
The **light client** mode of operation is active regardless of whether the app client is also active or not.
Light client connects to an Avail node via a WebSocket connection and waits for a newly finalized block, with the header containing its KZG commitments.

:::info
Avail blocks are chunked and divided into equal sized cells as a part of that blocks matrix. Each row in the matrix is then erasure coded using **Reed-Solomon (RS)** erasure codes and committed with **Kate-Zaverucha-Goldberg (KZG)** commitments.
:::
> Avail blocks are chunked and divided into equal sized cells as a part of that blocks matrix. Each row in the matrix is then erasure coded using **Reed-Solomon (RS)** erasure codes and committed with **Kate-Zaverucha-Goldberg (KZG)** commitments.
On each received header the client does random sampling of the matrix cells, which are retrieved using one of two mechanisms:

Expand All @@ -38,13 +36,9 @@ On each received header the client does random sampling of the matrix cells, whi

Once the data is received, light client verifies individual cells and calculates the confidence that is then stored locally.

:::note
Light client uses _libp2p_ with **Kademlia** as a DHT implementation. Peer-to-peer network is able to perform NAT traversal, both symmetric and asymmetric, enabling easy connectivity with various network configurations (e.g. symmetric and asymmetric NAT).
:::
> Light client uses _libp2p_ with **Kademlia** as a DHT implementation. Peer-to-peer network is able to perform NAT traversal, both symmetric and asymmetric, enabling easy connectivity with various network configurations (e.g. symmetric and asymmetric NAT).
:::note
On fresh startup, the LC performs a block sync with the node, using both DHT and RPC mechanisms. The block depth to which the sync is going to be done is set with the `sync_block_depth` config parameter, which needs to be set to the max number of blocks the connected node is caching (if downloading via RPC).
:::
> On fresh startup, the LC performs a block sync with the node, using both DHT and RPC mechanisms. The block depth to which the sync is going to be done is set with the `sync_block_depth` config parameter, which needs to be set to the max number of blocks the connected node is caching (if downloading via RPC).
## When and how to embed the light client

Expand Down
169 changes: 169 additions & 0 deletions docs/build/madara/madara.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
id: madara
title: How to Use Madara with Avail
sidebar_label: Avail-Powered Madara Validium
description: 'Discover how to utilize Avail as a data availability layer to build a Substrate-based Validium with Madara.'
keywords:
- documentation
- avail
- develop
- build
- data availability
- da
image: https://docs.availproject.org/img/avail/AvailDocs.png
---

## Introduction

Embark on setting up your own Madara-based Validium, leveraging Avail as the data availability layer. This guide is tailored for deploying on Ethereum's Sepolia testnet and integrating with the Avail Goldberg testnet. To gain a comprehensive understanding of Madara Starknet, review the [<ins>Madara documentation</ins>](https://docs.madara.zone/).

In this guide, you will conduct the following:

- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Hardware Requirements](#hardware-requirements)
- [Launch an Avail-Powered Madara Validium](#launch-an-avail-powered-madara-validium)
- [Running a Single-Node Development Chain](#running-a-single-node-development-chain)
- [Setting Up Avail as the DA Layer](#setting-up-avail-as-the-da-layer)
- [Deploying an Account on Your Chain](#deploying-an-account-on-your-chain)
- [Using Avail in Madara](#using-avail-in-madara)

## Prerequisites

Ensure you have installed the following software.

> Installation commands are based on Ubuntu 20.04 LTS:
<table>
<tr>
<td valign="top">

| Software | Version |
| ------------------------------------------------------------ | ------------------------------- |
| [**Rust**](https://www.rust-lang.org/) | `rustc 1.69.0-nightly` or later |
| [**nvm/Node.js**](https://github.com/nvm-sh/nvm) | Latest version |
| [**Cairo**](https://www.cairo-lang.org/docs/quickstart.html) | 1.0 |

</td>
<td valign="top">

```bash
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup toolchain install nightly

# Install nvm and Node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install --lts

# Install Cairo
curl -L https://github.com/franalgaba/cairo-installer/raw/main/bin/cairo-installer | bash
```

</td>
</tr>
</table>

### Hardware Requirements

The Madara stack, being a StarkNet sequencer, has specific hardware requirements for efficient operation. These requirements are particularly important when integrating Avail as the DA Layer.

| Component | Minimum Requirements | Recommended Setup | Suggested AWS Instance |
| -------------- | -------------------------------- | -------------------------------- | ---------------------- |
| Sequencer Node | 4-core CPU, 16GB RAM, 100 GB SSD | 8-core CPU, 32GB RAM, 200 GB SSD | m5a.xlarge |
| Avail Node | 4-core CPU, 8GB RAM, 50 GB SSD | 8-core CPU, 16GB RAM, 100 GB SSD | m5a.large |

:::note
The storage requirements can vary based on the volume of transactions and the length of the chain history you intend to maintain. For high-traffic networks, consider scaling your storage capacity accordingly.
:::

## Launch an Avail-Powered Madara Validium

1. Clone the Madara repository:

```bash
git clone [email protected]:keep-starknet-strange/madara.git
cd madara
```

2. Build the chain in release mode:

```bash
cargo build --release
```

### Running a Single-Node Development Chain

1. Start the development chain:

```bash
./target/release/madara --dev
```

2. Purge the chain's state:

```bash
./target/release/madara purge-chain --dev
```

3. Start with detailed logging:

```bash
RUST_BACKTRACE=1 ./target/release/madara -ldebug --dev
```

4. Create a plain chain spec:

```bash
./target/release/madara build-spec > ./infra/chain-sepcs/chain-spec-plain.json
```

### Setting Up Avail as the DA Layer

1. Configure Avail for Madara:

```bash
# Configuration for local Avail node
cat > da-config.json <<EOF
{
"ws_provider": "ws://127.0.0.1:9945",
"app_id": 0,
"validate_codegen": false,
"seed": "//Alice"
}
EOF
```
2. Start Avail Node (in another terminal):
```bash
./data-avail --dev --rpc-port 9945 --port 30334
```
3. Setup Madara for Avail:
```bash
./madara setup --chain=dev --from-remote --base-path=../.madara
```
4. Launch Madara with Avail:
```bash
./madara --chain=dev --base-path=../.madara --da-layer=avail --force-authoring --alice
```
### Deploying an Account on Your Chain
- After setting up your chain, you can deploy your own account and start making transactions.
### Using Avail in Madara
- Specify `--da-layer avail` when launching a Madara node to use Avail for publishing the state_diff.
:::tip
Remember to adjust the `da-config.json` file based on your setup, whether it's a local node or using the Avail network.
:::
<!-- Add test transactions -->
52 changes: 52 additions & 0 deletions docs/build/madara/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
id: overview
title: Building on the Madara Stack with Avail
sidebar_label: Overview
description: 'Discover how to utilize Avail as a data availability layer.'
keywords:
- documentation
- avail
- develop
- build
- data availability
- da
image: https://docs.availproject.org/img/avail/AvailDocs.png
---

The Madara stack, when integrated with Avail in a Validium setup, provides a seamless platform for scaling blockchain applications. This integration combines the customizability and Starknet compatibility of Madara with the robust data availability solutions of Avail.

### Transaction Lifecycle

1. **Transaction Submission**

- **Process**: Users initiate transactions which are sent to the Madara-based Validium Sequencer.
- **Role**: The Sequencer, leveraging the flexibility of Madara, temporarily holds these transactions.

2. **Batch Processing**

- **Component**: Customized within Madara's framework.
- **Function**: Transactions are batched for efficient processing, leveraging Madara's modular design.

3. **Data Availability with Avail**

- **Component**: Custom integration within Madara's setup.
- **Function**: Batches are published to Avail for data availability, ensuring transparency and accessibility.

4. **State Transition and Proof Generation**

- **Component**: Utilizes Madara's Starknet compatibility.
- **Function**: State transitions are processed, and cryptographic proofs are generated within the Madara environment.

5. **Commitment and Verification**
- **Action**: Commitments, along with proofs, are anchored to a primary blockchain (e.g., Ethereum), ensuring security and finality.

### Key Features

- **Customizability**: Madara's Substrate-based framework allows for extensive customization to meet specific blockchain requirements.
- **Starknet Compatibility**: Madara's compatibility with Starknet opens a wide array of tools and features for developers.
- **Robust Data Availability**: Avail provides a decentralized solution for data availability, crucial for scalability and security in blockchain applications.
- **Flexibility and Interoperability**: The combination of Madara and Avail supports a wide range of blockchain architectures and use cases.

### Developer Resources

To leverage Madara with Avail, developers are encouraged to refer to the [<ins>tutorial</ins>](/build/madara/madara.md) on creating an Avail-powered validium with Avail. For in-depth information on Madara's features, tools, and configurations, visit [<ins>Madara Documentation</ins>](https://docs.madara.zone/).
15 changes: 8 additions & 7 deletions docs/build/op-stack/op-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,14 @@ After building the repositories, configure your chain settings in the [<ins>cont

Deploy essential L1 contracts for the chain’s functionality:

1. Create `avail-optimism` directory:
1. Navigate to `/avail-op-stack-adapter/packages/contracts-bedrock/deployments`, and create `avail-optimism` directory:

```bash
mkdir deployments/avail-optimism
cd ~/avail-op-stack-adapter/packages/contracts-bedrock/deployments
mkdir avail-optimism
```

2. Deploy contracts (can take up to 15 minutes):
2. Navigate to `/avail-op-stack-adapter/packages/contracts-bedrock/` and the deploy contracts (this can take up to 15 minutes):
```bash
forge script scripts/Deploy.s.sol:Deploy --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL
forge script scripts/Deploy.s.sol:Deploy --sig 'sync()' --private-key $PRIVATE_KEY --broadcast --rpc-url $ETH_RPC_URL
Expand Down Expand Up @@ -429,7 +430,7 @@ In cases of database corruption indicated by `op-node` errors or failure to find
To launch `op-node`, which acts as a consensus client, run:

```bash
cd ~/optimism/op-node
cd ~/avail-op-stack-adapter/op-node
./bin/op-node \
--l2=http://localhost:9551 \
--l2.jwt-secret=./jwt.txt \
Expand Down Expand Up @@ -460,7 +461,7 @@ To optimize synchronization and avoid network resource waste:
`op-batcher` is crucial in publishing transactions from the Sequencer to L1. Ensure it has at least 1 Goerli ETH for operational continuity.

```bash
cd ~/optimism/op-batcher
cd ~/avail-op-stack-adapter/op-batcher
./bin/op-batcher \
--l2-eth-rpc=http://localhost:9545 \
--rollup-rpc=http://localhost:9547 \
Expand All @@ -486,7 +487,7 @@ Adjust the `--max-channel-duration=n` setting to balance transaction frequency o
Finally, start `op-proposer` to propose new state roots:

```bash
cd ~/optimism/op-proposer
cd ~/avail-op-stack-adapter/op-proposer
./bin/op-proposer \
--poll-interval=12s \
--rpc.port=9560 \
Expand All @@ -503,7 +504,7 @@ To obtain ETH on your Rollup:
1. Go to `contracts-bedrock`:

```bash
cd ~/optimism/packages/contracts-bedrock
cd ~/avail-op-stack-adapter/packages/contracts-bedrock
```

2. Find the L1 standard bridge contract address:
Expand Down
Loading

0 comments on commit bcfbf4d

Please sign in to comment.