Skip to content

Commit

Permalink
remove excess copies (#6142)
Browse files Browse the repository at this point in the history
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
nisdas and prylabs-bulldozer[bot] committed Jun 9, 2020
1 parent bea2b34 commit c956905
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions beacon-chain/blockchain/process_attestation_helpers.go
Expand Up @@ -45,7 +45,6 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (*sta
}

if helpers.StartSlot(c.Epoch) > baseState.Slot() {
baseState = baseState.Copy()
baseState, err = state.ProcessSlots(ctx, baseState, helpers.StartSlot(c.Epoch))
if err != nil {
return nil, errors.Wrapf(err, "could not process slots up to %d", helpers.StartSlot(c.Epoch))
Expand Down Expand Up @@ -91,23 +90,22 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (*sta
}

if helpers.StartSlot(c.Epoch) > baseState.Slot() {
savedState := baseState.Copy()
savedState, err = state.ProcessSlots(ctx, savedState, helpers.StartSlot(c.Epoch))
baseState, err = state.ProcessSlots(ctx, baseState, helpers.StartSlot(c.Epoch))
if err != nil {
return nil, errors.Wrapf(err, "could not process slots up to %d", helpers.StartSlot(c.Epoch))
}
if err := s.checkpointState.AddCheckpointState(&cache.CheckpointState{
Checkpoint: c,
State: savedState.Copy(),
State: baseState,
}); err != nil {
return nil, errors.Wrap(err, "could not saved checkpoint state to cache")
}
return savedState, nil
return baseState, nil
}

if err := s.checkpointState.AddCheckpointState(&cache.CheckpointState{
Checkpoint: c,
State: baseState.Copy(),
State: baseState,
}); err != nil {
return nil, errors.Wrap(err, "could not saved checkpoint state to cache")
}
Expand Down

0 comments on commit c956905

Please sign in to comment.