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

fix: fetch quorum parameters from edasm at RBN instead of latest block #190

Merged
Merged
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
20 changes: 12 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,10 @@ 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. This is not strictly needed right now
// since this threshold is hardcoded into the contract: https://github.com/Layr-Labs/eigenda/blob/master/contracts/src/core/EigenDAServiceManagerStorage.sol
// but it is good practice in case the contract changes in the future
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 +170,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 +185,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
Loading