From 9fd6d83a3d8596fa5963e91c6f86443224f8e985 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Wed, 29 Nov 2023 10:42:44 +0100 Subject: [PATCH] Add print_validator_info() --- .github/workflows/docker.yml | 129 +++++++++--------- beacon_node/network/Cargo.toml | 1 + .../gossip_methods.rs | 67 ++++++++- 3 files changed, 135 insertions(+), 62 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 007070dbb5b..4c84a131daa 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,6 +5,7 @@ on: branches: - unstable - stable + - hopr tags: - v* @@ -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 @@ -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: [aarch64, 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 @@ -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 @@ -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 @@ -115,47 +121,48 @@ jobs: context: . platforms: linux/${{ env.SHORT_ARCH }} push: true - tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-${{ env.SHORT_ARCH }}${{ env.VERSION_SUFFIX }}${{ env.MODERNITY_SUFFIX }}${{ env.FEATURE_SUFFIX }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - 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} diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index 0204fc2456c..5eea3b7d8f5 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -49,6 +49,7 @@ execution_layer = { workspace = true } beacon_processor = { workspace = true } parking_lot = { workspace = true } environment = { workspace = true } +bls = { workspace = true } [features] # NOTE: This can be run via cargo build --bin lighthouse --features network/disable-backfill diff --git a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs index ac7479db011..96555bb48f3 100644 --- a/beacon_node/network/src/network_beacon_processor/gossip_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/gossip_methods.rs @@ -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, @@ -290,6 +291,49 @@ impl NetworkBeaconProcessor { } } + 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)] @@ -308,6 +352,27 @@ impl NetworkBeaconProcessor { 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