Skip to content

Commit

Permalink
Add print_validator_info()
Browse files Browse the repository at this point in the history
  • Loading branch information
Giacomo Licari committed Nov 29, 2023
1 parent 441fc16 commit 772e57e
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 61 deletions.
126 changes: 66 additions & 60 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- unstable
- stable
- hopr
tags:
- v*

Expand All @@ -13,12 +14,9 @@ concurrency:
cancel-in-progress: true

env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
IMAGE_NAME: ${{ github.repository_owner}}/lighthouse
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli
# Enable self-hosted runners for the sigp repo only.
SELF_HOSTED_RUNNERS: ${{ github.repository == 'sigp/lighthouse' }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-hopr
LCLI_IMAGE_NAME: ${{ github.repository_owner }}/lcli

jobs:
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
Expand Down Expand Up @@ -48,19 +46,21 @@ jobs:
outputs:
VERSION: ${{ env.VERSION }}
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}

build-docker-single-arch:
name: build-docker-${{ matrix.binary }}${{ matrix.features.version_suffix }}
# Use self-hosted runners only on the sigp repo.
runs-on: ${{ github.repository == 'sigp/lighthouse' && fromJson('["self-hosted", "linux", "release"]') || 'ubuntu-22.04' }}
# Use self-hosted runners only on the gnosischain repo.
runs-on: ubuntu-22.04
strategy:
matrix:
binary: [aarch64,
aarch64-portable,
x86_64,
x86_64-portable]
binary: [x86_64]
# binary: [aarch64,
# aarch64-portable,
# x86_64,
# x86_64-portable]
features: [
{version_suffix: "", env: "gnosis,slasher-lmdb,slasher-mdbx,jemalloc"},
{version_suffix: "-dev", env: "jemalloc,spec-minimal"}
{version_suffix: "", env: "gnosis,slasher-lmdb,slasher-mdbx,jemalloc"}
# {version_suffix: "-dev", env: "jemalloc,spec-minimal"}
]
include:
- profile: maxperf
Expand All @@ -71,13 +71,21 @@ jobs:
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
FEATURE_SUFFIX: ${{ matrix.features.version_suffix }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update Rust
if: env.SELF_HOSTED_RUNNERS == 'false'
run: rustup update stable
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Cross build Lighthouse binary
run: |
cargo install cross
Expand All @@ -101,11 +109,9 @@ jobs:
run: echo "MODERNITY_SUFFIX=-modern" >> $GITHUB_ENV;

- name: Install QEMU
if: env.SELF_HOSTED_RUNNERS == 'false'
run: sudo apt-get update && sudo apt-get install -y qemu-user-static

- name: Set up Docker Buildx
if: env.SELF_HOSTED_RUNNERS == 'false'
uses: docker/setup-buildx-action@v2

- name: Build and push
Expand All @@ -117,45 +123,45 @@ jobs:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }}

build-docker-multiarch:
name: build-docker-multiarch${{ matrix.modernity }}
runs-on: ubuntu-22.04
needs: [build-docker-single-arch, extract-version]
strategy:
matrix:
modernity: ["", "-modern"]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# build-docker-multiarch:
# name: build-docker-multiarch${{ matrix.modernity }}
# runs-on: ubuntu-22.04
# needs: [build-docker-single-arch, extract-version]
# strategy:
# matrix:
# modernity: ["", "-modern"]
# env:
# VERSION: ${{ needs.extract-version.outputs.VERSION }}
# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
# steps:
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2

- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
# - name: Dockerhub login
# run: |
# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin

- name: Create and push multiarch manifest
run: |
docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};
# - name: Create and push multiarch manifest
# run: |
# docker buildx imagetools create -t ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}${{ matrix.modernity }} \
# ${IMAGE_NAME}:${VERSION}-arm64${VERSION_SUFFIX}${{ matrix.modernity }} \
# ${IMAGE_NAME}:${VERSION}-amd64${VERSION_SUFFIX}${{ matrix.modernity }};

