Skip to content

Commit

Permalink
[v2] Add quorum results to attestation (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-shim authored Dec 19, 2024
1 parent aba75de commit 1345e77
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 77 deletions.
11 changes: 10 additions & 1 deletion api/docs/disperser_v2.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ <h3 id="disperser.v2.Attestation">Attestation</h3>
<td>quorum_apks</td>
<td><a href="#bytes">bytes</a></td>
<td>repeated</td>
<td><p>Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum </p></td>
<td><p>Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum
The order of the quorum_apks should match the order of the quorum_numbers </p></td>
</tr>

<tr>
Expand All @@ -305,6 +306,14 @@ <h3 id="disperser.v2.Attestation">Attestation</h3>
<td><p>Relevant quorum numbers for the attestation </p></td>
</tr>

<tr>
<td>quorum_signed_percentages</td>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>The attestation rate for each quorum.
The order of the quorum_signed_percentages should match the order of the quorum_numbers </p></td>
</tr>

</tbody>
</table>

Expand Down
3 changes: 2 additions & 1 deletion api/docs/disperser_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
| ----- | ---- | ----- | ----------- |
| non_signer_pubkeys | [bytes](#bytes) | repeated | Serialized bytes of non signer public keys (G1 points) |
| apk_g2 | [bytes](#bytes) | | Serialized bytes of G2 point that represents aggregate public key of all signers |
| quorum_apks | [bytes](#bytes) | repeated | Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum |
| quorum_apks | [bytes](#bytes) | repeated | Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum The order of the quorum_apks should match the order of the quorum_numbers |
| sigma | [bytes](#bytes) | | Serialized bytes of aggregate signature |
| quorum_numbers | [uint32](#uint32) | repeated | Relevant quorum numbers for the attestation |
| quorum_signed_percentages | [bytes](#bytes) | | The attestation rate for each quorum. The order of the quorum_signed_percentages should match the order of the quorum_numbers |



Expand Down
11 changes: 10 additions & 1 deletion api/docs/eigenda-protos.html
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,8 @@ <h3 id="disperser.v2.Attestation">Attestation</h3>
<td>quorum_apks</td>
<td><a href="#bytes">bytes</a></td>
<td>repeated</td>
<td><p>Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum </p></td>
<td><p>Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum
The order of the quorum_apks should match the order of the quorum_numbers </p></td>
</tr>

<tr>
Expand All @@ -1976,6 +1977,14 @@ <h3 id="disperser.v2.Attestation">Attestation</h3>
<td><p>Relevant quorum numbers for the attestation </p></td>
</tr>

<tr>
<td>quorum_signed_percentages</td>
<td><a href="#bytes">bytes</a></td>
<td></td>
<td><p>The attestation rate for each quorum.
The order of the quorum_signed_percentages should match the order of the quorum_numbers </p></td>
</tr>

</tbody>
</table>

Expand Down
3 changes: 2 additions & 1 deletion api/docs/eigenda-protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,10 @@ If DisperseBlob returns the following error codes: INVALID_ARGUMENT (400): reque
| ----- | ---- | ----- | ----------- |
| non_signer_pubkeys | [bytes](#bytes) | repeated | Serialized bytes of non signer public keys (G1 points) |
| apk_g2 | [bytes](#bytes) | | Serialized bytes of G2 point that represents aggregate public key of all signers |
| quorum_apks | [bytes](#bytes) | repeated | Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum |
| quorum_apks | [bytes](#bytes) | repeated | Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum The order of the quorum_apks should match the order of the quorum_numbers |
| sigma | [bytes](#bytes) | | Serialized bytes of aggregate signature |
| quorum_numbers | [uint32](#uint32) | repeated | Relevant quorum numbers for the attestation |
| quorum_signed_percentages | [bytes](#bytes) | | The attestation rate for each quorum. The order of the quorum_signed_percentages should match the order of the quorum_numbers |



Expand Down
151 changes: 83 additions & 68 deletions api/grpc/disperser/v2/disperser_v2.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions api/proto/disperser/v2/disperser_v2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ message Attestation {
// Serialized bytes of G2 point that represents aggregate public key of all signers
bytes apk_g2 = 2;
// Serialized bytes of aggregate public keys (G1 points) from all nodes for each quorum
// The order of the quorum_apks should match the order of the quorum_numbers
repeated bytes quorum_apks = 3;
// Serialized bytes of aggregate signature
bytes sigma = 4;
// Relevant quorum numbers for the attestation
repeated uint32 quorum_numbers = 5;
// The attestation rate for each quorum.
// The order of the quorum_signed_percentages should match the order of the quorum_numbers
bytes quorum_signed_percentages = 6;
}

message PaymentGlobalParams {
Expand Down
15 changes: 10 additions & 5 deletions core/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ type Attestation struct {
Sigma *core.Signature
// QuorumNumbers contains the quorums relevant for the attestation
QuorumNumbers []core.QuorumID
// QuorumResults contains the results of the quorum verification
QuorumResults map[core.QuorumID]uint8
}

func (a *Attestation) ToProtobuf() (*disperserpb.Attestation, error) {
Expand All @@ -323,6 +325,7 @@ func (a *Attestation) ToProtobuf() (*disperserpb.Attestation, error) {

quorumAPKs := make([][]byte, len(a.QuorumAPKs))
quorumNumbers := make([]uint32, len(a.QuorumNumbers))
quorumResults := make([]uint8, len(a.QuorumResults))
for i, q := range a.QuorumNumbers {
quorumNumbers[i] = uint32(q)

Expand All @@ -332,17 +335,19 @@ func (a *Attestation) ToProtobuf() (*disperserpb.Attestation, error) {
}
apkBytes := apk.Bytes()
quorumAPKs[i] = apkBytes[:]
quorumResults[i] = a.QuorumResults[q]
}

apkG2Bytes := a.APKG2.Bytes()
sigmaBytes := a.Sigma.Bytes()

return &disperserpb.Attestation{
NonSignerPubkeys: nonSignerPubKeys,
ApkG2: apkG2Bytes[:],
QuorumApks: quorumAPKs,
Sigma: sigmaBytes[:],
QuorumNumbers: quorumNumbers,
NonSignerPubkeys: nonSignerPubKeys,
ApkG2: apkG2Bytes[:],
QuorumApks: quorumAPKs,
Sigma: sigmaBytes[:],
QuorumNumbers: quorumNumbers,
QuorumSignedPercentages: quorumResults,
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions disperser/common/v2/blobstore/dynamo_metadata_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ func TestBlobMetadataStoreBatchAttestation(t *testing.T) {
G1Point: core.NewG1Point(big.NewInt(9), big.NewInt(10)),
},
QuorumNumbers: []core.QuorumID{0, 1},
QuorumResults: map[uint8]uint8{
0: 100,
1: 80,
},
}

err = blobMetadataStore.PutAttestation(ctx, attestation)
Expand Down
5 changes: 5 additions & 0 deletions disperser/controller/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ func (d *Dispatcher) HandleSignatures(ctx context.Context, batchData *batchData,
return fmt.Errorf("failed to aggregate signatures for batch %s: %w", batchHeaderHash, err)
}

quorumResults := make(map[core.QuorumID]uint8)
for quorumID, result := range quorumAttestation.QuorumResults {
quorumResults[quorumID] = result.PercentSigned
}
err = d.blobMetadataStore.PutAttestation(ctx, &corev2.Attestation{
BatchHeader: batchData.Batch.BatchHeader,
AttestedAt: uint64(time.Now().UnixNano()),
Expand All @@ -282,6 +286,7 @@ func (d *Dispatcher) HandleSignatures(ctx context.Context, batchData *batchData,
QuorumAPKs: aggSig.QuorumAggPubKeys,
Sigma: aggSig.AggSignature,
QuorumNumbers: nonZeroQuorums,
QuorumResults: quorumResults,
})
putAttestationFinished := time.Now()
d.metrics.reportPutAttestationLatency(putAttestationFinished.Sub(aggregateSignaturesFinished))
Expand Down
1 change: 1 addition & 0 deletions disperser/controller/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestDispatcherHandleBatch(t *testing.T) {
require.Len(t, att.QuorumAPKs, 2)
require.NotNil(t, att.Sigma)
require.ElementsMatch(t, att.QuorumNumbers, []core.QuorumID{0, 1})
require.InDeltaMapValues(t, map[core.QuorumID]uint8{0: 100, 1: 100}, att.QuorumResults, 0)

deleteBlobs(t, components.BlobMetadataStore, objs.blobKeys, [][32]byte{bhh})
}
Expand Down
10 changes: 10 additions & 0 deletions inabox/tests/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ var _ = Describe("Inabox v2 Integration", func() {
Expect(batchHeader1.GetReferenceBlockNumber()).To(BeNumerically(">", 0))
attestation := reply1.GetSignedBatch().GetAttestation()
Expect(attestation).To(Not(BeNil()))
Expect(attestation.QuorumNumbers).To(Equal([]uint32{0, 1}))
Expect(len(attestation.NonSignerPubkeys)).To(Equal(0))
Expect(attestation.ApkG2).To(Not(BeNil()))
Expect(len(attestation.QuorumApks)).To(Equal(2))
Expect(attestation.QuorumSignedPercentages).To(Equal([]byte{100, 100}))
blobVerification := reply1.GetBlobVerificationInfo()
Expect(blobVerification).To(Not(BeNil()))
Expect(blobVerification.GetBlobCertificate()).To(Not(BeNil()))
Expand All @@ -116,6 +121,11 @@ var _ = Describe("Inabox v2 Integration", func() {
Expect(batchHeader2.GetReferenceBlockNumber()).To(BeNumerically(">", 0))
attestation = reply2.GetSignedBatch().GetAttestation()
Expect(attestation).To(Not(BeNil()))
Expect(attestation.QuorumNumbers).To(Equal([]uint32{0, 1}))
Expect(len(attestation.NonSignerPubkeys)).To(Equal(0))
Expect(attestation.ApkG2).To(Not(BeNil()))
Expect(len(attestation.QuorumApks)).To(Equal(2))
Expect(attestation.QuorumSignedPercentages).To(Equal([]byte{100, 100}))
blobVerification = reply2.GetBlobVerificationInfo()
Expect(blobVerification).To(Not(BeNil()))
Expect(blobVerification.GetBlobCertificate()).To(Not(BeNil()))
Expand Down

0 comments on commit 1345e77

Please sign in to comment.