mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Stop packing deposits early if we reach max allowed (#9806)
* Stop packing deposits early if we reach max allowed * Add logs to proposals without deposits * Update beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/proposer_deposits.go * reinsert debug log Co-authored-by: Radosław Kapka <rkapka@wp.pl> Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
parent
39c33b82ad
commit
788338a004
@ -94,7 +94,12 @@ func (vs *Server) deposits(
|
|||||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.deposits")
|
ctx, span := trace.StartSpan(ctx, "ProposerServer.deposits")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
if vs.MockEth1Votes || !vs.Eth1InfoFetcher.IsConnectedToETH1() {
|
if vs.MockEth1Votes {
|
||||||
|
return []*ethpb.Deposit{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !vs.Eth1InfoFetcher.IsConnectedToETH1() {
|
||||||
|
log.Warn("not connected to eth1 node, skip pending deposit insertion")
|
||||||
return []*ethpb.Deposit{}, nil
|
return []*ethpb.Deposit{}, nil
|
||||||
}
|
}
|
||||||
// Need to fetch if the deposits up to the state's latest eth1 data matches
|
// Need to fetch if the deposits up to the state's latest eth1 data matches
|
||||||
@ -112,6 +117,7 @@ func (vs *Server) deposits(
|
|||||||
// If there are no pending deposits, exit early.
|
// If there are no pending deposits, exit early.
|
||||||
allPendingContainers := vs.PendingDepositsFetcher.PendingContainers(ctx, canonicalEth1DataHeight)
|
allPendingContainers := vs.PendingDepositsFetcher.PendingContainers(ctx, canonicalEth1DataHeight)
|
||||||
if len(allPendingContainers) == 0 {
|
if len(allPendingContainers) == 0 {
|
||||||
|
log.Debug("no pending deposits for inclusion in block")
|
||||||
return []*ethpb.Deposit{}, nil
|
return []*ethpb.Deposit{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,21 +133,21 @@ func (vs *Server) deposits(
|
|||||||
if uint64(dep.Index) >= beaconState.Eth1DepositIndex() && uint64(dep.Index) < canonicalEth1Data.DepositCount {
|
if uint64(dep.Index) >= beaconState.Eth1DepositIndex() && uint64(dep.Index) < canonicalEth1Data.DepositCount {
|
||||||
pendingDeps = append(pendingDeps, dep)
|
pendingDeps = append(pendingDeps, dep)
|
||||||
}
|
}
|
||||||
|
// Don't try to pack more than the max allowed in a block
|
||||||
|
if uint64(len(pendingDeps)) == params.BeaconConfig().MaxDeposits {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range pendingDeps {
|
for i := range pendingDeps {
|
||||||
// Don't construct merkle proof if the number of deposits is more than max allowed in block.
|
|
||||||
if uint64(i) == params.BeaconConfig().MaxDeposits {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
pendingDeps[i].Deposit, err = constructMerkleProof(depositTrie, int(pendingDeps[i].Index), pendingDeps[i].Deposit)
|
pendingDeps[i].Deposit, err = constructMerkleProof(depositTrie, int(pendingDeps[i].Index), pendingDeps[i].Deposit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Limit the return of pending deposits to not be more than max deposits allowed in block.
|
|
||||||
var pendingDeposits []*ethpb.Deposit
|
var pendingDeposits []*ethpb.Deposit
|
||||||
for i := uint64(0); i < uint64(len(pendingDeps)) && i < params.BeaconConfig().MaxDeposits; i++ {
|
for i := uint64(0); i < uint64(len(pendingDeps)); i++ {
|
||||||
pendingDeposits = append(pendingDeposits, pendingDeps[i].Deposit)
|
pendingDeposits = append(pendingDeposits, pendingDeps[i].Deposit)
|
||||||
}
|
}
|
||||||
return pendingDeposits, nil
|
return pendingDeposits, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user