Skip to content

Commit

Permalink
Capella: validator log withdrawals (#11657)
Browse files Browse the repository at this point in the history
* Capella: validator log withdrawals

* Capella: validator log withdrawals
  • Loading branch information
terencechain authored Nov 13, 2022
1 parent de73baa commit cf46670
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
10 changes: 9 additions & 1 deletion validator/client/propose.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot types.Slot, pubKey [f
trace.Int64Attribute("numAttestations", int64(len(blk.Block().Body().Attestations()))),
)

if blk.Version() == version.Bellatrix {
if blk.Version() >= version.Bellatrix {
p, err := blk.Block().Body().Execution()
if err != nil {
log.WithError(err).Error("Failed to get execution payload")
Expand All @@ -167,6 +167,14 @@ func (v *validator) ProposeBlock(ctx context.Context, slot types.Slot, pubKey [f
if p.GasLimit() != 0 {
log = log.WithField("gasUtilized", float64(p.GasUsed())/float64(p.GasLimit()))
}
if blk.Version() >= version.Capella && !blk.IsBlinded() {
withdrawals, err := p.Withdrawals()
if err != nil {
log.WithError(err).Error("Failed to get execution payload withdrawals")
return
}
log = log.WithField("withdrawalCount", len(withdrawals))
}
}

blkRoot := fmt.Sprintf("%#x", bytesutil.Trunc(blkResp.BlockRoot))
Expand Down
24 changes: 24 additions & 0 deletions validator/client/propose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,30 @@ func testProposeBlock(t *testing.T, graffiti []byte) {
},
},
},
{
name: "capella",
block: &ethpb.GenericBeaconBlock{
Block: &ethpb.GenericBeaconBlock_Capella{
Capella: func() *ethpb.BeaconBlockCapella {
blk := util.NewBeaconBlockCapella()
blk.Block.Body.Graffiti = graffiti
return blk.Block
}(),
},
},
},
{
name: "capella blind block",
block: &ethpb.GenericBeaconBlock{
Block: &ethpb.GenericBeaconBlock_BlindedCapella{
BlindedCapella: func() *ethpb.BlindedBeaconBlockCapella {
blk := util.NewBlindedBeaconBlockCapella()
blk.Block.Body.Graffiti = graffiti
return blk.Block
}(),
},
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit cf46670

Please sign in to comment.