Skip to content

Commit

Permalink
Use the custom HTR in a few more places (#5743)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvanloon authored May 5, 2020
1 parent 9ea3f58 commit eb27f35
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/core/blocks/block_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func TestProcessBlockHeader_OK(t *testing.T) {
}
blockSig := priv.Sign(signingRoot[:])
block.Signature = blockSig.Marshal()[:]
bodyRoot, err := ssz.HashTreeRoot(block.Block.Body)
bodyRoot, err := stateutil.BlockBodyRoot(block.Block.Body)
if err != nil {
t.Fatalf("Failed to hash block bytes got: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions beacon-chain/state/stateutil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ go_library(
"//beacon-chain:__subpackages__",
"//proto/testing:__subpackages__",
"//shared/testutil:__subpackages__",
"//slasher:__subpackages__",
"//tools/blocktree:__pkg__",
"//tools/pcli:__pkg__",
"//validator/client:__pkg__",
],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion beacon-chain/sync/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ go_library(
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
"@org_golang_x_exp//rand:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/sync/subscriber_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/gogo/protobuf/proto"
"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)

Expand Down Expand Up @@ -59,7 +59,7 @@ func (r *Service) proposerSlashingSubscriber(ctx context.Context, msg proto.Mess
}
// Do some nil checks to prevent easy DoS'ing of this handler.
if ps.Header_1 != nil && ps.Header_1.Header != nil {
root, err := ssz.HashTreeRoot(ps.Header_1.Header)
root, err := stateutil.BlockHeaderRoot(ps.Header_1.Header)
s, err := r.db.State(ctx, root)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions beacon-chain/sync/subscriber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
lru "github.com/hashicorp/golang-lru"
pubsub "github.com/libp2p/go-libp2p-pubsub"
pb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
mockChain "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
statefeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/state"
db "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/operations/slashings"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
p2ptest "github.com/prysmaticlabs/prysm/beacon-chain/p2p/testing"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestSubscribe_ReceivesProposerSlashing(t *testing.T) {
if err != nil {
t.Fatalf("Error generating proposer slashing")
}
root, err := ssz.HashTreeRoot(proposerSlashing.Header_1.Header)
root, err := stateutil.BlockHeaderRoot(proposerSlashing.Header_1.Header)
if err := r.db.SaveState(ctx, beaconState, root); err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion slasher/detection/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/slasher/detection",
visibility = ["//slasher:__subpackages__"],
deps = [
"//beacon-chain/state/stateutil:go_default_library",
"//shared/event:go_default_library",
"//shared/hashutil:go_default_library",
"//shared/sliceutil:go_default_library",
Expand All @@ -27,7 +28,6 @@ go_library(
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_opencensus_go//trace:go_default_library",
],
Expand Down
4 changes: 2 additions & 2 deletions slasher/detection/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/pkg/errors"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
"go.opencensus.io/trace"
)

Expand Down Expand Up @@ -83,7 +83,7 @@ func (ds *Service) detectIncomingAttestations(ctx context.Context, ch chan *ethp
}

func signedBeaconBlockHeaderFromBlock(block *ethpb.SignedBeaconBlock) (*ethpb.SignedBeaconBlockHeader, error) {
bodyRoot, err := ssz.HashTreeRoot(block.Block.Body)
bodyRoot, err := stateutil.BlockBodyRoot(block.Block.Body)
if err != nil {
return nil, errors.Wrap(err, "failed to get body root of block")
}
Expand Down
1 change: 1 addition & 0 deletions validator/client/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go_library(
visibility = ["//validator:__subpackages__"],
deps = [
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/state/stateutil:go_default_library",
"//proto/slashing:go_default_library",
"//shared/bls:go_default_library",
"//shared/bytesutil:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions validator/client/validator_propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/go-ssz"
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
Expand Down Expand Up @@ -188,7 +188,7 @@ func (v *validator) signBlock(ctx context.Context, pubKey [48]byte, epoch uint64
}
var sig *bls.Signature
if protectingKeymanager, supported := v.keyManager.(keymanager.ProtectingKeyManager); supported {
bodyRoot, err := ssz.HashTreeRoot(b.Body)
bodyRoot, err := stateutil.BlockBodyRoot(b.Body)
if err != nil {
return nil, errors.Wrap(err, "could not get signing root")
}
Expand Down

0 comments on commit eb27f35

Please sign in to comment.