Skip to content

Commit

Permalink
Fix PayloadVersion naming
Browse files Browse the repository at this point in the history
Signed-off-by: litt3 <[email protected]>
  • Loading branch information
litt3 committed Feb 7, 2025
1 parent 132e8de commit da63536
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions api/clients/codecs/blob_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import (
"fmt"
)

type BlobEncodingVersion byte
type PayloadEncodingVersion byte

const (
// PayloadEncodingVersion0 entails a 32 byte header = [0x00, version byte, big-endian uint32 len of payload, 0x00, 0x00,...]
// followed by the encoded data [0x00, 31 bytes of data, 0x00, 31 bytes of data,...]
// NOTE: this encoding will soon be updated, such that the result will be padded to align to 32 bytes
PayloadEncodingVersion0 BlobEncodingVersion = 0x0
PayloadEncodingVersion0 PayloadEncodingVersion = 0x0
)

type BlobCodec interface {
DecodeBlob(encodedData []byte) ([]byte, error)
EncodeBlob(rawData []byte) ([]byte, error)
}

func BlobEncodingVersionToCodec(version BlobEncodingVersion) (BlobCodec, error) {
func BlobEncodingVersionToCodec(version PayloadEncodingVersion) (BlobCodec, error) {
switch version {
case PayloadEncodingVersion0:
return DefaultBlobCodec{}, nil
Expand All @@ -34,7 +33,7 @@ func GenericDecodeBlob(data []byte) ([]byte, error) {
// version byte is stored in [1], because [0] is always 0 to ensure the codecBlobHeader is a valid bn254 element
// see https://github.com/Layr-Labs/eigenda/blob/master/api/clients/codecs/default_blob_codec.go#L21
// TODO: we should prob be working over a struct with methods such as GetBlobEncodingVersion() to prevent index errors
version := BlobEncodingVersion(data[1])
version := PayloadEncodingVersion(data[1])
codec, err := BlobEncodingVersionToCodec(version)
if err != nil {
return nil, err
Expand All @@ -50,7 +49,7 @@ func GenericDecodeBlob(data []byte) ([]byte, error) {

// CreateCodec creates a new BlobCodec based on the defined polynomial form of payloads, and the desired
// BlobEncodingVersion
func CreateCodec(payloadPolynomialForm PolynomialForm, version BlobEncodingVersion) (BlobCodec, error) {
func CreateCodec(payloadPolynomialForm PolynomialForm, version PayloadEncodingVersion) (BlobCodec, error) {
lowLevelCodec, err := BlobEncodingVersionToCodec(version)
if err != nil {
return nil, fmt.Errorf("create low level codec: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion api/clients/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type EigenDAClientConfig struct {
DisableTLS bool

// The blob encoding version to use when writing blobs from the high level interface.
PutBlobEncodingVersion codecs.BlobEncodingVersion
PutBlobEncodingVersion codecs.PayloadEncodingVersion

// Point verification mode does an IFFT on data before it is written, and does an FFT on data after it is read.
// This makes it possible to open points on the KZG commitment to prove that the field elements correspond to
Expand Down
2 changes: 1 addition & 1 deletion api/clients/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type PayloadClientConfig struct {
// The payload encoding version to use when encoding payload bytes
//
// This is the version that is put into the header of the EncodedPayload.
PayloadEncodingVersion codecs.BlobEncodingVersion
PayloadEncodingVersion codecs.PayloadEncodingVersion

// The address of the EigenDACertVerifier contract
EigenDACertVerifierAddr string
Expand Down

0 comments on commit da63536

Please sign in to comment.