Skip to content

Commit

Permalink
Merge pull request #1938 from ssvlabs/stage
Browse files Browse the repository at this point in the history
release: stage to main for v2.0.2
  • Loading branch information
y0sher authored Dec 15, 2024
2 parents 2315559 + d6a3442 commit b5766a8
Show file tree
Hide file tree
Showing 277 changed files with 2,704 additions and 25,346 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/genesis-spec-alignment.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/workflows/spec-test-raceless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,5 @@ jobs:
with:
go-version: "1.22.x"

- name: Run pre-fork spec tests
run: make pre-fork-spec-test-raceless

- name: Run post-fork spec tests
run: make post-fork-spec-test-raceless

- name: Run all spec tests
run: make all-spec-test-raceless
86 changes: 0 additions & 86 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ variables:
IMAGE_NAME: ssv-node
DOCKER_BUILDKIT: 1

#STAGE
ACCOUNT_ID_INFRA_STAGE: 121827225315
AWS_REGION_INFRA_STAGE: "us-west-2"
DOCKER_REPO_INFRA_STAGE: $ACCOUNT_ID_INFRA_STAGE.dkr.ecr.$AWS_REGION_INFRA_STAGE.amazonaws.com/$IMAGE_NAME
APP_REPLICAS_INFRA_STAGE: "1"
ECRLOGIN_INFRA_STAGE: "aws ecr get-login --registry-ids $ACCOUNT_ID_INFRA_STAGE --region $AWS_REGION_INFRA_STAGE --no-include-email"
STAGE_HEALTH_CHECK_IMAGE: 121827225315.dkr.ecr.us-west-2.amazonaws.com/infra-stage-repo:ubuntu20

#PRODUCTION
ACCOUNT_ID_INFRA_PROD: 764289642555
AWS_REGION_INFRA_PROD: "us-west-2"
Expand All @@ -23,84 +15,6 @@ variables:
ECRLOGIN_INFRA_PROD: "aws ecr get-login --registry-ids $ACCOUNT_ID_INFRA_PROD --region $AWS_REGION_INFRA_PROD --no-include-email"
PROD_HEALTH_CHECK_IMAGE: 764289642555.dkr.ecr.us-west-2.amazonaws.com/infra-prod-repo:ubuntu20

# +-------+
# | STAGE |
# +-------+
Build stage Docker image:
image: docker:20.10.23
stage: build
tags:
- blox-infra-stage
script:
- apk add --no-cache py-pip
- pip install pyyaml==5.3.1
- pip install awscli
- docker build -t $IMAGE_NAME:$CI_COMMIT_SHA -f Dockerfile .
- DOCKER_LOGIN_TO_INFRA_STAGE_REPO=`$ECRLOGIN_INFRA_STAGE`
- docker tag $IMAGE_NAME:$CI_COMMIT_SHA $DOCKER_REPO_INFRA_STAGE:$CI_COMMIT_SHA
- $DOCKER_LOGIN_TO_INFRA_STAGE_REPO && docker push $DOCKER_REPO_INFRA_STAGE:$CI_COMMIT_SHA
only:
- stage

# +---------------------+
# | STAGE HETZNER NODES |
# +---------------------+


Deploy nodes to hetzner stage:
stage: deploy
tags:
- hetzner-k8s-stage
image: bitnami/kubectl:1.27.5
script:
- export K8S_API_VERSION=$INFRA_STAGE_K8_API_VERSION
- export SSV_NODES_CPU_LIMIT=$HETZNER_STAGE_SSV_NODES_CPU_LIMIT
- export SSV_NODES_MEM_LIMIT=$HETZNER_STAGE_SSV_NODES_MEM_LIMIT
- echo $HETZNER_KUBECONFIG | base64 -d > kubeconfig
- mv kubeconfig ~/.kube/
- export KUBECONFIG=~/.kube/kubeconfig
- kubectl config get-contexts
#
# +--------------------+
# | Deploy SSV nodes |
# +--------------------+
- .k8/hetzner-stage/scripts/deploy-cluster-1--4.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-5--8.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-9--12.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-13--16.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-17--20.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-21--24.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-25--28.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-29--32.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-33--36.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-37--40.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-41--44.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-45--48.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-49--52.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-53--56.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-57--60.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-61--64.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-65--68.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
- .k8/hetzner-stage/scripts/deploy-cluster-69--72.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $STAGE_HEALTH_CHECK_IMAGE $SSV_NODES_CPU_LIMIT $SSV_NODES_MEM_LIMIT
only:
- stage

