Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions da.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ type DA interface {
// in DA.
Submit(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace) ([]ID, error)

// SubmitWithOptions submits the Blobs to Data Availability layer.
//
// This method is synchronous. Upon successful submission to Data Availability layer, it returns the IDs identifying blobs
// in DA.
SubmitWithOptions(ctx context.Context, blobs []Blob, gasPrice float64, namespace Namespace, options []byte) ([]ID, error)

// Validate validates Commitments against the corresponding Proofs. This should be possible without retrieving the Blobs.
Validate(ctx context.Context, ids []ID, proofs []Proof, namespace Namespace) ([]bool, error)
}
Expand Down
1 change: 1 addition & 0 deletions proto/da/da.proto
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ message SubmitRequest {
repeated Blob blobs = 1;
double gas_price = 2;
Namespace namespace = 3;
bytes options = 4;
}

// SubmitResponse is the response type for the Submit rpc method.
Expand Down
22 changes: 22 additions & 0 deletions proxy/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,28 @@ func (c *Client) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64,
return ids, nil
}

// SubmitWithOptions submits the Blobs to Data Availability layer.
func (c *Client) SubmitWithOptions(ctx context.Context, blobs []da.Blob, gasPrice float64, namespace da.Namespace, options []byte) ([]da.ID, error) {
req := &pbda.SubmitRequest{
Blobs: blobsDA2PB(blobs),
GasPrice: gasPrice,
Namespace: &pbda.Namespace{Value: namespace},
Options: options,
}

resp, err := c.client.Submit(ctx, req)
if err != nil {
return nil, err
}

ids := make([]da.ID, len(resp.Ids))
for i := range resp.Ids {
ids[i] = resp.Ids[i].Value
}

return ids, nil
}

// Validate validates Commitments against the corresponding Proofs. This should be possible without retrieving the Blobs.
func (c *Client) Validate(ctx context.Context, ids []da.ID, proofs []da.Proof, namespace da.Namespace) ([]bool, error) {
req := &pbda.ValidateRequest{
Expand Down
2 changes: 1 addition & 1 deletion proxy/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (p *proxySrv) GetProofs(ctx context.Context, request *pbda.GetProofsRequest
func (p *proxySrv) Submit(ctx context.Context, request *pbda.SubmitRequest) (*pbda.SubmitResponse, error) {
blobs := blobsPB2DA(request.Blobs)

ids, err := p.target.Submit(ctx, blobs, request.GasPrice, request.Namespace.GetValue())
ids, err := p.target.SubmitWithOptions(ctx, blobs, request.GasPrice, request.Namespace.GetValue(), request.Options)
if err != nil {
return nil, err
}
Expand Down
20 changes: 13 additions & 7 deletions proxy/jsonrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ type Module interface {
// API defines the jsonrpc service module API
type API struct {
Internal struct {
MaxBlobSize func(ctx context.Context) (uint64, error) `perm:"read"`
Get func(ctx context.Context, ids []da.ID, ns da.Namespace) ([]da.Blob, error) `perm:"read"`
GetIDs func(ctx context.Context, height uint64, ns da.Namespace) ([]da.ID, error) `perm:"read"`
GetProofs func(ctx context.Context, ids []da.ID, ns da.Namespace) ([]da.Proof, error) `perm:"read"`
Commit func(ctx context.Context, blobs []da.Blob, ns da.Namespace) ([]da.Commitment, error) `perm:"read"`
Validate func(context.Context, []da.ID, []da.Proof, da.Namespace) ([]bool, error) `perm:"read"`
Submit func(context.Context, []da.Blob, float64, da.Namespace) ([]da.ID, error) `perm:"write"`
MaxBlobSize func(ctx context.Context) (uint64, error) `perm:"read"`
Get func(ctx context.Context, ids []da.ID, ns da.Namespace) ([]da.Blob, error) `perm:"read"`
GetIDs func(ctx context.Context, height uint64, ns da.Namespace) ([]da.ID, error) `perm:"read"`
GetProofs func(ctx context.Context, ids []da.ID, ns da.Namespace) ([]da.Proof, error) `perm:"read"`
Commit func(ctx context.Context, blobs []da.Blob, ns da.Namespace) ([]da.Commitment, error) `perm:"read"`
Validate func(context.Context, []da.ID, []da.Proof, da.Namespace) ([]bool, error) `perm:"read"`
Submit func(context.Context, []da.Blob, float64, da.Namespace) ([]da.ID, error) `perm:"write"`
SubmitWithOptions func(context.Context, []da.Blob, float64, da.Namespace, []byte) ([]da.ID, error) `perm:"write"`
}
}

Expand Down Expand Up @@ -65,6 +66,11 @@ func (api *API) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64, n
return api.Internal.Submit(ctx, blobs, gasPrice, ns)
}

// SubmitWithOptions submits the Blobs to Data Availability layer.
func (api *API) SubmitWithOptions(ctx context.Context, blobs []da.Blob, gasPrice float64, ns da.Namespace, options []byte) ([]da.ID, error) {
return api.Internal.SubmitWithOptions(ctx, blobs, gasPrice, ns, options)
}

// Client is the jsonrpc client
type Client struct {
DA API
Expand Down
7 changes: 6 additions & 1 deletion test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ func (d *DummyDA) Commit(ctx context.Context, blobs []da.Blob, _ da.Namespace) (
}

// Submit stores blobs in DA layer.
func (d *DummyDA) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64, _ da.Namespace) ([]da.ID, error) {
func (d *DummyDA) Submit(ctx context.Context, blobs []da.Blob, gasPrice float64, ns da.Namespace) ([]da.ID, error) {
return d.SubmitWithOptions(ctx, blobs, gasPrice, ns, nil)
}

// SubmitWithOptions stores blobs in DA layer (options are ignored).
func (d *DummyDA) SubmitWithOptions(ctx context.Context, blobs []da.Blob, gasPrice float64, _ da.Namespace, _ []byte) ([]da.ID, error) {
d.mu.Lock()
defer d.mu.Unlock()
ids := make([]da.ID, len(blobs))
Expand Down
2 changes: 1 addition & 1 deletion test/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func BasicDATest(t *testing.T, d da.DA) {
assert.NoError(t, err)
assert.NotEmpty(t, id2)

id3, err := d.Submit(ctx, []da.Blob{msg1}, 0, testNamespace)
id3, err := d.SubmitWithOptions(ctx, []da.Blob{msg1}, 0, testNamespace, []byte("random options"))
assert.NoError(t, err)
assert.NotEmpty(t, id3)

Expand Down
130 changes: 92 additions & 38 deletions types/pb/da/da.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.