-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeposit.go
39 lines (34 loc) · 1.15 KB
/
deposit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package execution
import (
"context"
"github.com/pkg/errors"
"github.com/theQRL/go-zond/common"
"github.com/theQRL/qrysm/v4/beacon-chain/core/blocks"
"github.com/theQRL/qrysm/v4/config/params"
zondpb "github.com/theQRL/qrysm/v4/proto/prysm/v1alpha1"
)
// DepositContractAddress returns the deposit contract address for the given chain.
func DepositContractAddress() (string, error) {
address := params.BeaconConfig().DepositContractAddress
if address == "" {
return "", errors.New("valid deposit contract is required")
}
if !common.IsHexAddress(address) {
return "", errors.New("invalid deposit contract address given: " + address)
}
return address, nil
}
func (s *Service) processDeposit(ctx context.Context, eth1Data *zondpb.Eth1Data, deposit *zondpb.Deposit) error {
var err error
if err := s.preGenesisState.SetEth1Data(eth1Data); err != nil {
return err
}
beaconState, err := blocks.ProcessPreGenesisDeposits(ctx, s.preGenesisState, []*zondpb.Deposit{deposit})
if err != nil {
return errors.Wrap(err, "could not process pre-genesis deposits")
}
if beaconState != nil && !beaconState.IsNil() {
s.preGenesisState = beaconState
}
return nil
}