Skip to content

Commit

Permalink
Merge pull request #1300 from bloxapp/stage
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
moshe-blox authored Feb 4, 2024
2 parents e5a6d71 + 4765191 commit f3c8bf1
Show file tree
Hide file tree
Showing 106 changed files with 189,666 additions and 418 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
data
docs
e2e
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: PR template
about: PR template to make sure devs run the E2E suite on the branch
title: ''
labels:
assignees: ''

---


- [ ] E2E passed - [action log](put link here)
36 changes: 36 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: E2E Test

on:
workflow_run:
workflows: [Lint, Unit tests]
types: [completed]
branches: [stage, main]
# pull_request:
# branches:
# - "**"

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
e2e:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Run e2e.sh
env:
BEACON_NODE_URL: ${{ secrets.E2E_BEACON_NODE_URL }}
EXECUTION_NODE_URL: ${{ secrets.E2E_EXECUTION_NODE_URL }}
run: |
cd ./e2e/
chmod +x ./run.sh
./run.sh
- name: clean up
run: docker compose down -v
33 changes: 33 additions & 0 deletions .k8/production/holesky/ssv-full-node-holesky-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-holesky-1-api
namespace: REPLACE_NAMESPACE
spec:
hosts:
- "ssv-full-node-holesky-1.REPLACE_DOMAIN_SUFFIX"
gateways:
- ssv-full-node-holesky-1-api
http:
- route:
- destination:
host: ssv-full-node-holesky-1
port:
number: 16021
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ssv-full-node-holesky-1-api
namespace: REPLACE_NAMESPACE
spec:
selector:
istio: ingressgateway-int
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "ssv-full-node-holesky-1.REPLACE_DOMAIN_SUFFIX"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-holesky-1
namespace: REPLACE_NAMESPACE
Expand Down
33 changes: 33 additions & 0 deletions .k8/production/mainnet/ssv-exporter-1.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-mainnet-1-api
namespace: REPLACE_NAMESPACE
spec:
hosts:
- "ssv-full-node-mainnet-1.REPLACE_DOMAIN_SUFFIX"
gateways:
- ssv-full-node-mainnet-1-api
http:
- route:
- destination:
host: ssv-full-node-mainnet-1
port:
number: 16015
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ssv-full-node-mainnet-1-api
namespace: REPLACE_NAMESPACE
spec:
selector:
istio: ingressgateway-int
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "ssv-full-node-mainnet-1.REPLACE_DOMAIN_SUFFIX"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-mainnet-1
namespace: REPLACE_NAMESPACE
Expand Down
33 changes: 33 additions & 0 deletions .k8/production/prater/ssv-exporter-1.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-prater-1-api
namespace: REPLACE_NAMESPACE
spec:
hosts:
- "ssv-full-node-prater-1.REPLACE_DOMAIN_SUFFIX"
gateways:
- ssv-full-node-prater-1-api
http:
- route:
- destination:
host: ssv-full-node-prater-1
port:
number: 16009
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: ssv-full-node-prater-1-api
namespace: REPLACE_NAMESPACE
spec:
selector:
istio: ingressgateway-int
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "ssv-full-node-prater-1.REPLACE_DOMAIN_SUFFIX"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: ssv-full-node-prater-1
namespace: REPLACE_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,mode=0755,target=/go/pkg \
COMMIT=$(git rev-parse HEAD) && \
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) && \
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1) --always) && \
CGO_ENABLED=1 GOOS=linux go install \
-tags="blst_enabled,jemalloc,allocator" \
-ldflags "-X main.Commit=$COMMIT -X main.Version=$VERSION -linkmode external -extldflags \"-static -lm\"" \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ UNFORMATTED=$(shell gofmt -s -l .)
.PHONY: lint-prepare
lint-prepare:
@echo "Preparing Linter"
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s latest
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest

