@@ -6,16 +6,13 @@ import (
6
6
"errors"
7
7
"fmt"
8
8
"log"
9
- "math"
10
9
11
- "github.com/celestiaorg/celestia-app/pkg/appconsts"
12
- "github.com/celestiaorg/celestia-app/pkg/square"
13
- "github.com/celestiaorg/celestia-app/x/blob/types"
10
+ "github.com/celestiaorg/celestia-app/v2/pkg/appconsts"
14
11
rpc "github.com/celestiaorg/celestia-node/api/rpc/client"
15
12
"github.com/celestiaorg/celestia-node/blob"
16
13
"github.com/celestiaorg/celestia-node/share"
17
- sdktypes "github.com/cosmos/cosmos-sdk/types "
18
- auth "github.com/cosmos/cosmos-sdk/x/auth/types "
14
+ "github.com/celestiaorg/celestia-node/state "
15
+ square "github.com/celestiaorg/go-square/v2 "
19
16
"github.com/tendermint/tendermint/rpc/client/http"
20
17
21
18
"github.com/stackrlabs/go-daash/da"
@@ -86,11 +83,8 @@ func (c *Client) Commit(ctx context.Context, daBlob da.Blob) (da.Commitment, err
86
83
if err != nil {
87
84
return nil , err
88
85
}
89
- commitment , err := types .CreateCommitment (& blob .Blob )
90
- if err != nil {
91
- return nil , err
92
- }
93
- return commitment , err
86
+
87
+ return blob .Commitment , nil
94
88
}
95
89
96
90
// Submit submits the Blobs to Data Availability layer.
@@ -99,21 +93,17 @@ func (c *Client) Submit(ctx context.Context, daBlob da.Blob, gasPrice float64) (
99
93
if err != nil {
100
94
return nil , err
101
95
}
102
- options := blob .DefaultSubmitOptions ()
103
- // if gas price was configured globally use that as the default
104
- if c .gasPrice >= 0 && gasPrice < 0 {
105
- gasPrice = c .gasPrice
106
- }
107
- if gasPrice >= 0 {
108
- options .GasLimit = types .EstimateGas ([]uint32 {uint32 (len (b .Data ))}, appconsts .DefaultGasPerBlobByte , auth .DefaultTxSizeCostPerByte )
109
- options .Fee = sdktypes .NewInt (int64 (math .Ceil (gasPrice * float64 (options .GasLimit )))).Int64 ()
110
- }
111
- txResp , err := c .lightClient .State .SubmitPayForBlob (ctx , sdktypes .NewInt (int64 (options .Fee )), options .GasLimit , []* blob.Blob {b })
96
+ opts := state .NewTxConfig (state .WithGasPrice (gasPrice ))
97
+ err = b .Namespace ().ValidateForBlob ()
112
98
if err != nil {
113
99
return nil , err
114
100
}
101
+ txResp , err := c .lightClient .State .SubmitPayForBlob (ctx , []* state.Blob {b .Blob }, opts )
102
+ if err != nil {
103
+ return nil , errors .Join (err , fmt .Errorf ("failed to submit blobs" ))
104
+ }
115
105
116
- log .Println ("successfully submitted blobs" , "height" , txResp .Height , "gas" , options . GasLimit , "fee" , options . Fee )
106
+ log .Println ("successfully submitted blobs" , "height" , txResp .Height , "gas" , txResp . GasUsed )
117
107
118
108
commitment , err := c .Commit (ctx , daBlob )
119
109
if err != nil {
@@ -181,8 +171,10 @@ func (c *Client) getSharePointer(ctx context.Context, txHash string) (SharePoint
181
171
if err != nil {
182
172
return SharePointer {}, fmt .Errorf ("failed to get block: %w" , err )
183
173
}
184
-
185
- shareRange , err := square .BlobShareRange (blockRes .Block .Data .Txs .ToSliceOfBytes (), int (tx .Index ), 0 , blockRes .Block .Header .Version .App )
174
+ version := blockRes .Block .Header .Version .App
175
+ maxSquareSize := appconsts .SquareSizeUpperBound (version )
176
+ subtreeRootThreshold := appconsts .SubtreeRootThreshold (version )
177
+ shareRange , err := square .BlobShareRange (blockRes .Block .Txs .ToSliceOfBytes (), int (tx .Index ), 0 , maxSquareSize , subtreeRootThreshold )
186
178
// shareRange, err := square.TxShareRange(blockRes.Block.Data.Txs.ToSliceOfBytes(), int(tx.Index), blockRes.Block.Header.Version.App)
187
179
if err != nil {
188
180
return SharePointer {}, fmt .Errorf ("failed to get share range: %w" , err )
0 commit comments