Skip to content

Commit

Permalink
Add bls_to_execution_change event.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdee committed Dec 23, 2023
1 parent 4dec6bb commit fa404f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dev:
- add proposer_slashing and attester_slashing events
- add bls_to_execution_change event

0.19.8
- more efficient fetching for large numbers of validators
Expand Down
10 changes: 10 additions & 0 deletions http/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
client "github.com/attestantio/go-eth2-client"
api "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/pkg/errors"
"github.com/r3labs/sse/v2"
Expand Down Expand Up @@ -196,6 +197,15 @@ func (s *Service) handleEvent(ctx context.Context, msg *sse.Event, handler clien
return
}
event.Data = attesterSlashingEvent
case "bls_to_execution_change":
blsToExecutionChangeEvent := &capella.BLSToExecutionChange{}
err := json.Unmarshal(msg.Data, blsToExecutionChangeEvent)
if err != nil {
log.Error().Err(err).RawJSON("data", msg.Data).Msg("Failed to parse bls to execution change event")

return
}
event.Data = blsToExecutionChangeEvent
case "blob_sidecar":
blobSidecar := &api.BlobSidecarEvent{}
err := json.Unmarshal(msg.Data, blobSidecar)
Expand Down
9 changes: 9 additions & 0 deletions http/events_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ func TestEventHandler(t *testing.T) {
handler: handler,
handled: true,
},
{
name: "BLSToExecutionChangeGood",
message: &sse.Event{
Event: []byte("bls_to_execution_change"),
Data: []byte(`{"validator_index":"63401","from_bls_pubkey":"0xa46ed2574770ec1942d577ef89e0bf7b0d601349dab791740dead3fb5a6e2624cf62b9e58de1074c49f44b986eb39002","to_execution_address":"0xd641D2Cc74C7b6A641861260d07D67eB67bc7403"}`),
},
handler: handler,
handled: true,
},
{
name: "ContributionAndProofGood",
message: &sse.Event{
Expand Down

0 comments on commit fa404f5

Please sign in to comment.