Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #70 from rollkit/tux/fix-max-blob-size
Browse files Browse the repository at this point in the history
  • Loading branch information
Manav-Aggarwal committed Feb 5, 2024
2 parents 6afe388 + 1a20032 commit 5892064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import (
"github.com/rollkit/go-da"
)

const (
// DefaultMaxBytes is the maximum blob size accepted by celestia core
// ADR-13 claims worst case padding approaches 2 rows for a full data square:
// see: https://github.com/celestiaorg/celestia-app/blob/main/docs/architecture/adr-013-non-interactive-default-rules-for-zero-padding.md
// square size (64) * two rows = 128 shares
// 128 shares * 512 bytes per share = 65,536 bytes to account for padding
// 1,973,786 - 65,536 = 1,908,250 bytes
DefaultMaxBytes = 1908250
)

// CelestiaDA implements the celestia backend for the DA interface
type CelestiaDA struct {
client *rpc.Client
Expand All @@ -40,7 +50,7 @@ func NewCelestiaDA(client *rpc.Client, namespace share.Namespace, gasPrice float
// MaxBlobSize returns the max blob size
func (c *CelestiaDA) MaxBlobSize(ctx context.Context) (uint64, error) {
// TODO: pass-through query to node, app
return appconsts.DefaultMaxBytes, nil
return DefaultMaxBytes, nil
}

// Get returns Blob for each given ID, or an error.
Expand Down
3 changes: 1 addition & 2 deletions celestia/celestia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"
"testing"

"github.com/celestiaorg/celestia-app/pkg/appconsts"
rpc "github.com/celestiaorg/celestia-node/api/rpc/client"
"github.com/celestiaorg/celestia-node/share"
"github.com/celestiaorg/nmt"
Expand Down Expand Up @@ -58,7 +57,7 @@ func TestCelestiaDA(t *testing.T) {
t.Run("MaxBlobSize", func(t *testing.T) {
maxBlobSize, err := m.MaxBlobSize(ctx)
assert.NoError(t, err)
assert.Equal(t, uint64(appconsts.DefaultMaxBytes), maxBlobSize)
assert.Equal(t, uint64(DefaultMaxBytes), maxBlobSize)
})

t.Run("Get_empty", func(t *testing.T) {
Expand Down

0 comments on commit 5892064

Please sign in to comment.