|
4 | 4 | "context"
|
5 | 5 | "crypto/rand"
|
6 | 6 | "fmt"
|
| 7 | + "math/big" |
7 | 8 | "sync"
|
8 | 9 | "time"
|
9 | 10 |
|
@@ -149,43 +150,55 @@ func (e *MemStore) Put(ctx context.Context, value []byte) ([]byte, error) {
|
149 | 150 | if err != nil {
|
150 | 151 | return nil, err
|
151 | 152 | }
|
152 |
| - mockBatchHeaderHash := crypto.Keccak256Hash(entropy) |
| 153 | + mockBatchRoot := crypto.Keccak256Hash(entropy) |
| 154 | + blockNum, _ := rand.Int(rand.Reader, big.NewInt(1000)) |
| 155 | + |
| 156 | + num := uint32(blockNum.Uint64()) |
153 | 157 |
|
154 |
| - // only filling out commitment fields for now |
155 | 158 | cert := &verify.Certificate{
|
156 | 159 | BlobHeader: &disperser.BlobHeader{
|
157 | 160 | Commitment: &common.G1Commitment{
|
158 | 161 | X: commitment.X.Marshal(),
|
159 | 162 | Y: commitment.Y.Marshal(),
|
160 | 163 | },
|
161 |
| - // DataLength: , |
162 |
| - // BlobQuorumParams: , |
| 164 | + DataLength: uint32(len(encodedVal)), |
| 165 | + BlobQuorumParams: []*disperser.BlobQuorumParam{ |
| 166 | + { |
| 167 | + QuorumNumber: 1, |
| 168 | + AdversaryThresholdPercentage: 29, |
| 169 | + ConfirmationThresholdPercentage: 30, |
| 170 | + ChunkLength: 300, |
| 171 | + }, |
| 172 | + }, |
163 | 173 | },
|
164 | 174 | BlobVerificationProof: &disperser.BlobVerificationProof{
|
165 | 175 | BatchMetadata: &disperser.BatchMetadata{
|
166 | 176 | BatchHeader: &disperser.BatchHeader{
|
167 |
| - // BatchRoot: , |
168 |
| - // QuorumNumbers: , |
169 |
| - // QuorumSignedPercentages: , |
170 |
| - // ReferenceBlockNumber: , |
| 177 | + BatchRoot: mockBatchRoot[:], |
| 178 | + QuorumNumbers: []byte{0x1, 0x0}, |
| 179 | + QuorumSignedPercentages: []byte{0x60, 0x90}, |
| 180 | + ReferenceBlockNumber: num, |
171 | 181 | },
|
172 |
| - // SignatoryRecordHash: , |
173 |
| - // Fee: , |
174 |
| - // ConfirmationBlockNumber: , |
175 |
| - BatchHeaderHash: mockBatchHeaderHash[:], |
| 182 | + SignatoryRecordHash: mockBatchRoot[:], |
| 183 | + Fee: []byte{}, |
| 184 | + ConfirmationBlockNumber: num, |
| 185 | + BatchHeaderHash: []byte{}, |
176 | 186 | },
|
177 |
| - // BatchId: , |
178 |
| - // BlobIndex: , |
179 |
| - // InclusionProof: , |
180 |
| - // QuorumIndexes: , |
| 187 | + BatchId: 69, |
| 188 | + BlobIndex: 420, |
| 189 | + InclusionProof: entropy, |
| 190 | + QuorumIndexes: []byte{0x1, 0x0}, |
181 | 191 | },
|
182 | 192 | }
|
183 | 193 |
|
184 | 194 | certBytes, err := rlp.EncodeToBytes(cert)
|
185 | 195 | if err != nil {
|
186 | 196 | return nil, err
|
187 | 197 | }
|
188 |
| - certStr := string(certBytes) |
| 198 | + // construct key |
| 199 | + bytesKeys := append([]byte{0x4}, cert.BlobVerificationProof.InclusionProof...) |
| 200 | + |
| 201 | + certStr := string(bytesKeys) |
189 | 202 |
|
190 | 203 | if _, exists := e.store[certStr]; exists {
|
191 | 204 | return nil, fmt.Errorf("commitment key already exists")
|
|
0 commit comments