Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/v1/blobsidecarevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type BlobSidecarEvent struct {
Index deneb.BlobIndex
KZGCommitment deneb.KZGCommitment
VersionedHash deneb.VersionedHash
// Provider is the address of the provider that returned this event.
Provider string
}

// blobSidecarEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/blobsidecarevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,20 @@ func TestBlobSidecarEventJSON(t *testing.T) {
})
}
}

func TestBlobSidecarEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"block_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","slot":"1","index":"1","kzg_commitment":"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2","versioned_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"}`)

var event api.BlobSidecarEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.BlobSidecarEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/blockevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type BlockEvent struct {
Slot phase0.Slot
Block phase0.Root
ExecutionOptimistic bool
// Provider is the address of the provider that returned this event.
Provider string
}

// blockEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/blockevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ func TestBlockEventJSON(t *testing.T) {
})
}
}

func TestBlockEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"slot":"525277","block":"0x99e3f24aab3dd084045a0c927a33b8463eb5c7b17eeadfecdcf4e4badf7b6028","execution_optimistic":false}`)

var event api.BlockEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.BlockEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/blockgossipevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
type BlockGossipEvent struct {
Slot phase0.Slot
Block phase0.Root
// Provider is the address of the provider that returned this event.
Provider string
}

// blockGossipEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/blockgossipevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,20 @@ func TestBlockGossipEventJSON(t *testing.T) {
})
}
}

func TestBlockGossipEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"slot":"525277","block":"0x99e3f24aab3dd084045a0c927a33b8463eb5c7b17eeadfecdcf4e4badf7b6028"}`)

var event api.BlockGossipEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.BlockGossipEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/chainreorgevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type ChainReorgEvent struct {
OldHeadState phase0.Root
NewHeadState phase0.Root
Epoch phase0.Epoch
// Provider is the address of the provider that returned this event.
Provider string
}

// chainReorgEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/chainreorgevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,20 @@ func TestChainReorgEventJSON(t *testing.T) {
})
}
}

func TestChainReorgEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"slot":"524986","depth":"2","old_head_block":"0x2ffc0a5b75de20f2a12853dff3e09b263e7c3cb19515134cba756b28e5ba25ee","new_head_block":"0xa3fe14d8d749318359aa3790d3588a23e12ea3b02bd879fbfbf04c3a66770df7","old_head_state":"0x97cc0a37b77fbac6fa140f330c92521ddcd5b1dfefeef99d86996a51f1993d60","new_head_state":"0x4ab800aaa51c14c786fe7e924abd1355aa2ac2e0434d7cb5ae568720ed1bf522","epoch":"16405"}`)

var event api.ChainReorgEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.ChainReorgEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/datacolumnsidecarevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type DataColumnSidecarEvent struct {
Slot phase0.Slot
Index uint64
KZGCommitments []deneb.KZGCommitment
// Provider is the address of the provider that returned this event.
Provider string
}

// dataColumnSidecarEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/datacolumnsidecarevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,20 @@ func TestDataColumnSidecarEventJSON(t *testing.T) {
})
}
}

func TestDataColumnSidecarEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"block_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","slot":"1","index":"1","kzg_commitments":["0xa590e760fdce951756d59c46b037bab8de815fe8ffc25e6e3a7b45e43289e1fdc942854cdfea1615385a0db63442f363"]}`)

var event api.DataColumnSidecarEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.DataColumnSidecarEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 1 addition & 1 deletion api/v1/electra/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

package electra

//nolint:revive
// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work.
//nolint:revive // go:generate directives exceed line length.
//go:generate rm -f blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblockcontents_ssz.go
//go:generate sszgen --include ../../../spec/phase0,../../../spec/altair,../../../spec/bellatrix,../../../spec/capella,../../../spec/deneb,../../../spec/electra -path . --suffix ssz -objs BlindedBeaconBlock,BlindedBeaconBlockBody,BlockContents,SignedBlindedBeaconBlock,SignedBlockContents
//go:generate goimports -w blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblockcontents_ssz.go
2 changes: 2 additions & 0 deletions api/v1/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Event struct {
Topic string
// Data is the data of the event.
Data any
// Provider is the address of the provider that returned this event.
Provider string
}

// SupportedEventTopics is a map of supported event topics.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,20 @@ func TestEvent(t *testing.T) {
})
}
}

func TestEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"topic":"head","data":{"block":"0xbe36e714a6114cf718e35dafc4ac530ce8f01e4a9a360e78098eb129772dcc39","current_duty_dependent_root":"0x92c6b763f610d5941d2041906007bf9449d37772aacf0483a76275ac27c096b4","epoch_transition":false,"previous_duty_dependent_root":"0xa692c095bbca3eeaf99eeabada78874c028c02b176ccf691f3e8fa075d67f5c6","slot":"231192","state":"0x61099b2c1dee0104c93ce0e14e5f5fc4b6faceff4cb863278d055bdfb73b7dc7"}}`)

