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

Filter empty quorums when confirming batch #581

Merged
merged 3 commits into from
Jun 3, 2024

Conversation

ian-shim
Copy link
Contributor

Why are these changes needed?

With additional (custom) quorums, blobs may fail to get attested by some quorums and the current implementation would still post the batch including all the non-signers in the failed quorums.
This PR makes batcher inspect the quorum results and filter out empty quorums when submitting the batch confirmation transaction onchain.

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@ian-shim ian-shim force-pushed the batch-quorum-filter branch from 62afa3b to f96b9cf Compare May 24, 2024 10:44
@ian-shim ian-shim marked this pull request as ready for review May 24, 2024 11:17
@@ -579,23 +587,25 @@ func (b *Batcher) getBatchID(ctx context.Context, txReceipt *types.Receipt) (uin
return batchID, nil
}

// numBlobsAttested returns the number of blobs that have been successfully attested by the given quorums
func numBlobsAttested(signedQuorums map[core.QuorumID]*core.QuorumResult, headers []*core.BlobHeader) int {
// numBlobsAttestedByQuorum returns the number of blobs that have been successfully attested by the given quorums
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the number of blobs that have been attested by all given quorums is still returned

nonEmptyQuorums := []core.QuorumID{}
for quorumID, count := range numPassedByQuorum {
log.Info("Blobs attested by quorum", "quorumID", quorumID, "count", count)
if count > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this filter out quorums that have a signing rate below confirmation threshold?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be already filtering out quorums that have a signing rate below the confirmation threshold.
count here in numPassedByQuorum is the number of blobs that have signing rate above the confirmation threshold, and we're filtering out quorums with count == 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all blobs are in the same batch, they have the same signing rate for a given quorum. It looks this doesn't need to count num blobs (it's going to be either 0 or Num-Blobs), just whether the quorum collected sufficient signing rate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, what you're suggesting is that we can make this logic simpler by simply comparing the quorum result vs. the confirmation threshold required at each quorum which is hardcoded in contracts. Correct?
But then the batcher needs to be aware of those thresholds and make an assumption that all blobs will be dispersed using the same thresholds for each quorum.
Comparing the security params for each blobs with the quorums results allows the batcher to just use the security params set at each blob and filter quorums more generally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think numBlobsAttestedByQuorum may just return a set of quorumIDs that have collected sufficient signatures. It's semantically more clear but cutting away the count since it's 0 or all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated

// including those that did not sign
QuorumAggPubKey map[QuorumID]*G1Point
// SignersAggPubKey is the aggregated public key for all of the operators that signed the message for each quorum,
// further aggregated across the quorums; operators signing for multiple quorums will be included in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this doesn't aggregate across quorums now (it's per quorum)

// SignersAggPubKey is the aggregated public key for all of the operators that signed the message for each quorum,
// further aggregated across the quorums; operators signing for multiple quorums will be included in
// the aggregation multiple times
SignersAggPubKey map[QuorumID]*G2Point
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pubkey is G2 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It aggregates operator's PubKeyG2

// QuorumResults contains the quorum ID and the amount signed for each quorum
QuorumResults map[QuorumID]*QuorumResult
// SignerMap contains the operator IDs that signed the message
SignerMap map[OperatorID]bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not per quorum, should it be left at in SignatureAggregation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a bit awkward because it's the only field not divided into quorums. But it's easier to track this map at the stage of receiving signatures. I added a comment in the struct to clarify what this field is

@ian-shim ian-shim force-pushed the batch-quorum-filter branch from f96b9cf to 3056bcc Compare May 31, 2024 01:46
@ian-shim ian-shim requested a review from jianoaix May 31, 2024 07:03
@ian-shim ian-shim merged commit c17a0b0 into Layr-Labs:master Jun 3, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants