Skip to content

Commit 680209d

Browse files
committed
use v2 attester slashing submission endpoint
1 parent 304fbf4 commit 680209d

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pkg/clients/consensus/rpc/beaconapi.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,26 @@ func (bc *BeaconClient) SubmitVoluntaryExits(ctx context.Context, exit *phase0.S
489489

490490
func (bc *BeaconClient) SubmitAttesterSlashing(ctx context.Context, slashing *phase0.AttesterSlashing) error {
491491
err := bc.postJSON(ctx, fmt.Sprintf("%s/eth/v1/beacon/pool/attester_slashings", bc.endpoint), slashing, nil)
492-
if err != nil {
493-
return err
492+
if err == nil {
493+
return nil
494494
}
495495

496-
return nil
496+
// Prysm removed the v1 endpoint post-Electra, fall back to v2 with version header.
497+
if err.Error() == "not found" {
498+
v2Err := bc.postJSONWithHeaders(
499+
ctx,
500+
fmt.Sprintf("%s/eth/v2/beacon/pool/attester_slashings", bc.endpoint),
501+
slashing, nil,
502+
map[string]string{"Eth-Consensus-Version": "electra"},
503+
)
504+
if v2Err != nil {
505+
return v2Err
506+
}
507+
508+
return nil
509+
}
510+
511+
return err
497512
}
498513

499514
func (bc *BeaconClient) SubmitProposerSlashing(ctx context.Context, slashing *phase0.ProposerSlashing) error {

0 commit comments

Comments
 (0)