From 6e81b4e84bbf26577a74505dc57d054a97b1cb53 Mon Sep 17 00:00:00 2001 From: terence Date: Mon, 13 May 2024 20:33:01 -0700 Subject: [PATCH] Correctly return electra attestations for block getter (#13993) --- consensus-types/blocks/getters.go | 2 +- consensus-types/blocks/getters_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/consensus-types/blocks/getters.go b/consensus-types/blocks/getters.go index e45e2f7dbe..369f972d42 100644 --- a/consensus-types/blocks/getters.go +++ b/consensus-types/blocks/getters.go @@ -1116,7 +1116,7 @@ func (b *BeaconBlockBody) Attestations() []interfaces.Attestation { return nil } atts = make([]interfaces.Attestation, len(b.attestationsElectra)) - for i, a := range b.attestations { + for i, a := range b.attestationsElectra { atts[i] = a } } diff --git a/consensus-types/blocks/getters_test.go b/consensus-types/blocks/getters_test.go index 95d9bc177d..6dac557099 100644 --- a/consensus-types/blocks/getters_test.go +++ b/consensus-types/blocks/getters_test.go @@ -369,6 +369,19 @@ func Test_BeaconBlockBody_Attestations(t *testing.T) { assert.DeepSSZEqual(t, a, bb.Block().Body().Attestations()) } +func Test_BeaconBlockBody_ElectraAttestations(t *testing.T) { + bb := &SignedBeaconBlock{ + block: &BeaconBlock{body: &BeaconBlockBody{ + version: version.Electra, + attestationsElectra: []*eth.AttestationElectra{{ + Signature: []byte("electra"), + }}, + }}} + a := bb.Block().Body().Attestations() + require.Equal(t, 1, len(a)) + require.DeepEqual(t, a[0].GetSignature(), []byte("electra")) +} + func Test_BeaconBlockBody_Deposits(t *testing.T) { d := make([]*eth.Deposit, 0) bb := &SignedBeaconBlock{block: &BeaconBlock{body: &BeaconBlockBody{}}}