build-docker-lcli:
runs-on: ubuntu-22.04
needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
steps:
- uses: actions/checkout@v3
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Build lcli dockerfile (with push)
run: |
docker build \
--build-arg PORTABLE=true \
--tag ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX} \
--file ./lcli/Dockerfile .
docker push ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}
# build-docker-lcli:
# runs-on: ubuntu-22.04
# needs: [extract-version]
# env:
# VERSION: ${{ needs.extract-version.outputs.VERSION }}
# VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
# steps:
# - uses: actions/checkout@v3
# - name: Dockerhub login
# run: |
# echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
# - name: Build lcli dockerfile (with push)
# run: |
# docker build \
# --build-arg PORTABLE=true \
# --tag ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX} \
# --file ./lcli/Dockerfile .
# docker push ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use store::hot_cold_store::HotColdDBError;
use bls::PublicKey;
use tokio::sync::mpsc;
use types::{
Attestation, AttesterSlashing, EthSpec, Hash256, IndexedAttestation, LightClientFinalityUpdate,
Attestation, AttestationData, AttesterSlashing, EthSpec, Hash256, IndexedAttestation, LightClientFinalityUpdate,
LightClientOptimisticUpdate, ProposerSlashing, SignedAggregateAndProof, SignedBeaconBlock,
SignedBlsToExecutionChange, SignedContributionAndProof, SignedVoluntaryExit, Slot, SubnetId,
SyncCommitteeMessage, SyncSubnetId,
Expand Down Expand Up @@ -290,6 +291,49 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
}
}

fn print_validator_info(&self, peer_id: String, data: &AttestationData, validator_idx: usize, pub_key: PublicKey) {

let peer_addrs = if let Some((_, pinfo)) = self.network_globals.peers
.read()
.peers()
.find(|(pid, _)| pid.to_base58() == peer_id)
{
if let Some(multiaddr) = pinfo.seen_multiaddrs().next() {
multiaddr.to_string()
} else if let Some(addr) = pinfo.listening_addresses().first() {
addr.to_string()
} else {
"none".to_string()
}

// if let Some(socket_addr) = pinfo.seen_ip_addresses().next() {
// let mut addr =
// lighthouse_network::Multiaddr::from(socket_addr.ip());
// addr.push(lighthouse_network::multiaddr::Protocol::Tcp(
// socket_addr.port(),
// ));
// addr.to_string()
// } else if let Some(addr) = pinfo.listening_addresses().first() {
// addr.to_string()
// } else {
// "none".to_string()
// }
}
else {
"none".to_string()
};

info!(self.log,
"Verified UNAGGREGATED attestation";
"validator_idx" => validator_idx,
"peer_id" => peer_id,
"pub_key" => pub_key.as_hex_string(),
"peer_addrs" => peer_addrs,
"slot" => data.slot.as_u64(), "epoch" => data.slot.epoch(T::EthSpec::slots_per_epoch()).as_u64(),
"rel_slot" => data.slot.epoch(T::EthSpec::slots_per_epoch()).position(data.slot, T::EthSpec::slots_per_epoch())
);
}

// Clippy warning is is ignored since the arguments are all of a different type (i.e., they
// cant' be mixed-up) and creating a struct would result in more complexity.
#[allow(clippy::too_many_arguments)]
Expand All @@ -308,6 +352,27 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
let indexed_attestation = &verified_attestation.indexed_attestation;
let beacon_block_root = indexed_attestation.data.beacon_block_root;

// HOPR - print info about validators
for validator_idx in &indexed_attestation.attesting_indices {
let idx = *validator_idx as usize;
if let Ok(pk) = self.chain.validator_pubkey(idx) {
if let Some(pub_key) = pk {
self.print_validator_info(peer_id.to_base58(),
&verified_attestation.attestation.data,
idx,
pub_key);
}
else {
error!(self.log, "Failed to determine public key for unaggregated attestation";
"validator_idx" => idx);
}
}
else {
error!(self.log, "Failed to determine public key for unaggregated attestation";
"validator_idx" => idx);
}
}

// Register the attestation with any monitored validators.
self.chain
.validator_monitor
Expand Down

0 comments on commit 772e57e

Please sign in to comment.