Skip to content

Commit 016d0fc

Browse files
committed
Fix errors
1 parent 3c1dfff commit 016d0fc

File tree

17 files changed

+337
-79
lines changed

17 files changed

+337
-79
lines changed

Diff for: api/server/structs/conversions.go

+7
Original file line numberDiff line numberDiff line change
@@ -1598,6 +1598,13 @@ func SignedExitsFromConsensus(src []*eth.SignedVoluntaryExit) []*SignedVoluntary
15981598
return exits
15991599
}
16001600

1601+
func sszBytesToUint8String(b []byte) (string, error) {
1602+
if len(b) != 1 {
1603+
return "", fmt.Errorf("expected 1 byte, got %d", len(b))
1604+
}
1605+
return fmt.Sprintf("%d", b[0]), nil
1606+
}
1607+
16011608
func sszBytesToUint256String(b []byte) (string, error) {
16021609
bi := bytesutil.LittleEndianBytesToBigInt(b)
16031610
if !math.IsValidUint256(bi) {

Diff for: api/server/structs/conversions_block.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -3584,10 +3584,11 @@ func (b *BeaconBlockFulu) ToConsensus() (*eth.BeaconBlockFulu, error) {
35843584
if err != nil {
35853585
return nil, server.NewDecodeError(err, "Body.ExecutionPayload.ExcessBlobGas")
35863586
}
3587-
payloadProofVersion, err := bytesutil.DecodeHexWithMaxLength(b.Body.ExecutionPayload.ProofVersion, 1)
3587+
proofVersion, err := strconv.ParseUint(b.Body.ExecutionPayload.ProofVersion, 10, 1)
35883588
if err != nil {
35893589
return nil, server.NewDecodeError(err, "Body.ExecutionPayload.ProofVersion")
35903590
}
3591+
payloadProofVersion := []byte{uint8(proofVersion)}
35913592

35923593
if b.Body.ExecutionRequests == nil {
35933594
return nil, server.NewDecodeError(errors.New("nil execution requests"), "Body.ExequtionRequests")
@@ -4118,6 +4119,10 @@ func ExecutionPayloadFuluFromConsensus(payload *enginev1.ExecutionPayloadFulu) (
41184119
for i, tx := range payload.Transactions {
41194120
transactions[i] = hexutil.Encode(tx)
41204121
}
4122+
proofVersion, err := sszBytesToUint8String(payload.ProofVersion)
4123+
if err != nil {
4124+
return nil, err
4125+
}
41214126

41224127
return &ExecutionPayloadFulu{
41234128
ParentHash: hexutil.Encode(payload.ParentHash),
@@ -4137,7 +4142,7 @@ func ExecutionPayloadFuluFromConsensus(payload *enginev1.ExecutionPayloadFulu) (
41374142
Withdrawals: WithdrawalsFromConsensus(payload.Withdrawals),
41384143
BlobGasUsed: fmt.Sprintf("%d", payload.BlobGasUsed),
41394144
ExcessBlobGas: fmt.Sprintf("%d", payload.ExcessBlobGas),
4140-
ProofVersion: fmt.Sprintf("%d", payload.ProofVersion),
4145+
ProofVersion: proofVersion,
41414146
}, nil
41424147
}
41434148

Diff for: beacon-chain/core/peerdas/das_core.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ func ComputeColumnsForCustodyGroup(custodyGroup uint64) ([]uint64, error) {
106106
// DataColumnSidecars computes the data column sidecars from the signed block and blobs.
107107
// https://github.com/ethereum/consensus-specs/blob/dev/specs/fulu/das-core.md#get_data_column_sidecars
108108
func DataColumnSidecars(signedBlock interfaces.ReadOnlySignedBeaconBlock, cellsAndProofs []kzg.CellsAndProofs) ([]*ethpb.DataColumnSidecar, error) {
109-
start := time.Now()
109+
if signedBlock == nil || len(cellsAndProofs) == 0 {
110+
return nil, nil
111+
}
110112

113+
start := time.Now()
111114
block := signedBlock.Block()
112115
blockBody := block.Body()
113116
blobKzgCommitments, err := blockBody.BlobKzgCommitments()

Diff for: beacon-chain/execution/engine_client.go

+2-15
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,6 @@ func (s *Service) GetBlobs(ctx context.Context, versionedHashes []common.Hash) (
528528
return result, handleRPCError(err)
529529
}
530530

531-
func (s *Service) GetBlobsV2(ctx context.Context, versionedHashes []common.Hash) ([]*pb.BlobAndProofV2, error) {
532-
ctx, span := trace.StartSpan(ctx, "powchain.engine-api-client.GetBlobsV2")
533-
defer span.End()
534-
535-
if !s.capabilityCache.has(GetBlobsV2) {
536-
return nil, errors.New(fmt.Sprintf("%s is not supported", GetBlobsV2))
537-
}
538-
539-
result := make([]*pb.BlobAndProofV2, len(versionedHashes))
540-
err := s.rpcClient.CallContext(ctx, &result, GetBlobsV2, versionedHashes)
541-
return result, handleRPCError(err)
542-
}
543-
544531
// ReconstructFullBlock takes in a blinded beacon block and reconstructs
545532
// a beacon block with a full execution payload via the engine API.
546533
func (s *Service) ReconstructFullBlock(
@@ -668,13 +655,13 @@ func (s *Service) ReconstructDataColumnSidecars(ctx context.Context, block inter
668655
}
669656

670657
// Fetch all blobsAndCellsProofs from EL
671-
blobsAndCellsProofs, err := s.GetBlobsV2(ctx, kzgHashes)
658+
blobsAndCellProofs, err := s.GetBlobs(ctx, kzgHashes)
672659
if err != nil {
673660
return nil, wrapWithBlockRoot(err, blockRoot, "get blobs V2")
674661
}
675662

676663
var cellsAndProofs []kzg.CellsAndProofs
677-
for _, blobAndCellProofs := range blobsAndCellsProofs {
664+
for _, blobAndCellProofs := range blobsAndCellProofs {
678665
if blobAndCellProofs == nil {
679666
return nil, wrapWithBlockRoot(errors.New("unable to reconstruct data column sidecars, did not get all blobs from EL"), blockRoot, "")
680667
}

Diff for: beacon-chain/execution/engine_client_test.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -2502,17 +2502,13 @@ func TestReconstructDataColumnSidecars(t *testing.T) {
25022502
require.NoError(t, err)
25032503

25042504
ctx := context.Background()
2505-
t.Run("GetBlobsV2 is not supported", func(t *testing.T) {
2506-
_, err := client.ReconstructDataColumnSidecars(ctx, sb, r)
2507-
require.ErrorContains(t, "get blobs V2 for block", err)
2508-
})
25092505

25102506
t.Run("receiving all blobs", func(t *testing.T) {
25112507
blobMasks := []bool{true, true, true, true, true, true}
25122508
srv := createBlobServerV2(t, 6, blobMasks)
25132509
defer srv.Close()
25142510

2515-
rpcClient, client := setupRpcClientV2(t, srv.URL, client)
2511+
rpcClient, client := setupRpcClient(t, srv.URL, client)
25162512
defer rpcClient.Close()
25172513

25182514
dataColumns, err := client.ReconstructDataColumnSidecars(ctx, sb, r)
@@ -2525,7 +2521,7 @@ func TestReconstructDataColumnSidecars(t *testing.T) {
25252521
srv := createBlobServerV2(t, 6, blobMasks)
25262522
defer srv.Close()
25272523

2528-
rpcClient, client := setupRpcClientV2(t, srv.URL, client)
2524+
rpcClient, client := setupRpcClient(t, srv.URL, client)
25292525
defer rpcClient.Close()
25302526

25312527
dataColumns, err := client.ReconstructDataColumnSidecars(ctx, sb, r)
@@ -2578,18 +2574,20 @@ func createBlobServerV2(t *testing.T, numBlobs int, blobMasks []bool) *httptest.
25782574

25792575
require.Equal(t, len(blobMasks), numBlobs)
25802576

2581-
blobAndCellProofs := make([]*pb.BlobAndCellProofJson, numBlobs)
2577+
blobAndCellProofs := make([]*pb.BlobAndProofJson, numBlobs)
25822578
for i := range blobAndCellProofs {
25832579
if !blobMasks[i] {
25842580
continue
25852581
}
25862582

2587-
blobAndCellProofs[i] = &pb.BlobAndCellProofJson{
2583+
blobAndCellProofs[i] = &pb.BlobAndProofJson{
25882584
Blob: []byte("0xblob"),
25892585
CellProofs: []hexutil.Bytes{},
25902586
}
25912587
for j := 0; j < int(params.BeaconConfig().NumberOfColumns); j++ {
2592-
blobAndCellProofs[i].CellProofs = append(blobAndCellProofs[i].CellProofs, []byte(fmt.Sprintf("0xproof%d", j)))
2588+
cellProof := make([]byte, 48)
2589+
2590+
blobAndCellProofs[i].CellProofs = append(blobAndCellProofs[i].CellProofs, cellProof)
25932591
}
25942592
}
25952593

Diff for: beacon-chain/rpc/eth/beacon/handlers_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ func TestGetBlockV2(t *testing.T) {
325325
s.GetBlockV2(writer, request)
326326
require.Equal(t, http.StatusOK, writer.Code)
327327
resp := &structs.GetBlockV2Response{}
328+
328329
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), resp))
329330
assert.Equal(t, version.String(version.Fulu), resp.Version)
330331
sbb := &structs.SignedBeaconBlockFulu{Message: &structs.BeaconBlockFulu{}}
@@ -1469,7 +1470,7 @@ func TestPublishBlock(t *testing.T) {
14691470
converted, err := structs.SignedBeaconBlockContentsElectraFromConsensus(block.Electra)
14701471
require.NoError(t, err)
14711472
var signedblock *structs.SignedBeaconBlockContentsElectra
1472-
err = json.Unmarshal([]byte(rpctesting.FuluBlockContents), &signedblock)
1473+
err = json.Unmarshal([]byte(rpctesting.ElectraBlockContents), &signedblock)
14731474
require.NoError(t, err)
14741475
require.DeepEqual(t, converted, signedblock)
14751476
return ok
@@ -4745,7 +4746,7 @@ func Test_validateBlobSidecars(t *testing.T) {
47454746
s := &Server{}
47464747
require.NoError(t, s.validateBlobSidecars(b, [][]byte{blob[:]}, [][]byte{proof[:]}))
47474748

4748-
require.ErrorContains(t, "number of blobs, proofs, and commitments do not match", s.validateBlobSidecars(b, [][]byte{blob[:]}, [][]byte{}))
4749+
require.ErrorContains(t, "number of blobs and proofs do not match", s.validateBlobSidecars(b, [][]byte{blob[:]}, [][]byte{}))
47494750

47504751
sk, err := bls.RandKey()
47514752
require.NoError(t, err)

Diff for: beacon-chain/rpc/eth/shared/testing/json.go

+231-1
Large diffs are not rendered by default.

Diff for: consensus-types/blocks/getters.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ func (b *BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error) {
747747
if b.IsBlinded() {
748748
return pb.(*eth.BlindedBeaconBlockFulu).HashTreeRoot()
749749
}
750-
return pb.(*eth.BeaconBlockElectra).HashTreeRoot()
750+
return pb.(*eth.BeaconBlockFulu).HashTreeRoot()
751751
default:
752752
return [field_params.RootLength]byte{}, errIncorrectBlockVersion
753753
}
@@ -788,7 +788,7 @@ func (b *BeaconBlock) HashTreeRootWith(h *ssz.Hasher) error {
788788
if b.IsBlinded() {
789789
return pb.(*eth.BlindedBeaconBlockFulu).HashTreeRootWith(h)
790790
}
791-
return pb.(*eth.BeaconBlockElectra).HashTreeRootWith(h)
791+
return pb.(*eth.BeaconBlockFulu).HashTreeRootWith(h)
792792
default:
793793
return errIncorrectBlockVersion
794794
}
@@ -830,7 +830,7 @@ func (b *BeaconBlock) MarshalSSZ() ([]byte, error) {
830830
if b.IsBlinded() {
831831
return pb.(*eth.BlindedBeaconBlockFulu).MarshalSSZ()
832832
}
833-
return pb.(*eth.BeaconBlockElectra).MarshalSSZ()
833+
return pb.(*eth.BeaconBlockFulu).MarshalSSZ()
834834
default:
835835
return []byte{}, errIncorrectBlockVersion
836836
}
@@ -1277,7 +1277,7 @@ func (b *BeaconBlockBody) HashTreeRoot() ([field_params.RootLength]byte, error)
12771277
if b.IsBlinded() {
12781278
return pb.(*eth.BlindedBeaconBlockBodyElectra).HashTreeRoot()
12791279
}
1280-
return pb.(*eth.BeaconBlockBodyElectra).HashTreeRoot()
1280+
return pb.(*eth.BeaconBlockBodyFulu).HashTreeRoot()
12811281
default:
12821282
return [field_params.RootLength]byte{}, errIncorrectBodyVersion
12831283
}

Diff for: consensus-types/blocks/proto.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,15 @@ func (b *BeaconBlock) Proto() (proto.Message, error) { // nolint:gocognit
382382
Body: body,
383383
}, nil
384384
}
385-
var body *eth.BeaconBlockBodyElectra
385+
var body *eth.BeaconBlockBodyFulu
386386
if bodyMessage != nil {
387387
var ok bool
388-
body, ok = bodyMessage.(*eth.BeaconBlockBodyElectra)
388+
body, ok = bodyMessage.(*eth.BeaconBlockBodyFulu)
389389
if !ok {
390390
return nil, errIncorrectBodyVersion
391391
}
392392
}
393-
return &eth.BeaconBlockElectra{
393+
return &eth.BeaconBlockFulu{
394394
Slot: b.slot,
395395
ProposerIndex: b.proposerIndex,
396396
ParentRoot: b.parentRoot[:],
@@ -643,15 +643,15 @@ func (b *BeaconBlockBody) Proto() (proto.Message, error) {
643643
ExecutionRequests: b.executionRequests,
644644
}, nil
645645
}
646-
var p *enginev1.ExecutionPayloadDeneb
646+
var p *enginev1.ExecutionPayloadFulu
647647
var ok bool
648648
if b.executionPayload != nil {
649-
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadDeneb)
649+
p, ok = b.executionPayload.Proto().(*enginev1.ExecutionPayloadFulu)
650650
if !ok {
651651
return nil, errPayloadWrongType
652652
}
653653
}
654-
return &eth.BeaconBlockBodyElectra{
654+
return &eth.BeaconBlockBodyFulu{
655655
RandaoReveal: b.randaoReveal[:],
656656
Eth1Data: b.eth1Data,
657657
Graffiti: b.graffiti[:],

Diff for: encoding/bytesutil/integers.go

+5
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ func BigIntToLittleEndianBytes(bigInt *big.Int) []byte {
155155
return ReverseByteOrder(bigInt.Bytes())
156156
}
157157

158+
// Uint8ToSSZBytes takes a uint8 and returns its bytes stored as little-endian
159+
func Uint8ToSSZBytes(num uint8) []byte {
160+
return []byte{num}
161+
}
162+
158163
// Uint256ToSSZBytes takes a string representation of uint256 and returns its bytes stored as little-endian
159164
func Uint256ToSSZBytes(num string) ([]byte, error) {
160165
uint256, ok := new(big.Int).SetString(num, 10)

Diff for: proto/engine/v1/engine.ssz.go

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: proto/engine/v1/execution_engine.pb.go

+30-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)