Skip to content

Commit

Permalink
fix: split in column
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniFrenchBread committed Feb 7, 2024
1 parent 6af4ec5 commit 4cd23bd
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 17 deletions.
39 changes: 39 additions & 0 deletions core/locate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package core

func AllocateChunks(encodedBlobs []*BlobLocation) uint {
n := len(encodedBlobs)
allocated := make([]int, n)
segments := uint(0)
for i := 0; i < n; {
offset := uint(0)
// allocate by column
for j := i; i < n; {
if allocated[j] == int(encodedBlobs[j].ChunkNum) {
// encoded blob is fully allocated
if j == i {
i++
}
} else {
// try to fill one chunk + proof
l := encodedBlobs[j].ChunkLength*CoeffSize + ProofSize
if offset+l <= SegmentSize {
encodedBlobs[j].SegmentIndexes[allocated[j]] = segments
encodedBlobs[j].Offsets[allocated[j]] = offset
allocated[j]++
offset += l
} else {
break
}
}
// move to next blob
j++
if j >= n {
j = i
}
}
if offset > 0 {
segments++
}
}
return segments
}
7 changes: 7 additions & 0 deletions disperser/batcher/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ func (c *dispatcher) DisperseBatch(ctx context.Context, batchHeaderHash [32]byte
return eth_common.Hash{}, errors.WithMessage(err, "failed to build encoded blobs data")
}

// calculate data root
tree, err := zg_core.MerkleTree(encodedBlobsData)
if err != nil {
return eth_common.Hash{}, errors.WithMessage(err, "failed to get encoded data merkle tree")
}
batchHeader.DataRoot = tree.Root()

// kv
// batcher info
batcher := c.KVNode.Batcher()
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ require (
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand Down Expand Up @@ -127,8 +126,6 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rs/zerolog v1.29.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
Expand Down
13 changes: 0 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY=
github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI=
Expand Down Expand Up @@ -803,12 +802,8 @@ github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
Expand Down Expand Up @@ -906,14 +901,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zero-gravity-labs/zerog-storage-client v0.1.8 h1:ceUxq7alFqUsaPIuk9/RxzjfMh+q5AZNaf1LhqGeAMk=
github.com/zero-gravity-labs/zerog-storage-client v0.1.8/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4=
github.com/zero-gravity-labs/zerog-storage-client v0.1.9 h1:Ns/iQXEfDJWyU0L8e13RPt1xdYJwVYWLwYIqNRDG2Cs=
github.com/zero-gravity-labs/zerog-storage-client v0.1.9/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4=
github.com/zero-gravity-labs/zerog-storage-client v0.1.10 h1:iIa6kqkBVPIoyjaPYxId4qs1yL9lxM8x1nwOJb2d1xM=
github.com/zero-gravity-labs/zerog-storage-client v0.1.10/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4=
github.com/zero-gravity-labs/zerog-storage-client v0.1.11 h1:oxHBlbL55uO8v8G4SjgYbdXLVW1WEU1j2VUTqavQWoo=
github.com/zero-gravity-labs/zerog-storage-client v0.1.11/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4=
github.com/zero-gravity-labs/zerog-storage-client v0.1.12 h1:jIHUfhAw3KREyqMuksJ/2K9pLl/9uN9c317mJuHadKY=
github.com/zero-gravity-labs/zerog-storage-client v0.1.12/go.mod h1:X0u50IkiCmB9hchf8mEiIWyk6bLlo0d2xAxrPPK8IZ4=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
3 changes: 2 additions & 1 deletion retriever/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package retriever

import (
"context"
"encoding/hex"
"fmt"

eth_common "github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -73,7 +74,7 @@ func (s *Server) RetrieveBlob(ctx context.Context, req *pb.BlobRequest) (*pb.Blo
if err != nil {
return nil, err
}
s.logger.Debugf("server fetched batch header: %v", *batchInfo.BatchHeader)
s.logger.Debugf("server fetched batch header, batch root: %v, data root: %v", hex.EncodeToString(batchInfo.BatchHeader.BatchRoot[:]), batchInfo.DataRoot)

data, err := s.retrievalClient.RetrieveBlob(
ctx,
Expand Down

0 comments on commit 4cd23bd

Please sign in to comment.