Skip to content

Commit

Permalink
Revert "add helpers (#4972)"
Browse files Browse the repository at this point in the history
This reverts commit cd6e06f.
  • Loading branch information
Nishant Das committed Mar 2, 2020
1 parent cd6e06f commit ca8a113
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
18 changes: 0 additions & 18 deletions beacon-chain/blockchain/process_attestation_helpers.go
@@ -1,7 +1,6 @@
package blockchain

import (
"bytes"
"context"
"encoding/hex"
"fmt"
Expand Down Expand Up @@ -29,23 +28,6 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (*sta
if cachedState != nil {
return cachedState, nil
}
headRoot, err := s.HeadRoot(ctx)
if err != nil {
return nil, errors.Wrapf(err, "could not get head root")
}
if bytes.Equal(headRoot, c.Root) {
st, err := s.HeadState(ctx)
if err != nil {
return nil, errors.Wrapf(err, "could not get head state")
}
if err := s.checkpointState.AddCheckpointState(&cache.CheckpointState{
Checkpoint: c,
State: st.Copy(),
}); err != nil {
return nil, errors.Wrap(err, "could not saved checkpoint state to cache")
}
return st, nil
}

baseState, err := s.beaconDB.State(ctx, bytesutil.ToBytes32(c.Root))
if err != nil {
Expand Down
8 changes: 1 addition & 7 deletions beacon-chain/blockchain/process_block_helpers.go
Expand Up @@ -58,14 +58,8 @@ func (s *Service) getBlockPreState(ctx context.Context, b *ethpb.BeaconBlock) (*
// verifyBlkPreState validates input block has a valid pre-state.
func (s *Service) verifyBlkPreState(ctx context.Context, b *ethpb.BeaconBlock) (*stateTrie.BeaconState, error) {
preState := s.initSyncState[bytesutil.ToBytes32(b.ParentRoot)]
var err error
if preState == nil {
headRoot, err := s.HeadRoot(ctx)
if err != nil {
return nil, errors.Wrapf(err, "could not get head root")
}
if bytes.Equal(headRoot, b.ParentRoot) {
return s.HeadState(ctx)
}
preState, err = s.beaconDB.State(ctx, bytesutil.ToBytes32(b.ParentRoot))
if err != nil {
return nil, errors.Wrapf(err, "could not get pre state for slot %d", b.Slot)
Expand Down

0 comments on commit ca8a113

Please sign in to comment.