@@ -17,14 +17,14 @@ import (
1717 "go.opentelemetry.io/otel/codes"
1818 "go.opentelemetry.io/otel/trace"
1919
20+ appfibre "github.com/celestiaorg/celestia-app/v8/fibre"
2021 "github.com/celestiaorg/celestia-app/v8/pkg/appconsts"
2122 pkgproof "github.com/celestiaorg/celestia-app/v8/pkg/proof"
2223 "github.com/celestiaorg/go-square/v4/inclusion"
2324 libshare "github.com/celestiaorg/go-square/v4/share"
2425 "github.com/celestiaorg/nmt"
2526 "github.com/celestiaorg/rsmt2d"
2627
27- "github.com/celestiaorg/celestia-node/fibre"
2828 "github.com/celestiaorg/celestia-node/header"
2929 "github.com/celestiaorg/celestia-node/libs/utils"
3030 "github.com/celestiaorg/celestia-node/share"
@@ -34,8 +34,9 @@ import (
3434)
3535
3636var (
37- ErrBlobNotFound = errors .New ("blob: not found" )
38- ErrInvalidProof = errors .New ("blob: invalid proof" )
37+ ErrBlobNotFound = errors .New ("blob: not found" )
38+ ErrInvalidProof = errors .New ("blob: invalid proof" )
39+ ErrMixedBlobTypes = errors .New ("blob: cannot mix fibre (v2) and regular blobs in a single submit" )
3940
4041 log = logging .Logger ("blob" )
4142 tracer = otel .Tracer ("blob/service" )
@@ -54,7 +55,16 @@ type Submitter interface {
5455
5556// FibreSubmitter is an interface for submitting blobs to the Fibre network.
5657type FibreSubmitter interface {
57- Submit (ctx context.Context , ns libshare.Namespace , data []byte , config * txclient.TxConfig ) (* fibre.SubmitResult , error )
58+ Submit (
59+ ctx context.Context ,
60+ ns libshare.Namespace ,
61+ data []byte ,
62+ config * txclient.TxConfig ,
63+ ) (
64+ _ * appfibre.PutResult ,
65+ _ * appfibre.PaymentPromise ,
66+ err error ,
67+ )
5868}
5969
6070type Service struct {
@@ -187,10 +197,14 @@ func (s *Service) Subscribe(ctx context.Context, ns libshare.Namespace) (<-chan
187197 return blobCh , nil
188198}
189199
190- // Submit sends PFB transaction and reports the height at which it was included.
200+ // Submit sends PFB/PFF transaction and reports the height at which it was included.
191201// Allows sending multiple Blobs atomically synchronously.
192202// Uses default wallet registered on the Node.
193203// Handles gas estimation and fee calculation.
204+ //
205+ // If all blobs are fibre blobs (share version 2), they are submitted via the fibre network.
206+ // If all blobs are regular blobs, they are submitted via the standard PFB path.
207+ // Mixing fibre and regular blobs in a single submit is not allowed.
194208func (s * Service ) Submit (ctx context.Context , blobs []* Blob , txConfig * SubmitOptions ) (_ uint64 , err error ) {
195209 ctx , span := tracer .Start (ctx , "blob/submit" )
196210 defer func () {
@@ -202,6 +216,17 @@ func (s *Service) Submit(ctx context.Context, blobs []*Blob, txConfig *SubmitOpt
202216 }
203217 }()
204218
219+ allFibre := slices .IndexFunc (blobs , func (b * Blob ) bool { return ! b .IsFibreBlob () }) == - 1
220+ anyFibre := slices .IndexFunc (blobs , func (b * Blob ) bool { return b .IsFibreBlob () }) != - 1
221+
222+ if anyFibre && ! allFibre {
223+ return 0 , ErrMixedBlobTypes
224+ }
225+
226+ if allFibre {
227+ return s .submitFibreBlobs (ctx , blobs , txConfig )
228+ }
229+
205230 libBlobs := make ([]* libshare.Blob , len (blobs ))
206231 for i := range blobs {
207232 libBlobs [i ] = blobs [i ].Blob
@@ -213,39 +238,20 @@ func (s *Service) Submit(ctx context.Context, blobs []*Blob, txConfig *SubmitOpt
213238 return uint64 (resp .Height ), nil
214239}
215240
216- // SubmitFibreBlob submits a blob via the Fibre network.
217- // It performs the full Fibre flow: upload to FSPs, aggregate validator signatures,
218- // and submit MsgPayForFibre on-chain.
219- func (s * Service ) SubmitFibreBlob (
220- ctx context.Context ,
221- ns libshare.Namespace ,
222- data []byte ,
223- txConfig * SubmitOptions ,
224- ) (_ * fibre.SubmitResult , err error ) {
225- ctx , span := tracer .Start (ctx , "blob/submit-fibre" )
226- defer func () {
227- utils .SetStatusAndEnd (span , err )
228- if err != nil {
229- log .Errorw ("submitting fibre blob failed" , "err" , err ,
230- "namespace" , ns .String (),
231- )
232- }
233- }()
234-
241+ func (s * Service ) submitFibreBlobs (ctx context.Context , blobs []* Blob , txConfig * SubmitOptions ) (uint64 , error ) {
235242 if s .fibreSubmitter == nil {
236- err = fmt .Errorf ("fibre submitter is not configured: node is not connected to a core endpoint" )
237- return nil , err
243+ return 0 , fmt .Errorf ("fibre submitter is not available" )
238244 }
239245
240- log .Infow ("submitting fibre blob" , "namespace" , ns .String (), "data-size" , len (data ))
241- result , err := s .fibreSubmitter .Submit (ctx , ns , data , txConfig )
242- if err != nil {
243- err = fmt .Errorf ("fibre submit: %w" , err )
244- return nil , err
246+ var height uint64
247+ for _ , blob := range blobs {
248+ res , _ , err := s .fibreSubmitter .Submit (ctx , blob .Namespace (), blob .Data (), txConfig )
249+ if err != nil {
250+ return 0 , err
251+ }
252+ height = res .Height
245253 }
246-
247- log .Debugw ("fibre blob submitted" , "namespace" , ns .String (), "height" , result .Height , "tx-hash" , result .TxHash )
248- return result , nil
254+ return height , nil
249255}
250256
251257// Get retrieves a blob in a given namespace at the given height by commitment.
0 commit comments