@@ -58,6 +58,14 @@ func NewLocalDA(logger zerolog.Logger, opts ...func(*LocalDA) *LocalDA) *LocalDA
5858
5959var _ coreda.DA = & LocalDA {}
6060
61+ // validateNamespace checks that namespace is exactly 29 bytes
62+ func validateNamespace (ns []byte ) error {
63+ if len (ns ) != 29 {
64+ return fmt .Errorf ("namespace must be exactly 29 bytes, got %d" , len (ns ))
65+ }
66+ return nil
67+ }
68+
6169// MaxBlobSize returns the max blob size in bytes.
6270func (d * LocalDA ) MaxBlobSize (ctx context.Context ) (uint64 , error ) {
6371 d .logger .Debug ().Uint64 ("maxBlobSize" , d .maxBlobSize ).Msg ("MaxBlobSize called" )
@@ -77,7 +85,11 @@ func (d *LocalDA) GasPrice(ctx context.Context) (float64, error) {
7785}
7886
7987// Get returns Blobs for given IDs.
80- func (d * LocalDA ) Get (ctx context.Context , ids []coreda.ID , _ []byte ) ([]coreda.Blob , error ) {
88+ func (d * LocalDA ) Get (ctx context.Context , ids []coreda.ID , ns []byte ) ([]coreda.Blob , error ) {
89+ if err := validateNamespace (ns ); err != nil {
90+ d .logger .Error ().Err (err ).Msg ("Get: invalid namespace" )
91+ return nil , err
92+ }
8193 d .logger .Debug ().Interface ("ids" , ids ).Msg ("Get called" )
8294 d .mu .Lock ()
8395 defer d .mu .Unlock ()
@@ -105,7 +117,11 @@ func (d *LocalDA) Get(ctx context.Context, ids []coreda.ID, _ []byte) ([]coreda.
105117}
106118
107119// GetIDs returns IDs of Blobs at given DA height.
108- func (d * LocalDA ) GetIDs (ctx context.Context , height uint64 , _ []byte ) (* coreda.GetIDsResult , error ) {
120+ func (d * LocalDA ) GetIDs (ctx context.Context , height uint64 , ns []byte ) (* coreda.GetIDsResult , error ) {
121+ if err := validateNamespace (ns ); err != nil {
122+ d .logger .Error ().Err (err ).Msg ("GetIDs: invalid namespace" )
123+ return nil , err
124+ }
109125 d .logger .Debug ().Uint64 ("height" , height ).Msg ("GetIDs called" )
110126 d .mu .Lock ()
111127 defer d .mu .Unlock ()
@@ -130,9 +146,13 @@ func (d *LocalDA) GetIDs(ctx context.Context, height uint64, _ []byte) (*coreda.
130146}
131147
132148// GetProofs returns inclusion Proofs for all Blobs located in DA at given height.
133- func (d * LocalDA ) GetProofs (ctx context.Context , ids []coreda.ID , _ []byte ) ([]coreda.Proof , error ) {
149+ func (d * LocalDA ) GetProofs (ctx context.Context , ids []coreda.ID , ns []byte ) ([]coreda.Proof , error ) {
150+ if err := validateNamespace (ns ); err != nil {
151+ d .logger .Error ().Err (err ).Msg ("GetProofs: invalid namespace" )
152+ return nil , err
153+ }
134154 d .logger .Debug ().Interface ("ids" , ids ).Msg ("GetProofs called" )
135- blobs , err := d .Get (ctx , ids , nil )
155+ blobs , err := d .Get (ctx , ids , ns )
136156 if err != nil {
137157 d .logger .Error ().Err (err ).Msg ("GetProofs: failed to get blobs" )
138158 return nil , err
@@ -149,7 +169,11 @@ func (d *LocalDA) GetProofs(ctx context.Context, ids []coreda.ID, _ []byte) ([]c
149169}
150170
151171// Commit returns cryptographic Commitments for given blobs.
152- func (d * LocalDA ) Commit (ctx context.Context , blobs []coreda.Blob , _ []byte ) ([]coreda.Commitment , error ) {
172+ func (d * LocalDA ) Commit (ctx context.Context , blobs []coreda.Blob , ns []byte ) ([]coreda.Commitment , error ) {
173+ if err := validateNamespace (ns ); err != nil {
174+ d .logger .Error ().Err (err ).Msg ("Commit: invalid namespace" )
175+ return nil , err
176+ }
153177 d .logger .Debug ().Int ("numBlobs" , len (blobs )).Msg ("Commit called" )
154178 commits := make ([]coreda.Commitment , len (blobs ))
155179 for i , blob := range blobs {
@@ -160,8 +184,12 @@ func (d *LocalDA) Commit(ctx context.Context, blobs []coreda.Blob, _ []byte) ([]
160184}
161185
162186// SubmitWithOptions stores blobs in DA layer (options are ignored).
163- func (d * LocalDA ) SubmitWithOptions (ctx context.Context , blobs []coreda.Blob , gasPrice float64 , _ []byte , _ []byte ) ([]coreda.ID , error ) {
164- d .logger .Info ().Int ("numBlobs" , len (blobs )).Float64 ("gasPrice" , gasPrice ).Msg ("SubmitWithOptions called" )
187+ func (d * LocalDA ) SubmitWithOptions (ctx context.Context , blobs []coreda.Blob , gasPrice float64 , ns []byte , _ []byte ) ([]coreda.ID , error ) {
188+ if err := validateNamespace (ns ); err != nil {
189+ d .logger .Error ().Err (err ).Msg ("SubmitWithOptions: invalid namespace" )
190+ return nil , err
191+ }
192+ d .logger .Info ().Int ("numBlobs" , len (blobs )).Float64 ("gasPrice" , gasPrice ).Str ("namespace" , string (ns )).Msg ("SubmitWithOptions called" )
165193
166194 // Validate blob sizes before processing
167195 for i , blob := range blobs {
@@ -186,8 +214,12 @@ func (d *LocalDA) SubmitWithOptions(ctx context.Context, blobs []coreda.Blob, ga
186214}
187215
188216// Submit stores blobs in DA layer (options are ignored).
189- func (d * LocalDA ) Submit (ctx context.Context , blobs []coreda.Blob , gasPrice float64 , _ []byte ) ([]coreda.ID , error ) {
190- d .logger .Info ().Int ("numBlobs" , len (blobs )).Float64 ("gasPrice" , gasPrice ).Msg ("Submit called" )
217+ func (d * LocalDA ) Submit (ctx context.Context , blobs []coreda.Blob , gasPrice float64 , ns []byte ) ([]coreda.ID , error ) {
218+ if err := validateNamespace (ns ); err != nil {
219+ d .logger .Error ().Err (err ).Msg ("Submit: invalid namespace" )
220+ return nil , err
221+ }
222+ d .logger .Info ().Int ("numBlobs" , len (blobs )).Float64 ("gasPrice" , gasPrice ).Str ("namespace" , string (ns )).Msg ("Submit called" )
191223
192224 // Validate blob sizes before processing
193225 for i , blob := range blobs {
@@ -212,7 +244,11 @@ func (d *LocalDA) Submit(ctx context.Context, blobs []coreda.Blob, gasPrice floa
212244}
213245
214246// Validate checks the Proofs for given IDs.
215- func (d * LocalDA ) Validate (ctx context.Context , ids []coreda.ID , proofs []coreda.Proof , _ []byte ) ([]bool , error ) {
247+ func (d * LocalDA ) Validate (ctx context.Context , ids []coreda.ID , proofs []coreda.Proof , ns []byte ) ([]bool , error ) {
248+ if err := validateNamespace (ns ); err != nil {
249+ d .logger .Error ().Err (err ).Msg ("Validate: invalid namespace" )
250+ return nil , err
251+ }
216252 d .logger .Debug ().Int ("numIDs" , len (ids )).Int ("numProofs" , len (proofs )).Msg ("Validate called" )
217253 if len (ids ) != len (proofs ) {
218254 d .logger .Error ().Int ("ids" , len (ids )).Int ("proofs" , len (proofs )).Msg ("Validate: id/proof count mismatch" )
0 commit comments