var event api.Event
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "\"provider\"")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.Event
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/finalizedcheckpointevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type FinalizedCheckpointEvent struct {
Block phase0.Root
State phase0.Root
Epoch phase0.Epoch
// Provider is the address of the provider that returned this event.
Provider string
}

// finalizedCheckpointEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/finalizedcheckpointevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@ func TestFinalizedCheckpointEventJSON(t *testing.T) {
})
}
}

func TestFinalizedCheckpointEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"block":"0x99e3f24aab3dd084045a0c927a33b8463eb5c7b17eeadfecdcf4e4badf7b6028","state":"0x749a95b1355828b758864ea601c007e69aabed7b34a0f2084c43c26242f77e28","epoch":"2"}`)

var event api.FinalizedCheckpointEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.FinalizedCheckpointEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/headevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type HeadEvent struct {
EpochTransition bool
CurrentDutyDependentRoot phase0.Root
PreviousDutyDependentRoot phase0.Root
// Provider is the address of the provider that returned this event.
Provider string
}

// headEventJSON is the spec representation of the struct.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/headevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,20 @@ func TestHeadEventJSON(t *testing.T) {
})
}
}

func TestHeadEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"slot":"525277","block":"0x99e3f24aab3dd084045a0c927a33b8463eb5c7b17eeadfecdcf4e4badf7b6028","state":"0x749a95b1355828b758864ea601c007e69aabed7b34a0f2084c43c26242f77e28","epoch_transition":false,"current_duty_dependent_root":"0x907a3462a2905e3df2624869aa7f9a8635eb35bdcf9ce68a26fab691f9dada61","previous_duty_dependent_root":"0x935569bdc1aaad65dbeb532a125390d039058924ea81799238ed53e4e4639a11"}`)

var event api.HeadEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "provider")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.HeadEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
2 changes: 2 additions & 0 deletions api/v1/payloadattributesevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type PayloadAttributesEvent struct {
Version spec.DataVersion
// Data is the data of the event.
Data *PayloadAttributesData
// Provider is the address of the provider that returned this event.
Provider string
}

// PayloadAttributesData represents the data of a payload_attributes event.
Expand Down
17 changes: 17 additions & 0 deletions api/v1/payloadattributesevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,20 @@ func TestPayloadAttributesEventJSON(t *testing.T) {
})
}
}

func TestPayloadAttributesEventProviderNotInJSON(t *testing.T) {
input := []byte(`{"version":"bellatrix","data":{"proposer_index":"123","proposal_slot":"10","parent_block_number":"9","parent_block_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","parent_block_hash":"0x9a2fefd2fdb57f74993c7780ea5b9030d2897b615b89f808011ca5aebed54eaf","payload_attributes":{"timestamp":"123456","prev_randao":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","suggested_fee_recipient":"0x0000000000000000000000000000000000000000"}}}`)

var event api.PayloadAttributesEvent
require.NoError(t, json.Unmarshal(input, &event))
event.Provider = "test-provider"

rt, err := json.Marshal(&event)
require.NoError(t, err)
assert.NotContains(t, string(rt), "\"provider\"")
assert.NotContains(t, string(rt), "test-provider")

var roundTripped api.PayloadAttributesEvent
require.NoError(t, json.Unmarshal(rt, &roundTripped))
assert.Empty(t, roundTripped.Provider)
}
Loading
Loading