From 1a20032aa15d1b37910d20d611c5c500efe7d729 Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Fri, 2 Feb 2024 14:35:19 -0800 Subject: [PATCH] celestia-da: account for padding shares --- celestia/celestia.go | 12 +++++++++++- celestia/celestia_test.go | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/celestia/celestia.go b/celestia/celestia.go index f66934d..4a031b7 100644 --- a/celestia/celestia.go +++ b/celestia/celestia.go @@ -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 @@ -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. diff --git a/celestia/celestia_test.go b/celestia/celestia_test.go index 5b3de0f..0d04a8f 100644 --- a/celestia/celestia_test.go +++ b/celestia/celestia_test.go @@ -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" @@ -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) {