Skip to content

Commit

Permalink
v2 blob metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim committed Oct 17, 2024
1 parent 2dcd573 commit 719dfc8
Show file tree
Hide file tree
Showing 4 changed files with 1,051 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,14 @@ func (cb Bundles) FromEncodedBundles(eb EncodedBundles) (Bundles, error) {

// PaymentMetadata represents the header information for a blob
type PaymentMetadata struct {
// Existing fields
AccountID string
// AccountID is the ETH account address for the payer
AccountID string `json:"account_id"`

// New fields
BinIndex uint32
// BinIndex represents the range of time at which the dispersal is made
BinIndex uint32 `json:"bin_index"`
// TODO: we are thinking the contract can use uint128 for cumulative payment,
// but the definition on v2 uses uint64. Double check with team.
CumulativePayment uint64
CumulativePayment uint64 `json:"cumulative_payment"`
}

// Hash returns the Keccak256 hash of the PaymentMetadata
Expand Down
51 changes: 51 additions & 0 deletions disperser/common/v2/blob.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package v2

import (
"encoding/hex"

"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/encoding"
)

type BlobStatus uint

const (
Queued BlobStatus = iota
Encoded
Certified
Failed
)

type BlobVersion uint32

type BlobKey [32]byte

func (b BlobKey) Hex() string {
return hex.EncodeToString(b[:])
}

func HexToBlobKey(h string) (BlobKey, error) {
b, err := hex.DecodeString(h)
if err != nil {
return BlobKey{}, err
}
return BlobKey(b), nil
}

type BlobHeader struct {
BlobVersion BlobVersion `json:"version"`
BlobQuorumInfos []*core.BlobQuorumInfo `json:"blob_quorum_infos"`
BlobCommitment encoding.BlobCommitments `json:"commitments"`

core.PaymentMetadata `json:"payment_metadata"`
}

type BlobMetadata struct {
BlobHeader `json:"blob_header"`

BlobStatus BlobStatus `json:"blob_status"`
Expiry uint64 `json:"expiry"`
NumRetries uint `json:"num_retries"`
BlobSize uint64 `json:"blob_size"`
RequestedAt uint64 `json:"requested_at"`
}
Loading

0 comments on commit 719dfc8

Please sign in to comment.