only initialize kzg if it will be used (#12803)

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
kasey
2023-08-25 08:56:31 -05:00
committed by Preston Van Loon
parent 5cf7b0458f
commit 34b995d0de
2 changed files with 14 additions and 3 deletions

View File

@@ -103,9 +103,12 @@ type blobNotifier struct {
// NewService instantiates a new block service instance that will
// be registered into a running beacon node.
func NewService(ctx context.Context, opts ...Option) (*Service, error) {
err := kzg.Start()
if err != nil {
return nil, errors.Wrap(err, "could not initialize go-kzg context")
var err error
if params.DenebEnabled() {
err = kzg.Start()
if err != nil {
return nil, errors.Wrap(err, "could not initialize go-kzg context")
}
}
ctx, cancel := context.WithCancel(ctx)
bn := &blobNotifier{

View File

@@ -2,6 +2,7 @@
package params
import (
"math"
"time"
"github.com/ethereum/go-ethereum/common"
@@ -275,3 +276,10 @@ func (b *BeaconChainConfig) PreviousEpochAttestationsLength() uint64 {
func (b *BeaconChainConfig) CurrentEpochAttestationsLength() uint64 {
return uint64(b.SlotsPerEpoch.Mul(b.MaxAttestations))
}
// DenebEnabled centralizes the check to determine if code paths
// that are specific to deneb should be allowed to execute. This will make it easier to find call sites that do this
// kind of check and remove them post-deneb.
func DenebEnabled() bool {
return BeaconConfig().DenebForkEpoch < math.MaxUint64
}