mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
delete ssz server which is no longer needed (#3578)
This commit is contained in:
parent
3dcaeabb3e
commit
7c9ddfeb58
@ -1,55 +0,0 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
|
||||
load("@io_bazel_rules_docker//go:image.bzl", "go_image")
|
||||
load("@io_bazel_rules_docker//container:container.bzl", "container_bundle")
|
||||
load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["main.go"],
|
||||
importpath = "github.com/prysmaticlabs/prysm/tools/ssz-server",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//proto/eth/v1alpha1:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||
"@org_uber_go_automaxprocs//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "ssz-server",
|
||||
embed = [":go_default_library"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
go_image(
|
||||
name = "image",
|
||||
srcs = ["main.go"],
|
||||
goarch = "amd64",
|
||||
goos = "linux",
|
||||
importpath = "github.com/prysmaticlabs/prysm/tools/ssz-server",
|
||||
pure = "on",
|
||||
race = "off",
|
||||
static = "on",
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//proto/eth/v1alpha1:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||
"@org_uber_go_automaxprocs//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
container_bundle(
|
||||
name = "image_bundle",
|
||||
images = {
|
||||
"gcr.io/prysmaticlabs/prysm/ssz-server:latest": ":image",
|
||||
"gcr.io/prysmaticlabs/prysm/ssz-server:{DOCKER_TAG}": ":image",
|
||||
},
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
docker_push(
|
||||
name = "push_images",
|
||||
bundle = ":image_bundle",
|
||||
tags = ["manual"],
|
||||
)
|
@ -1,96 +0,0 @@
|
||||
// This binary is a simple ssz deserializer REST API endpoint for the testnet
|
||||
// frontend to decode the deposit data for the user.
|
||||
// This should be removed after https://github.com/prysmaticlabs/prysm-testnet-site/issues/37
|
||||
// is resolved.
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
ssz "github.com/prysmaticlabs/go-ssz"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
||||
_ "go.uber.org/automaxprocs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/healthz", healthz)
|
||||
mux.HandleFunc("/api/decodeDepositData", decodeDepositData)
|
||||
|
||||
log.Println("Starting on port 4000")
|
||||
if err := http.ListenAndServe(":4000", mux); err != nil {
|
||||
log.Fatalf("Failed to start server %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func healthz(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
type deserializationRequest struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
func decodeDepositData(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
log.Printf("Failed to read request body: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
requestData := &deserializationRequest{}
|
||||
if err := json.Unmarshal(data, requestData); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
log.Printf("Unable to unmarshal JSON: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(requestData.Data) < 2 {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
encodedData, err := hex.DecodeString(requestData.Data[2:])
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, err = fmt.Fprintf(w, "Failed to decode hex string")
|
||||
if err != nil {
|
||||
log.Printf("Failed to write data to client: %v\n", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
di := ðpb.Deposit_Data{}
|
||||
|
||||
if err := ssz.Unmarshal(encodedData, di); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_, err := fmt.Fprintf(w, "Failed to decode SSZ data: %v", err)
|
||||
if err != nil {
|
||||
log.Printf("Failed to write data to client: %v\n", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
b, err := json.Marshal(di)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
log.Printf("Failed to marshal deposit data: %v\n", err)
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, err = w.Write(b)
|
||||
if err != nil {
|
||||
log.Printf("Failed to write data to client: %v\n", err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user