Skip to content

Commit

Permalink
fix index issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferret-san committed Aug 5, 2024
1 parent 5a9e7a0 commit 3926eb5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/ipfshelper/ipfshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 18 additions & 6 deletions das/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
5 changes: 5 additions & 0 deletions solgen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"
"path/filepath"
"regexp"
"runtime"
"strings"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3926eb5

Please sign in to comment.