mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
7f56ac6355
* Massive code cleanup * fix test issues * remove GetGenesis mock expectations * unused receiver * rename unused params Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package altair
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// ProcessDeposits processes validator deposits for beacon state Altair.
|
|
func ProcessDeposits(
|
|
ctx context.Context,
|
|
beaconState state.BeaconState,
|
|
deposits []*ethpb.Deposit,
|
|
) (state.BeaconState, error) {
|
|
batchVerified, err := blocks.BatchVerifyDepositsSignatures(ctx, deposits)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
for _, deposit := range deposits {
|
|
if deposit == nil || deposit.Data == nil {
|
|
return nil, errors.New("got a nil deposit in block")
|
|
}
|
|
beaconState, err = ProcessDeposit(beaconState, deposit, batchVerified)
|
|
if err != nil {
|
|
return nil, errors.Wrapf(err, "could not process deposit from %#x", bytesutil.Trunc(deposit.Data.PublicKey))
|
|
}
|
|
}
|
|
return beaconState, nil
|
|
}
|
|
|
|
// ProcessDeposit processes validator deposit for beacon state Altair.
|
|
func ProcessDeposit(beaconState state.BeaconState, deposit *ethpb.Deposit, verifySignature bool) (state.BeaconState, error) {
|
|
beaconState, isNewValidator, err := blocks.ProcessDeposit(beaconState, deposit, verifySignature)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if isNewValidator {
|
|
if err := beaconState.AppendInactivityScore(0); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := beaconState.AppendPreviousParticipationBits(0); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := beaconState.AppendCurrentParticipationBits(0); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return beaconState, nil
|
|
}
|