diff --git a/Dockerfile b/Dockerfile index 588d1c43ed..4cadfb436a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,7 +37,7 @@ RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity FROM debian:bookworm-20231218 as wasm-base WORKDIR /workspace -RUN apt-get update && apt-get install -y curl build-essential=12.9 +RUN apt-get update --fix-missing && apt-get install -y curl build-essential=12.9 FROM wasm-base as wasm-libs-builder # clang / lld used by soft-float wasm diff --git a/das/celestia/celestia.go b/das/celestia/celestia.go index ae72a7cc57..8bcb0ae22c 100644 --- a/das/celestia/celestia.go +++ b/das/celestia/celestia.go @@ -319,20 +319,35 @@ func (c *CelestiaDA) Store(ctx context.Context, message []byte) ([]byte, error) startColumn := blobIndex % squareSize - firstShare, err := c.ReadClient.Share.GetShare(ctx, header, int(startRow), int(startColumn)) + nodeShare, err := c.ReadClient.Share.GetShare(ctx, header, int(startRow), int(startColumn)) if err != nil { celestiaFailureCounter.Inc(1) log.Warn("Failed to get first share for the blob", "err", err) return nil, err } - sharesLength, err := firstShare.SequenceLen() - if err != nil || sharesLength == 0 { + // need to convert to app share + firstShare, err := share.NewShare(*nodeShare) + if err != nil { + celestiaFailureCounter.Inc(1) + log.Warn("Failed to convert share to app share type", "err", err) + return nil, err + } + sequenceLength, err := firstShare.SequenceLen() + if err != nil { celestiaFailureCounter.Inc(1) log.Warn("Failed to get blob sequence length", "err", err) return nil, err } + sharesLength := share.SparseSharesNeeded(sequenceLength) + + if sharesLength == 0 { + celestiaFailureCounter.Inc(1) + log.Warn("Shares length zero for blob", "err", err) + return nil, fmt.Errorf("Blob found, but has shares length zero") + } + startIndexOds := blobIndex - odsSize*startRow blobPointer := types.BlobPointer{ BlockHeight: height, @@ -393,20 +408,6 @@ func (c *CelestiaDA) Read(ctx context.Context, blobPointer *types.BlobPointer) ( return c.returnErrorHelper(fmt.Errorf("Data Root mismatch, header.DataHash=%v, blobPointer.DataRoot=%v", header.DataHash, hex.EncodeToString(blobPointer.DataRoot[:]))) } - proofs, err := c.ReadClient.Blob.GetProof(ctx, blobPointer.BlockHeight, *c.Namespace, blobPointer.TxCommitment[:]) - if err != nil { - return c.returnErrorHelper(fmt.Errorf("Error retrieving proof, err=%v", err)) - } - - sharesLength := uint64(0) - for _, proof := range *proofs { - sharesLength += uint64(proof.End()) - uint64(proof.Start()) - } - - if sharesLength != blobPointer.SharesLength { - return c.returnErrorHelper(fmt.Errorf("Share length mismatch, sharesLength=%v, blobPointer.SharesLength=%v", sharesLength, blobPointer.SharesLength)) - } - blob, err := c.ReadClient.Blob.Get(ctx, blobPointer.BlockHeight, *c.Namespace, blobPointer.TxCommitment[:]) if err != nil { // return an empty batch of data because we could not find the blob from the sequencer message @@ -450,6 +451,34 @@ func (c *CelestiaDA) Read(ctx context.Context, blobPointer *types.BlobPointer) ( return c.returnErrorHelper(fmt.Errorf("start and end row are the same and startColumn >= endColumn, startColumn=%v, endColumn+1=%v", startColumn, endColumn+1)) } + nodeShare, err := c.ReadClient.Share.GetShare(ctx, header, int(startRow), int(startColumn)) + if err != nil { + celestiaFailureCounter.Inc(1) + log.Warn("Failed to get first share for the blob", "err", err) + return nil, nil, err + } + + // need to convert to app share + firstShare, err := share.NewShare(*nodeShare) + if err != nil { + celestiaFailureCounter.Inc(1) + log.Warn("Failed to convert share to app share type", "err", err) + return nil, nil, err + } + sequenceLength, err := firstShare.SequenceLen() + if err != nil { + celestiaFailureCounter.Inc(1) + log.Warn("Failed to get blob sequence length", "err", err) + return nil, nil, err + } + + sharesLength := share.SparseSharesNeeded(sequenceLength) + + if uint64(sharesLength) != blobPointer.SharesLength || sharesLength == 0 { + celestiaFailureCounter.Inc(1) + return c.returnErrorHelper(fmt.Errorf("Share length mismatch, sharesLength=%v, blobPointer.SharesLength=%v", sharesLength, blobPointer.SharesLength)) + } + rows := [][][]byte{} for i := startRow; i <= endRow; i++ { rows = append(rows, eds.Row(uint(i))) diff --git a/go.mod b/go.mod index c90591b047..a29b1a59ba 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.10 github.com/aws/aws-sdk-go-v2/service/s3 v1.26.9 github.com/cavaliergopher/grab/v3 v3.0.1 - github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240603174346-256ddd020a0a + github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240813195623-e38feb19b4c6 github.com/celestiaorg/nmt v0.20.0 github.com/celestiaorg/rsmt2d v0.11.0 github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 diff --git a/go.sum b/go.sum index 16fc8c177c..b8dffb49af 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,10 @@ github.com/cavaliergopher/grab/v3 v3.0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIH github.com/cavaliergopher/grab/v3 v3.0.1/go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 h1:Fd7ymPUzExPGNl2gZw4i5S74arMw+iDHLE78M/cCxl4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29/go.mod h1:xrICN0PBhp3AdTaZ8q4wS5Jvi32V02HNjaC2EsWiEKk= -github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240603174346-256ddd020a0a h1:T9vsMQvvYvA/1FObT0eqL0J+XJJx/wG6Jzf+DH+IFxc= -github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240603174346-256ddd020a0a/go.mod h1:7kEhBB4KZh4vw3v5pMuMocNgYOk8uOpFZTo0cNpRjXc= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240813194139-2763b3a8a0d0 h1:5Gn9ROiWhl6rUuN/F7uHKBLEk13N9sGdYaIPWvwbzxc= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240813194139-2763b3a8a0d0/go.mod h1:7kEhBB4KZh4vw3v5pMuMocNgYOk8uOpFZTo0cNpRjXc= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240813195623-e38feb19b4c6 h1:dhkq67slPJf3zIoQVTCHd4Zz871FB+kg5WEa68X+YDQ= +github.com/celestiaorg/celestia-openrpc v0.4.1-0.20240813195623-e38feb19b4c6/go.mod h1:7kEhBB4KZh4vw3v5pMuMocNgYOk8uOpFZTo0cNpRjXc= github.com/celestiaorg/go-fraud v0.2.0 h1:aaq2JiW0gTnhEdac3l51UCqSyJ4+VjFGTTpN83V4q7I= github.com/celestiaorg/go-fraud v0.2.0/go.mod h1:lNY1i4K6kUeeE60Z2VK8WXd+qXb8KRzfBhvwPkK6aUc= github.com/celestiaorg/go-header v0.4.1 h1:bjbUcKDnhrJJ9EoE7vtPpgleNLVjc2S+cB4/qe8nQmo= diff --git a/nitro-testnode b/nitro-testnode index 3922df9caf..1da0bfa9b3 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 3922df9caf7a65dd4168b8158c1244c5fe88780e +Subproject commit 1da0bfa9b33f0523913ec9aa445bc76577151f9f