Skip to content

Commit

Permalink
Check for SIGILL before using gohashtree (prysmaticlabs#11224)
Browse files Browse the repository at this point in the history
* Check for SIGILL before using gohashtree

* gohashtree dep

* check error

* move to config startup

* Kasey's advice

* review #1

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 16, 2022
1 parent 2728b83 commit 85ad61e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/features/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
deps = [
"//cmd:go_default_library",
"//config/params:go_default_library",
"@com_github_prysmaticlabs_gohashtree//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli_v2//:go_default_library",
],
Expand Down
23 changes: 21 additions & 2 deletions config/features/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ The process for implementing new features using this package is as follows:
package features

import (
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/prysmaticlabs/gohashtree"
"github.com/prysmaticlabs/prysm/v3/cmd"
"github.com/prysmaticlabs/prysm/v3/config/params"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -225,8 +229,23 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
cfg.DisablePullTips = true
}
if ctx.Bool(enableVecHTR.Name) {
logEnabled(enableVecHTR)
cfg.EnableVectorizedHTR = true
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGILL)
defer signal.Stop(sigc)
buffer := make([][32]byte, 2)
err := gohashtree.Hash(buffer, buffer)
if err != nil {
log.Error("could not test if gohashtree is supported")
} else {
t := time.NewTimer(time.Millisecond * 100)
select {
case <-sigc:
log.Error("gohashtree is not supported in this CPU")
case <-t.C:
logEnabled(enableVecHTR)
cfg.EnableVectorizedHTR = true
}
}
}
if ctx.Bool(disableForkChoiceDoublyLinkedTree.Name) {
logEnabled(disableForkChoiceDoublyLinkedTree)
Expand Down

0 comments on commit 85ad61e

Please sign in to comment.