Skip to content

Commit

Permalink
Update blob interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
gavfu committed Mar 4, 2024
1 parent f5be046 commit 6013f25
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/developers/quick-start/using-ethda-faucet.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
Every user can claim 0.1 Devnet $ETH. Join [EthDA Discord](https://discord.com/invite/Jbw2PAUSCR), go to `EthDA` -> `faucet` channel, and use your wallet address to claim $ETH from `@ethda` bot.

<div style={{textAlign: 'center'}}>
<img src={useBaseUrl('/img/developers/quick-start/using-ethda-faucet/faucet.jpg')} style={{maxWidth: 860}} />
<img src={useBaseUrl('/img/developers/quick-start/using-ethda-faucet/faucet.jpg')} style={{maxWidth: '860'}} />
</div>
114 changes: 91 additions & 23 deletions docs/developers/upload-and-download-blobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,104 @@ The ultimate goal of EthDA is to support the new type of blob-carrying transacti

## Upload Blobs

FirsBlobs and their additional information should be placed in `data` field, and encoded in hexadecimal with UTF-8 character encoding.
### Step 1: Encode data to blobs

A typical blob uploading transaction have fields like below:
Encode raw data to blobs and compute KZG commitments, KZG proofs and versioned hashes.

```json
### Step 2: Generate signature

Use [eth_signTypedData_v4](https://docs.metamask.io/wallet/reference/eth_signTypedData_v4/) to generate an [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signature for blob uploading authentication.

The parameters to be signed looks like below:

```JS
{
domain: {
// EthDA Devnet
chainId: 177,
name: "EthDA Blobs",
// A place-holder
verifyingContract: "0x0000000000000000000000000000000000000000",
version: "1",
},

message: {
// Whether EthDA need to generate DA attestations and submit to L1
daAttestationsToL1: true,
contentTypes: [..., ...],
versionedHashes: [..., ...],
kzgCommitments: [..., ...],
kzgProofs: [..., ...]
},
// This refers to the keys of the following types object.
primaryType: "Blobs",
types: {
// This refers to the domain the contract is hosted on.
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" },
],
Blobs: [
{ name: "daAttestationsToL1", type: "boolean" },
{ name: "contentTypes", type: "string[]" },
{ name: "versionedHashes", type: "string[]" },
{ name: "kzgCommitments", type: "string[]" },
{ name: "kzgProofs", type: "string[]" }
]
},
}
```

### Step 3: Upload blobs

Blobs could then be uploaded for later retrieval, with the signature generated above. For this purpose, a new RPC interface is introduced.

**ethda_uploadBlobs**, with parameters:
- `signature`: Signature generated in step above
- `blobs`: Blobs data
- `daAttestationsToL1`
- `contentTypes`
- `versionedHashes`
- `kzgCommitments`
- `kzgProofs`


:::warning
Blobs are only stored for a very short of time (like 1 hour).
:::

### Step 4: Query blob storage fee

Similar to [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844), we introduce blob gas as a new type of gas. It is independent of normal gas and follows its own targeting rule, similar to [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559). Users could use RPC interface below to query the real-time fee per blob:

**ethda_estimatePerBlobFee**

### Step 5: Send transaction

Users could now sign and send a regular transaction to EthDA for blobs storage:

**to**: Should be a place-holder address *0x0000000000000000000000000000000000000000*

**value**: The blobs storage fee. Should be *PER_BLOB_FEE* * *BLOB_COUNT*

**data**: Should be a json encoded in hexadecimal with UTF-8 character encoding

```JS
{
from,
to,
gas,
value,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
data: {
blobs,
blobContentTypes,
blobVersionedHashes,
kzgCommitments,
kzgProofs
}
daAttestationsToL1,
contentTypes,
versionedHashes,
kzgCommitments,
kzgProofs
}
```

Please note:
### Step 6: Query transaction status

After a *blob transaction* described above is submitted, users could then monitor transaction status. If transaction is successfully minted, it means specified blobs are successfully stored by EthDA's DAS network.

- `to`: Should be always set to a placeholder address `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE`
- `value`: Should always be 0
- `gas`: Including normal transaction fees and blob storage fees
- `data` -> `blobs/blobVersionedHashes/kzgCommitments/kzgProofs`: Same to [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) blob carrying transactions
- `data` -> `blobContentTypes`: Specify mime type of the Blobs. Useful for users storing application data.

## Download Blobs

Expand Down
2 changes: 1 addition & 1 deletion docs/overview/da.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
EthDA employs a decentralized DA network for Blob data storage. The DA network comprises of a set of PoS node based on Tendermint consensus, which run DAS to ensure Blob storage, and submit *DA attestations* to Ethereum L1 for L2's rollup contracts to check data availability and verify proofs. Node rewarding and slash are managed by a set of PoS contracts deployed on EthDA's sequencer network.

<div style={{textAlign: 'center'}}>
<img src={useBaseUrl('/img/overview/da/da.png')} style={{maxWidth: 800}} />
<img src={useBaseUrl('/img/overview/da/da.png')} style={{maxWidth: '800'}} />
</div>

## Workflow
Expand Down
4 changes: 2 additions & 2 deletions docs/overview/technologies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
## Architecture

<div style={{textAlign: 'center'}}>
<img src={useBaseUrl('/img/overview/technologies/architecture.png')} style={{maxWidth: 800}} />
<img src={useBaseUrl('/img/overview/technologies/architecture.png')} style={{maxWidth: '800'}} />
</div>

## ZK Rollup
Expand All @@ -21,7 +21,7 @@ EthDA itself is an Ethereum ZK rollup powered by Polygon CDK, and derives securi
EthDA is 100% compatible with Blob structure introduced by [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844). The *header* of a Blob is the the Kate commitment to the Blob, plus a bit of other miscallaneous data (slot, shard, length proof), and a signature from the proposer; the *body* of a Blob consists of the original data, the extended data, and the proofs. Below is the detailed structure of a Blob from [Vitalik's notes](https://hackmd.io/@vbuterin/sharding_proposal):

<div style={{textAlign: 'center'}}>
<img src={useBaseUrl('/img/overview/technologies/blob.png')} style={{maxWidth: 600}} />
<img src={useBaseUrl('/img/overview/technologies/blob.png')} style={{maxWidth: '600'}} />
</div>

## Yield Bearing
Expand Down
Binary file modified static/img/overview/da/da.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/overview/technologies/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6013f25

Please sign in to comment.