.PHONY: lint
lint:
Expand Down
2 changes: 1 addition & 1 deletion api/handlers/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func byPubKeys(pubkeys []api.Hex) registrystorage.SharesFilter {
func byIndices(indices []uint64) registrystorage.SharesFilter {
return func(share *types.SSVShare) bool {
for _, index := range indices {
if share.Metadata.BeaconMetadata.Index == phase0.ValidatorIndex(index) {
if share.BeaconMetadata != nil && share.BeaconMetadata.Index == phase0.ValidatorIndex(index) {
return true
}
}
Expand Down
42 changes: 25 additions & 17 deletions beacon/goclient/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package goclient

import (
"encoding/binary"
"fmt"
"time"

"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
)

// SubmitAggregateSelectionProof returns an AggregateAndProof object
Expand All @@ -20,36 +21,43 @@ func (gc *goClient) SubmitAggregateSelectionProof(slot phase0.Slot, committeeInd
// differ from spec because we need to subscribe to subnet
isAggregator, err := isAggregator(committeeLength, slotSig)
if err != nil {
return nil, DataVersionNil, errors.Wrap(err, "could not get aggregator status")
return nil, DataVersionNil, fmt.Errorf("failed to check if validator is an aggregator: %w", err)
}
if !isAggregator {
return nil, DataVersionNil, errors.New("validator is not an aggregator")
return nil, DataVersionNil, fmt.Errorf("validator is not an aggregator")
}

attDataReqStart := time.Now()
data, err := gc.client.AttestationData(gc.ctx, slot, committeeIndex)
attDataSSZMarshal, _, err := gc.GetAttestationData(slot, committeeIndex)
if err != nil {
return nil, DataVersionNil, errors.Wrap(err, "failed to get attestation data")
return nil, DataVersionNil, fmt.Errorf("failed to get attestation data: %w", err)
}
if data == nil {
return nil, DataVersionNil, errors.New("attestation data is nil")
if attDataSSZMarshal == nil {
return nil, DataVersionNil, fmt.Errorf("attestation data is nil")
}
attData, ok := attDataSSZMarshal.(*phase0.AttestationData)
if !ok {
return nil, DataVersionNil, fmt.Errorf("failed to cast attestation data")
}

metricsAttesterDataRequest.Observe(time.Since(attDataReqStart).Seconds())

// Get aggregate attestation data.
root, err := data.HashTreeRoot()
root, err := attData.HashTreeRoot()
if err != nil {
return nil, DataVersionNil, errors.Wrap(err, "AttestationData.HashTreeRoot")
return nil, DataVersionNil, fmt.Errorf("failed to get attestation data root: %w", err)
}

aggDataReqStart := time.Now()
aggregateData, err := gc.client.AggregateAttestation(gc.ctx, slot, root)
aggDataResp, err := gc.client.AggregateAttestation(gc.ctx, &api.AggregateAttestationOpts{
Slot: slot,
AttestationDataRoot: root,
})
if err != nil {
return nil, DataVersionNil, errors.Wrap(err, "failed to get aggregate attestation")
return nil, DataVersionNil, fmt.Errorf("failed to get aggregate attestation: %w", err)
}
if aggDataResp == nil {
return nil, DataVersionNil, fmt.Errorf("aggregate attestation response is nil")
}
if aggregateData == nil {
return nil, DataVersionNil, errors.New("aggregation data is nil")
if aggDataResp.Data == nil {
return nil, DataVersionNil, fmt.Errorf("aggregate attestation data is nil")
}

metricsAggregatorDataRequest.Observe(time.Since(aggDataReqStart).Seconds())
Expand All @@ -59,7 +67,7 @@ func (gc *goClient) SubmitAggregateSelectionProof(slot phase0.Slot, committeeInd

return &phase0.AggregateAndProof{
AggregatorIndex: index,
Aggregate: aggregateData,
Aggregate: aggDataResp.Data,
SelectionProof: selectionProof,
}, spec.DataVersionPhase0, nil
}
Expand Down
32 changes: 25 additions & 7 deletions beacon/goclient/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package goclient

import (
"context"
"fmt"
"time"

"github.com/attestantio/go-eth2-client/api"
eth2apiv1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/phase0"
Expand All @@ -14,20 +16,36 @@ import (

// AttesterDuties returns attester duties for a given epoch.
func (gc *goClient) AttesterDuties(ctx context.Context, epoch phase0.Epoch, validatorIndices []phase0.ValidatorIndex) ([]*eth2apiv1.AttesterDuty, error) {
return gc.client.AttesterDuties(ctx, epoch, validatorIndices)
resp, err := gc.client.AttesterDuties(ctx, &api.AttesterDutiesOpts{
Epoch: epoch,
Indices: validatorIndices,
})
if err != nil {
return nil, fmt.Errorf("failed to obtain attester duties: %w", err)
}
if resp == nil {
return nil, fmt.Errorf("attester duties response is nil")
}

return resp.Data, nil
}

func (gc *goClient) GetAttestationData(slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (ssz.Marshaler, spec.DataVersion, error) {

startTime := time.Now()
attestationData, err := gc.client.AttestationData(gc.ctx, slot, committeeIndex)
attDataReqStart := time.Now()
resp, err := gc.client.AttestationData(gc.ctx, &api.AttestationDataOpts{
Slot: slot,
CommitteeIndex: committeeIndex,
})
if err != nil {
return nil, DataVersionNil, err
return nil, DataVersionNil, fmt.Errorf("failed to get attestation data: %w", err)
}
if resp == nil {
return nil, DataVersionNil, fmt.Errorf("attestation data response is nil")
}

metricsAttesterDataRequest.Observe(time.Since(startTime).Seconds())
metricsAttesterDataRequest.Observe(time.Since(attDataReqStart).Seconds())

return attestationData, spec.DataVersionPhase0, nil
return resp.Data, spec.DataVersionPhase0, nil
}

// SubmitAttestation implements Beacon interface
Expand Down
Loading

0 comments on commit f3c8bf1

Please sign in to comment.