diff --git a/api/clients/cert.go b/api/clients/cert.go deleted file mode 100644 index 7c69b08168..0000000000 --- a/api/clients/cert.go +++ /dev/null @@ -1,13 +0,0 @@ -package clients - -import "github.com/Layr-Labs/eigenda/api/grpc/common" - -type Cert struct { - BatchHeaderHash []byte - BlobIndex uint32 - ReferenceBlockNumber uint32 - QuorumIDs []uint32 - - // Used for kzg verification when reading blob data from DA - BlobCommitment *common.G1Commitment -} diff --git a/api/clients/cert_test.go b/api/clients/cert_test.go deleted file mode 100644 index 4675a9c718..0000000000 --- a/api/clients/cert_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package clients - -import ( - "testing" - - "github.com/Layr-Labs/eigenda/api/grpc/common" - "github.com/ethereum/go-ethereum/rlp" - "github.com/stretchr/testify/assert" -) - -func TestCertEncodingDecoding(t *testing.T) { - c := Cert{ - BatchHeaderHash: []byte{0x42, 0x69}, - BlobIndex: 420, - ReferenceBlockNumber: 80085, - QuorumIDs: []uint32{666}, - BlobCommitment: &common.G1Commitment{ - X: []byte{0x1}, - Y: []byte{0x3}, - }, - } - - bytes, err := rlp.EncodeToBytes(c) - assert.NoError(t, err, "encoding should pass") - - var c2 *Cert - err = rlp.DecodeBytes(bytes, &c2) - assert.NoError(t, err, "decoding should pass") - - assert.Equal(t, c.BatchHeaderHash, c2.BatchHeaderHash) - assert.Equal(t, c.BlobIndex, c2.BlobIndex) - assert.Equal(t, c.ReferenceBlockNumber, c2.ReferenceBlockNumber) - assert.Equal(t, c.QuorumIDs, c2.QuorumIDs) - assert.Equal(t, c.BlobCommitment.X, c2.BlobCommitment.X) - assert.Equal(t, c.BlobCommitment.Y, c2.BlobCommitment.Y) -} diff --git a/api/clients/eigenda_client.go b/api/clients/eigenda_client.go index 7a66e3ea7b..8fb6f03cd6 100644 --- a/api/clients/eigenda_client.go +++ b/api/clients/eigenda_client.go @@ -16,7 +16,7 @@ import ( type IEigenDAClient interface { GetBlob(ctx context.Context, BatchHeaderHash []byte, BlobIndex uint32) ([]byte, error) - PutBlob(ctx context.Context, txData []byte) (*Cert, error) + PutBlob(ctx context.Context, txData []byte) (*grpcdisperser.BlobInfo, error) } type EigenDAClient struct { @@ -80,7 +80,7 @@ func (m EigenDAClient) GetBlob(ctx context.Context, BatchHeaderHash []byte, Blob return rawData, nil } -func (m EigenDAClient) PutBlob(ctx context.Context, data []byte) (*Cert, error) { +func (m EigenDAClient) PutBlob(ctx context.Context, data []byte) (*grpcdisperser.BlobInfo, error) { resultChan, errorChan := m.PutBlobAsync(ctx, data) select { // no timeout here because we depend on the configured timeout in PutBlobAsync case result := <-resultChan: @@ -90,14 +90,14 @@ func (m EigenDAClient) PutBlob(ctx context.Context, data []byte) (*Cert, error) } } -func (m EigenDAClient) PutBlobAsync(ctx context.Context, data []byte) (resultChan chan *Cert, errChan chan error) { - resultChan = make(chan *Cert, 1) +func (m EigenDAClient) PutBlobAsync(ctx context.Context, data []byte) (resultChan chan *grpcdisperser.BlobInfo, errChan chan error) { + resultChan = make(chan *grpcdisperser.BlobInfo, 1) errChan = make(chan error, 1) go m.putBlob(ctx, data, resultChan, errChan) return } -func (m EigenDAClient) putBlob(ctx context.Context, rawData []byte, resultChan chan *Cert, errChan chan error) { +func (m EigenDAClient) putBlob(ctx context.Context, rawData []byte, resultChan chan *grpcdisperser.BlobInfo, errChan chan error) { m.Log.Info("Attempting to disperse blob to EigenDA") // encode blob @@ -164,19 +164,7 @@ func (m EigenDAClient) putBlob(ctx context.Context, rawData []byte, resultChan c case grpcdisperser.BlobStatus_FINALIZED: batchHeaderHashHex := fmt.Sprintf("0x%s", hex.EncodeToString(statusRes.Info.BlobVerificationProof.BatchMetadata.BatchHeaderHash)) m.Log.Info("Successfully dispersed blob to EigenDA", "requestID", base64RequestID, "batchHeaderHash", batchHeaderHashHex) - blobInfo := statusRes.Info - quorumIDs := make([]uint32, len(blobInfo.BlobHeader.BlobQuorumParams)) - for i := range quorumIDs { - quorumIDs[i] = blobInfo.BlobHeader.BlobQuorumParams[i].QuorumNumber - } - cert := &Cert{ - BatchHeaderHash: blobInfo.BlobVerificationProof.BatchMetadata.BatchHeaderHash, - BlobIndex: blobInfo.BlobVerificationProof.BlobIndex, - ReferenceBlockNumber: blobInfo.BlobVerificationProof.BatchMetadata.BatchHeader.ReferenceBlockNumber, - QuorumIDs: quorumIDs, - BlobCommitment: blobInfo.BlobHeader.Commitment, - } - resultChan <- cert + resultChan <- statusRes.Info return default: errChan <- fmt.Errorf("EigenDA blob dispersal failed in processing with reply status %d", statusRes.Status) diff --git a/api/clients/eigenda_client_test.go b/api/clients/eigenda_client_test.go index 4779be0add..865083f9ff 100644 --- a/api/clients/eigenda_client_test.go +++ b/api/clients/eigenda_client_test.go @@ -71,16 +71,10 @@ func TestPutRetrieveBlobSuccess(t *testing.T) { PutCodec: clients.DefaultBlobEncodingCodec{}, } expectedBlob := []byte("dc49e7df326cfb2e7da5cf68f263e1898443ec2e862350606e7dfbda55ad10b5d61ed1d54baf6ae7a86279c1b4fa9c49a7de721dacb211264c1f5df31bade51c") - cert, err := eigendaClient.PutBlob(context.Background(), expectedBlob) + blobInfo, err := eigendaClient.PutBlob(context.Background(), expectedBlob) require.NoError(t, err) - require.NotNil(t, cert) - assert.Equal(t, &clients.Cert{ - BatchHeaderHash: []byte("mock-batch-header-hash"), - BlobIndex: 100, - ReferenceBlockNumber: 200, - QuorumIDs: []uint32{0, 1}, - BlobCommitment: &common.G1Commitment{X: []byte{0x00, 0x00, 0x00, 0x00}, Y: []byte{0x01, 0x00, 0x00, 0x00}}, - }, cert) + require.NotNil(t, blobInfo) + assert.Equal(t, finalizedBlobInfo, blobInfo) resultBlob, err := eigendaClient.GetBlob(context.Background(), []byte("mock-batch-header-hash"), 100) require.NoError(t, err) @@ -107,9 +101,9 @@ func TestPutBlobFailDispersal(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } func TestPutBlobFailureInsufficentSignatures(t *testing.T) { @@ -139,9 +133,9 @@ func TestPutBlobFailureInsufficentSignatures(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } func TestPutBlobFailureGeneral(t *testing.T) { @@ -171,9 +165,9 @@ func TestPutBlobFailureGeneral(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } func TestPutBlobFailureUnknown(t *testing.T) { @@ -203,9 +197,9 @@ func TestPutBlobFailureUnknown(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } func TestPutBlobFinalizationTimeout(t *testing.T) { @@ -237,9 +231,9 @@ func TestPutBlobFinalizationTimeout(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } func TestPutBlobIndividualRequestTimeout(t *testing.T) { @@ -296,18 +290,12 @@ func TestPutBlobIndividualRequestTimeout(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) // despite initial timeout it should succeed require.NoError(t, err) - require.NotNil(t, cert) - assert.Equal(t, &clients.Cert{ - BatchHeaderHash: []byte("mock-batch-header-hash"), - BlobIndex: 100, - ReferenceBlockNumber: 200, - QuorumIDs: []uint32{0, 1}, - BlobCommitment: &common.G1Commitment{X: []byte{0x00, 0x00, 0x00, 0x00}, Y: []byte{0x01, 0x00, 0x00, 0x00}}, - }, cert) + require.NotNil(t, blobInfo) + assert.Equal(t, finalizedBlobInfo, blobInfo) } func TestPutBlobTotalTimeout(t *testing.T) { @@ -364,9 +352,9 @@ func TestPutBlobTotalTimeout(t *testing.T) { Client: disperserClient, PutCodec: clients.DefaultBlobEncodingCodec{}, } - cert, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) + blobInfo, err := eigendaClient.PutBlob(context.Background(), []byte("hello")) // should timeout even though it would have finalized eventually require.Error(t, err) - require.Nil(t, cert) + require.Nil(t, blobInfo) } diff --git a/api/clients/eigenda_client_testnet_test.go b/api/clients/eigenda_client_testnet_test.go index c576413d86..ff6474005b 100644 --- a/api/clients/eigenda_client_testnet_test.go +++ b/api/clients/eigenda_client_testnet_test.go @@ -32,9 +32,11 @@ func TestClientUsingTestnet(t *testing.T) { }) data := "hello world!" assert.NoError(t, err) - cert, err := client.PutBlob(context.Background(), []byte(data)) + blobInfo, err := client.PutBlob(context.Background(), []byte(data)) assert.NoError(t, err) - blob, err := client.GetBlob(context.Background(), cert.BatchHeaderHash, cert.BlobIndex) + batchHeaderHash := blobInfo.BlobVerificationProof.BatchMetadata.BatchHeaderHash + blobIndex := blobInfo.BlobVerificationProof.BlobIndex + blob, err := client.GetBlob(context.Background(), batchHeaderHash, blobIndex) assert.NoError(t, err) assert.Equal(t, data, string(blob)) }