Skip to content

Commit

Permalink
Required quorums glitch (#255)
Browse files Browse the repository at this point in the history
* Avoid quorum 1 check on range of Holesky blocks

* Improve SVC address check

* Update verify/verifier.go

Co-authored-by: Samuel Laferriere <[email protected]>

* Update verify/verifier.go

Co-authored-by: Samuel Laferriere <[email protected]>

* Avoid unnecessary cast

* Rename constant

* Fix lint

---------

Co-authored-by: Samuel Laferriere <[email protected]>
  • Loading branch information
gastonponti and samlaf authored Jan 24, 2025
1 parent ad8ad21 commit 5715ace
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"

"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark-crypto/ecc/bn254"
Expand All @@ -17,6 +18,10 @@ import (
"github.com/Layr-Labs/eigenda/encoding/rs"
)

const (
HoleskySVCManagerV1Address = "0xD4A7E1Bd8015057293f0D0A557088c286942e84b"
)

type Config struct {
KzgConfig *kzg.KzgConfig
VerifyCerts bool
Expand Down Expand Up @@ -45,6 +50,8 @@ type Verifier struct {
// cert verification is optional, and verifies certs retrieved from eigenDA when turned on
verifyCerts bool
cv *CertVerifier
// holesky is a flag to enable/disable holesky specific checks
holesky bool
}

func NewVerifier(cfg *Config, l log.Logger) (*Verifier, error) {
Expand All @@ -67,6 +74,7 @@ func NewVerifier(cfg *Config, l log.Logger) (*Verifier, error) {
kzgVerifier: kzgVerifier,
verifyCerts: cfg.VerifyCerts,
cv: cv,
holesky: isHolesky(cfg.SvcManagerAddr),
}, nil
}

Expand Down Expand Up @@ -183,11 +191,27 @@ func (v *Verifier) verifySecurityParams(blobHeader BlobHeader, batchHeader *disp
}

// ensure that required quorums are present in the confirmed ones
for _, quorum := range v.cv.quorumsRequired {
for _, quorum := range requiredQuorum(batchHeader.ReferenceBlockNumber, v) {
if !confirmedQuorums[quorum] {
return fmt.Errorf("quorum %d is required but not present in confirmed quorums", quorum)
}
}

return nil
}

func requiredQuorum(referenceBlockNumber uint32, v *Verifier) []uint8 {
// This check is required due to a bug we had when we updated the EigenDAServiceManager in Holesky. For a brief period of time, the quorum 1 was not
// required for the commitment to be confirmed, so the disperser created batches with only quorum 0 signatures.
// Archive nodes trying to sync from these stored batches would thus fail validation here since
// quorumsRequired is read from the latestBlock, where the bug has been fixed and both quorums are required.
// This check is only for testnet and for a specific block range.
if v.holesky && referenceBlockNumber >= 2950000 && referenceBlockNumber < 2960000 {
return []uint8{0}
}
return v.cv.quorumsRequired
}

func isHolesky(svcAddress string) bool {
return strings.EqualFold(strings.TrimPrefix(svcAddress, "0x"), strings.TrimPrefix(HoleskySVCManagerV1Address, "0x"))
}

0 comments on commit 5715ace

Please sign in to comment.