Skip to content

Commit

Permalink
fix: fetch quorum parameters from edasm at RBN instead of latest block
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Oct 24, 2024
1 parent 0035323 commit 4cf63fd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package verify

import (
"fmt"
"math/big"

"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/consensys/gnark-crypto/ecc/bn254/fp"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/log"

binding "github.com/Layr-Labs/eigenda/contracts/bindings/EigenDAServiceManager"
Expand Down Expand Up @@ -149,8 +151,9 @@ func (v *Verifier) VerifySecurityParams(blobHeader BlobHeader, batchHeader bindi
if blobHeader.QuorumBlobParams[i].AdversaryThresholdPercentage > blobHeader.QuorumBlobParams[i].ConfirmationThresholdPercentage {
return fmt.Errorf("adversary threshold percentage must be greater than or equal to confirmation threshold percentage")
}

quorumAdversaryThreshold, err := v.getQuorumAdversaryThreshold(blobHeader.QuorumBlobParams[i].QuorumNumber)
// we get the quorum adversary threshold at the batch's reference block number, since that is the parameter
// that the eigenda disperser used to verify the batch signature's validity
quorumAdversaryThreshold, err := v.getQuorumAdversaryThreshold(blobHeader.QuorumBlobParams[i].QuorumNumber, int64(batchHeader.ReferenceBlockNumber))
if err != nil {
log.Warn("failed to get quorum adversary threshold", "err", err)
}
Expand All @@ -166,9 +169,9 @@ func (v *Verifier) VerifySecurityParams(blobHeader BlobHeader, batchHeader bindi
confirmedQuorums[blobHeader.QuorumBlobParams[i].QuorumNumber] = true
}

requiredQuorums, err := v.cv.manager.QuorumNumbersRequired(nil)
requiredQuorums, err := v.cv.manager.QuorumNumbersRequired(&bind.CallOpts{BlockNumber: big.NewInt(int64(batchHeader.ReferenceBlockNumber))})
if err != nil {
log.Warn("failed to get required quorum numbers", "err", err)
log.Warn("failed to get required quorum numbers at block number", "err", err, "referenceBlockNumber", batchHeader.ReferenceBlockNumber)
}

// ensure that required quorums are present in the confirmed ones
Expand All @@ -181,10 +184,10 @@ func (v *Verifier) VerifySecurityParams(blobHeader BlobHeader, batchHeader bindi
return nil
}

// getQuorumAdversaryThreshold reads the adversarial threshold percentage for a given quorum number
// returns 0 if DNE
func (v *Verifier) getQuorumAdversaryThreshold(quorumNum uint8) (uint8, error) {
percentages, err := v.cv.manager.QuorumAdversaryThresholdPercentages(nil)
// getQuorumAdversaryThreshold reads the adversarial threshold percentage for a given quorum number,
// at a given block number. If the quorum number does not exist, it returns 0.
func (v *Verifier) getQuorumAdversaryThreshold(quorumNum uint8, blockNumber int64) (uint8, error) {
percentages, err := v.cv.manager.QuorumAdversaryThresholdPercentages(&bind.CallOpts{BlockNumber: big.NewInt(blockNumber)})
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 4cf63fd

Please sign in to comment.