From 3926eb562617b40841be9d1824fb24cb9858f0c9 Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 5 Aug 2024 19:22:06 -0400 Subject: [PATCH] fix index issue --- cmd/ipfshelper/ipfshelper.go | 2 +- das/celestia/celestia.go | 24 ++++++++++++++++++------ go.mod | 2 +- go.sum | 2 +- solgen/gen.go | 5 +++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/cmd/ipfshelper/ipfshelper.go b/cmd/ipfshelper/ipfshelper.go index f580d8fabf..f907a0dff8 100644 --- a/cmd/ipfshelper/ipfshelper.go +++ b/cmd/ipfshelper/ipfshelper.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/log" iface "github.com/ipfs/boxo/coreiface" "github.com/ipfs/boxo/coreiface/options" - "github.com/ipfs/go-libipfs/files" + "github.com/ipfs/boxo/files" "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/config" "github.com/ipfs/kubo/core" diff --git a/das/celestia/celestia.go b/das/celestia/celestia.go index 70b7143e47..946bb8c761 100644 --- a/das/celestia/celestia.go +++ b/das/celestia/celestia.go @@ -298,11 +298,6 @@ func (c *CelestiaDA) Store(ctx context.Context, message []byte) ([]byte, error) return nil, err } - sharesLength := uint64(0) - for _, proof := range *proofs { - sharesLength += uint64(proof.End()) - uint64(proof.Start()) - } - txCommitment, dataRoot := [32]byte{}, [32]byte{} copy(txCommitment[:], dataBlob.Commitment) @@ -321,11 +316,28 @@ func (c *CelestiaDA) Store(ctx context.Context, message []byte) ([]byte, error) // return an empty batch return nil, fmt.Errorf("storing Celestia information, odsSize*startRow=%v was larger than blobIndex=%v", odsSize*startRow, dataBlob.Index()) } + + startColumn := blobIndex % squareSize + + firstShare, err := c.Client.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 { + celestiaFailureCounter.Inc(1) + log.Warn("Failed to get blob sequence length", "err", err) + return nil, err + } + startIndexOds := blobIndex - odsSize*startRow blobPointer := types.BlobPointer{ BlockHeight: height, Start: startIndexOds, - SharesLength: sharesLength, + SharesLength: uint64(sharesLength), TxCommitment: txCommitment, DataRoot: dataRoot, } diff --git a/go.mod b/go.mod index 78dd2797f2..c90591b047 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( github.com/holiman/uint256 v1.2.4 github.com/ipfs/boxo v0.13.1 github.com/ipfs/go-cid v0.4.1 - github.com/ipfs/go-libipfs v0.7.0 github.com/ipfs/interface-go-ipfs-core v0.11.0 github.com/ipfs/kubo v0.23.0 github.com/knadh/koanf v1.4.0 @@ -167,6 +166,7 @@ require ( github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect github.com/ipfs/go-ipfs-delay v0.0.1 // indirect github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect + github.com/ipfs/go-ipfs-files v0.3.0 // indirect github.com/ipfs/go-ipfs-pq v0.0.3 // indirect github.com/ipfs/go-ipfs-redirects-file v0.1.1 // indirect github.com/ipfs/go-ipfs-util v0.0.3 // indirect diff --git a/go.sum b/go.sum index 145dcd01f3..16fc8c177c 100644 --- a/go.sum +++ b/go.sum @@ -646,6 +646,7 @@ github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNo github.com/ipfs/go-ipfs-exchange-interface v0.2.0 h1:8lMSJmKogZYNo2jjhUs0izT+dck05pqUw4mWNW9Pw6Y= github.com/ipfs/go-ipfs-exchange-offline v0.3.0 h1:c/Dg8GDPzixGd0MC8Jh6mjOwU57uYokgWRFidfvEkuA= github.com/ipfs/go-ipfs-files v0.3.0 h1:fallckyc5PYjuMEitPNrjRfpwl7YFt69heCOUhsbGxQ= +github.com/ipfs/go-ipfs-files v0.3.0/go.mod h1:xAUtYMwB+iu/dtf6+muHNSFQCJG2dSiStR2P6sn9tIM= github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs= github.com/ipfs/go-ipfs-pq v0.0.3 h1:YpoHVJB+jzK15mr/xsWC574tyDLkezVrDNeaalQBsTE= github.com/ipfs/go-ipfs-pq v0.0.3/go.mod h1:btNw5hsHBpRcSSgZtiNm/SLj5gYIZ18AKtv3kERkRb4= @@ -665,7 +666,6 @@ github.com/ipfs/go-ipld-git v0.1.1/go.mod h1:+VyMqF5lMcJh4rwEppV0e6g4nCCHXThLYYD github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk= github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM= github.com/ipfs/go-libipfs v0.7.0 h1:Mi54WJTODaOL2/ZSm5loi3SwI3jI2OuFWUrQIkJ5cpM= -github.com/ipfs/go-libipfs v0.7.0/go.mod h1:KsIf/03CqhICzyRGyGo68tooiBE2iFbI/rXW7FhAYr0= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= github.com/ipfs/go-log v1.0.3/go.mod h1:OsLySYkwIbiSUR/yBTdv1qPtcE4FW3WPWk/ewz9Ru+A= github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= diff --git a/solgen/gen.go b/solgen/gen.go index 770fa08571..bd83e8d500 100644 --- a/solgen/gen.go +++ b/solgen/gen.go @@ -9,6 +9,7 @@ import ( "log" "os" "path/filepath" + "regexp" "runtime" "strings" @@ -118,6 +119,10 @@ func main() { _, file := filepath.Split(path) name := file[:len(file)-5] + if regexp.MustCompile(`^[0-9a-fA-F]+$`).MatchString(name) { + continue + } + data, err := os.ReadFile(path) if err != nil { log.Fatal("could not read", path, "for contract", name, err)