diff --git a/api/clients/codecs/blob_codec.go b/api/clients/codecs/blob_codec.go index 40bab4e7f5..cc3eec841e 100644 --- a/api/clients/codecs/blob_codec.go +++ b/api/clients/codecs/blob_codec.go @@ -27,8 +27,7 @@ const ( func EncodePayload(payload []byte) []byte { payloadHeader := make([]byte, 32) // first byte is always 0 to ensure the payloadHeader is a valid bn254 element - // encode version byte - payloadHeader[1] = byte(DefaultBlobEncoding) + payloadHeader[1] = byte(DefaultBlobEncoding) // encode version byte // encode payload length as uint32 binary.BigEndian.PutUint32( @@ -36,7 +35,7 @@ func EncodePayload(payload []byte) []byte { uint32(len(payload))) // uint32 should be more than enough to store the length (approx 4gb) // encode payload modulo bn254 - // the resulting bytes are subsequently treated as the evaluation of a polynomial + // the resulting bytes subsequently may be treated as the evaluation of a polynomial polynomialEval := codec.ConvertByPaddingEmptyByte(payload) encodedPayload := append(payloadHeader, polynomialEval...) @@ -56,10 +55,9 @@ func DecodePayload(encodedPayload []byte) ([]byte, error) { payloadLength := binary.BigEndian.Uint32(encodedPayload[2:6]) // decode raw data modulo bn254 - decodedData := codec.RemoveEmptyByteFromPaddedBytes(encodedPayload[32:]) + nonPaddedData := codec.RemoveEmptyByteFromPaddedBytes(encodedPayload[32:]) - // get non blob header data - reader := bytes.NewReader(decodedData) + reader := bytes.NewReader(nonPaddedData) payload := make([]byte, payloadLength) readLength, err := reader.Read(payload) if err != nil { diff --git a/api/clients/eigenda_client.go b/api/clients/eigenda_client.go index 685d5502f7..53d75b86b7 100644 --- a/api/clients/eigenda_client.go +++ b/api/clients/eigenda_client.go @@ -28,6 +28,7 @@ import ( type IEigenDAClient interface { GetBlob(ctx context.Context, batchHeaderHash []byte, blobIndex uint32) ([]byte, error) PutBlob(ctx context.Context, txData []byte) (*grpcdisperser.BlobInfo, error) + GetPolynomialForm() codecs.PolynomialForm Close() error } @@ -131,6 +132,14 @@ func NewEigenDAClient(log log.Logger, config EigenDAClientConfig) (*EigenDAClien }, nil } +// GetPolynomialForm returns the form of polynomials, as they are distributed in the system +// +// The polynomial form indicates how blobs must be constructed before dispersal, and how received blobs ought to be +// interpreted. +func (m *EigenDAClient) GetPolynomialForm() codecs.PolynomialForm { + return m.PolynomialForm +} + // GetBlob retrieves a blob from the EigenDA service using the provided context, // batch header hash, and blob index. If decode is set to true, the function // decodes the retrieved blob data. If set to false it returns the encoded blob