Deploy exporter to hetzner stage:
stage: deploy
tags:
- hetzner-k8s-stage
image: bitnami/kubectl:1.27.5
script:
- export K8S_API_VERSION=$INFRA_STAGE_K8_API_VERSION
- export SSV_EXPORTER_CPU_LIMIT=$STAGE_SSV_EXPORTER_CPU_LIMIT
- export SSV_EXPORTER_MEM_LIMIT=$STAGE_SSV_EXPORTER_MEM_LIMIT
- echo $HETZNER_KUBECONFIG | base64 -d > kubeconfig
- mv kubeconfig ~/.kube/
- export KUBECONFIG=~/.kube/kubeconfig
- kubectl config get-contexts
- .k8/hetzner-stage/scripts/deploy-holesky-exporters.sh $DOCKER_REPO_INFRA_STAGE $CI_COMMIT_SHA ssv $APP_REPLICAS_INFRA_STAGE hetzner.stage.k8s.local hetzner.stage.k8s.local stage.ssv.network $K8S_API_VERSION $SSV_EXPORTER_CPU_LIMIT $SSV_EXPORTER_MEM_LIMIT
only:
- stage

# +---------------+
# | Prod |
Expand Down
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ FROM golang:1.22 AS preparer
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl \
git=1:2.39.5-0+deb12u1 \
zip=3.0-13 \
unzip=6.0-28 \
g++=4:12.2.0-3 \
gcc-aarch64-linux-gnu=4:12.2.0-3 \
bzip2=1.0.8-5+b1 \
make=4.3-4.1 \
git \
zip \
unzip \
g++ \
gcc-aarch64-linux-gnu \
bzip2 \
make \
&& rm -rf /var/lib/apt/lists/*

RUN go version
Expand Down Expand Up @@ -49,7 +49,7 @@ FROM golang:1.22 AS runner

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
dnsutils=1:9.18.28-1~deb12u2 && \
dnsutils && \
rm -rf /var/lib/apt/lists/*

WORKDIR /
Expand Down
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,11 @@ spec-test:
@echo "Running spec tests"
@go test -tags blst_enabled -timeout 90m ${COV_CMD} -race -count=1 -p 1 -v `go list ./... | grep spectest`


.PHONY: all-spec-test-raceless
all-spec-test-raceless:
@echo "Running spec tests"
@go test -tags blst_enabled -timeout 90m ${COV_CMD} -p 1 -v ./protocol/...


.PHONY: pre-fork-spec-test-raceless
pre-fork-spec-test-raceless:
@echo "Running spec tests"
@go test -tags blst_enabled -timeout 90m ${COV_CMD} -p 1 -v ./protocol/genesis/...

.PHONY: post-fork-spec-test-raceless
post-fork-spec-test-raceless:
@echo "Running spec tests"
@go test -tags blst_enabled -timeout 90m ${COV_CMD} -p 1 -v ./protocol/v2/...

.PHONY: spec-test-raceless
spec-test-raceless:
@echo "Running spec tests without race flag"
Expand Down
6 changes: 6 additions & 0 deletions api/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ func Bind(r *http.Request, dest interface{}) error {
return err
}
fieldValue.SetInt(v)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
v, err := strconv.ParseUint(formValue, 10, 64)
if err != nil {
return err
}
fieldValue.SetUint(v)
case reflect.Float32, reflect.Float64:
v, err := strconv.ParseFloat(formValue, 64)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (e *ErrorResponse) Error() string {
return e.Err.Error()
}

func InvalidRequestError(err error) *ErrorResponse {
func BadRequestError(err error) *ErrorResponse {
return &ErrorResponse{
Err: err,
Code: 400,
Expand Down
119 changes: 119 additions & 0 deletions api/handlers/exporter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package handlers

import (
"fmt"
"net/http"

"github.com/attestantio/go-eth2-client/spec/phase0"
spectypes "github.com/ssvlabs/ssv-spec/types"

"github.com/ssvlabs/ssv/api"
exporterapi "github.com/ssvlabs/ssv/exporter/api"
"github.com/ssvlabs/ssv/exporter/convert"
ibftstorage "github.com/ssvlabs/ssv/ibft/storage"
qbftstorage "github.com/ssvlabs/ssv/protocol/v2/qbft/storage"
"github.com/ssvlabs/ssv/utils/casts"
)

type Exporter struct {
DomainType spectypes.DomainType
QBFTStores *ibftstorage.QBFTStores
}

type ParticipantResponse struct {
Role string `json:"role"`
Slot uint64 `json:"slot"`
PublicKey string `json:"public_key"`
Message struct {
// We're keeping "Signers" capitalized to avoid breaking existing clients that rely on the current structure
Signers []uint64 `json:"Signers"`
} `json:"message"`
}

func (e *Exporter) Decideds(w http.ResponseWriter, r *http.Request) error {
var request struct {
From uint64 `json:"from"`
To uint64 `json:"to"`
Roles api.RoleSlice `json:"roles"`
PubKeys api.HexSlice `json:"pubkeys"`
}
var response struct {
Data []*ParticipantResponse `json:"data"`
}

if err := api.Bind(r, &request); err != nil {
return api.BadRequestError(err)
}

if request.From > request.To {
return api.BadRequestError(fmt.Errorf("'from' must be less than or equal to 'to'"))
}

if len(request.PubKeys) == 0 {
return api.BadRequestError(fmt.Errorf("at least one public key is required"))
}

if len(request.Roles) == 0 {
return api.BadRequestError(fmt.Errorf("at least one role is required"))
}

response.Data = []*ParticipantResponse{}

qbftStores := make(map[convert.RunnerRole]qbftstorage.QBFTStore, len(request.Roles))
for _, role := range request.Roles {
runnerRole := casts.BeaconRoleToConvertRole(spectypes.BeaconRole(role))
storage := e.QBFTStores.Get(runnerRole)
if storage == nil {
return api.Error(fmt.Errorf("role storage doesn't exist: %v", role))
}

qbftStores[runnerRole] = storage
}

for _, role := range request.Roles {
runnerRole := casts.BeaconRoleToConvertRole(spectypes.BeaconRole(role))
qbftStore := qbftStores[runnerRole]

for _, pubKey := range request.PubKeys {
msgID := convert.NewMsgID(e.DomainType, pubKey, runnerRole)
from := phase0.Slot(request.From)
to := phase0.Slot(request.To)

participantsList, err := qbftStore.GetParticipantsInRange(msgID, from, to)
if err != nil {
return api.Error(fmt.Errorf("error getting participants: %w", err))
}

if len(participantsList) == 0 {
continue
}

data, err := exporterapi.ParticipantsAPIData(participantsList...)
if err != nil {
return api.Error(fmt.Errorf("error getting participants API data: %w", err))
}

apiData, ok := data.([]*exporterapi.ParticipantsAPI)
if !ok {
return api.Error(fmt.Errorf("invalid type for participants API data"))
}

for _, apiMsg := range apiData {
response.Data = append(response.Data, transformToParticipantResponse(apiMsg))
}
}
}

return api.Render(w, r, response)
}

func transformToParticipantResponse(apiMsg *exporterapi.ParticipantsAPI) *ParticipantResponse {
response := &ParticipantResponse{
Role: apiMsg.Role,
Slot: uint64(apiMsg.Slot),
PublicKey: apiMsg.ValidatorPK,
}
response.Message.Signers = apiMsg.Signers

return response
}
Loading

0 comments on commit b5766a8

Please sign in to comment.