Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress signatures in minibatch response #699

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,14 @@ func TestParseOperatorSocket(t *testing.T) {
assert.NotNil(t, err)
assert.Equal(t, "invalid socket address format: localhost1234;5678", err.Error())
}

func TestSignatureBytes(t *testing.T) {
sig := &core.Signature{
G1Point: core.NewG1Point(big.NewInt(1), big.NewInt(2)),
}
bytes := sig.Bytes()
recovered := new(bn254.G1Affine)
_, err := recovered.SetBytes(bytes[:])
assert.NoError(t, err)
assert.Equal(t, recovered, sig.G1Point.G1Affine)
}
10 changes: 5 additions & 5 deletions disperser/batcher/batch_confirmer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func TestBatchConfirmerIteration(t *testing.T) {
NumBlobs: 1,
RequestedAt: time.Now(),
DispersalResponse: bat.DispersalResponse{
Signatures: []*core.Signature{opInfo.KeyPair.SignMessage(batchHeaderHash1)},
Signatures: [][32]byte{opInfo.KeyPair.SignMessage(batchHeaderHash1).Bytes()},
RespondedAt: time.Now(),
Error: nil,
},
Expand All @@ -215,7 +215,7 @@ func TestBatchConfirmerIteration(t *testing.T) {
NumBlobs: 1,
RequestedAt: time.Now(),
DispersalResponse: bat.DispersalResponse{
Signatures: []*core.Signature{opInfo.KeyPair.SignMessage(batchHeaderHash2)},
Signatures: [][32]byte{opInfo.KeyPair.SignMessage(batchHeaderHash2).Bytes()},
RespondedAt: time.Now(),
Error: nil,
},
Expand Down Expand Up @@ -359,7 +359,7 @@ func TestBatchConfirmerIterationFailure(t *testing.T) {
NumBlobs: 2,
RequestedAt: time.Now(),
DispersalResponse: bat.DispersalResponse{
Signatures: []*core.Signature{opInfo.KeyPair.SignMessage([32]byte{0})},
Signatures: [][32]byte{opInfo.KeyPair.SignMessage([32]byte{0}).Bytes()},
RespondedAt: time.Now(),
Error: nil,
},
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestBatchConfirmerInsufficientSignatures(t *testing.T) {
NumBlobs: 2,
RequestedAt: time.Now(),
DispersalResponse: bat.DispersalResponse{
Signatures: []*core.Signature{opInfo.KeyPair.SignMessage([32]byte{0})},
Signatures: [][32]byte{opInfo.KeyPair.SignMessage([32]byte{0}).Bytes()},
RespondedAt: time.Now(),
Error: nil,
},
Expand All @@ -449,7 +449,7 @@ func TestBatchConfirmerInsufficientSignatures(t *testing.T) {
NumBlobs: 2,
RequestedAt: time.Now(),
DispersalResponse: bat.DispersalResponse{
Signatures: []*core.Signature{opInfo.KeyPair.SignMessage([32]byte{1})},
Signatures: [][32]byte{opInfo.KeyPair.SignMessage([32]byte{1}).Bytes()},
RespondedAt: time.Now(),
Error: nil,
},
Expand Down
5 changes: 4 additions & 1 deletion disperser/batcher/minibatch_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ type BatchRecord struct {
}

type DispersalResponse struct {
Signatures []*core.Signature
// Signatures is the signatures of the blobs that were dispersed to the operator
// The order of the signatures is the same as the order of the blobs in the minibatch
// The signatures are compressed using G1Affine.Bytes(), to be decompressed using G1Affine.SetBytes()
Signatures [][32]byte
RespondedAt time.Time
Error error
}
Expand Down
6 changes: 5 additions & 1 deletion disperser/batcher/minibatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,13 @@ func (b *Minibatcher) DisperseBatch(ctx context.Context, state *core.IndexedOper
if err != nil {
b.logger.Errorf("failed to send blobs to operator %s: %v", opID.Hex(), err)
}
compressedSignatures := make([][32]byte, 0, len(signatures))
for _, signature := range signatures {
compressedSignatures = append(compressedSignatures, signature.Bytes())
}
// Update the minibatch state
err = b.MinibatchStore.UpdateDispersalResponse(ctx, req, &DispersalResponse{
Signatures: signatures,
Signatures: compressedSignatures,
RespondedAt: time.Now().UTC(),
Error: err,
})
Expand Down
Loading