Skip to content

Commit 755acd2

Browse files
authored
Merge pull request #31 from rollkit/tux/gas-price
da: replace submit options with gas price
2 parents 704b67e + 0707fa9 commit 755acd2

File tree

8 files changed

+68
-333
lines changed

8 files changed

+68
-333
lines changed

da.go

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package da
22

3-
// SubmitOptions contains the information about fee and gas price in order to configure the
4-
// Submit request.
5-
type SubmitOptions struct {
6-
Fee int64
7-
Gas uint64
8-
}
9-
103
// DA defines very generic interface for interaction with Data Availability layers.
114
type DA interface {
125
// MaxBlobSize returns the max blob size
@@ -29,7 +22,7 @@ type DA interface {
2922
// This method is synchronous. Upon successful submission to Data Availability layer, it returns ID identifying blob
3023
// in DA and Proof of inclusion.
3124
// If options is nil, default options are used.
32-
Submit(blobs []Blob, options *SubmitOptions) ([]ID, []Proof, error)
25+
Submit(blobs []Blob, gasPrice float64) ([]ID, []Proof, error)
3326

3427
// Validate validates Commitments against the corresponding Proofs. This should be possible without retrieving the Blobs.
3528
Validate(ids []ID, proofs []Proof) ([]bool, error)
@@ -46,11 +39,3 @@ type Commitment = []byte
4639

4740
// Proof should contain serialized proof of inclusion (publication) of Blob in Data Availability layer.
4841
type Proof = []byte
49-
50-
// DefaultSubmitOptions creates a default fee and gas price values.
51-
func DefaultSubmitOptions() *SubmitOptions {
52-
return &SubmitOptions{
53-
Fee: -1,
54-
Gas: 0,
55-
}
56-
}

proto/da/da.proto

+1-7
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,10 @@ message CommitResponse {
8181
repeated Commitment commitments = 1;
8282
}
8383

84-
// SubmitOptions is the options type for the Submit method.
85-
message SubmitOptions {
86-
int64 fee = 1;
87-
uint64 gas = 2;
88-
}
89-
9084
// SubmitRequest is the request type for the Submit rpc method.
9185
message SubmitRequest {
9286
repeated Blob blobs = 1;
93-
SubmitOptions options = 2;
87+
double gas_price = 2;
9488
}
9589

9690
// SubmitResponse is the response type for the Submit rpc method.

proxy/client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ func (c *Client) Commit(blobs []da.Blob) ([]da.Commitment, error) {
8989
}
9090

9191
// Submit submits the Blobs to Data Availability layer.
92-
func (c *Client) Submit(blobs []da.Blob, options *da.SubmitOptions) ([]da.ID, []da.Proof, error) {
92+
func (c *Client) Submit(blobs []da.Blob, gasPrice float64) ([]da.ID, []da.Proof, error) {
9393
req := &pbda.SubmitRequest{
94-
Blobs: blobsDA2PB(blobs),
95-
Options: optionsDA2PB(options),
94+
Blobs: blobsDA2PB(blobs),
95+
GasPrice: gasPrice,
9696
}
9797

9898
resp, err := c.client.Submit(context.TODO(), req)

proxy/server.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ func (p *proxySrv) Commit(ctx context.Context, request *pbda.CommitRequest) (*pb
5656

5757
func (p *proxySrv) Submit(ctx context.Context, request *pbda.SubmitRequest) (*pbda.SubmitResponse, error) {
5858
blobs := blobsPB2DA(request.Blobs)
59-
options := optionsPB2DA(request.GetOptions())
6059

61-
ids, proofs, err := p.target.Submit(blobs, options)
60+
ids, proofs, err := p.target.Submit(blobs, request.GasPrice)
6261
if err != nil {
6362
return nil, err
6463
}

proxy/util.go

-20
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,6 @@ func blobsPB2DA(pb []*pbda.Blob) []da.Blob {
2121
return blobs
2222
}
2323

24-
func optionsDA2PB(options *da.SubmitOptions) *pbda.SubmitOptions {
25-
if options != nil {
26-
return &pbda.SubmitOptions{
27-
Fee: options.Fee,
28-
Gas: options.Gas,
29-
}
30-
}
31-
return &pbda.SubmitOptions{Fee: -1}
32-
}
33-
34-
func optionsPB2DA(pb *pbda.SubmitOptions) *da.SubmitOptions {
35-
if pb != nil {
36-
return &da.SubmitOptions{
37-
Fee: pb.Fee,
38-
Gas: pb.Gas,
39-
}
40-
}
41-
return da.DefaultSubmitOptions()
42-
}
43-
4424
func idsPB2DA(pb []*pbda.ID) []da.ID {
4525
ids := make([]da.ID, len(pb))
4626
for i := range ids {

test/dummy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (d *DummyDA) Commit(blobs []da.Blob) ([]da.Commitment, error) {
9999
}
100100

101101
// Submit stores blobs in DA layer.
102-
func (d *DummyDA) Submit(blobs []da.Blob, options *da.SubmitOptions) ([]da.ID, []da.Proof, error) {
102+
func (d *DummyDA) Submit(blobs []da.Blob, gasPrice float64) ([]da.ID, []da.Proof, error) {
103103
d.mu.Lock()
104104
defer d.mu.Unlock()
105105
ids := make([]da.ID, len(blobs))

test/test_suite.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ func BasicDATest(t *testing.T, da da.DA) {
4040
msg1 := []byte("message 1")
4141
msg2 := []byte("message 2")
4242

43-
id1, proof1, err := da.Submit([]Blob{msg1}, nil)
43+
id1, proof1, err := da.Submit([]Blob{msg1}, -1)
4444
assert.NoError(t, err)
4545
assert.NotEmpty(t, id1)
4646
assert.NotEmpty(t, proof1)
4747

48-
id2, proof2, err := da.Submit([]Blob{msg2}, nil)
48+
id2, proof2, err := da.Submit([]Blob{msg2}, -1)
4949
assert.NoError(t, err)
5050
assert.NotEmpty(t, id2)
5151
assert.NotEmpty(t, proof2)
5252

53-
id3, proof3, err := da.Submit([]Blob{msg1}, nil)
53+
id3, proof3, err := da.Submit([]Blob{msg1}, -1)
5454
assert.NoError(t, err)
5555
assert.NotEmpty(t, id3)
5656
assert.NotEmpty(t, proof3)
@@ -110,7 +110,7 @@ func CheckErrors(t *testing.T, da da.DA) {
110110
func GetIDsTest(t *testing.T, da da.DA) {
111111
msgs := [][]byte{[]byte("msg1"), []byte("msg2"), []byte("msg3")}
112112

113-
ids, proofs, err := da.Submit(msgs, nil)
113+
ids, proofs, err := da.Submit(msgs, -1)
114114
assert.NoError(t, err)
115115
assert.Len(t, ids, len(msgs))
116116
assert.Len(t, proofs, len(msgs))
@@ -162,7 +162,7 @@ func ConcurrentReadWriteTest(t *testing.T, da da.DA) {
162162
go func() {
163163
defer wg.Done()
164164
for i := uint64(1); i <= 100; i++ {
165-
_, _, err := da.Submit([][]byte{[]byte("test")}, nil)
165+
_, _, err := da.Submit([][]byte{[]byte("test")}, -1)
166166
assert.NoError(t, err)
167167
}
168168
}()

0 commit comments

Comments
 (0)