Skip to content

Commit

Permalink
adding ssz response for get blobs beacon api endpoint (#12611)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm committed Aug 9, 2023
1 parent 64dd282 commit c3ddb2d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7,475 deletions.
52 changes: 0 additions & 52 deletions beacon-chain/rpc/apimiddleware/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,52 +0,0 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"custom_handlers.go",
"custom_hooks.go",
"endpoint_factory.go",
"structs.go",
"structs_marshalling.go",
],
importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/apimiddleware",
visibility = ["//visibility:public"],
deps = [
"//api:go_default_library",
"//api/gateway/apimiddleware:go_default_library",
"//api/grpc:go_default_library",
"//beacon-chain/rpc/eth/events:go_default_library",
"//beacon-chain/rpc/eth/helpers:go_default_library",
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//network/http:go_default_library",
"//proto/eth/v2:go_default_library",
"//runtime/version:go_default_library",
"//time/slots:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_r3labs_sse_v2//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"custom_handlers_test.go",
"custom_hooks_test.go",
"structs_marshalling_test.go",
],
embed = [":go_default_library"],
deps = [
"//api:go_default_library",
"//api/gateway/apimiddleware:go_default_library",
"//api/grpc:go_default_library",
"//beacon-chain/rpc/eth/events:go_default_library",
"//config/params:go_default_library",
"//proto/eth/v2:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"//time/slots:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_r3labs_sse_v2//:go_default_library",
],
)
47 changes: 0 additions & 47 deletions beacon-chain/rpc/eth/blob/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,47 +0,0 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"handlers.go",
"server.go",
"structs.go",
],
importpath = "github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/eth/blob",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/blockchain:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/rpc/eth/helpers:go_default_library",
"//beacon-chain/rpc/lookup:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//network/http:go_default_library",
"//proto/eth/v2:go_default_library",
"//proto/migration:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//time/slots:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
"@com_github_pkg_errors//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["handlers_test.go"],
embed = [":go_default_library"],
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/db/testing:go_default_library",
"//config/fieldparams:go_default_library",
"//config/params:go_default_library",
"//encoding/bytesutil:go_default_library",
"//network/http:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
],
)
37 changes: 0 additions & 37 deletions network/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,37 +0,0 @@
load("@prysm//tools/go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"auth.go",
"endpoint.go",
"external_ip.go",
],
importpath = "github.com/prysmaticlabs/prysm/v4/network",
visibility = ["//visibility:public"],
deps = [
"//network/authorization:go_default_library",
"@com_github_ethereum_go_ethereum//rpc:go_default_library",
"@com_github_golang_jwt_jwt_v4//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"auth_test.go",
"endpoint_test.go",
"external_ip_test.go",
],
embed = [":go_default_library"],
deps = [
"//encoding/bytesutil:go_default_library",
"//network/authorization:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"@com_github_golang_jwt_jwt_v4//:go_default_library",
"@com_github_sirupsen_logrus//hooks/test:go_default_library",
],
)
35 changes: 35 additions & 0 deletions network/writer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package network

import (
"fmt"
"net/http/httptest"
"strings"
"testing"

"github.com/ethereum/go-ethereum/common/hexutil"
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
eth "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/v4/testing/require"
)

func TestWriteSsz(t *testing.T) {
name := "test.ssz"
sidecar := &eth.BlobSidecar{
BlockRoot: make([]byte, fieldparams.RootLength),
Index: 0,
Slot: 0,
BlockParentRoot: make([]byte, fieldparams.RootLength),
ProposerIndex: 123,
Blob: make([]byte, fieldparams.BlobLength),
KzgCommitment: make([]byte, fieldparams.BLSPubkeyLength),
KzgProof: make([]byte, fieldparams.BLSPubkeyLength),
}
respSsz, err := sidecar.MarshalSSZ()
require.NoError(t, err)
writer := httptest.NewRecorder()
WriteSsz(writer, respSsz, name)
require.Equal(t, writer.Header().Get("Content-Type"), "application/octet-stream")
require.Equal(t, true, strings.Contains(writer.Header().Get("Content-Disposition"), name))
require.Equal(t, writer.Header().Get("Content-Length"), fmt.Sprintf("%v", len(respSsz)))
require.Equal(t, hexutil.Encode(writer.Body.Bytes()), hexutil.Encode(respSsz))
}
117 changes: 0 additions & 117 deletions proto/eth/v2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,117 +0,0 @@
##############################################################################
# Common
##############################################################################

load("@rules_proto//proto:defs.bzl", "proto_library")

# gazelle:ignore
proto_library(
name = "proto",
srcs = [
"beacon_chain.proto",
"ssz.proto",
"version.proto",
":ssz_proto_files",
],
visibility = ["//visibility:public"],
deps = [
"//proto/engine/v1:proto",
"//proto/eth/ext:proto",
"//proto/eth/v1:proto",
],
)

##############################################################################
# Go
##############################################################################
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("//proto:ssz_proto_library.bzl", "ssz_proto_files")
load("//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal")

ssz_gen_marshal(
name = "ssz_generated_files",
go_proto = ":go_proto",
includes = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/v1:go_default_library",
],
objs = [
"BlsToExecutionChange",
"SignedBeaconBlockAltair",
"SignedBeaconBlockBellatrix",
"SignedBlindedBeaconBlockBellatrix",
"SignedBeaconBlockCapella",
"SignedBlindedBeaconBlockCapella",
"SignedBeaconBlockDeneb",
"SignedBlindedBeaconBlockDeneb",
"BlsToExecutionChange",
"SignedBlsToExecutionChange",
"SignedBlindedBlobSidecar",
"BlindedBlobSidecar",
"BlobSidecar",
"BlobSidecars",
"SignedBeaconBlockContentsDeneb",
"SignedBlindedBeaconBlockContentsDeneb",
"BeaconBlockContentsDeneb",
"BlindedBeaconBlockContentsDeneb",
],
)

go_proto_library(
name = "go_proto",
compilers = [
"@com_github_prysmaticlabs_protoc_gen_go_cast//:go_cast_grpc",
],
importpath = "github.com/prysmaticlabs/prysm/v4/proto/eth/v2",
proto = ":proto",
visibility = ["//visibility:public"],
deps = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/eth/ext:go_default_library",
"//proto/eth/v1:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
],
)

go_proto_library(
name = "go_grpc_gateway_library",
compilers = [
"@com_github_grpc_ecosystem_grpc_gateway_v2//protoc-gen-grpc-gateway:go_gen_grpc_gateway",
],
embed = [":go_proto"],
importpath = "github.com/prysmaticlabs/prysm/v4/proto/eth/v2",
protos = [":proto"],
visibility = ["//proto:__subpackages__"],
)

go_library(
name = "go_default_library",
srcs = [
":ssz_generated_files",
],
embed = [":go_grpc_gateway_library"],
importpath = "github.com/prysmaticlabs/prysm/v4/proto/eth/v2",
visibility = ["//visibility:public"],
deps = SSZ_DEPS,
)

ssz_proto_files(
name = "ssz_proto_files",
srcs = [
"beacon_block.proto",
"beacon_state.proto",
"blobs.proto",
"sync_committee.proto",
"validator.proto",
"withdrawals.proto",
],
config = select({
"//conditions:default": "mainnet",
"//proto:ssz_mainnet": "mainnet",
"//proto:ssz_minimal": "minimal",
}),
)
Loading

0 comments on commit c3ddb2d

Please sign in to comment.