EspressoSystems / nitro-espresso-integration

Nitro goes vroom and fixes everything
Other
13 stars 7 forks source link

How does TEE integration work with celestia DA? #285

Closed sveitser closed 2 weeks ago

sveitser commented 3 weeks ago

We need to work with the celestia nitro integration version v3.2.1-rc.1 and nitro-contracts celestia fork v2.1.0

The method that the celestia DA client use to read and write from celestia are implemented in another repo: https://github.com/celestiaorg/nitro-das-celestia

Store:

https://github.com/celestiaorg/nitro-das-celestia/blob/56804d494c88c39bbf91d65a241245cb9f18aa33/das/celestia.go#L221

This method

  1. calls the Submit API to send the data to celestia
  2. waits for inclusion
  3. fetches a celestia proof
  4. checks for inclusion
  5. retrieves the Blob from DA
  6. fetches the celestia header (to get the DataRoot)
  7. constructs the serializedBlobPointerData that will become the sequencerMsg in nitro

The return value of this Store method serializedBlobPointerData, is the sequencerMsg that will be sent to L1:

https://github.com/celestiaorg/nitro-das-celestia/blob/56804d494c88c39bbf91d65a241245cb9f18aa33/das/celestia.go#L374-L394

The BlobPointer is

type BlobPointer struct {
    BlockHeight  uint64   `json:"block_height"`
    Start        uint64   `json:"start"`
    SharesLength uint64   `json:"shares_length"`
    TxCommitment [32]byte `json:"tx_commitment"`
    DataRoot     [32]byte `json:"data_root"`
}

The TxCommitment is the commitment of the data Blob.

The format for serializedBlobPointerData the const CelestiaMessageHeaderFlag byte = 0x63 plus the serialized blob pointer data: celestia msg header flag | height | start | length | commitment | data root

The RPC method to Read from DA is

https://github.com/celestiaorg/nitro-das-celestia/blob/56804d494c88c39bbf91d65a241245cb9f18aa33/das/celestia.go#L397

Sneh1999 commented 2 weeks ago

Closing this because we have completed the research and are now moving towards implementation: https://github.com/EspressoSystems/nitro-espresso-integration/issues/309