From a1e2b8647e1864818e07251897c5a1e663e5ce04 Mon Sep 17 00:00:00 2001 From: Teddy Knox Date: Wed, 26 Jun 2024 16:31:57 -0400 Subject: [PATCH] Add configuration setting for high-level EigenDA client for returning as soon as the blob has been confirmed --- api/clients/config.go | 3 +++ api/clients/eigenda_client.go | 8 +++++++- api/clients/eigenda_client_e2e_test.go | 1 + api/clients/eigenda_client_test.go | 10 ++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/api/clients/config.go b/api/clients/config.go index d09f05bcf2..096134e183 100644 --- a/api/clients/config.go +++ b/api/clients/config.go @@ -37,6 +37,9 @@ type EigenDAClientConfig struct { // the commitment. With this mode disabled, you will need to supply the entire blob to perform a verification // that any part of the data matches the KZG commitment. DisablePointVerificationMode bool + + // If true, will wait for the blob to finalize, if false, will wait only for the blob to confirm. + WaitForFinalization bool } func (c *EigenDAClientConfig) CheckAndSetDefaults() error { diff --git a/api/clients/eigenda_client.go b/api/clients/eigenda_client.go index ae6ff078fd..40c9b461fd 100644 --- a/api/clients/eigenda_client.go +++ b/api/clients/eigenda_client.go @@ -180,7 +180,13 @@ func (m EigenDAClient) putBlob(ctx context.Context, rawData []byte, resultChan c errChan <- fmt.Errorf("EigenDA blob dispersal failed in processing with insufficient signatures, requestID=%s: %w", base64RequestID, err) return case grpcdisperser.BlobStatus_CONFIRMED: - m.Log.Info("EigenDA blob confirmed, waiting for finalization", "requestID", base64RequestID) + if m.Config.WaitForFinalization { + m.Log.Info("EigenDA blob confirmed, waiting for finalization", "requestID", base64RequestID) + } else { + m.Log.Info("EigenDA blob confirmed", "requestID", base64RequestID) + resultChan <- statusRes.Info + return + } 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) diff --git a/api/clients/eigenda_client_e2e_test.go b/api/clients/eigenda_client_e2e_test.go index ff6474005b..f10a6aec91 100644 --- a/api/clients/eigenda_client_e2e_test.go +++ b/api/clients/eigenda_client_e2e_test.go @@ -29,6 +29,7 @@ func TestClientUsingTestnet(t *testing.T) { StatusQueryRetryInterval: 5 * time.Second, CustomQuorumIDs: []uint{}, SignerPrivateKeyHex: "2d23e142a9e86a9175b9dfa213f20ea01f6c1731e09fa6edf895f70fe279cbb1", + WaitForFinalization: true, }) data := "hello world!" assert.NoError(t, err) diff --git a/api/clients/eigenda_client_test.go b/api/clients/eigenda_client_test.go index 39b64da0fd..41351158fc 100644 --- a/api/clients/eigenda_client_test.go +++ b/api/clients/eigenda_client_test.go @@ -68,6 +68,7 @@ func TestPutRetrieveBlobIFFTSuccess(t *testing.T) { DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, DisablePointVerificationMode: false, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -133,6 +134,7 @@ func TestPutRetrieveBlobIFFTNoDecodeSuccess(t *testing.T) { DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, DisablePointVerificationMode: false, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -203,6 +205,7 @@ func TestPutRetrieveBlobNoIFFTSuccess(t *testing.T) { DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, DisablePointVerificationMode: true, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewNoIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -234,6 +237,7 @@ func TestPutBlobFailDispersal(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -266,6 +270,7 @@ func TestPutBlobFailureInsufficentSignatures(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -298,6 +303,7 @@ func TestPutBlobFailureGeneral(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -330,6 +336,7 @@ func TestPutBlobFailureUnknown(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -364,6 +371,7 @@ func TestPutBlobFinalizationTimeout(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -423,6 +431,7 @@ func TestPutBlobIndividualRequestTimeout(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()), @@ -485,6 +494,7 @@ func TestPutBlobTotalTimeout(t *testing.T) { SignerPrivateKeyHex: "75f9e29cac7f5774d106adb355ef294987ce39b7863b75bb3f2ea42ca160926d", DisableTLS: false, PutBlobEncodingVersion: codecs.DefaultBlobEncoding, + WaitForFinalization: true, }, Client: disperserClient, Codec: codecs.NewIFFTCodec(codecs.NewDefaultBlobCodec()),