# DA layer solutions for Kalypso
**Why we need a DA layer solution for Kalypso?**
Storing private inputs onchain for generating zk proofs can be expensive. However, data availability (DA) layers like Celestia and Avail may offer a solution to this issue in the long run by enabling provers to store their secret inputs at a more affordable rate.
**What is the data availability problem?**
Data availability issues arise when newly proposed block transaction data cannot be downloaded and verified, leading to what's known as a data withholding attack by a block producer. This attack involves the block producer withholding transaction data of a new block. This results in nodes being unable to update to the latest state, potentially causing severe outcomes such as chain halts or fund theft.
**How are DA layers trying to solve this problem?**
DA layers like celestia are trying to solve this problem by implemetning a mechanism called Data availability sampling (DAS) which allow light nodes to verify data availability without having to download all data for a block.
For a simple explanation of DAS go through this thread by Nick White : https://twitter.com/nickwh8te/status/1559977957195751424
### Primary candidates:
1. Avail : https://availproject.github.io/
2. Celestia : https://docs.celestia.org/
## Avail
* Generating a new account on avail : https://availproject.github.io/using-avail/getting-started/managing-accounts
* Getting the testnet token : https://availproject.github.io/using-avail/getting-started/testnet-faucet
**Submitting data on avail using typescript**
```
api.tx.dataAvailability.submitData(data)
```
Output:
```
Finalized block hash 0x3b1fd797f0ae033d981b4953473b93d33fc178f1b77689f4f77ed9569cd42f15
```
**Fetching data on avail using typescript**
```
api.rpc.chain.getBlock(blockHash)
```
Output:
```
{
isSigned: true,
method: {
args: { data: 'infy8 was here' },
method: 'submitData',
section: 'dataAvailability'
},
era: { MortalEra: { period: '32', phase: '8' } },
nonce: '3',
signature: '0x72000278c810c91d43091650bc714a7cdc40aa18b199aa27b36e737bba9ce64c52c3cde21aedccc44c01fc3deeed5bd632d4d910f1d6e2d0b2e958dfdb3e7487',
signer: { Id: '5G473CfyEczfiVgW4iU74Ewh7WD4f5oEMCkUUn6QTKxM6iZV' },
tip: '0'
}
```
**For the entire ts example for submitting and fetching data :** https://github.com/availproject/avail/blob/develop/examples/ts/src/data_submit.ts
## Celestia
### Steps to save and fetch data blob on Celestia
1. Submitting and fetching data (blobs) from the data availability layer by their namespace requires us to run a celestia light node. For a tutorial on how to run a celestia light node follow this guide : https://docs.celestia.org/developers/node-tutorial/#introduction
2. Generate a new account on celestia : https://docs.celestia.org/developers/wallets/#for-developers
3. Getting the testnet token (Mocha testnet): https://docs.celestia.org/developers/node-tutorial/#keys-and-wallets
4. After generating the account setup a auth token : ```export CELESTIA_NODE_AUTH_TOKEN=$(celestia <node-type> auth admin --p2p.network <network>)```
5. Celestia partitions the block data into multiple namespaces, one for every application. This allows applications to only download their data, and not the data of other applications. Generate a namespace id using: https://go.dev/play/p/7ltvaj8lhRl
6. Submit blob using : ```celestia rpc blob Submit [namespace in hex] [data in hex]```
7. Fetching data using : ```celestia rpc blob GetAll [block height] [namespace in hex]```
**Sample output for storing data blob:**
```
{
"jsonrpc": "2.0",
"result": 300760,
"id": 1
}
```
**Sample output for fetching data blob
Fetching:**
```
{
"jsonrpc": "2.0",
"result": [
{
"namespace": "AAAAAAAAAAAAAAAAAAAAAAAAAEJpDCBNOWAP3dM=",
"data": "8fIMqAB+kQo7+LLmHaDya8oH73hxem6lQWX1",
"share_version": 0,
"commitment": "R4DRTAENQ7fGawPbt8aMse1+YReCZYg87xZIZf2fAxc="
}
],
"id": 1
}
```
**Trasnactions for zkbob private input stored on celestia :**
* private input1 : (0.0303 TIA) https://testnet.mintscan.io/celestia-testnet/txs/0B89EA9DA686CC17E39CCD83BB16E7E83DF8B0B5C5AC598AE78CA4ABF83EF2DA?height=343459
* private input2: (0.0303 TIA) https://testnet.mintscan.io/celestia-testnet/txs/A6FAF695C4C781DF81B27784153187F498AEA78FEF2D7D644734D9664686C602?height=343475
**For a in-depth RPC CLI guide :**
https://docs.celestia.org/developers/node-tutorial/#rpc-cli-guide
## Current Limitations of the DA layers
1. Both Celestia and Avail are on the testnet, and there are no confirmed dates for their mainnet launches. The testnet token faucets are only accessible through Discord.
2. Kalypso would need to implement a dual token model. This is because the prover will be required to submit the public input using Arbitrum nova and the private input using the DA layer. As a result, users will need to follow additional steps to generate wallets and acquire gas tokens.