mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Capella E2E (#11951)
* save changes * fix build * fix build * fix signatures * fix * fix * finally fix it * mainnet * deps * make it 10 * back to phase0 * fix build * gofmt * etherbase * rm logs * build * james review * fix yaml * Update testing/endtoend/evaluators/fork.go Co-authored-by: Radosław Kapka <rkapka@wp.pl> * radek's review --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/container/trie"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/time"
|
||||
)
|
||||
@@ -119,7 +120,7 @@ func DepositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey) ([]*
|
||||
depositDataItems := make([]*ethpb.Deposit_Data, len(privKeys))
|
||||
depositDataRoots := make([][]byte, len(privKeys))
|
||||
results, err := async.Scatter(len(privKeys), func(offset int, entries int, _ *sync.RWMutex) (interface{}, error) {
|
||||
items, roots, err := depositDataFromKeys(privKeys[offset:offset+entries], pubKeys[offset:offset+entries])
|
||||
items, roots, err := depositDataFromKeys(privKeys[offset:offset+entries], pubKeys[offset:offset+entries], 0)
|
||||
return &depositData{items: items, roots: roots}, err
|
||||
})
|
||||
if err != nil {
|
||||
@@ -136,11 +137,17 @@ func DepositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey) ([]*
|
||||
return depositDataItems, depositDataRoots, nil
|
||||
}
|
||||
|
||||
func depositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey) ([]*ethpb.Deposit_Data, [][]byte, error) {
|
||||
// DepositDataFromKeysWithExecCreds generates a list of deposit data items from a set of BLS validator keys.
|
||||
func DepositDataFromKeysWithExecCreds(privKeys []bls.SecretKey, pubKeys []bls.PublicKey, numOfCreds uint64) ([]*ethpb.Deposit_Data, [][]byte, error) {
|
||||
return depositDataFromKeys(privKeys, pubKeys, numOfCreds)
|
||||
}
|
||||
|
||||
func depositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey, numOfCreds uint64) ([]*ethpb.Deposit_Data, [][]byte, error) {
|
||||
dataRoots := make([][]byte, len(privKeys))
|
||||
depositDataItems := make([]*ethpb.Deposit_Data, len(privKeys))
|
||||
for i := 0; i < len(privKeys); i++ {
|
||||
data, err := createDepositData(privKeys[i], pubKeys[i])
|
||||
withCred := uint64(i) < numOfCreds
|
||||
data, err := createDepositData(privKeys[i], pubKeys[i], withCred)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "could not create deposit data for key: %#x", privKeys[i].Marshal())
|
||||
}
|
||||
@@ -155,12 +162,18 @@ func depositDataFromKeys(privKeys []bls.SecretKey, pubKeys []bls.PublicKey) ([]*
|
||||
}
|
||||
|
||||
// Generates a deposit data item from BLS keys and signs the hash tree root of the data.
|
||||
func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Deposit_Data, error) {
|
||||
func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey, withExecCreds bool) (*ethpb.Deposit_Data, error) {
|
||||
depositMessage := ðpb.DepositMessage{
|
||||
PublicKey: pubKey.Marshal(),
|
||||
WithdrawalCredentials: withdrawalCredentialsHash(pubKey.Marshal()),
|
||||
Amount: params.BeaconConfig().MaxEffectiveBalance,
|
||||
}
|
||||
if withExecCreds {
|
||||
newCredentials := make([]byte, 12)
|
||||
newCredentials[0] = params.BeaconConfig().ETH1AddressWithdrawalPrefixByte
|
||||
execAddr := bytesutil.ToBytes20(pubKey.Marshal())
|
||||
depositMessage.WithdrawalCredentials = append(newCredentials, execAddr[:]...)
|
||||
}
|
||||
sr, err := depositMessage.HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user