diff --git a/.github/packer/ubuntu-jammy-x86_64-public-ami.json b/.github/packer/ubuntu-jammy-x86_64-public-ami.json deleted file mode 100644 index cb0562b9bd6f..000000000000 --- a/.github/packer/ubuntu-jammy-x86_64-public-ami.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "variables": { - "version": "jammy-22.04", - "tag": "{{env `TAG`}}", - "skip_create_ami": "{{env `SKIP_CREATE_AMI`}}" - }, - "builders": [ - { - "type": "amazon-ebs", - "region": "us-east-1", - "skip_create_ami": "{{ user `skip_create_ami` }}", - "ami_name": "public-avalanche-ubuntu-{{ user `version` }}-{{ user `tag` }}-{{timestamp}}", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "name": "ubuntu/images/*ubuntu-{{ user `version` }}-*-server-*", - "root-device-type": "ebs", - "architecture": "x86_64" - }, - "most_recent": true, - "owners": [ - "099720109477" - ] - }, - "ssh_username": "ubuntu", - "instance_type": "c5.large", - "ami_groups": "all", - "tags": { - "Name": "public-avalanche-ubuntu-{{ user `version` }}-{{ user `tag` }}-{{ isotime | clean_resource_name }}", - "Release": "{{ user `version` }}", - "Base_AMI_Name": "{{ .SourceAMIName }}" - } - } - ], - "provisioners": [ - { - "type": "shell", - "inline": [ - "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done", - "wait_apt=$(ps aux | grep apt | wc -l)", - "while [ \"$wait_apt\" -gt \"1\" ]; do echo \"waiting for apt to be ready....\"; wait_apt=$(ps aux | grep apt | wc -l); sleep 5; done", - "sudo apt-get -y update", - "sudo apt-get install -y python3-boto3 golang" - ] - }, - { - "type": "ansible", - "playbook_file": ".github/packer/create_public_ami.yml", - "roles_path": ".github/packer/roles/", - "use_proxy": false, - "extra_arguments": ["-e", "component=public-ami build=packer os_release=jammy tag={{ user `tag` }}"] - }, - { - "type": "shell", - "script": ".github/packer/clean-public-ami.sh", - "execute_command": "sudo bash -x {{.Path}}" - } - ] -} - diff --git a/.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl b/.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl new file mode 100644 index 000000000000..c319e87134c7 --- /dev/null +++ b/.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl @@ -0,0 +1,81 @@ +packer { + required_plugins { + amazon = { + source = "github.com/hashicorp/amazon" + version = "~> 1" + } + ansible = { + source = "github.com/hashicorp/ansible" + version = "~> 1" + } + } +} + +variable "skip_create_ami" { + type = string + default = "${env("SKIP_CREATE_AMI")}" +} + +variable "tag" { + type = string + default = "${env("TAG")}" +} + +variable "version" { + type = string + default = "jammy-22.04" +} + +data "amazon-ami" "autogenerated_1" { + filters = { + architecture = "x86_64" + name = "ubuntu/images/*ubuntu-${var.version}-*-server-*" + root-device-type = "ebs" + virtualization-type = "hvm" + } + most_recent = true + owners = ["099720109477"] + region = "us-east-1" +} + +locals { + skip_create_ami = var.skip_create_ami == "True" + timestamp = regex_replace(timestamp(), "[- TZ:]", "") + clean_name = regex_replace(timestamp(), "[^a-zA-Z0-9-]", "-") +} + +source "amazon-ebs" "autogenerated_1" { + ami_groups = ["all"] + ami_name = "public-avalanche-ubuntu-${var.version}-${var.tag}-${local.timestamp}" + instance_type = "c5.large" + region = "us-east-1" + skip_create_ami = local.skip_create_ami + source_ami = "${data.amazon-ami.autogenerated_1.id}" + ssh_username = "ubuntu" + tags = { + Base_AMI_Name = "{{ .SourceAMIName }}" + Name = "public-avalanche-ubuntu-${var.version}-${var.tag}-${local.clean_name}" + Release = "${var.version}" + } +} + +build { + sources = ["source.amazon-ebs.autogenerated_1"] + + provisioner "shell" { + inline = ["while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done", "wait_apt=$(ps aux | grep apt | wc -l)", "while [ \"$wait_apt\" -gt \"1\" ]; do echo \"waiting for apt to be ready....\"; wait_apt=$(ps aux | grep apt | wc -l); sleep 5; done", "sudo apt-get -y update", "sudo apt-get install -y python3-boto3 golang"] + } + + provisioner "ansible" { + extra_arguments = ["-e", "component=public-ami build=packer os_release=jammy tag=${var.tag}"] + playbook_file = ".github/packer/create_public_ami.yml" + roles_path = ".github/packer/roles/" + use_proxy = false + } + + provisioner "shell" { + execute_command = "sudo bash -x {{ .Path }}" + script = ".github/packer/clean-public-ami.sh" + } + +} diff --git a/.github/workflows/buf-push.yml b/.github/workflows/buf-push.yml index 1b2f72dca75c..52407fe8b092 100644 --- a/.github/workflows/buf-push.yml +++ b/.github/workflows/buf-push.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.29.0 + - uses: bufbuild/buf-setup-action@v1.30.0 - uses: bufbuild/buf-push-action@v1 with: input: "proto" diff --git a/.github/workflows/build-public-ami.yml b/.github/workflows/build-public-ami.yml index 3ecd2fd4fb8f..84273d9900bc 100644 --- a/.github/workflows/build-public-ami.yml +++ b/.github/workflows/build-public-ami.yml @@ -10,6 +10,10 @@ on: tags: - "*" +env: + PACKER_VERSION: "1.10.2" + PYTHON3_BOTO3_VERSION: "1.20.34+dfsg-1" + jobs: build-public-ami-and-upload: runs-on: ubuntu-22.04 @@ -26,7 +30,7 @@ jobs: - name: Install aws cli run: | sudo apt update - sudo apt-get -y install packer python3-boto3 + sudo apt-get -y install python3-boto3=${PYTHON3_BOTO3_VERSION} - name: Get the tag id: get_tag @@ -53,6 +57,20 @@ jobs: aws-secret-access-key: ${{ secrets.MARKETPLACE_KEY }} aws-region: us-east-1 + - name: Setup `packer` + uses: hashicorp/setup-packer@main + id: setup + with: + version: ${{ env.PACKER_VERSION }} + + - name: Run `packer init` + id: init + run: "packer init ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" + + - name: Run `packer validate` + id: validate + run: "packer validate ./.github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" + - name: Create AMI and upload to marketplace run: | ./.github/workflows/update-ami.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1dfd862d566..7103cc1ace1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ concurrency: env: go_version: '~1.21.8' - tmpnet_data_path: ~/.tmpnet/networks/1000 + grafana_url: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?orgId=1&refresh=10s&var-filter=is_ephemeral_node%7C%3D%7Cfalse&var-filter=gh_repo%7C%3D%7Cava-labs%2Favalanchego&var-filter=gh_run_id%7C%3D%7C${{ github.run_id }}&var-filter=gh_run_attempt%7C%3D%7C${{ github.run_attempt }} jobs: Unit: @@ -67,15 +67,44 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r + - name: Start prometheus + shell: bash + run: bash -x ./scripts/run_prometheus.sh + env: + PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }} + PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }} + - name: Start promtail + shell: bash + run: bash -x ./scripts/run_promtail.sh + env: + LOKI_ID: ${{ secrets.LOKI_ID }} + LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }} + - name: Notify of metrics availability + shell: bash + run: .github/workflows/notify-metrics-availability.sh + env: + GRAFANA_URL: ${{ env.grafana_url }} + GH_JOB_ID: ${{ github.job }} + FILTER_BY_OWNER: avalanchego-e2e - name: Run e2e tests shell: bash run: E2E_SERIAL=1 ./scripts/tests.e2e.sh + env: + GH_REPO: ${{ github.repository }} + GH_WORKFLOW: ${{ github.workflow }} + GH_RUN_ID: ${{ github.run_id }} + GH_RUN_NUMBER: ${{ github.run_number }} + GH_RUN_ATTEMPT: ${{ github.run_attempt }} + GH_JOB_ID: ${{ github.job }} - name: Upload tmpnet network dir uses: actions/upload-artifact@v4 if: always() with: name: e2e-tmpnet-data - path: ${{ env.tmpnet_data_path }} + path: | + ~/.tmpnet/networks + ~/.tmpnet/prometheus/prometheus.log + ~/.tmpnet/promtail/promtail.log if-no-files-found: error e2e_existing_network: runs-on: ubuntu-latest @@ -88,15 +117,43 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh -r + - name: Start prometheus + shell: bash + run: bash -x ./scripts/run_prometheus.sh + env: + PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }} + PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }} + - name: Start promtail + shell: bash + run: bash -x ./scripts/run_promtail.sh + env: + LOKI_ID: ${{ secrets.LOKI_ID }} + LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }} + - name: Notify of metrics availability + shell: bash + run: .github/workflows/notify-metrics-availability.sh + env: + GRAFANA_URL: ${{ env.grafana_url }} + GH_JOB_ID: ${{ github.job }} - name: Run e2e tests with existing network shell: bash run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh + env: + GH_REPO: ${{ github.repository }} + GH_WORKFLOW: ${{ github.workflow }} + GH_RUN_ID: ${{ github.run_id }} + GH_RUN_NUMBER: ${{ github.run_number }} + GH_RUN_ATTEMPT: ${{ github.run_attempt }} + GH_JOB_ID: ${{ github.job }} - name: Upload tmpnet network dir uses: actions/upload-artifact@v4 if: always() with: name: e2e-existing-network-tmpnet-data - path: ${{ env.tmpnet_data_path }} + path: | + ~/.tmpnet/networks + ~/.tmpnet/prometheus/prometheus.log + ~/.tmpnet/promtail/promtail.log if-no-files-found: error Upgrade: runs-on: ubuntu-latest @@ -109,15 +166,43 @@ jobs: - name: Build AvalancheGo Binary shell: bash run: ./scripts/build.sh + - name: Start prometheus + shell: bash + run: bash -x ./scripts/run_prometheus.sh + env: + PROMETHEUS_ID: ${{ secrets.PROMETHEUS_ID }} + PROMETHEUS_PASSWORD: ${{ secrets.PROMETHEUS_PASSWORD }} + - name: Start promtail + shell: bash + run: bash -x ./scripts/run_promtail.sh + env: + LOKI_ID: ${{ secrets.LOKI_ID }} + LOKI_PASSWORD: ${{ secrets.LOKI_PASSWORD }} + - name: Notify of metrics availability + shell: bash + run: .github/workflows/notify-metrics-availability.sh + env: + GRAFANA_URL: ${{ env.grafana_url }} + GH_JOB_ID: ${{ github.job }} - name: Run e2e tests shell: bash run: ./scripts/tests.upgrade.sh + env: + GH_REPO: ${{ github.repository }} + GH_WORKFLOW: ${{ github.workflow }} + GH_RUN_ID: ${{ github.run_id }} + GH_RUN_NUMBER: ${{ github.run_number }} + GH_RUN_ATTEMPT: ${{ github.run_attempt }} + GH_JOB_ID: ${{ github.job }} - name: Upload tmpnet network dir uses: actions/upload-artifact@v4 if: always() with: name: upgrade-tmpnet-data - path: ${{ env.tmpnet_data_path }} + path: | + ~/.tmpnet/networks + ~/.tmpnet/prometheus/prometheus.log + ~/.tmpnet/promtail/promtail.log if-no-files-found: error Lint: runs-on: ubuntu-latest @@ -138,7 +223,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: bufbuild/buf-setup-action@v1.29.0 + - uses: bufbuild/buf-setup-action@v1.30.0 with: github_token: ${{ github.token }} - uses: bufbuild/buf-lint-action@v1 @@ -153,7 +238,7 @@ jobs: with: go-version: ${{ env.go_version }} check-latest: true - - uses: bufbuild/buf-setup-action@v1.29.0 + - uses: bufbuild/buf-setup-action@v1.30.0 - shell: bash run: scripts/protobuf_codegen.sh - shell: bash diff --git a/.github/workflows/notify-metrics-availability.sh b/.github/workflows/notify-metrics-availability.sh new file mode 100755 index 000000000000..fd69064045c1 --- /dev/null +++ b/.github/workflows/notify-metrics-availability.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Timestamps are in seconds +from_timestamp="$(date '+%s')" +monitoring_period=900 # 15 minutes +to_timestamp="$((from_timestamp + monitoring_period))" + +# Grafana expects microseconds, so pad timestamps with 3 zeros +metrics_url="${GRAFANA_URL}&var-filter=gh_job_id%7C%3D%7C${GH_JOB_ID}&from=${from_timestamp}000&to=${to_timestamp}000" + +# Optionally ensure that the link displays metrics only for the shared +# network rather than mixing it with the results for private networks. +if [[ -n "${FILTER_BY_OWNER:-}" ]]; then + metrics_url="${metrics_url}&var-filter=network_owner%7C%3D%7C${FILTER_BY_OWNER}" +fi + +echo "::notice links::metrics ${metrics_url}" diff --git a/.github/workflows/publish_antithesis_images.yml b/.github/workflows/publish_antithesis_images.yml new file mode 100644 index 000000000000..851260858990 --- /dev/null +++ b/.github/workflows/publish_antithesis_images.yml @@ -0,0 +1,54 @@ +name: Publish Antithesis Images + +on: + workflow_dispatch: + push: + branches: + - master + +env: + REGISTRY: us-central1-docker.pkg.dev + REPOSITORY: molten-verve-216720/avalanche-repository + NODE_NAME: avalanche-node + WORKLOAD_NAME: workload + CONFIG_NAME: config + TAG: latest + +jobs: + antithesis: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Login to GAR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: _json_key + password: ${{ secrets.ANTITHESIS_GAR_JSON_KEY }} + + - name: Build node + id: build-node-image + run: | + docker build -t $REGISTRY/$REPOSITORY/$NODE_NAME:$TAG -f ./tests/antithesis/Dockerfile.node . + echo "name=image::$REGISTRY/$REPOSITORY/$NODE_NAME:$TAG" >> $GITHUB_OUTPUT + + - name: Build workload + id: build-workload-image + run: | + docker build -t $REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG -f ./tests/antithesis/Dockerfile.workload . + echo "name=image::$REGISTRY/$REPOSITORY/$WORKLOAD_NAME:$TAG" >> $GITHUB_OUTPUT + + - name: Build config + id: build-config-image + run: | + docker build -t $REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG -f ./tests/antithesis/Dockerfile.config . + echo "name=image::$REGISTRY/$REPOSITORY/$CONFIG_NAME:$TAG" >> $GITHUB_OUTPUT + + - name: Publish images + run: | + docker push ${REGISTRY}/${REPOSITORY}/${NODE_NAME}:${TAG} + docker push ${REGISTRY}/${REPOSITORY}/${WORKLOAD_NAME}:${TAG} + docker push ${REGISTRY}/${REPOSITORY}/${CONFIG_NAME}:${TAG} diff --git a/.github/workflows/update-ami.py b/.github/workflows/update-ami.py index 09e8154454cc..95360c553d39 100755 --- a/.github/workflows/update-ami.py +++ b/.github/workflows/update-ami.py @@ -5,10 +5,11 @@ import uuid import re import subprocess +import sys # Globals amifile = '.github/workflows/amichange.json' -packerfile = ".github/packer/ubuntu-jammy-x86_64-public-ami.json" +packerfile = ".github/packer/ubuntu-jammy-x86_64-public-ami.pkr.hcl" # Environment Globals product_id = os.getenv('PRODUCT_ID') @@ -19,11 +20,16 @@ def packer_build(packerfile): print("Running the packer build") - subprocess.run('/usr/local/bin/packer build ' + packerfile, shell=True) + output = subprocess.run('/usr/local/bin/packer build ' + packerfile, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if output.returncode != 0: + raise RuntimeError(f"Command returned with code: {output.returncode}") def packer_build_update(packerfile): print("Creating packer AMI image for Marketplace") - output = subprocess.run('/usr/local/bin/packer build ' + packerfile, shell=True, stdout=subprocess.PIPE) + output = subprocess.run('/usr/local/bin/packer build ' + packerfile, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + if output.returncode != 0: + raise RuntimeError(f"Command returned with code: {output.returncode}") + found = re.findall('ami-[a-z0-9]*', str(output.stdout)) if found: @@ -76,10 +82,16 @@ def update_ami(amifile, amiid): print(f"An error occurred while updating AMI delivery options: {e}") def main(): - if skip_create_ami == "True": - packer_build(packerfile) - else: - update_ami(amifile, packer_build_update(packerfile)) + try: + if skip_create_ami == "True": + packer_build(packerfile) + else: + update_ami(amifile, packer_build_update(packerfile)) + + print("Ran packer build and update ami successfully") + except Exception as e: + print(f"An error occurred while running packer") + sys.exit(5) if __name__ == '__main__': main() diff --git a/Dockerfile b/Dockerfile index 035b203d8ca2..e0c1c941b9fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ # Changes to the minimum golang version must also be replicated in # scripts/build_avalanche.sh +# tests/antithesis/Dockerfile.node +# tests/antithesis/Dockerfile.workload # Dockerfile (here) # README.md # go.mod diff --git a/README.md b/README.md index b4e213d368b3..0b0149030b45 100644 --- a/README.md +++ b/README.md @@ -159,12 +159,12 @@ To regenerate the protobuf go code, run `scripts/protobuf_codegen.sh` from the r This should only be necessary when upgrading protobuf versions or modifying .proto definition files. -To use this script, you must have [buf](https://docs.buf.build/installation) (v1.29.0), protoc-gen-go (v1.30.0) and protoc-gen-go-grpc (v1.3.0) installed. +To use this script, you must have [buf](https://docs.buf.build/installation) (v1.30.0), protoc-gen-go (v1.33.0) and protoc-gen-go-grpc (v1.3.0) installed. To install the buf dependencies: ```sh -go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0 +go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 ``` diff --git a/RELEASES.md b/RELEASES.md index ebf1482be310..0d8f251825b6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,94 @@ # Release Notes +## [v1.11.3](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.3) + +This version is backwards compatible to [v1.11.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0). It is optional, but encouraged. + +The plugin version is updated to `35` all plugins must update to be compatible. + +### APIs + +- Removed: + - `platform.GetPendingValidators` + - `platform.GetMaxStakeAmount` + +### Configs + +- Removed avalanchego configs: + - `network-peer-list-validator-gossip-size` + - `network-peer-list-non-validator-gossip-size` + - `network-peer-list-peers-gossip-size` + - `network-peer-list-gossip-frequency` + - `consensus-accepted-frontier-gossip-validator-size` + - `consensus-accepted-frontier-gossip-non-validator-size` + - `consensus-accepted-frontier-gossip-peer-size` + - `consensus-on-accept-gossip-validator-size` + - `consensus-on-accept-gossip-non-validator-size` + - `consensus-on-accept-gossip-peer-size` +- Added P-chain, X-chain, and C-chain configs: + - `push-gossip-percent-stake` + +### Fixes + +- Fixed p2p SDK validator sampling to only return connected validators + +### What's Changed + +- Cleanup BLS naming and documentation by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2798 +- Add BLS keys + signers config for local network by @Nuttymoon in https://github.com/ava-labs/avalanchego/pull/2794 +- Remove double spaces by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2802 +- [vms/platformvm] Remove `platform.getMaxStakeAmount` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2795 +- Remove unused engine interface by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2811 +- Cleanup Duplicate Transitive Constructor by @joshua-kim in https://github.com/ava-labs/avalanchego/pull/2812 +- Update minimum golang version to v1.21.8 by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2814 +- Cleanup consensus metrics by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2815 +- Remove peerlist push gossip by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2791 +- Remove bitmaskCodec by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2792 +- Use `BaseTx` in P-chain wallet by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2731 +- Remove put gossip by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2790 +- [vms/platformvm] Remove `GetPendingValidators` API by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2817 +- [vms/platformvm] Remove `ErrFutureStakeTime` check in `VerifyTx` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2797 +- Remove pre-Durango block building logic and verification by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2823 +- Remove pre-Durango checks in BLS key verification by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2824 +- [snow/networking] Enforce `PreferredIDAtHeight` in `Chits` messages by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2827 +- Combine AppGossip and AppGossipSpecific by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2836 +- [network/peer] Disconnect from peers who only send legacy version field by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2830 +- [vms/avm] Cleanup `GetTx` + remove state pruning logic by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2826 +- [vms/avm] Remove `snow.Context` from `Network` by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2834 +- [vms/platformvm] Remove state pruning logic by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2825 +- Prevent zero length values in slices and maps in codec by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2819 +- [utils/compression] Remove gzip compressor by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2839 +- Remove legacy p2p message handling by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2833 +- Remove Durango codec check by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2818 +- Remove Pre-Durango TLS certificate parsing logic by @dhrubabasu in https://github.com/ava-labs/avalanchego/pull/2831 +- Remove engine type handling for everything other than GetAncestors by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2800 +- P-chain: Improve GetValidatorsSet error expressivity by @abi87 in https://github.com/ava-labs/avalanchego/pull/2808 +- Add antithesis PoC workload by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2796 +- Add Antithesis docker compose file by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2838 +- merkledb metric naming nits by @danlaine in https://github.com/ava-labs/avalanchego/pull/2844 +- Allow configuring push gossip to send txs to validators by stake by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2835 +- update merkledb readme to specify key length is in bits by @danlaine in https://github.com/ava-labs/avalanchego/pull/2840 +- `tmpnet`: Add a UUID to temporary networks to support metrics collection by @marun in https://github.com/ava-labs/avalanchego/pull/2763 +- packer build by @Dirrk in https://github.com/ava-labs/avalanchego/pull/2806 +- Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 by @dependabot in https://github.com/ava-labs/avalanchego/pull/2849 +- Bump bufbuild/buf-setup-action from 1.29.0 to 1.30.0 by @dependabot in https://github.com/ava-labs/avalanchego/pull/2842 +- Remove verify height index by @aaronbuchwald in https://github.com/ava-labs/avalanchego/pull/2634 +- Dynamic Fees - Add E Upgrade boilerplate by @abi87 in https://github.com/ava-labs/avalanchego/pull/2597 +- `tmpnet`: Enable collection of logs and metrics by @marun in https://github.com/ava-labs/avalanchego/pull/2820 +- P-Chain - repackaged wallet backends by @abi87 in https://github.com/ava-labs/avalanchego/pull/2757 +- X-Chain - repackaged wallet backends by @abi87 in https://github.com/ava-labs/avalanchego/pull/2762 +- Remove fallback validator height indexing by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2801 +- `tmpnet`: Reuse dynamically-allocated API port across restarts by @marun in https://github.com/ava-labs/avalanchego/pull/2857 +- Remove useless bootstrapping metric by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2858 +- Remove duplicate log by @StephenButtolph in https://github.com/ava-labs/avalanchego/pull/2860 + +### New Contributors + +- @Nuttymoon made their first contribution in https://github.com/ava-labs/avalanchego/pull/2794 +- @Dirrk made their first contribution in https://github.com/ava-labs/avalanchego/pull/2806 + +**Full Changelog**: https://github.com/ava-labs/avalanchego/compare/v1.11.2...v1.11.3 + ## [v1.11.2](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.2) This version is backwards compatible to [v1.11.0](https://github.com/ava-labs/avalanchego/releases/tag/v1.11.0). It is optional, but strongly encouraged. diff --git a/go.mod b/go.mod index 7f960396638f..154b2b63763d 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/ava-labs/avalanchego // Changes to the minimum golang version must also be replicated in // scripts/build_avalanche.sh +// tests/antithesis/Dockerfile.node +// tests/antithesis/Dockerfile.workload // Dockerfile // README.md // go.mod (here, only major.minor can be specified) @@ -10,14 +12,15 @@ go 1.21 require ( github.com/DataDog/zstd v1.5.2 github.com/NYTimes/gziphandler v1.1.1 - github.com/ava-labs/coreth v0.13.2-stake-sampling.2 + github.com/ava-labs/coreth v0.13.2-rc.2 github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 github.com/btcsuite/btcd/btcutil v1.1.3 github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 - github.com/ethereum/go-ethereum v1.12.0 + github.com/ethereum/go-ethereum v1.12.2 github.com/google/btree v1.1.2 github.com/google/renameio/v2 v2.0.0 + github.com/google/uuid v1.6.0 github.com/gorilla/mux v1.8.0 github.com/gorilla/rpc v1.2.0 github.com/gorilla/websocket v1.4.2 @@ -37,7 +40,7 @@ require ( github.com/rs/cors v1.7.0 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/cast v1.5.0 - github.com/spf13/cobra v1.0.0 + github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.12.0 github.com/stretchr/testify v1.8.4 @@ -59,11 +62,11 @@ require ( golang.org/x/net v0.20.0 golang.org/x/sync v0.6.0 golang.org/x/term v0.16.0 - golang.org/x/time v0.0.0-20220922220347-f3bd1da661af + golang.org/x/time v0.3.0 gonum.org/v1/gonum v0.11.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 google.golang.org/grpc v1.62.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/protobuf v1.33.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) @@ -72,17 +75,22 @@ require ( github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect github.com/VictoriaMetrics/fastcache v1.10.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.9.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.3 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/dlclark/regexp2 v1.7.0 // indirect github.com/dop251/goja v0.0.0-20230605162241-28ee0ee714f3 // indirect + github.com/ethereum/c-kzg-4844 v0.3.1 // indirect github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect github.com/frankban/quicktest v1.14.4 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect @@ -99,13 +107,13 @@ require ( github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect - github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect + github.com/holiman/uint256 v1.2.3 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/klauspost/compress v1.15.15 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -116,6 +124,7 @@ require ( github.com/mattn/go-runewidth v0.0.9 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/pointerstructure v1.2.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect @@ -133,7 +142,7 @@ require ( github.com/tklauser/go-sysconf v0.3.5 // indirect github.com/tklauser/numcpus v0.2.2 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect - github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa // indirect + github.com/urfave/cli/v2 v2.24.1 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect github.com/zondax/hid v0.9.2 // indirect @@ -148,4 +157,5 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index ee572632f5fd..bca37ada15a2 100644 --- a/go.sum +++ b/go.sum @@ -52,26 +52,23 @@ github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1 github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY= github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/coreth v0.13.2-stake-sampling.2 h1:tFnjwSEIMeh+dkWcB52c//wTVngZiJ2Rf6TW4ZcsCCc= -github.com/ava-labs/coreth v0.13.2-stake-sampling.2/go.mod h1:3AtWfbwSDORoaWEui9o5X2WmPlVbksm3zWuUzN9q/60= +github.com/ava-labs/coreth v0.13.2-rc.2 h1:GmXSyDykDUuDyW7933T8lK7Fp6/4k/IcHhLJjkvjUYI= +github.com/ava-labs/coreth v0.13.2-rc.2/go.mod h1:jOapwtgvroqZ2U8PJpoaq1PHrUFOrlgshUWQfM3nba0= github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34 h1:mg9Uw6oZFJKytJxgxnl3uxZOs/SB8CVHg6Io4Tf99Zc= github.com/ava-labs/ledger-avalanche/go v0.0.0-20231102202641-ae2ebdaeac34/go.mod h1:pJxaT9bUgeRNVmNRgtCHb7sFDIRKy7CzTQVi8gGNT6g= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= @@ -101,7 +98,6 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -129,16 +125,18 @@ github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lg github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A= +github.com/crate-crypto/go-kzg-4844 v0.3.0/go.mod h1:SBP7ikXEgDnUPONgm33HtuDZEDtWa3L4QtN1ocJSEQ4= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -154,9 +152,7 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -175,8 +171,10 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= -github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= -github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= +github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg= +github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.12.2 h1:eGHJ4ij7oyVqUQn48LBz3B7pvQ8sV0wGJiIE6gDq/6Y= +github.com/ethereum/go-ethereum v1.12.2/go.mod h1:1cRAEV+rp/xX0zraSCBnu9Py3HQ+geRMj3HdR+k0wfI= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= @@ -194,7 +192,6 @@ github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= @@ -204,9 +201,6 @@ github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3Bop github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -217,7 +211,6 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -228,9 +221,7 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gogo/googleapis v0.0.0-20180223154316-0cd9801be74a/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= @@ -238,7 +229,6 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -309,6 +299,7 @@ github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8q github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -320,14 +311,11 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms= github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= @@ -339,10 +327,12 @@ github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuW github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw= +github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= +github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= @@ -365,21 +355,18 @@ github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7Bd github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8= github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE= github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE= github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro= github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= @@ -388,9 +375,7 @@ github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= @@ -424,7 +409,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8= @@ -436,6 +420,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= @@ -443,7 +430,6 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= @@ -453,7 +439,6 @@ github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96d github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -485,7 +470,6 @@ github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTw github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8= github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -493,25 +477,15 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= @@ -521,7 +495,6 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -532,11 +505,8 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= @@ -544,8 +514,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -553,13 +523,11 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.1.5-0.20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -587,7 +555,6 @@ github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJdv5KE= github.com/tyler-smith/go-bip32 v1.0.0/go.mod h1:onot+eHknzV4BVPwrzqY5OoVpyCvnwD7lMawL5aQupE= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= @@ -596,8 +563,8 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= -github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= -github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/urfave/cli/v2 v2.24.1 h1:/QYYr7g0EhwXEML8jO+8OYt5trPnLHS0p3mrgExJ5NU= +github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= @@ -607,7 +574,6 @@ github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= @@ -627,7 +593,6 @@ github.com/zondax/hid v0.9.2 h1:WCJFnEDMiqGF64nlZz28E9qLVZ0KSJ7xpc5DLEyma2U= github.com/zondax/hid v0.9.2/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfUCw= github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -650,20 +615,16 @@ go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -722,7 +683,6 @@ golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -731,7 +691,6 @@ golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -790,10 +749,7 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -878,9 +834,8 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1018,7 +973,6 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go. google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -1048,9 +1002,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1066,10 +1019,8 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1093,3 +1044,5 @@ launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/indexer/examples/x-chain-blocks/main.go b/indexer/examples/x-chain-blocks/main.go index 226460720fc5..c118a7ad378b 100644 --- a/indexer/examples/x-chain-blocks/main.go +++ b/indexer/examples/x-chain-blocks/main.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/avalanchego/indexer" "github.com/ava-labs/avalanchego/vms/proposervm/block" - "github.com/ava-labs/avalanchego/wallet/chain/x" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary" ) @@ -37,7 +37,7 @@ func main() { } avmBlockBytes := proposerVMBlock.Block() - avmBlock, err := x.Parser.ParseBlock(avmBlockBytes) + avmBlock, err := builder.Parser.ParseBlock(avmBlockBytes) if err != nil { log.Fatalf("failed to parse avm block: %s\n", err) } diff --git a/node/node.go b/node/node.go index 48f4fa74457e..58e903404470 100644 --- a/node/node.go +++ b/node/node.go @@ -1122,6 +1122,7 @@ func (n *Node) initVMs() error { } // Register the VMs that Avalanche supports + eUpgradeTime := version.GetEUpgradeTime(n.Config.NetworkID) err := utils.Err( n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{ Config: platformconfig.Config{ @@ -1153,6 +1154,7 @@ func (n *Node) initVMs() error { BanffTime: version.GetBanffTime(n.Config.NetworkID), CortinaTime: version.GetCortinaTime(n.Config.NetworkID), DurangoTime: version.GetDurangoTime(n.Config.NetworkID), + EUpgradeTime: eUpgradeTime, UseCurrentHeight: n.Config.UseCurrentHeight, }, }), @@ -1160,6 +1162,7 @@ func (n *Node) initVMs() error { Config: avmconfig.Config{ TxFee: n.Config.TxFee, CreateAssetTxFee: n.Config.CreateAssetTxFee, + EUpgradeTime: eUpgradeTime, }, }), n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}), diff --git a/proto/Dockerfile.buf b/proto/Dockerfile.buf index 2b826b17062f..c7c5b2e00192 100644 --- a/proto/Dockerfile.buf +++ b/proto/Dockerfile.buf @@ -1,4 +1,4 @@ -FROM bufbuild/buf:1.29.0 AS builder +FROM bufbuild/buf:1.30.0 AS builder FROM ubuntu:20.04 @@ -16,7 +16,7 @@ COPY --from=builder /usr/local/bin/buf /usr/local/bin/ # any version changes here should also be bumped in scripts/protobuf_codegen.sh RUN \ - go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0 && \ + go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.33.0 && \ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 ENV PATH="${PATH}:/root/go/bin/" diff --git a/proto/README.md b/proto/README.md index 760ab6dee4bd..5d60f6bb094e 100644 --- a/proto/README.md +++ b/proto/README.md @@ -1,6 +1,6 @@ # Avalanche gRPC -Now Serving: **Protocol Version 34** +Now Serving: **Protocol Version 35** Protobuf files are hosted at [https://buf.build/ava-labs/avalanche](https://buf.build/ava-labs/avalanche) and diff --git a/proto/pb/aliasreader/aliasreader.pb.go b/proto/pb/aliasreader/aliasreader.pb.go index 20084292d030..4fbac30f6659 100644 --- a/proto/pb/aliasreader/aliasreader.pb.go +++ b/proto/pb/aliasreader/aliasreader.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: aliasreader/aliasreader.proto diff --git a/proto/pb/appsender/appsender.pb.go b/proto/pb/appsender/appsender.pb.go index 16ccb35821e7..0513d08bb736 100644 --- a/proto/pb/appsender/appsender.pb.go +++ b/proto/pb/appsender/appsender.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: appsender/appsender.proto diff --git a/proto/pb/http/http.pb.go b/proto/pb/http/http.pb.go index 76b6d916d9bb..dc2d8c8ebc06 100644 --- a/proto/pb/http/http.pb.go +++ b/proto/pb/http/http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: http/http.proto diff --git a/proto/pb/http/responsewriter/responsewriter.pb.go b/proto/pb/http/responsewriter/responsewriter.pb.go index a49113f3bb5a..008ef7ad006a 100644 --- a/proto/pb/http/responsewriter/responsewriter.pb.go +++ b/proto/pb/http/responsewriter/responsewriter.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: http/responsewriter/responsewriter.proto diff --git a/proto/pb/io/reader/reader.pb.go b/proto/pb/io/reader/reader.pb.go index 34977aa39422..110fc4719380 100644 --- a/proto/pb/io/reader/reader.pb.go +++ b/proto/pb/io/reader/reader.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: io/reader/reader.proto diff --git a/proto/pb/io/writer/writer.pb.go b/proto/pb/io/writer/writer.pb.go index 850afaa8c2cf..80984dbcfbd7 100644 --- a/proto/pb/io/writer/writer.pb.go +++ b/proto/pb/io/writer/writer.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: io/writer/writer.proto diff --git a/proto/pb/keystore/keystore.pb.go b/proto/pb/keystore/keystore.pb.go index ed9d3813f6c3..97620355c820 100644 --- a/proto/pb/keystore/keystore.pb.go +++ b/proto/pb/keystore/keystore.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: keystore/keystore.proto diff --git a/proto/pb/messenger/messenger.pb.go b/proto/pb/messenger/messenger.pb.go index 830de252a04e..f1aabe97d788 100644 --- a/proto/pb/messenger/messenger.pb.go +++ b/proto/pb/messenger/messenger.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: messenger/messenger.proto diff --git a/proto/pb/net/conn/conn.pb.go b/proto/pb/net/conn/conn.pb.go index 8882e8de45ff..53ce91a4cfef 100644 --- a/proto/pb/net/conn/conn.pb.go +++ b/proto/pb/net/conn/conn.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: net/conn/conn.proto diff --git a/proto/pb/p2p/p2p.pb.go b/proto/pb/p2p/p2p.pb.go index e3b1f5d86888..fedced79978b 100644 --- a/proto/pb/p2p/p2p.pb.go +++ b/proto/pb/p2p/p2p.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: p2p/p2p.proto diff --git a/proto/pb/rpcdb/rpcdb.pb.go b/proto/pb/rpcdb/rpcdb.pb.go index 246732f1bba3..5849d778bd44 100644 --- a/proto/pb/rpcdb/rpcdb.pb.go +++ b/proto/pb/rpcdb/rpcdb.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: rpcdb/rpcdb.proto diff --git a/proto/pb/sdk/sdk.pb.go b/proto/pb/sdk/sdk.pb.go index b90c23450270..ca0904ffcb0c 100644 --- a/proto/pb/sdk/sdk.pb.go +++ b/proto/pb/sdk/sdk.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: sdk/sdk.proto diff --git a/proto/pb/sharedmemory/sharedmemory.pb.go b/proto/pb/sharedmemory/sharedmemory.pb.go index 5de7c788691c..3708c3fb924c 100644 --- a/proto/pb/sharedmemory/sharedmemory.pb.go +++ b/proto/pb/sharedmemory/sharedmemory.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: sharedmemory/sharedmemory.proto diff --git a/proto/pb/sync/sync.pb.go b/proto/pb/sync/sync.pb.go index eb72e145420a..3a80cc22830b 100644 --- a/proto/pb/sync/sync.pb.go +++ b/proto/pb/sync/sync.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: sync/sync.proto diff --git a/proto/pb/validatorstate/validator_state.pb.go b/proto/pb/validatorstate/validator_state.pb.go index 84ddc0ab3100..591087a08342 100644 --- a/proto/pb/validatorstate/validator_state.pb.go +++ b/proto/pb/validatorstate/validator_state.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: validatorstate/validator_state.proto diff --git a/proto/pb/vm/runtime/runtime.pb.go b/proto/pb/vm/runtime/runtime.pb.go index 2a5f15dbfed3..5db5a490a359 100644 --- a/proto/pb/vm/runtime/runtime.pb.go +++ b/proto/pb/vm/runtime/runtime.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: vm/runtime/runtime.proto diff --git a/proto/pb/vm/vm.pb.go b/proto/pb/vm/vm.pb.go index 7f38e5bbf4a7..356f34d061ac 100644 --- a/proto/pb/vm/vm.pb.go +++ b/proto/pb/vm/vm.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: vm/vm.proto @@ -134,8 +134,7 @@ const ( Error_ERROR_UNSPECIFIED Error = 0 Error_ERROR_CLOSED Error = 1 Error_ERROR_NOT_FOUND Error = 2 - Error_ERROR_HEIGHT_INDEX_INCOMPLETE Error = 3 - Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED Error = 4 + Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED Error = 3 ) // Enum value maps for Error. @@ -144,15 +143,13 @@ var ( 0: "ERROR_UNSPECIFIED", 1: "ERROR_CLOSED", 2: "ERROR_NOT_FOUND", - 3: "ERROR_HEIGHT_INDEX_INCOMPLETE", - 4: "ERROR_STATE_SYNC_NOT_IMPLEMENTED", + 3: "ERROR_STATE_SYNC_NOT_IMPLEMENTED", } Error_value = map[string]int32{ "ERROR_UNSPECIFIED": 0, "ERROR_CLOSED": 1, "ERROR_NOT_FOUND": 2, - "ERROR_HEIGHT_INDEX_INCOMPLETE": 3, - "ERROR_STATE_SYNC_NOT_IMPLEMENTED": 4, + "ERROR_STATE_SYNC_NOT_IMPLEMENTED": 3, } ) @@ -232,7 +229,7 @@ func (x StateSummaryAcceptResponse_Mode) Number() protoreflect.EnumNumber { // Deprecated: Use StateSummaryAcceptResponse_Mode.Descriptor instead. func (StateSummaryAcceptResponse_Mode) EnumDescriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{44, 0} + return file_vm_vm_proto_rawDescGZIP(), []int{43, 0} } type InitializeRequest struct { @@ -2280,53 +2277,6 @@ func (x *BatchedParseBlockResponse) GetResponse() []*ParseBlockResponse { return nil } -type VerifyHeightIndexResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Err Error `protobuf:"varint,1,opt,name=err,proto3,enum=vm.Error" json:"err,omitempty"` -} - -func (x *VerifyHeightIndexResponse) Reset() { - *x = VerifyHeightIndexResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[32] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VerifyHeightIndexResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VerifyHeightIndexResponse) ProtoMessage() {} - -func (x *VerifyHeightIndexResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[32] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VerifyHeightIndexResponse.ProtoReflect.Descriptor instead. -func (*VerifyHeightIndexResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{32} -} - -func (x *VerifyHeightIndexResponse) GetErr() Error { - if x != nil { - return x.Err - } - return Error_ERROR_UNSPECIFIED -} - type GetBlockIDAtHeightRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2338,7 +2288,7 @@ type GetBlockIDAtHeightRequest struct { func (x *GetBlockIDAtHeightRequest) Reset() { *x = GetBlockIDAtHeightRequest{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[33] + mi := &file_vm_vm_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2351,7 +2301,7 @@ func (x *GetBlockIDAtHeightRequest) String() string { func (*GetBlockIDAtHeightRequest) ProtoMessage() {} func (x *GetBlockIDAtHeightRequest) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[33] + mi := &file_vm_vm_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2364,7 +2314,7 @@ func (x *GetBlockIDAtHeightRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBlockIDAtHeightRequest.ProtoReflect.Descriptor instead. func (*GetBlockIDAtHeightRequest) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{33} + return file_vm_vm_proto_rawDescGZIP(), []int{32} } func (x *GetBlockIDAtHeightRequest) GetHeight() uint64 { @@ -2386,7 +2336,7 @@ type GetBlockIDAtHeightResponse struct { func (x *GetBlockIDAtHeightResponse) Reset() { *x = GetBlockIDAtHeightResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[34] + mi := &file_vm_vm_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2399,7 +2349,7 @@ func (x *GetBlockIDAtHeightResponse) String() string { func (*GetBlockIDAtHeightResponse) ProtoMessage() {} func (x *GetBlockIDAtHeightResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[34] + mi := &file_vm_vm_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2412,7 +2362,7 @@ func (x *GetBlockIDAtHeightResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBlockIDAtHeightResponse.ProtoReflect.Descriptor instead. func (*GetBlockIDAtHeightResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{34} + return file_vm_vm_proto_rawDescGZIP(), []int{33} } func (x *GetBlockIDAtHeightResponse) GetBlkId() []byte { @@ -2440,7 +2390,7 @@ type GatherResponse struct { func (x *GatherResponse) Reset() { *x = GatherResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[35] + mi := &file_vm_vm_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2453,7 +2403,7 @@ func (x *GatherResponse) String() string { func (*GatherResponse) ProtoMessage() {} func (x *GatherResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[35] + mi := &file_vm_vm_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2466,7 +2416,7 @@ func (x *GatherResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GatherResponse.ProtoReflect.Descriptor instead. func (*GatherResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{35} + return file_vm_vm_proto_rawDescGZIP(), []int{34} } func (x *GatherResponse) GetMetricFamilies() []*_go.MetricFamily { @@ -2488,7 +2438,7 @@ type StateSyncEnabledResponse struct { func (x *StateSyncEnabledResponse) Reset() { *x = StateSyncEnabledResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[36] + mi := &file_vm_vm_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2501,7 +2451,7 @@ func (x *StateSyncEnabledResponse) String() string { func (*StateSyncEnabledResponse) ProtoMessage() {} func (x *StateSyncEnabledResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[36] + mi := &file_vm_vm_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2514,7 +2464,7 @@ func (x *StateSyncEnabledResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StateSyncEnabledResponse.ProtoReflect.Descriptor instead. func (*StateSyncEnabledResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{36} + return file_vm_vm_proto_rawDescGZIP(), []int{35} } func (x *StateSyncEnabledResponse) GetEnabled() bool { @@ -2545,7 +2495,7 @@ type GetOngoingSyncStateSummaryResponse struct { func (x *GetOngoingSyncStateSummaryResponse) Reset() { *x = GetOngoingSyncStateSummaryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[37] + mi := &file_vm_vm_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2558,7 +2508,7 @@ func (x *GetOngoingSyncStateSummaryResponse) String() string { func (*GetOngoingSyncStateSummaryResponse) ProtoMessage() {} func (x *GetOngoingSyncStateSummaryResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[37] + mi := &file_vm_vm_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2571,7 +2521,7 @@ func (x *GetOngoingSyncStateSummaryResponse) ProtoReflect() protoreflect.Message // Deprecated: Use GetOngoingSyncStateSummaryResponse.ProtoReflect.Descriptor instead. func (*GetOngoingSyncStateSummaryResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{37} + return file_vm_vm_proto_rawDescGZIP(), []int{36} } func (x *GetOngoingSyncStateSummaryResponse) GetId() []byte { @@ -2616,7 +2566,7 @@ type GetLastStateSummaryResponse struct { func (x *GetLastStateSummaryResponse) Reset() { *x = GetLastStateSummaryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[38] + mi := &file_vm_vm_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2629,7 +2579,7 @@ func (x *GetLastStateSummaryResponse) String() string { func (*GetLastStateSummaryResponse) ProtoMessage() {} func (x *GetLastStateSummaryResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[38] + mi := &file_vm_vm_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2642,7 +2592,7 @@ func (x *GetLastStateSummaryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetLastStateSummaryResponse.ProtoReflect.Descriptor instead. func (*GetLastStateSummaryResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{38} + return file_vm_vm_proto_rawDescGZIP(), []int{37} } func (x *GetLastStateSummaryResponse) GetId() []byte { @@ -2684,7 +2634,7 @@ type ParseStateSummaryRequest struct { func (x *ParseStateSummaryRequest) Reset() { *x = ParseStateSummaryRequest{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[39] + mi := &file_vm_vm_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2697,7 +2647,7 @@ func (x *ParseStateSummaryRequest) String() string { func (*ParseStateSummaryRequest) ProtoMessage() {} func (x *ParseStateSummaryRequest) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[39] + mi := &file_vm_vm_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2710,7 +2660,7 @@ func (x *ParseStateSummaryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ParseStateSummaryRequest.ProtoReflect.Descriptor instead. func (*ParseStateSummaryRequest) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{39} + return file_vm_vm_proto_rawDescGZIP(), []int{38} } func (x *ParseStateSummaryRequest) GetBytes() []byte { @@ -2733,7 +2683,7 @@ type ParseStateSummaryResponse struct { func (x *ParseStateSummaryResponse) Reset() { *x = ParseStateSummaryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[40] + mi := &file_vm_vm_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2746,7 +2696,7 @@ func (x *ParseStateSummaryResponse) String() string { func (*ParseStateSummaryResponse) ProtoMessage() {} func (x *ParseStateSummaryResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[40] + mi := &file_vm_vm_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2759,7 +2709,7 @@ func (x *ParseStateSummaryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ParseStateSummaryResponse.ProtoReflect.Descriptor instead. func (*ParseStateSummaryResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{40} + return file_vm_vm_proto_rawDescGZIP(), []int{39} } func (x *ParseStateSummaryResponse) GetId() []byte { @@ -2794,7 +2744,7 @@ type GetStateSummaryRequest struct { func (x *GetStateSummaryRequest) Reset() { *x = GetStateSummaryRequest{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[41] + mi := &file_vm_vm_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2807,7 +2757,7 @@ func (x *GetStateSummaryRequest) String() string { func (*GetStateSummaryRequest) ProtoMessage() {} func (x *GetStateSummaryRequest) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[41] + mi := &file_vm_vm_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2820,7 +2770,7 @@ func (x *GetStateSummaryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStateSummaryRequest.ProtoReflect.Descriptor instead. func (*GetStateSummaryRequest) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{41} + return file_vm_vm_proto_rawDescGZIP(), []int{40} } func (x *GetStateSummaryRequest) GetHeight() uint64 { @@ -2843,7 +2793,7 @@ type GetStateSummaryResponse struct { func (x *GetStateSummaryResponse) Reset() { *x = GetStateSummaryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[42] + mi := &file_vm_vm_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2856,7 +2806,7 @@ func (x *GetStateSummaryResponse) String() string { func (*GetStateSummaryResponse) ProtoMessage() {} func (x *GetStateSummaryResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[42] + mi := &file_vm_vm_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2869,7 +2819,7 @@ func (x *GetStateSummaryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStateSummaryResponse.ProtoReflect.Descriptor instead. func (*GetStateSummaryResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{42} + return file_vm_vm_proto_rawDescGZIP(), []int{41} } func (x *GetStateSummaryResponse) GetId() []byte { @@ -2904,7 +2854,7 @@ type StateSummaryAcceptRequest struct { func (x *StateSummaryAcceptRequest) Reset() { *x = StateSummaryAcceptRequest{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[43] + mi := &file_vm_vm_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2917,7 +2867,7 @@ func (x *StateSummaryAcceptRequest) String() string { func (*StateSummaryAcceptRequest) ProtoMessage() {} func (x *StateSummaryAcceptRequest) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[43] + mi := &file_vm_vm_proto_msgTypes[42] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2930,7 +2880,7 @@ func (x *StateSummaryAcceptRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StateSummaryAcceptRequest.ProtoReflect.Descriptor instead. func (*StateSummaryAcceptRequest) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{43} + return file_vm_vm_proto_rawDescGZIP(), []int{42} } func (x *StateSummaryAcceptRequest) GetBytes() []byte { @@ -2952,7 +2902,7 @@ type StateSummaryAcceptResponse struct { func (x *StateSummaryAcceptResponse) Reset() { *x = StateSummaryAcceptResponse{} if protoimpl.UnsafeEnabled { - mi := &file_vm_vm_proto_msgTypes[44] + mi := &file_vm_vm_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2965,7 +2915,7 @@ func (x *StateSummaryAcceptResponse) String() string { func (*StateSummaryAcceptResponse) ProtoMessage() {} func (x *StateSummaryAcceptResponse) ProtoReflect() protoreflect.Message { - mi := &file_vm_vm_proto_msgTypes[44] + mi := &file_vm_vm_proto_msgTypes[43] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2978,7 +2928,7 @@ func (x *StateSummaryAcceptResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StateSummaryAcceptResponse.ProtoReflect.Descriptor instead. func (*StateSummaryAcceptResponse) Descriptor() ([]byte, []int) { - return file_vm_vm_proto_rawDescGZIP(), []int{44} + return file_vm_vm_proto_rawDescGZIP(), []int{43} } func (x *StateSummaryAcceptResponse) GetMode() StateSummaryAcceptResponse_Mode { @@ -3245,246 +3195,236 @@ var file_vm_vm_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x38, 0x0a, 0x19, 0x56, 0x65, 0x72, 0x69, - 0x66, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x50, 0x0a, + 0x1a, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x62, + 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6b, + 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, + 0x5d, 0x0a, 0x0e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x5f, 0x66, 0x61, 0x6d, 0x69, + 0x6c, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, + 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x52, 0x0e, + 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x22, 0x51, + 0x0a, 0x18, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, + 0x72, 0x22, 0x7f, 0x0a, 0x22, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, + 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, + 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, - 0x72, 0x72, 0x22, 0x33, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, - 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x50, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x62, 0x6c, 0x6b, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6b, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x03, - 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x5d, 0x0a, 0x0e, 0x47, 0x61, 0x74, - 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x6d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x5f, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x6d, 0x65, 0x74, - 0x68, 0x65, 0x75, 0x73, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x52, 0x0e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x22, 0x51, 0x0a, 0x18, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1b, - 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, - 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x7f, 0x0a, 0x22, 0x47, - 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, + 0x72, 0x72, 0x22, 0x78, 0x0a, 0x1b, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, - 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x78, 0x0a, 0x1b, - 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, + 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x18, + 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x60, + 0x0a, 0x19, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x18, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0x60, 0x0a, 0x19, 0x50, 0x61, 0x72, 0x73, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1b, 0x0a, - 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, - 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x5c, 0x0a, 0x17, - 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, - 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x31, 0x0a, 0x19, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x22, 0xc5, 0x01, - 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, - 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x04, - 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x76, 0x6d, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, - 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, - 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, - 0x72, 0x72, 0x22, 0x51, 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x4f, - 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x4b, 0x49, 0x50, 0x50, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, - 0x43, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x44, 0x59, 0x4e, 0x41, - 0x4d, 0x49, 0x43, 0x10, 0x03, 0x2a, 0x65, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, - 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, - 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, - 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x17, - 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x42, 0x4f, 0x4f, 0x54, 0x53, 0x54, 0x52, 0x41, - 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x45, - 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x5f, 0x4f, 0x50, 0x10, 0x03, 0x2a, 0x61, 0x0a, 0x06, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, - 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, - 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, - 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, - 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x03, 0x2a, - 0x8e, 0x01, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x52, 0x52, - 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, - 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x21, 0x0a, 0x1d, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x5f, 0x48, 0x45, 0x49, 0x47, 0x48, 0x54, 0x5f, 0x49, 0x4e, 0x44, 0x45, 0x58, 0x5f, 0x49, 0x4e, - 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x12, 0x24, 0x0a, 0x20, 0x45, 0x52, - 0x52, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x5f, 0x4e, - 0x4f, 0x54, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x45, 0x44, 0x10, 0x04, - 0x32, 0xd2, 0x11, 0x0a, 0x02, 0x56, 0x4d, 0x12, 0x3b, 0x0a, 0x0a, 0x49, 0x6e, 0x69, 0x74, 0x69, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, - 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x76, - 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, 0x08, 0x53, - 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, - 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x44, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x67, 0x68, 0x74, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, + 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, + 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x22, 0x5c, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, + 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, + 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x03, 0x65, 0x72, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, + 0x22, 0x31, 0x0a, 0x19, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, + 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x22, 0xc5, 0x01, 0x0a, 0x1a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x37, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x23, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x03, 0x65, + 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x76, 0x6d, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x03, 0x65, 0x72, 0x72, 0x22, 0x51, 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, + 0x12, 0x14, 0x0a, 0x10, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, + 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x53, + 0x4b, 0x49, 0x50, 0x50, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x4d, 0x4f, 0x44, 0x45, + 0x5f, 0x53, 0x54, 0x41, 0x54, 0x49, 0x43, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x4f, 0x44, + 0x45, 0x5f, 0x44, 0x59, 0x4e, 0x41, 0x4d, 0x49, 0x43, 0x10, 0x03, 0x2a, 0x65, 0x0a, 0x05, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x53, + 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, 0x49, + 0x4e, 0x47, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x42, 0x4f, + 0x4f, 0x54, 0x53, 0x54, 0x52, 0x41, 0x50, 0x50, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, 0x13, 0x0a, + 0x0f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x5f, 0x4f, 0x50, + 0x10, 0x03, 0x2a, 0x61, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, + 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, + 0x52, 0x4f, 0x43, 0x45, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x02, + 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, + 0x54, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x6b, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x15, + 0x0a, 0x11, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, + 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x52, 0x52, 0x4f, 0x52, + 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x24, 0x0a, 0x20, + 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x53, 0x59, 0x4e, 0x43, + 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x45, 0x4d, 0x45, 0x4e, 0x54, 0x45, 0x44, + 0x10, 0x03, 0x32, 0x86, 0x11, 0x0a, 0x02, 0x56, 0x4d, 0x12, 0x3b, 0x0a, 0x0a, 0x49, 0x6e, 0x69, + 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, + 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x76, 0x6d, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3a, 0x0a, + 0x08, 0x53, 0x68, 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x1a, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, 0x61, 0x6e, - 0x64, 0x6c, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, - 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x14, 0x2e, 0x76, 0x6d, 0x2e, - 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3f, 0x0a, 0x0c, 0x44, 0x69, 0x73, 0x63, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x44, 0x69, - 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x0a, 0x42, 0x75, 0x69, - 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, - 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x76, 0x6d, - 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, - 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x65, - 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x76, 0x6d, - 0x2e, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x44, 0x0a, 0x0e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x48, + 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x39, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x14, 0x2e, 0x76, + 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3f, 0x0a, 0x0c, 0x44, 0x69, + 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, + 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3b, 0x0a, 0x0a, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x42, + 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x73, + 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, + 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, + 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0d, + 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x2e, + 0x76, 0x6d, 0x2e, 0x53, 0x65, 0x74, 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, + 0x34, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x1a, 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, + 0x0a, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x76, 0x6d, + 0x2e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, + 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, + 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x39, 0x0a, 0x0b, 0x41, + 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x76, 0x6d, 0x2e, + 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x35, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, + 0x73, 0x69, 0x70, 0x12, 0x10, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, + 0x69, 0x70, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x34, 0x0a, - 0x06, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x06, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, - 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x13, 0x2e, 0x76, 0x6d, 0x2e, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x41, - 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x76, 0x6d, 0x2e, 0x41, - 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, + 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x14, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, + 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x76, 0x6d, + 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x12, 0x57, 0x0a, 0x1a, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x21, + 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x39, 0x0a, 0x0b, 0x41, 0x70, 0x70, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, - 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x12, 0x35, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, - 0x70, 0x12, 0x10, 0x2e, 0x76, 0x6d, 0x2e, 0x41, 0x70, 0x70, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, - 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x34, 0x0a, 0x06, 0x47, - 0x61, 0x74, 0x68, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, - 0x76, 0x6d, 0x2e, 0x47, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x4b, 0x0a, 0x14, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, - 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x2e, 0x76, 0x6d, 0x2e, 0x43, - 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x57, - 0x0a, 0x1a, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x12, 0x21, 0x2e, 0x76, - 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x4d, 0x73, 0x67, 0x1a, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x4d, 0x0a, 0x15, 0x43, 0x72, 0x6f, + 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, + 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, + 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x41, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, + 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, + 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x18, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, + 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, + 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, + 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, + 0x12, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x12, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x48, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, + 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x1a, + 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x26, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, + 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x13, 0x47, 0x65, + 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, + 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x76, 0x6d, 0x2e, 0x47, + 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, + 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x50, 0x61, + 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, + 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, + 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, + 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, + 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x6d, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x4d, 0x0a, 0x15, 0x43, 0x72, 0x6f, 0x73, 0x73, - 0x43, 0x68, 0x61, 0x69, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x43, 0x68, 0x61, 0x69, 0x6e, - 0x41, 0x70, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x73, 0x67, 0x1a, 0x16, + 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x41, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, - 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, - 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x18, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x6e, 0x63, 0x65, 0x73, 0x74, 0x6f, 0x72, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x42, 0x61, 0x74, - 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1c, - 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x76, - 0x6d, 0x2e, 0x42, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x50, 0x61, 0x72, 0x73, 0x65, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x11, 0x56, - 0x65, 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x56, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x2e, - 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, - 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x41, 0x74, 0x48, 0x65, - 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x10, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, - 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, - 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, - 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x26, 0x2e, 0x76, - 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x6e, 0x67, 0x6f, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6e, 0x63, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x1a, 0x1f, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x76, 0x6d, 0x2e, 0x50, - 0x61, 0x72, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x50, 0x61, 0x72, - 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, - 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x76, 0x6d, 0x2e, 0x47, - 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x76, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, - 0x79, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, - 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x76, 0x6d, 0x2e, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, 0x70, - 0x74, 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x41, 0x63, 0x63, 0x65, - 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, - 0x12, 0x16, 0x2e, 0x76, 0x6d, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x6a, 0x65, 0x63, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x12, 0x53, 0x0a, 0x12, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x1d, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x76, 0x61, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, - 0x62, 0x2f, 0x76, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x53, 0x0a, 0x12, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, + 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x12, 0x1d, 0x2e, 0x76, + 0x6d, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, + 0x63, 0x65, 0x70, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x6d, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x76, 0x61, 0x2d, 0x6c, 0x61, + 0x62, 0x73, 0x2f, 0x61, 0x76, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x67, 0x6f, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x62, 0x2f, 0x76, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -3500,7 +3440,7 @@ func file_vm_vm_proto_rawDescGZIP() []byte { } var file_vm_vm_proto_enumTypes = make([]protoimpl.EnumInfo, 4) -var file_vm_vm_proto_msgTypes = make([]protoimpl.MessageInfo, 45) +var file_vm_vm_proto_msgTypes = make([]protoimpl.MessageInfo, 44) var file_vm_vm_proto_goTypes = []interface{}{ (State)(0), // 0: vm.State (Status)(0), // 1: vm.Status @@ -3538,119 +3478,115 @@ var file_vm_vm_proto_goTypes = []interface{}{ (*GetAncestorsResponse)(nil), // 33: vm.GetAncestorsResponse (*BatchedParseBlockRequest)(nil), // 34: vm.BatchedParseBlockRequest (*BatchedParseBlockResponse)(nil), // 35: vm.BatchedParseBlockResponse - (*VerifyHeightIndexResponse)(nil), // 36: vm.VerifyHeightIndexResponse - (*GetBlockIDAtHeightRequest)(nil), // 37: vm.GetBlockIDAtHeightRequest - (*GetBlockIDAtHeightResponse)(nil), // 38: vm.GetBlockIDAtHeightResponse - (*GatherResponse)(nil), // 39: vm.GatherResponse - (*StateSyncEnabledResponse)(nil), // 40: vm.StateSyncEnabledResponse - (*GetOngoingSyncStateSummaryResponse)(nil), // 41: vm.GetOngoingSyncStateSummaryResponse - (*GetLastStateSummaryResponse)(nil), // 42: vm.GetLastStateSummaryResponse - (*ParseStateSummaryRequest)(nil), // 43: vm.ParseStateSummaryRequest - (*ParseStateSummaryResponse)(nil), // 44: vm.ParseStateSummaryResponse - (*GetStateSummaryRequest)(nil), // 45: vm.GetStateSummaryRequest - (*GetStateSummaryResponse)(nil), // 46: vm.GetStateSummaryResponse - (*StateSummaryAcceptRequest)(nil), // 47: vm.StateSummaryAcceptRequest - (*StateSummaryAcceptResponse)(nil), // 48: vm.StateSummaryAcceptResponse - (*timestamppb.Timestamp)(nil), // 49: google.protobuf.Timestamp - (*_go.MetricFamily)(nil), // 50: io.prometheus.client.MetricFamily - (*emptypb.Empty)(nil), // 51: google.protobuf.Empty + (*GetBlockIDAtHeightRequest)(nil), // 36: vm.GetBlockIDAtHeightRequest + (*GetBlockIDAtHeightResponse)(nil), // 37: vm.GetBlockIDAtHeightResponse + (*GatherResponse)(nil), // 38: vm.GatherResponse + (*StateSyncEnabledResponse)(nil), // 39: vm.StateSyncEnabledResponse + (*GetOngoingSyncStateSummaryResponse)(nil), // 40: vm.GetOngoingSyncStateSummaryResponse + (*GetLastStateSummaryResponse)(nil), // 41: vm.GetLastStateSummaryResponse + (*ParseStateSummaryRequest)(nil), // 42: vm.ParseStateSummaryRequest + (*ParseStateSummaryResponse)(nil), // 43: vm.ParseStateSummaryResponse + (*GetStateSummaryRequest)(nil), // 44: vm.GetStateSummaryRequest + (*GetStateSummaryResponse)(nil), // 45: vm.GetStateSummaryResponse + (*StateSummaryAcceptRequest)(nil), // 46: vm.StateSummaryAcceptRequest + (*StateSummaryAcceptResponse)(nil), // 47: vm.StateSummaryAcceptResponse + (*timestamppb.Timestamp)(nil), // 48: google.protobuf.Timestamp + (*_go.MetricFamily)(nil), // 49: io.prometheus.client.MetricFamily + (*emptypb.Empty)(nil), // 50: google.protobuf.Empty } var file_vm_vm_proto_depIdxs = []int32{ - 49, // 0: vm.InitializeResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 0: vm.InitializeResponse.timestamp:type_name -> google.protobuf.Timestamp 0, // 1: vm.SetStateRequest.state:type_name -> vm.State - 49, // 2: vm.SetStateResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 2: vm.SetStateResponse.timestamp:type_name -> google.protobuf.Timestamp 9, // 3: vm.CreateHandlersResponse.handlers:type_name -> vm.Handler - 49, // 4: vm.BuildBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 4: vm.BuildBlockResponse.timestamp:type_name -> google.protobuf.Timestamp 1, // 5: vm.ParseBlockResponse.status:type_name -> vm.Status - 49, // 6: vm.ParseBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 6: vm.ParseBlockResponse.timestamp:type_name -> google.protobuf.Timestamp 1, // 7: vm.GetBlockResponse.status:type_name -> vm.Status - 49, // 8: vm.GetBlockResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 8: vm.GetBlockResponse.timestamp:type_name -> google.protobuf.Timestamp 2, // 9: vm.GetBlockResponse.err:type_name -> vm.Error - 49, // 10: vm.BlockVerifyResponse.timestamp:type_name -> google.protobuf.Timestamp - 49, // 11: vm.AppRequestMsg.deadline:type_name -> google.protobuf.Timestamp - 49, // 12: vm.CrossChainAppRequestMsg.deadline:type_name -> google.protobuf.Timestamp + 48, // 10: vm.BlockVerifyResponse.timestamp:type_name -> google.protobuf.Timestamp + 48, // 11: vm.AppRequestMsg.deadline:type_name -> google.protobuf.Timestamp + 48, // 12: vm.CrossChainAppRequestMsg.deadline:type_name -> google.protobuf.Timestamp 13, // 13: vm.BatchedParseBlockResponse.response:type_name -> vm.ParseBlockResponse - 2, // 14: vm.VerifyHeightIndexResponse.err:type_name -> vm.Error - 2, // 15: vm.GetBlockIDAtHeightResponse.err:type_name -> vm.Error - 50, // 16: vm.GatherResponse.metric_families:type_name -> io.prometheus.client.MetricFamily - 2, // 17: vm.StateSyncEnabledResponse.err:type_name -> vm.Error - 2, // 18: vm.GetOngoingSyncStateSummaryResponse.err:type_name -> vm.Error - 2, // 19: vm.GetLastStateSummaryResponse.err:type_name -> vm.Error - 2, // 20: vm.ParseStateSummaryResponse.err:type_name -> vm.Error - 2, // 21: vm.GetStateSummaryResponse.err:type_name -> vm.Error - 3, // 22: vm.StateSummaryAcceptResponse.mode:type_name -> vm.StateSummaryAcceptResponse.Mode - 2, // 23: vm.StateSummaryAcceptResponse.err:type_name -> vm.Error - 4, // 24: vm.VM.Initialize:input_type -> vm.InitializeRequest - 6, // 25: vm.VM.SetState:input_type -> vm.SetStateRequest - 51, // 26: vm.VM.Shutdown:input_type -> google.protobuf.Empty - 51, // 27: vm.VM.CreateHandlers:input_type -> google.protobuf.Empty - 30, // 28: vm.VM.Connected:input_type -> vm.ConnectedRequest - 31, // 29: vm.VM.Disconnected:input_type -> vm.DisconnectedRequest - 10, // 30: vm.VM.BuildBlock:input_type -> vm.BuildBlockRequest - 12, // 31: vm.VM.ParseBlock:input_type -> vm.ParseBlockRequest - 14, // 32: vm.VM.GetBlock:input_type -> vm.GetBlockRequest - 16, // 33: vm.VM.SetPreference:input_type -> vm.SetPreferenceRequest - 51, // 34: vm.VM.Health:input_type -> google.protobuf.Empty - 51, // 35: vm.VM.Version:input_type -> google.protobuf.Empty - 23, // 36: vm.VM.AppRequest:input_type -> vm.AppRequestMsg - 24, // 37: vm.VM.AppRequestFailed:input_type -> vm.AppRequestFailedMsg - 25, // 38: vm.VM.AppResponse:input_type -> vm.AppResponseMsg - 26, // 39: vm.VM.AppGossip:input_type -> vm.AppGossipMsg - 51, // 40: vm.VM.Gather:input_type -> google.protobuf.Empty - 27, // 41: vm.VM.CrossChainAppRequest:input_type -> vm.CrossChainAppRequestMsg - 28, // 42: vm.VM.CrossChainAppRequestFailed:input_type -> vm.CrossChainAppRequestFailedMsg - 29, // 43: vm.VM.CrossChainAppResponse:input_type -> vm.CrossChainAppResponseMsg - 32, // 44: vm.VM.GetAncestors:input_type -> vm.GetAncestorsRequest - 34, // 45: vm.VM.BatchedParseBlock:input_type -> vm.BatchedParseBlockRequest - 51, // 46: vm.VM.VerifyHeightIndex:input_type -> google.protobuf.Empty - 37, // 47: vm.VM.GetBlockIDAtHeight:input_type -> vm.GetBlockIDAtHeightRequest - 51, // 48: vm.VM.StateSyncEnabled:input_type -> google.protobuf.Empty - 51, // 49: vm.VM.GetOngoingSyncStateSummary:input_type -> google.protobuf.Empty - 51, // 50: vm.VM.GetLastStateSummary:input_type -> google.protobuf.Empty - 43, // 51: vm.VM.ParseStateSummary:input_type -> vm.ParseStateSummaryRequest - 45, // 52: vm.VM.GetStateSummary:input_type -> vm.GetStateSummaryRequest - 17, // 53: vm.VM.BlockVerify:input_type -> vm.BlockVerifyRequest - 19, // 54: vm.VM.BlockAccept:input_type -> vm.BlockAcceptRequest - 20, // 55: vm.VM.BlockReject:input_type -> vm.BlockRejectRequest - 47, // 56: vm.VM.StateSummaryAccept:input_type -> vm.StateSummaryAcceptRequest - 5, // 57: vm.VM.Initialize:output_type -> vm.InitializeResponse - 7, // 58: vm.VM.SetState:output_type -> vm.SetStateResponse - 51, // 59: vm.VM.Shutdown:output_type -> google.protobuf.Empty - 8, // 60: vm.VM.CreateHandlers:output_type -> vm.CreateHandlersResponse - 51, // 61: vm.VM.Connected:output_type -> google.protobuf.Empty - 51, // 62: vm.VM.Disconnected:output_type -> google.protobuf.Empty - 11, // 63: vm.VM.BuildBlock:output_type -> vm.BuildBlockResponse - 13, // 64: vm.VM.ParseBlock:output_type -> vm.ParseBlockResponse - 15, // 65: vm.VM.GetBlock:output_type -> vm.GetBlockResponse - 51, // 66: vm.VM.SetPreference:output_type -> google.protobuf.Empty - 21, // 67: vm.VM.Health:output_type -> vm.HealthResponse - 22, // 68: vm.VM.Version:output_type -> vm.VersionResponse - 51, // 69: vm.VM.AppRequest:output_type -> google.protobuf.Empty - 51, // 70: vm.VM.AppRequestFailed:output_type -> google.protobuf.Empty - 51, // 71: vm.VM.AppResponse:output_type -> google.protobuf.Empty - 51, // 72: vm.VM.AppGossip:output_type -> google.protobuf.Empty - 39, // 73: vm.VM.Gather:output_type -> vm.GatherResponse - 51, // 74: vm.VM.CrossChainAppRequest:output_type -> google.protobuf.Empty - 51, // 75: vm.VM.CrossChainAppRequestFailed:output_type -> google.protobuf.Empty - 51, // 76: vm.VM.CrossChainAppResponse:output_type -> google.protobuf.Empty - 33, // 77: vm.VM.GetAncestors:output_type -> vm.GetAncestorsResponse - 35, // 78: vm.VM.BatchedParseBlock:output_type -> vm.BatchedParseBlockResponse - 36, // 79: vm.VM.VerifyHeightIndex:output_type -> vm.VerifyHeightIndexResponse - 38, // 80: vm.VM.GetBlockIDAtHeight:output_type -> vm.GetBlockIDAtHeightResponse - 40, // 81: vm.VM.StateSyncEnabled:output_type -> vm.StateSyncEnabledResponse - 41, // 82: vm.VM.GetOngoingSyncStateSummary:output_type -> vm.GetOngoingSyncStateSummaryResponse - 42, // 83: vm.VM.GetLastStateSummary:output_type -> vm.GetLastStateSummaryResponse - 44, // 84: vm.VM.ParseStateSummary:output_type -> vm.ParseStateSummaryResponse - 46, // 85: vm.VM.GetStateSummary:output_type -> vm.GetStateSummaryResponse - 18, // 86: vm.VM.BlockVerify:output_type -> vm.BlockVerifyResponse - 51, // 87: vm.VM.BlockAccept:output_type -> google.protobuf.Empty - 51, // 88: vm.VM.BlockReject:output_type -> google.protobuf.Empty - 48, // 89: vm.VM.StateSummaryAccept:output_type -> vm.StateSummaryAcceptResponse - 57, // [57:90] is the sub-list for method output_type - 24, // [24:57] is the sub-list for method input_type - 24, // [24:24] is the sub-list for extension type_name - 24, // [24:24] is the sub-list for extension extendee - 0, // [0:24] is the sub-list for field type_name + 2, // 14: vm.GetBlockIDAtHeightResponse.err:type_name -> vm.Error + 49, // 15: vm.GatherResponse.metric_families:type_name -> io.prometheus.client.MetricFamily + 2, // 16: vm.StateSyncEnabledResponse.err:type_name -> vm.Error + 2, // 17: vm.GetOngoingSyncStateSummaryResponse.err:type_name -> vm.Error + 2, // 18: vm.GetLastStateSummaryResponse.err:type_name -> vm.Error + 2, // 19: vm.ParseStateSummaryResponse.err:type_name -> vm.Error + 2, // 20: vm.GetStateSummaryResponse.err:type_name -> vm.Error + 3, // 21: vm.StateSummaryAcceptResponse.mode:type_name -> vm.StateSummaryAcceptResponse.Mode + 2, // 22: vm.StateSummaryAcceptResponse.err:type_name -> vm.Error + 4, // 23: vm.VM.Initialize:input_type -> vm.InitializeRequest + 6, // 24: vm.VM.SetState:input_type -> vm.SetStateRequest + 50, // 25: vm.VM.Shutdown:input_type -> google.protobuf.Empty + 50, // 26: vm.VM.CreateHandlers:input_type -> google.protobuf.Empty + 30, // 27: vm.VM.Connected:input_type -> vm.ConnectedRequest + 31, // 28: vm.VM.Disconnected:input_type -> vm.DisconnectedRequest + 10, // 29: vm.VM.BuildBlock:input_type -> vm.BuildBlockRequest + 12, // 30: vm.VM.ParseBlock:input_type -> vm.ParseBlockRequest + 14, // 31: vm.VM.GetBlock:input_type -> vm.GetBlockRequest + 16, // 32: vm.VM.SetPreference:input_type -> vm.SetPreferenceRequest + 50, // 33: vm.VM.Health:input_type -> google.protobuf.Empty + 50, // 34: vm.VM.Version:input_type -> google.protobuf.Empty + 23, // 35: vm.VM.AppRequest:input_type -> vm.AppRequestMsg + 24, // 36: vm.VM.AppRequestFailed:input_type -> vm.AppRequestFailedMsg + 25, // 37: vm.VM.AppResponse:input_type -> vm.AppResponseMsg + 26, // 38: vm.VM.AppGossip:input_type -> vm.AppGossipMsg + 50, // 39: vm.VM.Gather:input_type -> google.protobuf.Empty + 27, // 40: vm.VM.CrossChainAppRequest:input_type -> vm.CrossChainAppRequestMsg + 28, // 41: vm.VM.CrossChainAppRequestFailed:input_type -> vm.CrossChainAppRequestFailedMsg + 29, // 42: vm.VM.CrossChainAppResponse:input_type -> vm.CrossChainAppResponseMsg + 32, // 43: vm.VM.GetAncestors:input_type -> vm.GetAncestorsRequest + 34, // 44: vm.VM.BatchedParseBlock:input_type -> vm.BatchedParseBlockRequest + 36, // 45: vm.VM.GetBlockIDAtHeight:input_type -> vm.GetBlockIDAtHeightRequest + 50, // 46: vm.VM.StateSyncEnabled:input_type -> google.protobuf.Empty + 50, // 47: vm.VM.GetOngoingSyncStateSummary:input_type -> google.protobuf.Empty + 50, // 48: vm.VM.GetLastStateSummary:input_type -> google.protobuf.Empty + 42, // 49: vm.VM.ParseStateSummary:input_type -> vm.ParseStateSummaryRequest + 44, // 50: vm.VM.GetStateSummary:input_type -> vm.GetStateSummaryRequest + 17, // 51: vm.VM.BlockVerify:input_type -> vm.BlockVerifyRequest + 19, // 52: vm.VM.BlockAccept:input_type -> vm.BlockAcceptRequest + 20, // 53: vm.VM.BlockReject:input_type -> vm.BlockRejectRequest + 46, // 54: vm.VM.StateSummaryAccept:input_type -> vm.StateSummaryAcceptRequest + 5, // 55: vm.VM.Initialize:output_type -> vm.InitializeResponse + 7, // 56: vm.VM.SetState:output_type -> vm.SetStateResponse + 50, // 57: vm.VM.Shutdown:output_type -> google.protobuf.Empty + 8, // 58: vm.VM.CreateHandlers:output_type -> vm.CreateHandlersResponse + 50, // 59: vm.VM.Connected:output_type -> google.protobuf.Empty + 50, // 60: vm.VM.Disconnected:output_type -> google.protobuf.Empty + 11, // 61: vm.VM.BuildBlock:output_type -> vm.BuildBlockResponse + 13, // 62: vm.VM.ParseBlock:output_type -> vm.ParseBlockResponse + 15, // 63: vm.VM.GetBlock:output_type -> vm.GetBlockResponse + 50, // 64: vm.VM.SetPreference:output_type -> google.protobuf.Empty + 21, // 65: vm.VM.Health:output_type -> vm.HealthResponse + 22, // 66: vm.VM.Version:output_type -> vm.VersionResponse + 50, // 67: vm.VM.AppRequest:output_type -> google.protobuf.Empty + 50, // 68: vm.VM.AppRequestFailed:output_type -> google.protobuf.Empty + 50, // 69: vm.VM.AppResponse:output_type -> google.protobuf.Empty + 50, // 70: vm.VM.AppGossip:output_type -> google.protobuf.Empty + 38, // 71: vm.VM.Gather:output_type -> vm.GatherResponse + 50, // 72: vm.VM.CrossChainAppRequest:output_type -> google.protobuf.Empty + 50, // 73: vm.VM.CrossChainAppRequestFailed:output_type -> google.protobuf.Empty + 50, // 74: vm.VM.CrossChainAppResponse:output_type -> google.protobuf.Empty + 33, // 75: vm.VM.GetAncestors:output_type -> vm.GetAncestorsResponse + 35, // 76: vm.VM.BatchedParseBlock:output_type -> vm.BatchedParseBlockResponse + 37, // 77: vm.VM.GetBlockIDAtHeight:output_type -> vm.GetBlockIDAtHeightResponse + 39, // 78: vm.VM.StateSyncEnabled:output_type -> vm.StateSyncEnabledResponse + 40, // 79: vm.VM.GetOngoingSyncStateSummary:output_type -> vm.GetOngoingSyncStateSummaryResponse + 41, // 80: vm.VM.GetLastStateSummary:output_type -> vm.GetLastStateSummaryResponse + 43, // 81: vm.VM.ParseStateSummary:output_type -> vm.ParseStateSummaryResponse + 45, // 82: vm.VM.GetStateSummary:output_type -> vm.GetStateSummaryResponse + 18, // 83: vm.VM.BlockVerify:output_type -> vm.BlockVerifyResponse + 50, // 84: vm.VM.BlockAccept:output_type -> google.protobuf.Empty + 50, // 85: vm.VM.BlockReject:output_type -> google.protobuf.Empty + 47, // 86: vm.VM.StateSummaryAccept:output_type -> vm.StateSummaryAcceptResponse + 55, // [55:87] is the sub-list for method output_type + 23, // [23:55] is the sub-list for method input_type + 23, // [23:23] is the sub-list for extension type_name + 23, // [23:23] is the sub-list for extension extendee + 0, // [0:23] is the sub-list for field type_name } func init() { file_vm_vm_proto_init() } @@ -4044,18 +3980,6 @@ func file_vm_vm_proto_init() { } } file_vm_vm_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VerifyHeightIndexResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_vm_vm_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetBlockIDAtHeightRequest); i { case 0: return &v.state @@ -4067,7 +3991,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetBlockIDAtHeightResponse); i { case 0: return &v.state @@ -4079,7 +4003,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GatherResponse); i { case 0: return &v.state @@ -4091,7 +4015,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StateSyncEnabledResponse); i { case 0: return &v.state @@ -4103,7 +4027,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetOngoingSyncStateSummaryResponse); i { case 0: return &v.state @@ -4115,7 +4039,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetLastStateSummaryResponse); i { case 0: return &v.state @@ -4127,7 +4051,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ParseStateSummaryRequest); i { case 0: return &v.state @@ -4139,7 +4063,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ParseStateSummaryResponse); i { case 0: return &v.state @@ -4151,7 +4075,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetStateSummaryRequest); i { case 0: return &v.state @@ -4163,7 +4087,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetStateSummaryResponse); i { case 0: return &v.state @@ -4175,7 +4099,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StateSummaryAcceptRequest); i { case 0: return &v.state @@ -4187,7 +4111,7 @@ func file_vm_vm_proto_init() { return nil } } - file_vm_vm_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_vm_vm_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StateSummaryAcceptResponse); i { case 0: return &v.state @@ -4208,7 +4132,7 @@ func file_vm_vm_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vm_vm_proto_rawDesc, NumEnums: 4, - NumMessages: 45, + NumMessages: 44, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/pb/vm/vm_grpc.pb.go b/proto/pb/vm/vm_grpc.pb.go index 6d7bb17f6c33..4a67f13408ce 100644 --- a/proto/pb/vm/vm_grpc.pb.go +++ b/proto/pb/vm/vm_grpc.pb.go @@ -42,7 +42,6 @@ const ( VM_CrossChainAppResponse_FullMethodName = "/vm.VM/CrossChainAppResponse" VM_GetAncestors_FullMethodName = "/vm.VM/GetAncestors" VM_BatchedParseBlock_FullMethodName = "/vm.VM/BatchedParseBlock" - VM_VerifyHeightIndex_FullMethodName = "/vm.VM/VerifyHeightIndex" VM_GetBlockIDAtHeight_FullMethodName = "/vm.VM/GetBlockIDAtHeight" VM_StateSyncEnabled_FullMethodName = "/vm.VM/StateSyncEnabled" VM_GetOngoingSyncStateSummary_FullMethodName = "/vm.VM/GetOngoingSyncStateSummary" @@ -102,7 +101,6 @@ type VMClient interface { GetAncestors(ctx context.Context, in *GetAncestorsRequest, opts ...grpc.CallOption) (*GetAncestorsResponse, error) BatchedParseBlock(ctx context.Context, in *BatchedParseBlockRequest, opts ...grpc.CallOption) (*BatchedParseBlockResponse, error) // HeightIndexedChainVM - VerifyHeightIndex(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*VerifyHeightIndexResponse, error) GetBlockIDAtHeight(ctx context.Context, in *GetBlockIDAtHeightRequest, opts ...grpc.CallOption) (*GetBlockIDAtHeightResponse, error) // StateSyncableVM // @@ -331,15 +329,6 @@ func (c *vMClient) BatchedParseBlock(ctx context.Context, in *BatchedParseBlockR return out, nil } -func (c *vMClient) VerifyHeightIndex(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*VerifyHeightIndexResponse, error) { - out := new(VerifyHeightIndexResponse) - err := c.cc.Invoke(ctx, VM_VerifyHeightIndex_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *vMClient) GetBlockIDAtHeight(ctx context.Context, in *GetBlockIDAtHeightRequest, opts ...grpc.CallOption) (*GetBlockIDAtHeightResponse, error) { out := new(GetBlockIDAtHeightResponse) err := c.cc.Invoke(ctx, VM_GetBlockIDAtHeight_FullMethodName, in, out, opts...) @@ -477,7 +466,6 @@ type VMServer interface { GetAncestors(context.Context, *GetAncestorsRequest) (*GetAncestorsResponse, error) BatchedParseBlock(context.Context, *BatchedParseBlockRequest) (*BatchedParseBlockResponse, error) // HeightIndexedChainVM - VerifyHeightIndex(context.Context, *emptypb.Empty) (*VerifyHeightIndexResponse, error) GetBlockIDAtHeight(context.Context, *GetBlockIDAtHeightRequest) (*GetBlockIDAtHeightResponse, error) // StateSyncableVM // @@ -571,9 +559,6 @@ func (UnimplementedVMServer) GetAncestors(context.Context, *GetAncestorsRequest) func (UnimplementedVMServer) BatchedParseBlock(context.Context, *BatchedParseBlockRequest) (*BatchedParseBlockResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BatchedParseBlock not implemented") } -func (UnimplementedVMServer) VerifyHeightIndex(context.Context, *emptypb.Empty) (*VerifyHeightIndexResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method VerifyHeightIndex not implemented") -} func (UnimplementedVMServer) GetBlockIDAtHeight(context.Context, *GetBlockIDAtHeightRequest) (*GetBlockIDAtHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBlockIDAtHeight not implemented") } @@ -1013,24 +998,6 @@ func _VM_BatchedParseBlock_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _VM_VerifyHeightIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(emptypb.Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(VMServer).VerifyHeightIndex(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: VM_VerifyHeightIndex_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(VMServer).VerifyHeightIndex(ctx, req.(*emptypb.Empty)) - } - return interceptor(ctx, in, info, handler) -} - func _VM_GetBlockIDAtHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetBlockIDAtHeightRequest) if err := dec(in); err != nil { @@ -1306,10 +1273,6 @@ var VM_ServiceDesc = grpc.ServiceDesc{ MethodName: "BatchedParseBlock", Handler: _VM_BatchedParseBlock_Handler, }, - { - MethodName: "VerifyHeightIndex", - Handler: _VM_VerifyHeightIndex_Handler, - }, { MethodName: "GetBlockIDAtHeight", Handler: _VM_GetBlockIDAtHeight_Handler, diff --git a/proto/pb/warp/message.pb.go b/proto/pb/warp/message.pb.go index d6cb37360817..14827b49b549 100644 --- a/proto/pb/warp/message.pb.go +++ b/proto/pb/warp/message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.33.0 // protoc (unknown) // source: warp/message.proto diff --git a/proto/vm/vm.proto b/proto/vm/vm.proto index 4a0557ba4e67..038744d4e2d5 100644 --- a/proto/vm/vm.proto +++ b/proto/vm/vm.proto @@ -56,7 +56,6 @@ service VM { rpc BatchedParseBlock(BatchedParseBlockRequest) returns (BatchedParseBlockResponse); // HeightIndexedChainVM - rpc VerifyHeightIndex(google.protobuf.Empty) returns (VerifyHeightIndexResponse); rpc GetBlockIDAtHeight(GetBlockIDAtHeightRequest) returns (GetBlockIDAtHeightResponse); // StateSyncableVM @@ -101,8 +100,7 @@ enum Error { ERROR_UNSPECIFIED = 0; ERROR_CLOSED = 1; ERROR_NOT_FOUND = 2; - ERROR_HEIGHT_INDEX_INCOMPLETE = 3; - ERROR_STATE_SYNC_NOT_IMPLEMENTED = 4; + ERROR_STATE_SYNC_NOT_IMPLEMENTED = 3; } message InitializeRequest { @@ -334,10 +332,6 @@ message BatchedParseBlockResponse { repeated ParseBlockResponse response = 1; } -message VerifyHeightIndexResponse { - Error err = 1; -} - message GetBlockIDAtHeightRequest { uint64 height = 1; } diff --git a/scripts/build_antithesis_workload.sh b/scripts/build_antithesis_workload.sh new file mode 100755 index 000000000000..e0d99d1fed11 --- /dev/null +++ b/scripts/build_antithesis_workload.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Directory above this script +AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) +# Load the constants +source "$AVALANCHE_PATH"/scripts/constants.sh + +echo "Building Workload..." +go build -o "$AVALANCHE_PATH/build/workload" "$AVALANCHE_PATH/tests/antithesis/"*.go diff --git a/scripts/build_avalanche.sh b/scripts/build_avalanche.sh index a2b06508668e..094fa5467a2b 100755 --- a/scripts/build_avalanche.sh +++ b/scripts/build_avalanche.sh @@ -24,6 +24,8 @@ done # Changes to the minimum golang version must also be replicated in # scripts/build_avalanche.sh (here) +# tests/antithesis/Dockerfile.node +# tests/antithesis/Dockerfile.workload # Dockerfile # README.md # go.mod diff --git a/scripts/protobuf_codegen.sh b/scripts/protobuf_codegen.sh index 5230ca7b83a2..288903780487 100755 --- a/scripts/protobuf_codegen.sh +++ b/scripts/protobuf_codegen.sh @@ -11,7 +11,7 @@ fi # any version changes here should also be bumped in Dockerfile.buf # ref. https://docs.buf.build/installation # ref. https://github.com/bufbuild/buf/releases -BUF_VERSION='1.29.0' +BUF_VERSION='1.30.0' if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then echo "could not find buf ${BUF_VERSION}, is it installed + in PATH?" exit 255 @@ -20,7 +20,7 @@ fi ## install "protoc-gen-go" # any version changes here should also be bumped in Dockerfile.buf # ref. https://github.com/protocolbuffers/protobuf-go/releases -PROTOC_GEN_GO_VERSION='v1.30.0' +PROTOC_GEN_GO_VERSION='v1.33.0' go install -v google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GEN_GO_VERSION} if [[ $(protoc-gen-go --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_VERSION}" ]]; then # e.g., protoc-gen-go v1.28.1 diff --git a/scripts/run_prometheus.sh b/scripts/run_prometheus.sh new file mode 100755 index 000000000000..195222723107 --- /dev/null +++ b/scripts/run_prometheus.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Starts a prometheus instance in agent-mode, forwarding to a central +# instance. Intended to enable metrics collection from temporary networks running +# locally and in CI. +# +# The prometheus instance will remain running in the background and will forward +# metrics to the central instance for all tmpnet networks. +# +# To stop it: +# +# $ kill -9 `cat ~/.tmpnet/prometheus/run.pid` && rm ~/.tmpnet/prometheus/run.pid +# + +# e.g., +# PROMETHEUS_ID= PROMETHEUS_PASSWORD= ./scripts/run_prometheus.sh +if ! [[ "$0" =~ scripts/run_prometheus.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +PROMETHEUS_WORKING_DIR="${HOME}/.tmpnet/prometheus" +PIDFILE="${PROMETHEUS_WORKING_DIR}"/run.pid + +# First check if an agent-mode prometheus is already running. A single instance can collect +# metrics from all local temporary networks. +if pgrep --pidfile="${PIDFILE}" -f 'prometheus.*enable-feature=agent' &> /dev/null; then + echo "prometheus is already running locally with --enable-feature=agent" + exit 0 +fi + +PROMETHEUS_URL="${PROMETHEUS_URL:-https://prometheus-experimental.avax-dev.network}" +if [[ -z "${PROMETHEUS_URL}" ]]; then + echo "Please provide a value for PROMETHEUS_URL" + exit 1 +fi + +PROMETHEUS_ID="${PROMETHEUS_ID:-}" +if [[ -z "${PROMETHEUS_ID}" ]]; then + echo "Please provide a value for PROMETHEUS_ID" + exit 1 +fi + +PROMETHEUS_PASSWORD="${PROMETHEUS_PASSWORD:-}" +if [[ -z "${PROMETHEUS_PASSWORD}" ]]; then + echo "Plase provide a value for PROMETHEUS_PASSWORD" + exit 1 +fi + +# This was the LTS version when this script was written. Probably not +# much reason to update it unless something breaks since the usage +# here is only to collect metrics from temporary networks. +VERSION="2.45.3" + +# Ensure the prometheus command is locally available +CMD=prometheus +if ! command -v "${CMD}" &> /dev/null; then + # Try to use a local version + CMD="${PWD}/bin/prometheus" + if ! command -v "${CMD}" &> /dev/null; then + echo "prometheus not found, attempting to install..." + + # Determine the arch + if which sw_vers &> /dev/null; then + echo "on macos, only amd64 binaries are available so rosetta is required on apple silicon machines." + echo "to avoid using rosetta, install via homebrew: brew install prometheus" + DIST=darwin + else + ARCH="$(uname -i)" + if [[ "${ARCH}" != "x86_64" ]]; then + echo "on linux, only amd64 binaries are available. manual installation of prometheus is required." + exit 1 + else + DIST="linux" + fi + fi + + # Install the specified release + PROMETHEUS_FILE="prometheus-${VERSION}.${DIST}-amd64" + URL="https://github.com/prometheus/prometheus/releases/download/v${VERSION}/${PROMETHEUS_FILE}.tar.gz" + curl -s -L "${URL}" | tar zxv -C /tmp > /dev/null + mkdir -p "$(dirname "${CMD}")" + cp /tmp/"${PROMETHEUS_FILE}/prometheus" "${CMD}" + fi +fi + +# Configure prometheus +FILE_SD_PATH="${PROMETHEUS_WORKING_DIR}/file_sd_configs" +mkdir -p "${FILE_SD_PATH}" + +echo "writing configuration..." +cat >"${PROMETHEUS_WORKING_DIR}"/prometheus.yaml < prometheus.log 2>&1 & +echo $! > "${PIDFILE}" +echo "running with pid $(cat "${PIDFILE}")" diff --git a/scripts/run_promtail.sh b/scripts/run_promtail.sh new file mode 100755 index 000000000000..9b386d3d55f2 --- /dev/null +++ b/scripts/run_promtail.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Starts a promtail instance to collect logs from temporary networks +# running locally and in CI. +# +# The promtail instance will remain running in the background and will forward +# logs to the central instance for all tmpnet networks. +# +# To stop it: +# +# $ kill -9 `cat ~/.tmpnet/promtail/run.pid` && rm ~/.tmpnet/promtail/run.pid +# + +# e.g., +# LOKI_ID= LOKI_PASSWORD= ./scripts/run_promtail.sh +if ! [[ "$0" =~ scripts/run_promtail.sh ]]; then + echo "must be run from repository root" + exit 255 +fi + +PROMTAIL_WORKING_DIR="${HOME}/.tmpnet/promtail" +PIDFILE="${PROMTAIL_WORKING_DIR}"/run.pid + +# First check if promtail is already running. A single instance can +# collect logs from all local temporary networks. +if pgrep --pidfile="${PIDFILE}" &> /dev/null; then + echo "promtail is already running" + exit 0 +fi + +LOKI_URL="${LOKI_URL:-https://loki-experimental.avax-dev.network}" +if [[ -z "${LOKI_URL}" ]]; then + echo "Please provide a value for LOKI_URL" + exit 1 +fi + +LOKI_ID="${LOKI_ID:-}" +if [[ -z "${LOKI_ID}" ]]; then + echo "Please provide a value for LOKI_ID" + exit 1 +fi + +LOKI_PASSWORD="${LOKI_PASSWORD:-}" +if [[ -z "${LOKI_PASSWORD}" ]]; then + echo "Plase provide a value for LOKI_PASSWORD" + exit 1 +fi + +# Version as of this writing +VERSION="v2.9.5" + +# Ensure the promtail command is locally available +CMD=promtail +if ! command -v "${CMD}" &> /dev/null; then + # Try to use a local version + CMD="${PWD}/bin/promtail" + if ! command -v "${CMD}" &> /dev/null; then + echo "promtail not found, attempting to install..." + # Determine the arch + if which sw_vers &> /dev/null; then + DIST="darwin-$(uname -m)" + else + ARCH="$(uname -i)" + if [[ "${ARCH}" == "aarch64" ]]; then + ARCH="arm64" + elif [[ "${ARCH}" == "x86_64" ]]; then + ARCH="amd64" + fi + DIST="linux-${ARCH}" + fi + + # Install the specified release + PROMTAIL_FILE="promtail-${DIST}" + ZIP_PATH="/tmp/${PROMTAIL_FILE}.zip" + BIN_DIR="$(dirname "${CMD}")" + URL="https://github.com/grafana/loki/releases/download/${VERSION}/promtail-${DIST}.zip" + curl -L -o "${ZIP_PATH}" "${URL}" + unzip "${ZIP_PATH}" -d "${BIN_DIR}" + mv "${BIN_DIR}/${PROMTAIL_FILE}" "${CMD}" + fi +fi + +# Configure promtail +FILE_SD_PATH="${PROMTAIL_WORKING_DIR}/file_sd_configs" +mkdir -p "${FILE_SD_PATH}" + +echo "writing configuration..." +cat >"${PROMTAIL_WORKING_DIR}"/promtail.yaml < promtail.log 2>&1 & +echo $! > "${PIDFILE}" +echo "running with pid $(cat "${PIDFILE}")" diff --git a/snow/engine/avalanche/bootstrap/bootstrapper.go b/snow/engine/avalanche/bootstrap/bootstrapper.go index cd530d1cb1f8..d3028bc3bfce 100644 --- a/snow/engine/avalanche/bootstrap/bootstrapper.go +++ b/snow/engine/avalanche/bootstrap/bootstrapper.go @@ -325,7 +325,6 @@ func (b *bootstrapper) Start(ctx context.Context, startReqID uint32) error { if err := b.VtxBlocked.SetParser(ctx, &vtxParser{ log: b.Ctx.Log, numAccepted: b.numAcceptedVts, - numDropped: b.numDroppedVts, manager: b.Manager, }); err != nil { return err @@ -334,7 +333,6 @@ func (b *bootstrapper) Start(ctx context.Context, startReqID uint32) error { if err := b.TxBlocked.SetParser(&txParser{ log: b.Ctx.Log, numAccepted: b.numAcceptedTxs, - numDropped: b.numDroppedTxs, vm: b.VM, }); err != nil { return err @@ -475,7 +473,6 @@ func (b *bootstrapper) process(ctx context.Context, vtxs ...avalanche.Vertex) er pushed, err := b.VtxBlocked.Push(ctx, &vertexJob{ log: b.Ctx.Log, numAccepted: b.numAcceptedVts, - numDropped: b.numDroppedVts, vtx: vtx, }) if err != nil { @@ -497,7 +494,6 @@ func (b *bootstrapper) process(ctx context.Context, vtxs ...avalanche.Vertex) er pushed, err := b.TxBlocked.Push(ctx, &txJob{ log: b.Ctx.Log, numAccepted: b.numAcceptedTxs, - numDropped: b.numDroppedTxs, tx: tx, }) if err != nil { diff --git a/snow/engine/avalanche/bootstrap/metrics.go b/snow/engine/avalanche/bootstrap/metrics.go index cc357f25901f..5ad1b3713647 100644 --- a/snow/engine/avalanche/bootstrap/metrics.go +++ b/snow/engine/avalanche/bootstrap/metrics.go @@ -10,8 +10,8 @@ import ( ) type metrics struct { - numFetchedVts, numDroppedVts, numAcceptedVts, - numFetchedTxs, numDroppedTxs, numAcceptedTxs prometheus.Counter + numFetchedVts, numAcceptedVts, + numFetchedTxs, numAcceptedTxs prometheus.Counter } func (m *metrics) Initialize( @@ -23,11 +23,6 @@ func (m *metrics) Initialize( Name: "fetched_vts", Help: "Number of vertices fetched during bootstrapping", }) - m.numDroppedVts = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: namespace, - Name: "dropped_vts", - Help: "Number of vertices dropped during bootstrapping", - }) m.numAcceptedVts = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: namespace, Name: "accepted_vts", @@ -39,11 +34,6 @@ func (m *metrics) Initialize( Name: "fetched_txs", Help: "Number of transactions fetched during bootstrapping", }) - m.numDroppedTxs = prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: namespace, - Name: "dropped_txs", - Help: "Number of transactions dropped during bootstrapping", - }) m.numAcceptedTxs = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: namespace, Name: "accepted_txs", @@ -52,10 +42,8 @@ func (m *metrics) Initialize( return utils.Err( registerer.Register(m.numFetchedVts), - registerer.Register(m.numDroppedVts), registerer.Register(m.numAcceptedVts), registerer.Register(m.numFetchedTxs), - registerer.Register(m.numDroppedTxs), registerer.Register(m.numAcceptedTxs), ) } diff --git a/snow/engine/avalanche/bootstrap/tx_job.go b/snow/engine/avalanche/bootstrap/tx_job.go index 5a2ff3d98f64..17a2dcb53127 100644 --- a/snow/engine/avalanche/bootstrap/tx_job.go +++ b/snow/engine/avalanche/bootstrap/tx_job.go @@ -23,9 +23,9 @@ import ( var errMissingTxDependenciesOnAccept = errors.New("attempting to accept a transaction with missing dependencies") type txParser struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - vm vertex.LinearizableVM + log logging.Logger + numAccepted prometheus.Counter + vm vertex.LinearizableVM } func (p *txParser) Parse(ctx context.Context, txBytes []byte) (queue.Job, error) { @@ -36,15 +36,14 @@ func (p *txParser) Parse(ctx context.Context, txBytes []byte) (queue.Job, error) return &txJob{ log: p.log, numAccepted: p.numAccepted, - numDropped: p.numDropped, tx: tx, }, nil } type txJob struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - tx snowstorm.Tx + log logging.Logger + numAccepted prometheus.Counter + tx snowstorm.Tx } func (t *txJob) ID() ids.ID { @@ -67,14 +66,12 @@ func (t *txJob) Execute(ctx context.Context) error { return err } if hasMissingDeps { - t.numDropped.Inc() return errMissingTxDependenciesOnAccept } status := t.tx.Status() switch status { case choices.Unknown, choices.Rejected: - t.numDropped.Inc() return fmt.Errorf("attempting to execute transaction with status %s", status) case choices.Processing: txID := t.tx.ID() diff --git a/snow/engine/avalanche/bootstrap/vertex_job.go b/snow/engine/avalanche/bootstrap/vertex_job.go index 8860b61d816a..21c0b93ed937 100644 --- a/snow/engine/avalanche/bootstrap/vertex_job.go +++ b/snow/engine/avalanche/bootstrap/vertex_job.go @@ -20,12 +20,15 @@ import ( "github.com/ava-labs/avalanchego/utils/set" ) -var errMissingVtxDependenciesOnAccept = errors.New("attempting to execute blocked vertex") +var ( + errMissingVtxDependenciesOnAccept = errors.New("attempting to execute blocked vertex") + errTxNotAcceptedInVtxOnAccept = errors.New("attempting to execute vertex with non-accepted transaction") +) type vtxParser struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - manager vertex.Manager + log logging.Logger + numAccepted prometheus.Counter + manager vertex.Manager } func (p *vtxParser) Parse(ctx context.Context, vtxBytes []byte) (queue.Job, error) { @@ -36,15 +39,14 @@ func (p *vtxParser) Parse(ctx context.Context, vtxBytes []byte) (queue.Job, erro return &vertexJob{ log: p.log, numAccepted: p.numAccepted, - numDropped: p.numDropped, vtx: vtx, }, nil } type vertexJob struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - vtx avalanche.Vertex + log logging.Logger + numAccepted prometheus.Counter + vtx avalanche.Vertex } func (v *vertexJob) ID() ids.ID { @@ -85,7 +87,6 @@ func (v *vertexJob) Execute(ctx context.Context) error { return err } if hasMissingDependencies { - v.numDropped.Inc() return errMissingVtxDependenciesOnAccept } txs, err := v.vtx.Txs(ctx) @@ -94,15 +95,12 @@ func (v *vertexJob) Execute(ctx context.Context) error { } for _, tx := range txs { if tx.Status() != choices.Accepted { - v.numDropped.Inc() - v.log.Warn("attempting to execute vertex with non-accepted transactions") - return nil + return errTxNotAcceptedInVtxOnAccept } } status := v.vtx.Status() switch status { case choices.Unknown, choices.Rejected: - v.numDropped.Inc() return fmt.Errorf("attempting to execute vertex with status %s", status) case choices.Processing: v.numAccepted.Inc() diff --git a/snow/engine/avalanche/vertex/mock_vm.go b/snow/engine/avalanche/vertex/mock_vm.go index 7ad293f6313f..18903544bd6f 100644 --- a/snow/engine/avalanche/vertex/mock_vm.go +++ b/snow/engine/avalanche/vertex/mock_vm.go @@ -364,20 +364,6 @@ func (mr *MockLinearizableVMMockRecorder) Shutdown(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockLinearizableVM)(nil).Shutdown), arg0) } -// VerifyHeightIndex mocks base method. -func (m *MockLinearizableVM) VerifyHeightIndex(arg0 context.Context) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyHeightIndex", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyHeightIndex indicates an expected call of VerifyHeightIndex. -func (mr *MockLinearizableVMMockRecorder) VerifyHeightIndex(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyHeightIndex", reflect.TypeOf((*MockLinearizableVM)(nil).VerifyHeightIndex), arg0) -} - // Version mocks base method. func (m *MockLinearizableVM) Version(arg0 context.Context) (string, error) { m.ctrl.T.Helper() diff --git a/snow/engine/snowman/block/mock_chain_vm.go b/snow/engine/snowman/block/mock_chain_vm.go index ad99e3f716d0..c927282c1f93 100644 --- a/snow/engine/snowman/block/mock_chain_vm.go +++ b/snow/engine/snowman/block/mock_chain_vm.go @@ -334,20 +334,6 @@ func (mr *MockChainVMMockRecorder) Shutdown(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockChainVM)(nil).Shutdown), arg0) } -// VerifyHeightIndex mocks base method. -func (m *MockChainVM) VerifyHeightIndex(arg0 context.Context) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "VerifyHeightIndex", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// VerifyHeightIndex indicates an expected call of VerifyHeightIndex. -func (mr *MockChainVMMockRecorder) VerifyHeightIndex(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyHeightIndex", reflect.TypeOf((*MockChainVM)(nil).VerifyHeightIndex), arg0) -} - // Version mocks base method. func (m *MockChainVM) Version(arg0 context.Context) (string, error) { m.ctrl.T.Helper() diff --git a/snow/engine/snowman/block/test_vm.go b/snow/engine/snowman/block/test_vm.go index 376dd27066f7..7c04c90ec238 100644 --- a/snow/engine/snowman/block/test_vm.go +++ b/snow/engine/snowman/block/test_vm.go @@ -19,7 +19,6 @@ var ( errParseBlock = errors.New("unexpectedly called ParseBlock") errGetBlock = errors.New("unexpectedly called GetBlock") errLastAccepted = errors.New("unexpectedly called LastAccepted") - errVerifyHeightIndex = errors.New("unexpectedly called VerifyHeightIndex") errGetBlockIDAtHeight = errors.New("unexpectedly called GetBlockIDAtHeight") _ ChainVM = (*TestVM)(nil) @@ -34,7 +33,6 @@ type TestVM struct { CantGetBlock, CantSetPreference, CantLastAccepted, - CantVerifyHeightIndex, CantGetBlockIDAtHeight bool BuildBlockF func(context.Context) (snowman.Block, error) @@ -42,7 +40,6 @@ type TestVM struct { GetBlockF func(context.Context, ids.ID) (snowman.Block, error) SetPreferenceF func(context.Context, ids.ID) error LastAcceptedF func(context.Context) (ids.ID, error) - VerifyHeightIndexF func(context.Context) error GetBlockIDAtHeightF func(ctx context.Context, height uint64) (ids.ID, error) } @@ -106,16 +103,6 @@ func (vm *TestVM) LastAccepted(ctx context.Context) (ids.ID, error) { return ids.ID{}, errLastAccepted } -func (vm *TestVM) VerifyHeightIndex(ctx context.Context) error { - if vm.VerifyHeightIndexF != nil { - return vm.VerifyHeightIndexF(ctx) - } - if vm.CantVerifyHeightIndex && vm.T != nil { - require.FailNow(vm.T, errVerifyHeightIndex.Error()) - } - return errVerifyHeightIndex -} - func (vm *TestVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) { if vm.GetBlockIDAtHeightF != nil { return vm.GetBlockIDAtHeightF(ctx, height) diff --git a/snow/engine/snowman/block/vm.go b/snow/engine/snowman/block/vm.go index 4153632a7616..d28dc7ef7a6d 100644 --- a/snow/engine/snowman/block/vm.go +++ b/snow/engine/snowman/block/vm.go @@ -5,19 +5,12 @@ package block import ( "context" - "errors" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/common" ) -// ErrIndexIncomplete is used to indicate that the VM is currently repairing its -// index. -// -// TODO: Remove after v1.11.x activates. -var ErrIndexIncomplete = errors.New("query failed because height index is incomplete") - // ChainVM defines the required functionality of a Snowman VM. // // A Snowman VM is responsible for defining the representation of state, @@ -56,15 +49,6 @@ type ChainVM interface { // returned. LastAccepted(context.Context) (ids.ID, error) - // VerifyHeightIndex should return: - // - nil if the height index is available. - // - ErrIndexIncomplete if the height index is not currently available. - // - Any other non-standard error that may have occurred when verifying the - // index. - // - // TODO: Remove after v1.11.x activates. - VerifyHeightIndex(context.Context) error - // GetBlockIDAtHeight returns: // - The ID of the block that was accepted with [height]. // - database.ErrNotFound if the [height] index is unknown. diff --git a/snow/engine/snowman/bootstrap/block_job.go b/snow/engine/snowman/bootstrap/block_job.go index a9496316f1fb..403327006f85 100644 --- a/snow/engine/snowman/bootstrap/block_job.go +++ b/snow/engine/snowman/bootstrap/block_job.go @@ -23,9 +23,9 @@ import ( var errMissingDependenciesOnAccept = errors.New("attempting to accept a block with missing dependencies") type parser struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - vm block.ChainVM + log logging.Logger + numAccepted prometheus.Counter + vm block.ChainVM } func (p *parser) Parse(ctx context.Context, blkBytes []byte) (queue.Job, error) { @@ -36,17 +36,16 @@ func (p *parser) Parse(ctx context.Context, blkBytes []byte) (queue.Job, error) return &blockJob{ log: p.log, numAccepted: p.numAccepted, - numDropped: p.numDropped, blk: blk, vm: p.vm, }, nil } type blockJob struct { - log logging.Logger - numAccepted, numDropped prometheus.Counter - blk snowman.Block - vm block.Getter + log logging.Logger + numAccepted prometheus.Counter + blk snowman.Block + vm block.Getter } func (b *blockJob) ID() ids.ID { @@ -76,13 +75,11 @@ func (b *blockJob) Execute(ctx context.Context) error { return err } if hasMissingDeps { - b.numDropped.Inc() return errMissingDependenciesOnAccept } status := b.blk.Status() switch status { case choices.Unknown, choices.Rejected: - b.numDropped.Inc() return fmt.Errorf("attempting to execute block with status %s", status) case choices.Processing: blkID := b.blk.ID() diff --git a/snow/engine/snowman/bootstrap/bootstrapper.go b/snow/engine/snowman/bootstrap/bootstrapper.go index 29754a24d734..ebbbd6f13ff7 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper.go +++ b/snow/engine/snowman/bootstrap/bootstrapper.go @@ -170,7 +170,6 @@ func (b *Bootstrapper) Start(ctx context.Context, startReqID uint32) error { b.parser = &parser{ log: b.Ctx.Log, numAccepted: b.numAccepted, - numDropped: b.numDropped, vm: b.VM, } if err := b.Blocked.SetParser(ctx, b.parser); err != nil { @@ -308,16 +307,6 @@ func (b *Bootstrapper) sendBootstrappingMessagesOrFinish(ctx context.Context) er return b.startBootstrapping(ctx) } - if !b.restarted { - b.Ctx.Log.Info("bootstrapping started syncing", - zap.Int("numAccepted", numAccepted), - ) - } else { - b.Ctx.Log.Debug("bootstrapping started syncing", - zap.Int("numAccepted", numAccepted), - ) - } - return b.startSyncing(ctx, accepted) } @@ -393,9 +382,14 @@ func (b *Bootstrapper) startSyncing(ctx context.Context, acceptedContainerIDs [] // Append the list of accepted container IDs to pendingContainerIDs to ensure // we iterate over every container that must be traversed. pendingContainerIDs = append(pendingContainerIDs, acceptedContainerIDs...) - b.Ctx.Log.Debug("starting bootstrapping", - zap.Int("numPendingBlocks", len(pendingContainerIDs)), + + log := b.Ctx.Log.Info + if b.restarted { + log = b.Ctx.Log.Debug + } + log("starting to fetch blocks", zap.Int("numAcceptedBlocks", len(acceptedContainerIDs)), + zap.Int("numMissingBlocks", len(pendingContainerIDs)), ) toProcess := make([]snowman.Block, 0, len(pendingContainerIDs)) @@ -616,7 +610,6 @@ func (b *Bootstrapper) process(ctx context.Context, blk snowman.Block, processin pushed, err := b.Blocked.Push(ctx, &blockJob{ log: b.Ctx.Log, numAccepted: b.numAccepted, - numDropped: b.numDropped, blk: blk, vm: b.VM, }) diff --git a/snow/engine/snowman/bootstrap/bootstrapper_test.go b/snow/engine/snowman/bootstrap/bootstrapper_test.go index d5cb9cc763fc..846b082ce8f0 100644 --- a/snow/engine/snowman/bootstrap/bootstrapper_test.go +++ b/snow/engine/snowman/bootstrap/bootstrapper_test.go @@ -1386,7 +1386,6 @@ func TestBootstrapNoParseOnNew(t *testing.T) { pushed, err := blocker.Push(context.Background(), &blockJob{ log: logging.NoLog{}, numAccepted: prometheus.NewCounter(prometheus.CounterOpts{}), - numDropped: prometheus.NewCounter(prometheus.CounterOpts{}), blk: blk1, vm: vm, }) diff --git a/snow/engine/snowman/bootstrap/metrics.go b/snow/engine/snowman/bootstrap/metrics.go index f6ad90d16419..aea46d2a93e8 100644 --- a/snow/engine/snowman/bootstrap/metrics.go +++ b/snow/engine/snowman/bootstrap/metrics.go @@ -10,8 +10,8 @@ import ( ) type metrics struct { - numFetched, numDropped, numAccepted prometheus.Counter - fetchETA prometheus.Gauge + numFetched, numAccepted prometheus.Counter + fetchETA prometheus.Gauge } func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, error) { @@ -21,11 +21,6 @@ func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, e Name: "fetched", Help: "Number of blocks fetched during bootstrapping", }), - numDropped: prometheus.NewCounter(prometheus.CounterOpts{ - Namespace: namespace, - Name: "dropped", - Help: "Number of blocks dropped during bootstrapping", - }), numAccepted: prometheus.NewCounter(prometheus.CounterOpts{ Namespace: namespace, Name: "accepted", @@ -40,7 +35,6 @@ func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, e err := utils.Err( registerer.Register(m.numFetched), - registerer.Register(m.numDropped), registerer.Register(m.numAccepted), registerer.Register(m.fetchETA), ) diff --git a/tests/antithesis/Dockerfile.config b/tests/antithesis/Dockerfile.config new file mode 100644 index 000000000000..f00caae693be --- /dev/null +++ b/tests/antithesis/Dockerfile.config @@ -0,0 +1,3 @@ +FROM scratch + +COPY ./tests/antithesis/docker-compose.yml /docker-compose.yml diff --git a/tests/antithesis/Dockerfile.node b/tests/antithesis/Dockerfile.node new file mode 100644 index 000000000000..3b32041dd3cb --- /dev/null +++ b/tests/antithesis/Dockerfile.node @@ -0,0 +1,64 @@ +# Antithesis: Getting the Antithesis golang instrumentation library +FROM docker.io/antithesishq/go-instrumentor AS instrumentor + +# Changes to the minimum golang version must also be replicated in +# scripts/build_avalanche.sh +# tests/antithesis/Dockerfile.node (here) +# Dockerfile +# README.md +# go.mod +# ============= Compilation Stage ================ +FROM golang:1.21.8-bullseye AS builder + +WORKDIR /build +# Copy and download avalanche dependencies using go mod +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy the code into the container +COPY . . + +# Keep the commit hash to easily verify the exact version that is running +RUN git rev-parse HEAD > ./commit_hash.txt + +# Copy the instrumentor and supporting files to their correct locations +COPY --from=instrumentor /opt/antithesis /opt/antithesis +COPY --from=instrumentor /opt/antithesis/lib /lib + +# Create the destination output directory for the instrumented code +RUN mkdir -p /avalanchego_instrumented + +# Park the .git file in a safe location +RUN mkdir -p /opt/tmp/ +RUN cp -r .git /opt/tmp/ + +# Instrument avalanchego +RUN /opt/antithesis/bin/goinstrumentor \ + -stderrthreshold=INFO \ + -antithesis /opt/antithesis/instrumentation \ + . \ + /avalanchego_instrumented + +WORKDIR /avalanchego_instrumented/customer +RUN go mod download +RUN ln -s /opt/tmp/.git .git + +# Build avalanchego with race detection (-r) enabled. +RUN ./scripts/build.sh -r + +# ============= Cleanup Stage ================ +FROM debian:11-slim AS execution + +# Copy identifying information into the container +COPY --from=builder /build/commit_hash.txt ./commit_hash.txt + +# Copy the antithesis dependencies into the container +RUN mkdir -p /symbols +COPY --from=builder /avalanchego_instrumented/symbols /symbols +COPY --from=builder /opt/antithesis/lib/libvoidstar.so /usr/lib/libvoidstar.so + +# Copy the executable into the container +COPY --from=builder /avalanchego_instrumented/customer/build/avalanchego ./avalanchego + +CMD [ "./avalanchego" ] diff --git a/tests/antithesis/Dockerfile.workload b/tests/antithesis/Dockerfile.workload new file mode 100644 index 000000000000..755c931c1a07 --- /dev/null +++ b/tests/antithesis/Dockerfile.workload @@ -0,0 +1,29 @@ +# Changes to the minimum golang version must also be replicated in +# scripts/build_avalanche.sh +# tests/antithesis/Dockerfile.node +# tests/antithesis/Dockerfile.workload (here) +# Dockerfile +# README.md +# go.mod +# ============= Compilation Stage ================ +FROM golang:1.21.8-bullseye AS builder + +WORKDIR /build +# Copy and download avalanche dependencies using go mod +COPY go.mod . +COPY go.sum . +RUN go mod download + +# Copy the code into the container +COPY . . + +# Build the workload +RUN ./scripts/build_antithesis_workload.sh + +# ============= Cleanup Stage ================ +FROM debian:11-slim AS execution + +# Copy the executable into the container +COPY --from=builder /build/build/workload ./workload + +CMD [ "./workload" ] diff --git a/tests/antithesis/docker-compose.yml b/tests/antithesis/docker-compose.yml index 5a23f8b71d2f..6a13eca55761 100644 --- a/tests/antithesis/docker-compose.yml +++ b/tests/antithesis/docker-compose.yml @@ -8,7 +8,6 @@ services: # workload waits until cluster is up, issues 5 transactions, and the intializes the wallet. THEN we start fuzzing workload: container_name: workload - entrypoint: [ "./antithesis-workload" ] image: workload:latest environment: { AVAWL_URIS: "http://10.0.20.3:9650 http://10.0.20.4:9650 http://10.0.20.5:9650 http://10.0.20.6:9650 http://10.0.20.7:9650" @@ -117,4 +116,4 @@ services: AVAGO_STAKING_SIGNER_KEY_FILE_CONTENT: "QXZhbGFuY2hlTG9jYWxOZXR3b3JrVmFsaWRhdG9yMDU=" } networks: - avalanche-testnet: { ipv4_address: 10.0.20.7 } \ No newline at end of file + avalanche-testnet: { ipv4_address: 10.0.20.7 } diff --git a/tests/antithesis/main.go b/tests/antithesis/main.go index 24f766133309..5d7d614f75c5 100644 --- a/tests/antithesis/main.go +++ b/tests/antithesis/main.go @@ -27,12 +27,12 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/status" "github.com/ava-labs/avalanchego/vms/propertyfx" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - "github.com/ava-labs/avalanchego/wallet/chain/x" "github.com/ava-labs/avalanchego/wallet/subnet/primary" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" xtxs "github.com/ava-labs/avalanchego/vms/avm/txs" ptxs "github.com/ava-labs/avalanchego/vms/platformvm/txs" + xbuilder "github.com/ava-labs/avalanchego/wallet/chain/x/builder" ) const NumKeys = 5 @@ -69,8 +69,10 @@ func main() { workloads[0] = genesisWorkload var ( - genesisXWallet = wallet.X() - avaxAssetID = genesisXWallet.AVAXAssetID() + genesisXWallet = wallet.X() + genesisXBuilder = genesisXWallet.Builder() + genesisXContext = genesisXBuilder.Context() + avaxAssetID = genesisXContext.AVAXAssetID ) for i := 1; i < NumKeys; i++ { key, err := secp256k1.NewPrivateKey() @@ -192,7 +194,8 @@ func (w *workload) run(ctx context.Context) { log.Fatalf("failed to fetch P-chain balances: %s", err) } var ( - avaxAssetID = xWallet.AVAXAssetID() + xContext = xBuilder.Context() + avaxAssetID = xContext.AVAXAssetID xAVAX = xBalances[avaxAssetID] pAVAX = pBalances[avaxAssetID] ) @@ -245,9 +248,10 @@ func (w *workload) issueXChainBaseTx(ctx context.Context) { } var ( - avaxAssetID = xWallet.AVAXAssetID() + xContext = xBuilder.Context() + avaxAssetID = xContext.AVAXAssetID avaxBalance = balances[avaxAssetID] - baseTxFee = xWallet.BaseTxFee() + baseTxFee = xContext.BaseTxFee neededBalance = baseTxFee + units.Schmeckle ) if avaxBalance < neededBalance { @@ -294,9 +298,10 @@ func (w *workload) issueXChainCreateAssetTx(ctx context.Context) { } var ( - avaxAssetID = xWallet.AVAXAssetID() + xContext = xBuilder.Context() + avaxAssetID = xContext.AVAXAssetID avaxBalance = balances[avaxAssetID] - neededBalance = xWallet.CreateAssetTxFee() + neededBalance = xContext.CreateAssetTxFee ) if avaxBalance < neededBalance { log.Printf("skipping X-chain tx issuance due to insufficient balance: %d < %d", avaxBalance, neededBalance) @@ -342,10 +347,11 @@ func (w *workload) issueXChainOperationTx(ctx context.Context) { } var ( - avaxAssetID = xWallet.AVAXAssetID() + xContext = xBuilder.Context() + avaxAssetID = xContext.AVAXAssetID avaxBalance = balances[avaxAssetID] - createAssetTxFee = xWallet.CreateAssetTxFee() - baseTxFee = xWallet.BaseTxFee() + createAssetTxFee = xContext.CreateAssetTxFee + baseTxFee = xContext.BaseTxFee neededBalance = createAssetTxFee + baseTxFee ) if avaxBalance < neededBalance { @@ -405,10 +411,13 @@ func (w *workload) issueXToPTransfer(ctx context.Context) { } var ( - avaxAssetID = xWallet.AVAXAssetID() + xContext = xBuilder.Context() + avaxAssetID = xContext.AVAXAssetID avaxBalance = balances[avaxAssetID] - xBaseTxFee = xWallet.BaseTxFee() - pBaseTxFee = pWallet.BaseTxFee() + xBaseTxFee = xContext.BaseTxFee + pBuilder = pWallet.Builder() + pContext = pBuilder.Context() + pBaseTxFee = pContext.BaseTxFee txFees = xBaseTxFee + pBaseTxFee neededBalance = txFees + units.Avax ) @@ -439,7 +448,7 @@ func (w *workload) issueXToPTransfer(ctx context.Context) { log.Printf("created X-chain export transaction %s in %s", exportTx.ID(), time.Since(exportStartTime)) var ( - xChainID = xWallet.BlockchainID() + xChainID = xContext.BlockchainID importStartTime = time.Now() ) importTx, err := pWallet.IssueImportTx( @@ -462,6 +471,7 @@ func (w *workload) issuePToXTransfer(ctx context.Context) { var ( xWallet = w.wallet.X() pWallet = w.wallet.P() + xBuilder = xWallet.Builder() pBuilder = pWallet.Builder() ) balances, err := pBuilder.GetBalance() @@ -471,10 +481,12 @@ func (w *workload) issuePToXTransfer(ctx context.Context) { } var ( - avaxAssetID = pWallet.AVAXAssetID() + xContext = xBuilder.Context() + pContext = pBuilder.Context() + avaxAssetID = pContext.AVAXAssetID avaxBalance = balances[avaxAssetID] - pBaseTxFee = pWallet.BaseTxFee() - xBaseTxFee = xWallet.BaseTxFee() + pBaseTxFee = pContext.BaseTxFee + xBaseTxFee = xContext.BaseTxFee txFees = pBaseTxFee + xBaseTxFee neededBalance = txFees + units.Schmeckle ) @@ -484,7 +496,7 @@ func (w *workload) issuePToXTransfer(ctx context.Context) { } var ( - xChainID = xWallet.BlockchainID() + xChainID = xContext.BlockchainID owner = w.makeOwner() exportStartTime = time.Now() ) @@ -570,7 +582,7 @@ func (w *workload) confirmPChainTx(ctx context.Context, tx *ptxs.Tx) { func (w *workload) verifyXChainTxConsumedUTXOs(ctx context.Context, tx *xtxs.Tx) { txID := tx.ID() - chainID := w.wallet.X().BlockchainID() + chainID := w.wallet.X().Builder().Context().BlockchainID for _, uri := range w.uris { client := avm.NewClient(uri, "X") @@ -579,7 +591,7 @@ func (w *workload) verifyXChainTxConsumedUTXOs(ctx context.Context, tx *xtxs.Tx) ctx, utxos, client, - x.Parser.Codec(), + xbuilder.Parser.Codec(), chainID, chainID, w.addrs.List(), diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 50ab608a3c4f..fa28ecd88506 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -77,12 +77,12 @@ $ ./scripts/build_tmpnetctl.sh # Start a new network $ ./build/tmpnetctl start-network --avalanchego-path=/path/to/avalanchego ... -Started network 1000 @ /home/me/.tmpnet/networks/1000 +Started network /home/me/.tmpnet/networks/20240306-152305.924531 (UUID: abaab590-b375-44f6-9ca5-f8a6dc061725) Configure tmpnetctl and the test suite to target this network by default with one of the following statements: - - source /home/me/.tmpnet/networks/1000/network.env - - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/1000 + - source /home/me/.tmpnet/networks/20240306-152305.924531/network.env + - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/20240306-152305.924531 - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/latest # Start a new test run using the existing network diff --git a/tests/e2e/banff/suites.go b/tests/e2e/banff/suites.go index 7ac486b373fe..b6da324c98ea 100644 --- a/tests/e2e/banff/suites.go +++ b/tests/e2e/banff/suites.go @@ -30,9 +30,11 @@ var _ = ginkgo.Describe("[Banff]", func() { // Get the P-chain and the X-chain wallets pWallet := wallet.P() xWallet := wallet.X() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() // Pull out useful constants to use when issuing transactions. - xChainID := xWallet.BlockchainID() + xChainID := xContext.BlockchainID owner := &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{ diff --git a/tests/e2e/c/dynamic_fees.go b/tests/e2e/c/dynamic_fees.go index d218f2df4fa5..9af074894afc 100644 --- a/tests/e2e/c/dynamic_fees.go +++ b/tests/e2e/c/dynamic_fees.go @@ -37,7 +37,10 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() { ginkgo.It("should ensure that the gas price is affected by load", func() { ginkgo.By("creating a new private network to ensure isolation from other tests") - privateNetwork := e2e.Env.NewPrivateNetwork() + privateNetwork := &tmpnet.Network{ + Owner: "avalanchego-e2e-dynamic-fees", + } + e2e.Env.StartPrivateNetwork(privateNetwork) ginkgo.By("allocating a pre-funded key") key := privateNetwork.PreFundedKeys[0] diff --git a/tests/e2e/c/interchain_workflow.go b/tests/e2e/c/interchain_workflow.go index cf8437b751b8..f5afc4abe059 100644 --- a/tests/e2e/c/interchain_workflow.go +++ b/tests/e2e/c/interchain_workflow.go @@ -84,7 +84,9 @@ var _ = e2e.DescribeCChain("[Interchain Workflow]", func() { pWallet := baseWallet.P() ginkgo.By("defining common configuration") - avaxAssetID := xWallet.AVAXAssetID() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() + avaxAssetID := xContext.AVAXAssetID // Use the same owner for import funds to X-Chain and P-Chain recipientOwner := secp256k1fx.OutputOwners{ Threshold: 1, @@ -107,7 +109,7 @@ var _ = e2e.DescribeCChain("[Interchain Workflow]", func() { ginkgo.By("exporting AVAX from the C-Chain to the X-Chain", func() { _, err := cWallet.IssueExportTx( - xWallet.BlockchainID(), + xContext.BlockchainID, exportOutputs, e2e.WithDefaultContext(), e2e.WithSuggestedGasPrice(ethClient), diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 3f526d84a94e..7642c3ce3e96 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -35,7 +35,12 @@ func init() { var _ = ginkgo.SynchronizedBeforeSuite(func() []byte { // Run only once in the first ginkgo process - return e2e.NewTestEnvironment(flagVars, &tmpnet.Network{}).Marshal() + return e2e.NewTestEnvironment( + flagVars, + &tmpnet.Network{ + Owner: "avalanchego-e2e", + }, + ).Marshal() }, func(envBytes []byte) { // Run in every ginkgo process diff --git a/tests/e2e/p/interchain_workflow.go b/tests/e2e/p/interchain_workflow.go index a9c70beacbf0..d27d080d9c00 100644 --- a/tests/e2e/p/interchain_workflow.go +++ b/tests/e2e/p/interchain_workflow.go @@ -56,9 +56,14 @@ var _ = e2e.DescribePChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL cWallet := baseWallet.C() pWallet := baseWallet.P() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + ginkgo.By("defining common configuration") recipientEthAddress := evm.GetEthAddress(recipientKey) - avaxAssetID := xWallet.AVAXAssetID() + avaxAssetID := xContext.AVAXAssetID // Use the same owner for sending to X-Chain and importing funds to P-Chain recipientOwner := secp256k1fx.OutputOwners{ Threshold: 1, @@ -114,7 +119,7 @@ var _ = e2e.DescribePChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL Subnet: constants.PrimaryNetworkID, }, nodePOP, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{rewardKey.Address()}, @@ -143,7 +148,7 @@ var _ = e2e.DescribePChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL }, Subnet: constants.PrimaryNetworkID, }, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{rewardKey.Address()}, @@ -155,7 +160,7 @@ var _ = e2e.DescribePChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL ginkgo.By("exporting AVAX from the P-Chain to the X-Chain", func() { _, err := pWallet.IssueExportTx( - xWallet.BlockchainID(), + xContext.BlockchainID, exportOutputs, e2e.WithDefaultContext(), ) diff --git a/tests/e2e/p/permissionless_subnets.go b/tests/e2e/p/permissionless_subnets.go index eb0a6e129ae8..dc92bdd60d5c 100644 --- a/tests/e2e/p/permissionless_subnets.go +++ b/tests/e2e/p/permissionless_subnets.go @@ -36,7 +36,9 @@ var _ = e2e.DescribePChain("[Permissionless Subnets]", func() { pWallet := baseWallet.P() xWallet := baseWallet.X() - xChainID := xWallet.BlockchainID() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() + xChainID := xContext.BlockchainID var validatorID ids.NodeID ginkgo.By("retrieving the node ID of a primary network validator", func() { diff --git a/tests/e2e/p/staking_rewards.go b/tests/e2e/p/staking_rewards.go index 436d89675bc5..e988cf43c2c4 100644 --- a/tests/e2e/p/staking_rewards.go +++ b/tests/e2e/p/staking_rewards.go @@ -104,6 +104,9 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { baseWallet := e2e.NewWallet(keychain, nodeURI) pWallet := baseWallet.P() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + const ( delegationPercent = 0.10 // 10% delegationShare = reward.PercentDenominator * delegationPercent @@ -130,7 +133,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { Subnet: constants.PrimaryNetworkID, }, alphaPOP, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{alphaValidationRewardKey.Address()}, @@ -159,7 +162,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { Subnet: constants.PrimaryNetworkID, }, betaPOP, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{betaValidationRewardKey.Address()}, @@ -191,7 +194,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { }, Subnet: constants.PrimaryNetworkID, }, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{gammaDelegationRewardKey.Address()}, @@ -214,7 +217,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { }, Subnet: constants.PrimaryNetworkID, }, - pWallet.AVAXAssetID(), + pContext.AVAXAssetID, &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{deltaDelegationRewardKey.Address()}, @@ -276,7 +279,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() { pWallet := baseWallet.P() balances, err := pWallet.Builder().GetBalance() require.NoError(err) - rewardBalances[rewardKey.Address()] = balances[pWallet.AVAXAssetID()] + rewardBalances[rewardKey.Address()] = balances[pContext.AVAXAssetID] } require.Len(rewardBalances, len(rewardKeys)) diff --git a/tests/e2e/p/validator_sets.go b/tests/e2e/p/validator_sets.go index 36072e327a21..a3f3e1e9f075 100644 --- a/tests/e2e/p/validator_sets.go +++ b/tests/e2e/p/validator_sets.go @@ -36,11 +36,14 @@ var _ = e2e.DescribePChain("[Validator Sets]", func() { baseWallet := e2e.NewWallet(keychain, nodeURI) pWallet := baseWallet.P() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + const delegatorCount = 15 ginkgo.By(fmt.Sprintf("adding %d delegators", delegatorCount), func() { rewardKey, err := secp256k1.NewPrivateKey() require.NoError(err) - avaxAssetID := pWallet.AVAXAssetID() + avaxAssetID := pContext.AVAXAssetID startTime := time.Now().Add(tmpnet.DefaultValidatorStartTimeDiff) endTime := startTime.Add(time.Second * 360) // This is the default flag value for MinDelegatorStake. diff --git a/tests/e2e/p/workflow.go b/tests/e2e/p/workflow.go index 1819df448568..3708c6b82c0a 100644 --- a/tests/e2e/p/workflow.go +++ b/tests/e2e/p/workflow.go @@ -41,8 +41,12 @@ var _ = e2e.DescribePChain("[Workflow]", func() { baseWallet := e2e.NewWallet(keychain, nodeURI) pWallet := baseWallet.P() - avaxAssetID := baseWallet.P().AVAXAssetID() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + avaxAssetID := pContext.AVAXAssetID xWallet := baseWallet.X() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() pChainClient := platformvm.NewClient(nodeURI.URI) tests.Outf("{{blue}} fetching minimal stake amounts {{/}}\n") @@ -141,7 +145,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() { ginkgo.By("export avax from P to X chain", func() { _, err := pWallet.IssueExportTx( - xWallet.BlockchainID(), + xContext.BlockchainID, []*avax.TransferableOutput{ { Asset: avax.Asset{ diff --git a/tests/e2e/x/interchain_workflow.go b/tests/e2e/x/interchain_workflow.go index ce13cf8ab7ad..838c6d11773d 100644 --- a/tests/e2e/x/interchain_workflow.go +++ b/tests/e2e/x/interchain_workflow.go @@ -42,7 +42,9 @@ var _ = e2e.DescribeXChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL ginkgo.By("defining common configuration") recipientEthAddress := evm.GetEthAddress(recipientKey) - avaxAssetID := xWallet.AVAXAssetID() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() + avaxAssetID := xContext.AVAXAssetID // Use the same owner for sending to X-Chain and importing funds to P-Chain recipientOwner := secp256k1fx.OutputOwners{ Threshold: 1, @@ -106,7 +108,7 @@ var _ = e2e.DescribeXChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL ginkgo.By("importing AVAX from the X-Chain to the C-Chain", func() { _, err := cWallet.IssueImportTx( - xWallet.BlockchainID(), + xContext.BlockchainID, recipientEthAddress, e2e.WithDefaultContext(), e2e.WithSuggestedGasPrice(ethClient), @@ -132,7 +134,7 @@ var _ = e2e.DescribeXChain("[Interchain Workflow]", ginkgo.Label(e2e.UsesCChainL ginkgo.By("importing AVAX from the X-Chain to the P-Chain", func() { _, err := pWallet.IssueImportTx( - xWallet.BlockchainID(), + xContext.BlockchainID, &recipientOwner, e2e.WithDefaultContext(), ) diff --git a/tests/e2e/x/transfer/virtuous.go b/tests/e2e/x/transfer/virtuous.go index 4736ba93f17a..886f7bbe834e 100644 --- a/tests/e2e/x/transfer/virtuous.go +++ b/tests/e2e/x/transfer/virtuous.go @@ -84,7 +84,10 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { keychain := secp256k1fx.NewKeychain(testKeys...) baseWallet := e2e.NewWallet(keychain, e2e.Env.GetRandomNodeURI()) - avaxAssetID := baseWallet.X().AVAXAssetID() + xWallet := baseWallet.X() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() + avaxAssetID := xContext.AVAXAssetID wallets := make([]primary.Wallet, len(testKeys)) shortAddrs := make([]ids.ShortID, len(testKeys)) @@ -146,7 +149,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() { amountToTransfer := senderOrigBal / 10 - senderNewBal := senderOrigBal - amountToTransfer - baseWallet.X().BaseTxFee() + senderNewBal := senderOrigBal - amountToTransfer - xContext.BaseTxFee receiverNewBal := receiverOrigBal + amountToTransfer ginkgo.By("X-Chain transfer with wrong amount must fail", func() { diff --git a/tests/fixture/e2e/env.go b/tests/fixture/e2e/env.go index a5fe08d4d899..d445f4de24a6 100644 --- a/tests/fixture/e2e/env.go +++ b/tests/fixture/e2e/env.go @@ -6,8 +6,6 @@ package e2e import ( "encoding/json" "math/rand" - "os" - "path/filepath" "time" "github.com/stretchr/testify/require" @@ -18,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/tests/fixture" "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" - "github.com/ava-labs/avalanchego/utils/perms" "github.com/ava-labs/avalanchego/vms/secp256k1fx" ginkgo "github.com/onsi/ginkgo/v2" @@ -43,6 +40,10 @@ type TestEnvironment struct { URIs []tmpnet.NodeURI // The URI used to access the http server that allocates test data TestDataServerURI string + // The duration to wait before shutting down private networks. A + // non-zero value may be useful to ensure all metrics can be + // scraped before shutdown. + PrivateNetworkShutdownDelay time.Duration require *require.Assertions } @@ -77,7 +78,7 @@ func NewTestEnvironment(flagVars *FlagVars, desiredNetwork *tmpnet.Network) *Tes } } else { network = desiredNetwork - StartNetwork(network, DefaultNetworkDir, flagVars.AvalancheGoExecPath(), flagVars.PluginDir()) + StartNetwork(network, flagVars.AvalancheGoExecPath(), flagVars.PluginDir(), flagVars.NetworkShutdownDelay()) } // A new network will always need subnet creation and an existing @@ -115,10 +116,11 @@ func NewTestEnvironment(flagVars *FlagVars, desiredNetwork *tmpnet.Network) *Tes require.NoError(err) return &TestEnvironment{ - NetworkDir: network.Dir, - URIs: uris, - TestDataServerURI: testDataServerURI, - require: require, + NetworkDir: network.Dir, + URIs: uris, + TestDataServerURI: testDataServerURI, + PrivateNetworkShutdownDelay: flagVars.NetworkShutdownDelay(), + require: require, } } @@ -158,27 +160,18 @@ func (te *TestEnvironment) NewKeychain(count int) *secp256k1fx.Keychain { } // Create a new private network that is not shared with other tests. -func (te *TestEnvironment) NewPrivateNetwork() *tmpnet.Network { - // Load the shared network to retrieve its path and exec path +func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network) { + // Use the same configuration as the shared network sharedNetwork, err := tmpnet.ReadNetwork(te.NetworkDir) te.require.NoError(err) - network := &tmpnet.Network{} - - // The private networks dir is under the shared network dir to ensure it - // will be included in the artifact uploaded in CI. - privateNetworksDir := filepath.Join(sharedNetwork.Dir, PrivateNetworksDirName) - te.require.NoError(os.MkdirAll(privateNetworksDir, perms.ReadWriteExecute)) - pluginDir, err := sharedNetwork.DefaultFlags.GetStringVal(config.PluginDirKey) te.require.NoError(err) StartNetwork( network, - privateNetworksDir, sharedNetwork.DefaultRuntimeConfig.AvalancheGoPath, pluginDir, + te.PrivateNetworkShutdownDelay, ) - - return network } diff --git a/tests/fixture/e2e/flags.go b/tests/fixture/e2e/flags.go index 2a00df97a885..4a0e12add4dd 100644 --- a/tests/fixture/e2e/flags.go +++ b/tests/fixture/e2e/flags.go @@ -7,15 +7,17 @@ import ( "flag" "fmt" "os" + "time" "github.com/ava-labs/avalanchego/tests/fixture/tmpnet" ) type FlagVars struct { - avalancheGoExecPath string - pluginDir string - networkDir string - useExistingNetwork bool + avalancheGoExecPath string + pluginDir string + networkDir string + useExistingNetwork bool + networkShutdownDelay time.Duration } func (v *FlagVars) AvalancheGoExecPath() string { @@ -40,6 +42,10 @@ func (v *FlagVars) UseExistingNetwork() bool { return v.useExistingNetwork } +func (v *FlagVars) NetworkShutdownDelay() time.Duration { + return v.networkShutdownDelay +} + func RegisterFlags() *FlagVars { vars := FlagVars{} flag.StringVar( @@ -66,6 +72,12 @@ func RegisterFlags() *FlagVars { false, "[optional] whether to target the existing network identified by --network-dir.", ) + flag.DurationVar( + &vars.networkShutdownDelay, + "network-shutdown-delay", + 12*time.Second, // Make sure this value takes into account the scrape_interval defined in scripts/run_prometheus.sh + "[optional] the duration to wait before shutting down the test network at the end of the test run. A value greater than the scrape interval is suggested. 0 avoids waiting for shutdown.", + ) return &vars } diff --git a/tests/fixture/e2e/helpers.go b/tests/fixture/e2e/helpers.go index c88f3cacfb10..0adffd60c7f2 100644 --- a/tests/fixture/e2e/helpers.go +++ b/tests/fixture/e2e/helpers.go @@ -216,7 +216,7 @@ func CheckBootstrapIsPossible(network *tmpnet.Network) { } // Start a temporary network with the provided avalanchego binary. -func StartNetwork(network *tmpnet.Network, rootNetworkDir string, avalancheGoExecPath string, pluginDir string) { +func StartNetwork(network *tmpnet.Network, avalancheGoExecPath string, pluginDir string, shutdownDelay time.Duration) { require := require.New(ginkgo.GinkgoT()) require.NoError( @@ -224,7 +224,7 @@ func StartNetwork(network *tmpnet.Network, rootNetworkDir string, avalancheGoExe DefaultContext(), ginkgo.GinkgoWriter, network, - rootNetworkDir, + DefaultNetworkDir, avalancheGoExecPath, pluginDir, tmpnet.DefaultNodeCount, @@ -232,6 +232,11 @@ func StartNetwork(network *tmpnet.Network, rootNetworkDir string, avalancheGoExe ) ginkgo.DeferCleanup(func() { + if shutdownDelay > 0 { + tests.Outf("Waiting %s before network shutdown to ensure final metrics scrape\n", shutdownDelay) + time.Sleep(shutdownDelay) + } + tests.Outf("Shutting down network\n") ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout) defer cancel() diff --git a/tests/fixture/tmpnet/README.md b/tests/fixture/tmpnet/README.md index 909a29c6ee12..9c678c35d96f 100644 --- a/tests/fixture/tmpnet/README.md +++ b/tests/fixture/tmpnet/README.md @@ -52,11 +52,11 @@ $ ./scripts/build_tmpnetctl.sh # Start a new network $ ./build/tmpnetctl start-network --avalanchego-path=/path/to/avalanchego ... -Started network 1000 @ /home/me/.tmpnet/networks/1000 +Started network /home/me/.tmpnet/networks/20240306-152305.924531 (UUID: abaab590-b375-44f6-9ca5-f8a6dc061725) Configure tmpnetctl to target this network by default with one of the following statements: - - source /home/me/.tmpnet/networks/1000/network.env - - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/1000 + - source /home/me/.tmpnet/networks/20240306-152305.924531/network.env + - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/20240306-152305.924531 - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/latest # Stop the network @@ -128,8 +128,12 @@ A temporary network relies on configuration written to disk in the following str ``` HOME └── .tmpnet // Root path for the temporary network fixture + ├── prometheus // Working directory for a metrics-scraping prometheus instance + │ └── file_sd_configs // Directory containing file-based service discovery config for prometheus + ├── promtail // Working directory for a log-collecting promtail instance + │ └── file_sd_configs // Directory containing file-based service discovery config for promtail └── networks // Default parent directory for temporary networks - └── 1000 // The networkID is used to name the network dir and starts at 1000 + └── 20240306-152305.924531 // The timestamp of creation is the name of a network's directory ├── NodeID-37E8UK3x2YFsHE3RdALmfWcppcZ1eTuj9 // The ID of a node is the name of its data dir │ ├── chainData │ │ └── ... @@ -229,3 +233,44 @@ The process details of a node are written by avalanchego to `[base-data-dir]/process.json`. The file contains the PID of the node process, the URI of the node's API, and the address other nodes can use to bootstrap themselves (aka staking address). + +## Metrics + +### Prometheus configuration + +When nodes are started, prometheus configuration for each node is +written to `~/.tmpnet/prometheus/file_sd_configs/` with a filename of +`[network uuid]-[node id].json`. Prometheus can be configured to +scrape the nodes as per the following example: + +```yaml +scrape_configs: + - job_name: "avalanchego" + metrics_path: "/ext/metrics" + file_sd_configs: + - files: + - '/home/me/.tmpnet/prometheus/file_sd_configs/*.yaml' +``` + +### Viewing metrics + +When a network is started with `tmpnet`, a grafana link for the +network's metrics will be emitted. + +The metrics emitted by temporary networks configured with tmpnet will +have the following labels applied: + + - `network_uuid` + - `node_id` + - `is_ephemeral_node` + - `network_owner` + +When a tmpnet network runs as part of github CI, the following +additional labels will be applied: + + - `gh_repo` + - `gh_workflow` + - `gh_run_id` + - `gh_run_number` + - `gh_run_attempt` + - `gh_job_id` diff --git a/tests/fixture/tmpnet/cmd/main.go b/tests/fixture/tmpnet/cmd/main.go index dd59c300bbb3..af717a50a3c6 100644 --- a/tests/fixture/tmpnet/cmd/main.go +++ b/tests/fixture/tmpnet/cmd/main.go @@ -49,6 +49,7 @@ func main() { var ( rootDir string + networkOwner string avalancheGoPath string pluginDir string nodeCount uint8 @@ -63,7 +64,9 @@ func main() { // Root dir will be defaulted on start if not provided - network := &tmpnet.Network{} + network := &tmpnet.Network{ + Owner: networkOwner, + } // Extreme upper bound, should never take this long networkStartTimeout := 2 * time.Minute @@ -106,6 +109,7 @@ func main() { startNetworkCmd.PersistentFlags().StringVar(&avalancheGoPath, "avalanchego-path", os.Getenv(tmpnet.AvalancheGoPathEnvName), "The path to an avalanchego binary") startNetworkCmd.PersistentFlags().StringVar(&pluginDir, "plugin-dir", os.ExpandEnv("$HOME/.avalanchego/plugins"), "[optional] the dir containing VM plugins") startNetworkCmd.PersistentFlags().Uint8Var(&nodeCount, "node-count", tmpnet.DefaultNodeCount, "Number of nodes the network should initially consist of") + startNetworkCmd.PersistentFlags().StringVar(&networkOwner, "network-owner", "", "The string identifying the intended owner of the network") rootCmd.AddCommand(startNetworkCmd) stopNetworkCmd := &cobra.Command{ diff --git a/tests/fixture/tmpnet/network.go b/tests/fixture/tmpnet/network.go index 28626af3c4df..3ca8318efa85 100644 --- a/tests/fixture/tmpnet/network.go +++ b/tests/fixture/tmpnet/network.go @@ -9,17 +9,17 @@ import ( "errors" "fmt" "io" - "io/fs" "os" "path/filepath" "strconv" "strings" "time" + "github.com/google/uuid" + "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/genesis" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/perms" "github.com/ava-labs/avalanchego/utils/set" @@ -40,6 +40,9 @@ const ( // increase the time for a network's nodes to be seen as healthy. networkHealthCheckInterval = 200 * time.Millisecond + // All temporary networks will use this arbitrary network ID by default. + defaultNetworkID = 88888 + // eth address: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC HardHatKeyStr = "56289e99c94b6912bfc12adc093c9b51124f0dc54ac7a766b2bc5ccf558d8027" ) @@ -61,6 +64,18 @@ func init() { // Collects the configuration for running a temporary avalanchego network type Network struct { + // Uniquely identifies the temporary network for metrics + // collection. Distinct from avalanchego's concept of network ID + // since the utility of special network ID values (e.g. to trigger + // specific fork behavior in a given network) precludes requiring + // unique network ID values across all temporary networks. + UUID string + + // A string identifying the entity that started or maintains this + // network. Useful for differentiating between networks when a + // given CI job uses multiple networks. + Owner string + // Path where network configuration and data is stored Dir string @@ -150,6 +165,11 @@ func (n *Network) EnsureDefaultConfig(w io.Writer, avalancheGoPath string, plugi return err } + // A UUID supports centralized metrics collection + if len(n.UUID) == 0 { + n.UUID = uuid.NewString() + } + // Ensure default flags if n.DefaultFlags == nil { n.DefaultFlags = FlagsMap{} @@ -206,45 +226,32 @@ func (n *Network) EnsureDefaultConfig(w io.Writer, avalancheGoPath string, plugi return nil } -// Creates the network on disk, choosing its network id and generating its genesis in the process. +// Creates the network on disk, generating its genesis and configuring its nodes in the process. func (n *Network) Create(rootDir string) error { + // Ensure creation of the root dir if len(rootDir) == 0 { // Use the default root dir var err error - rootDir, err = getDefaultRootDir() + rootDir, err = getDefaultRootNetworkDir() if err != nil { return err } } - - // Ensure creation of the root dir if err := os.MkdirAll(rootDir, perms.ReadWriteExecute); err != nil { return fmt.Errorf("failed to create root network dir: %w", err) } - // Determine the network path and ID - var ( - networkDir string - networkID uint32 - ) - if n.Genesis != nil && n.Genesis.NetworkID > 0 { - // Use the network ID defined in the provided genesis - networkID = n.Genesis.NetworkID + // A time-based name ensures consistent directory ordering + dirName := time.Now().Format("20060102-150405.999999") + if len(n.Owner) > 0 { + // Include the owner to differentiate networks created at similar times + dirName = fmt.Sprintf("%s-%s", dirName, n.Owner) } - if networkID > 0 { - // Use a directory with a random suffix - var err error - networkDir, err = os.MkdirTemp(rootDir, fmt.Sprintf("%d.", n.Genesis.NetworkID)) - if err != nil { - return fmt.Errorf("failed to create network dir: %w", err) - } - } else { - // Find the next available network ID based on the contents of the root dir - var err error - networkID, networkDir, err = findNextNetworkID(rootDir) - if err != nil { - return err - } + + // Ensure creation of the network dir + networkDir := filepath.Join(rootDir, dirName) + if err := os.MkdirAll(networkDir, perms.ReadWriteExecute); err != nil { + return fmt.Errorf("failed to create network dir: %w", err) } canonicalDir, err := toCanonicalDir(networkDir) if err != nil { @@ -252,12 +259,12 @@ func (n *Network) Create(rootDir string) error { } n.Dir = canonicalDir + // Ensure the existence of the plugin directory or nodes won't be able to start. pluginDir, err := n.DefaultFlags.GetStringVal(config.PluginDirKey) if err != nil { return err } if len(pluginDir) > 0 { - // Ensure the existence of the plugin directory or nodes won't be able to start. if err := os.MkdirAll(pluginDir, perms.ReadWriteExecute); err != nil { return fmt.Errorf("failed to create plugin dir: %w", err) } @@ -275,7 +282,7 @@ func (n *Network) Create(rootDir string) error { } keysToFund = append(keysToFund, n.PreFundedKeys...) - genesis, err := NewTestGenesis(networkID, n.Nodes, keysToFund) + genesis, err := NewTestGenesis(defaultNetworkID, n.Nodes, keysToFund) if err != nil { return err } @@ -296,10 +303,13 @@ func (n *Network) Create(rootDir string) error { // Starts all nodes in the network func (n *Network) Start(ctx context.Context, w io.Writer) error { - if _, err := fmt.Fprintf(w, "Starting network %d @ %s\n", n.Genesis.NetworkID, n.Dir); err != nil { + if _, err := fmt.Fprintf(w, "Starting network %s (UUID: %s)\n", n.Dir, n.UUID); err != nil { return err } + // Record the time before nodes are started to ensure visibility of subsequently collected metrics via the emitted link + startTime := time.Now() + // Configure the networking for each node and start for _, node := range n.Nodes { if err := n.StartNode(ctx, w, node); err != nil { @@ -313,7 +323,11 @@ func (n *Network) Start(ctx context.Context, w io.Writer) error { if err := n.WaitForHealthy(ctx, w); err != nil { return err } - if _, err := fmt.Fprintf(w, "\nStarted network %d @ %s\n", n.Genesis.NetworkID, n.Dir); err != nil { + if _, err := fmt.Fprintf(w, "\nStarted network %s (UUID: %s)\n", n.Dir, n.UUID); err != nil { + return err + } + // Provide a link to the main dashboard filtered by the uuid and showing results from now till whenever the link is viewed + if _, err := fmt.Fprintf(w, "\nMetrics: https://grafana-experimental.avax-dev.network/d/kBQpRdWnk/avalanche-main-dashboard?&var-filter=network_uuid%%7C%%3D%%7C%s&var-filter=is_ephemeral_node%%7C%%3D%%7Cfalse&from=%d&to=now\n", n.UUID, startTime.UnixMilli()); err != nil { return err } @@ -427,6 +441,23 @@ func (n *Network) Restart(ctx context.Context, w io.Writer) error { return err } for _, node := range n.Nodes { + // Ensure the node reuses the same API port across restarts to ensure + // consistent labeling of metrics. Otherwise prometheus's automatic + // addition of the `instance` label (host:port) results in + // segmentation of results for a given node every time the port + // changes on restart. This segmentation causes graphs on the grafana + // dashboards to display multiple series per graph for a given node, + // one for each port that the node used. + // + // There is a non-zero chance of the port being allocatted to a + // different process and the node subsequently being unable to start, + // but the alternative is having to update the grafana dashboards + // query-by-query to ensure that node metrics ignore the instance + // label. + if err := node.SaveAPIPort(); err != nil { + return err + } + if err := node.Stop(ctx); err != nil { return fmt.Errorf("failed to stop node %s: %w", node.NodeID, err) } @@ -450,6 +481,12 @@ func (n *Network) Restart(ctx context.Context, w io.Writer) error { func (n *Network) EnsureNodeConfig(node *Node) error { flags := node.Flags + // Ensure nodes can label their metrics with the network uuid + node.NetworkUUID = n.UUID + + // Ensure nodes can label metrics with an indication of the shared/private nature of the network + node.NetworkOwner = n.Owner + // Set the network name if available if n.Genesis != nil && n.Genesis.NetworkID > 0 { // Convert the network id to a string to ensure consistency in JSON round-tripping. @@ -667,42 +704,21 @@ func (n *Network) getBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string, return bootstrapIPs, bootstrapIDs, nil } -// Retrieves the default root dir for storing networks and their -// configuration. -func getDefaultRootDir() (string, error) { +// Retrieves the root dir for tmpnet data. +func getTmpnetPath() (string, error) { homeDir, err := os.UserHomeDir() if err != nil { return "", err } - return filepath.Join(homeDir, ".tmpnet", "networks"), nil + return filepath.Join(homeDir, ".tmpnet"), nil } -// Finds the next available network ID by attempting to create a -// directory numbered from 1000 until creation succeeds. Returns the -// network id and the full path of the created directory. -func findNextNetworkID(rootDir string) (uint32, string, error) { - var ( - networkID uint32 = 1000 - dirPath string - ) - for { - _, reserved := constants.NetworkIDToNetworkName[networkID] - if reserved { - networkID++ - continue - } - - dirPath = filepath.Join(rootDir, strconv.FormatUint(uint64(networkID), 10)) - err := os.Mkdir(dirPath, perms.ReadWriteExecute) - if err == nil { - return networkID, dirPath, nil - } - - if !errors.Is(err, fs.ErrExist) { - return 0, "", fmt.Errorf("failed to create network directory: %w", err) - } - - // Directory already exists, keep iterating - networkID++ +// Retrieves the default root dir for storing networks and their +// configuration. +func getDefaultRootNetworkDir() (string, error) { + tmpnetPath, err := getTmpnetPath() + if err != nil { + return "", err } + return filepath.Join(tmpnetPath, "networks"), nil } diff --git a/tests/fixture/tmpnet/network_config.go b/tests/fixture/tmpnet/network_config.go index 1ae4e96788d7..7aee35cb8a39 100644 --- a/tests/fixture/tmpnet/network_config.go +++ b/tests/fixture/tmpnet/network_config.go @@ -185,6 +185,8 @@ func (n *Network) readConfig() error { // The subset of network fields to store in the network config file. type serializedNetworkConfig struct { + UUID string + Owner string DefaultFlags FlagsMap DefaultRuntimeConfig NodeRuntimeConfig PreFundedKeys []*secp256k1.PrivateKey @@ -192,6 +194,8 @@ type serializedNetworkConfig struct { func (n *Network) writeNetworkConfig() error { config := &serializedNetworkConfig{ + UUID: n.UUID, + Owner: n.Owner, DefaultFlags: n.DefaultFlags, DefaultRuntimeConfig: n.DefaultRuntimeConfig, PreFundedKeys: n.PreFundedKeys, diff --git a/tests/fixture/tmpnet/node.go b/tests/fixture/tmpnet/node.go index 99c0aeb3ebce..2d20ce098587 100644 --- a/tests/fixture/tmpnet/node.go +++ b/tests/fixture/tmpnet/node.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "io" + "net" "net/http" "os" "path/filepath" @@ -53,6 +54,16 @@ type NodeRuntimeConfig struct { // Node supports configuring and running a node participating in a temporary network. type Node struct { + // Uniquely identifies the network the node is part of to enable monitoring. + NetworkUUID string + + // Identify the entity associated with this network. This is + // intended to be used to label metrics to enable filtering + // results for a test run between the primary/shared network used + // by the majority of tests and private networks used by + // individual tests. + NetworkOwner string + // Set by EnsureNodeID which is also called when the node is read. NodeID ids.NodeID @@ -204,13 +215,14 @@ func (n *Node) Stop(ctx context.Context) error { // Sets networking configuration for the node. // Convenience method for setting networking flags. func (n *Node) SetNetworkingConfig(bootstrapIDs []string, bootstrapIPs []string) { - var ( - // Use dynamic port allocation. - httpPort uint16 = 0 - stakingPort uint16 = 0 - ) - n.Flags[config.HTTPPortKey] = httpPort - n.Flags[config.StakingPortKey] = stakingPort + if _, ok := n.Flags[config.HTTPPortKey]; !ok { + // Default to dynamic port allocation + n.Flags[config.HTTPPortKey] = 0 + } + if _, ok := n.Flags[config.StakingPortKey]; !ok { + // Default to dynamic port allocation + n.Flags[config.StakingPortKey] = 0 + } n.Flags[config.BootstrapIDsKey] = strings.Join(bootstrapIDs, ",") n.Flags[config.BootstrapIPsKey] = strings.Join(bootstrapIPs, ",") } @@ -338,3 +350,16 @@ func (n *Node) EnsureNodeID() error { return nil } + +// Saves the currently allocated API port to the node's configuration +// for use across restarts. Reusing the port ensures consistent +// labeling of metrics. +func (n *Node) SaveAPIPort() error { + hostPort := strings.TrimPrefix(n.URI, "http://") + _, port, err := net.SplitHostPort(hostPort) + if err != nil { + return err + } + n.Flags[config.HTTPPortKey] = port + return nil +} diff --git a/tests/fixture/tmpnet/node_config.go b/tests/fixture/tmpnet/node_config.go index 3ebbc01b6c32..1f47c926dfc0 100644 --- a/tests/fixture/tmpnet/node_config.go +++ b/tests/fixture/tmpnet/node_config.go @@ -61,12 +61,16 @@ func (n *Node) readConfig() error { } type serializedNodeConfig struct { + NetworkUUID string + NetworkOwner string IsEphemeral bool RuntimeConfig *NodeRuntimeConfig } func (n *Node) writeConfig() error { config := serializedNodeConfig{ + NetworkUUID: n.NetworkUUID, + NetworkOwner: n.NetworkOwner, IsEphemeral: n.IsEphemeral, RuntimeConfig: n.RuntimeConfig, } diff --git a/tests/fixture/tmpnet/node_process.go b/tests/fixture/tmpnet/node_process.go index c2e2e33139bf..dc5c5bfebf16 100644 --- a/tests/fixture/tmpnet/node_process.go +++ b/tests/fixture/tmpnet/node_process.go @@ -14,12 +14,15 @@ import ( "os" "os/exec" "path/filepath" + "strconv" + "strings" "syscall" "time" "github.com/ava-labs/avalanchego/api/health" "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/node" + "github.com/ava-labs/avalanchego/utils/perms" ) const ( @@ -142,8 +145,12 @@ func (p *NodeProcess) Start(w io.Writer) error { return fmt.Errorf("failed to start local node: %w", err) } - _, err = fmt.Fprintf(w, "Started %s\n", nodeDescription) - return err + if _, err = fmt.Fprintf(w, "Started %s\n", nodeDescription); err != nil { + return err + } + + // Configure collection of metrics and logs + return p.writeMonitoringConfig() } // Signals the node process to stop. @@ -154,7 +161,7 @@ func (p *NodeProcess) InitiateStop() error { } if proc == nil { // Already stopped - return nil + return p.removeMonitoringConfig() } if err := proc.Signal(syscall.SIGTERM); err != nil { return fmt.Errorf("failed to send SIGTERM to pid %d: %w", p.pid, err) @@ -172,7 +179,7 @@ func (p *NodeProcess) WaitForStopped(ctx context.Context) error { return fmt.Errorf("failed to retrieve process: %w", err) } if proc == nil { - return nil + return p.removeMonitoringConfig() } select { @@ -256,3 +263,95 @@ func (p *NodeProcess) getProcess() (*os.Process, error) { } return nil, fmt.Errorf("failed to determine process status: %w", err) } + +// Write monitoring configuration enabling collection of metrics and logs from the node. +func (p *NodeProcess) writeMonitoringConfig() error { + // Ensure labeling that uniquely identifies the node and its network + commonLabels := FlagsMap{ + "network_uuid": p.node.NetworkUUID, + "node_id": p.node.NodeID, + "is_ephemeral_node": strconv.FormatBool(p.node.IsEphemeral), + "network_owner": p.node.NetworkOwner, + // prometheus/promtail ignore empty values so including these + // labels with empty values outside of a github worker (where + // the env vars will not be set) should not be a problem. + "gh_repo": os.Getenv("GH_REPO"), + "gh_workflow": os.Getenv("GH_WORKFLOW"), + "gh_run_id": os.Getenv("GH_RUN_ID"), + "gh_run_number": os.Getenv("GH_RUN_NUMBER"), + "gh_run_attempt": os.Getenv("GH_RUN_ATTEMPT"), + "gh_job_id": os.Getenv("GH_JOB_ID"), + } + + tmpnetDir, err := getTmpnetPath() + if err != nil { + return err + } + + prometheusConfig := []FlagsMap{ + { + "targets": []string{strings.TrimPrefix(p.node.URI, "http://")}, + "labels": commonLabels, + }, + } + if err := p.writeMonitoringConfigFile(tmpnetDir, "prometheus", prometheusConfig); err != nil { + return err + } + + promtailLabels := FlagsMap{ + "__path__": filepath.Join(p.node.getDataDir(), "logs", "*.log"), + } + promtailLabels.SetDefaults(commonLabels) + promtailConfig := []FlagsMap{ + { + "targets": []string{"localhost"}, + "labels": promtailLabels, + }, + } + return p.writeMonitoringConfigFile(tmpnetDir, "promtail", promtailConfig) +} + +// Return the path for this node's prometheus configuration. +func (p *NodeProcess) getMonitoringConfigPath(tmpnetDir string, name string) string { + // Ensure a unique filename to allow config files to be added and removed + // by multiple nodes without conflict. + return filepath.Join(tmpnetDir, name, "file_sd_configs", fmt.Sprintf("%s_%s.json", p.node.NetworkUUID, p.node.NodeID)) +} + +// Ensure the removal of the prometheus configuration file for this node. +func (p *NodeProcess) removeMonitoringConfig() error { + tmpnetDir, err := getTmpnetPath() + if err != nil { + return err + } + + for _, name := range []string{"promtail", "prometheus"} { + configPath := p.getMonitoringConfigPath(tmpnetDir, name) + if err := os.Remove(configPath); err != nil && !errors.Is(err, fs.ErrNotExist) { + return fmt.Errorf("failed to remove %s config: %w", name, err) + } + } + + return nil +} + +// Write the configuration for a type of monitoring (e.g. prometheus, promtail). +func (p *NodeProcess) writeMonitoringConfigFile(tmpnetDir string, name string, config []FlagsMap) error { + configPath := p.getMonitoringConfigPath(tmpnetDir, name) + + dir := filepath.Dir(configPath) + if err := os.MkdirAll(dir, perms.ReadWriteExecute); err != nil { + return fmt.Errorf("failed to create %s service discovery dir: %w", name, err) + } + + bytes, err := DefaultJSONMarshal(config) + if err != nil { + return fmt.Errorf("failed to marshal %s config: %w", name, err) + } + + if err := os.WriteFile(configPath, bytes, perms.ReadWrite); err != nil { + return fmt.Errorf("failed to write %s config: %w", name, err) + } + + return nil +} diff --git a/tests/upgrade/upgrade_test.go b/tests/upgrade/upgrade_test.go index 131d3d53cd2a..3e4509fa2c93 100644 --- a/tests/upgrade/upgrade_test.go +++ b/tests/upgrade/upgrade_test.go @@ -45,8 +45,10 @@ var _ = ginkgo.Describe("[Upgrade]", func() { require := require.New(ginkgo.GinkgoT()) ginkgo.It("can upgrade versions", func() { - network := &tmpnet.Network{} - e2e.StartNetwork(network, e2e.DefaultNetworkDir, avalancheGoExecPath, "" /* pluginDir */) + network := &tmpnet.Network{ + Owner: "avalanchego-upgrade", + } + e2e.StartNetwork(network, avalancheGoExecPath, "" /* pluginDir */, 0 /* shutdownDelay */) ginkgo.By(fmt.Sprintf("restarting all nodes with %q binary", avalancheGoExecPathToUpgradeTo)) for _, node := range network.Nodes { diff --git a/version/compatibility.json b/version/compatibility.json index 07531e693613..ea69228f3cfb 100644 --- a/version/compatibility.json +++ b/version/compatibility.json @@ -1,4 +1,7 @@ { + "35": [ + "v1.11.3" + ], "34": [ "v1.11.2" ], diff --git a/version/constants.go b/version/constants.go index 24fe783f0b03..48bca40c6a98 100644 --- a/version/constants.go +++ b/version/constants.go @@ -18,7 +18,7 @@ const ( // RPCChainVMProtocol should be bumped anytime changes are made which // require the plugin vm to upgrade to latest avalanchego release to be // compatible. - RPCChainVMProtocol uint = 34 + RPCChainVMProtocol uint = 35 ) // These are globals that describe network upgrades and node versions @@ -26,7 +26,7 @@ var ( Current = &Semantic{ Major: 1, Minor: 11, - Patch: 2, + Patch: 3, } CurrentApp = &Application{ Name: Client, @@ -140,6 +140,11 @@ var ( constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC), constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC), } + + EUpgradeTimes = map[uint32]time.Time{ + constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), + constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC), + } ) func init() { @@ -240,6 +245,13 @@ func GetDurangoTime(networkID uint32) time.Time { return DefaultUpgradeTime } +func GetEUpgradeTime(networkID uint32) time.Time { + if upgradeTime, exists := EUpgradeTimes[networkID]; exists { + return upgradeTime + } + return DefaultUpgradeTime +} + func GetCompatibility(networkID uint32) Compatibility { return NewCompatibility( CurrentApp, diff --git a/vms/avm/block/executor/block_test.go b/vms/avm/block/executor/block_test.go index 988f02be315e..8e72f4c21ebe 100644 --- a/vms/avm/block/executor/block_test.go +++ b/vms/avm/block/executor/block_test.go @@ -22,6 +22,7 @@ import ( "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/avm/block" + "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/metrics" "github.com/ava-labs/avalanchego/vms/avm/state" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -45,6 +46,7 @@ func TestBlockVerify(t *testing.T) { b := &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{}, }, } @@ -62,8 +64,10 @@ func TestBlockVerify(t *testing.T) { mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.GenerateTestID()).AnyTimes() return &Block{ - Block: mockBlock, - manager: &manager{}, + Block: mockBlock, + manager: &manager{ + backend: defaultTestBackend(false, nil), + }, } }, expectedErr: ErrUnexpectedMerkleRoot, @@ -82,7 +86,8 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ - clk: clk, + backend: defaultTestBackend(false, nil), + clk: clk, }, } }, @@ -99,6 +104,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{}, clk: &mockable.Clock{}, }, @@ -125,6 +131,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), blkIDToState: map[ids.ID]*blockState{}, @@ -157,6 +164,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), state: mockState, blkIDToState: map[ids.ID]*blockState{}, clk: &mockable.Clock{}, @@ -193,6 +201,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), state: mockState, blkIDToState: map[ids.ID]*blockState{}, clk: &mockable.Clock{}, @@ -232,6 +241,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ parentID: { onAcceptState: mockParentState, @@ -279,6 +289,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), blkIDToState: map[ids.ID]*blockState{ @@ -331,7 +342,7 @@ func TestBlockVerify(t *testing.T) { manager: &manager{ mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{}, + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ parentID: { onAcceptState: mockParentState, @@ -409,7 +420,7 @@ func TestBlockVerify(t *testing.T) { manager: &manager{ mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{}, + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ parentID: { onAcceptState: mockParentState, @@ -467,7 +478,7 @@ func TestBlockVerify(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ - backend: &executor.Backend{}, + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ parentID: { onAcceptState: mockParentState, @@ -519,7 +530,7 @@ func TestBlockVerify(t *testing.T) { manager: &manager{ mempool: mockMempool, metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{}, + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ parentID: { onAcceptState: mockParentState, @@ -591,13 +602,9 @@ func TestBlockAccept(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ - mempool: mempool, - metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{ - Ctx: &snow.Context{ - Log: logging.NoLog{}, - }, - }, + mempool: mempool, + metrics: metrics.NewMockMetrics(ctrl), + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{}, }, } @@ -627,11 +634,7 @@ func TestBlockAccept(t *testing.T) { manager: &manager{ state: mockManagerState, mempool: mempool, - backend: &executor.Backend{ - Ctx: &snow.Context{ - Log: logging.NoLog{}, - }, - }, + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ blockID: { onAcceptState: mockOnAcceptState, @@ -670,12 +673,7 @@ func TestBlockAccept(t *testing.T) { manager: &manager{ state: mockManagerState, mempool: mempool, - backend: &executor.Backend{ - Ctx: &snow.Context{ - SharedMemory: mockSharedMemory, - Log: logging.NoLog{}, - }, - }, + backend: defaultTestBackend(false, mockSharedMemory), blkIDToState: map[ids.ID]*blockState{ blockID: { onAcceptState: mockOnAcceptState, @@ -718,12 +716,7 @@ func TestBlockAccept(t *testing.T) { state: mockManagerState, mempool: mempool, metrics: metrics, - backend: &executor.Backend{ - Ctx: &snow.Context{ - SharedMemory: mockSharedMemory, - Log: logging.NoLog{}, - }, - }, + backend: defaultTestBackend(false, mockSharedMemory), blkIDToState: map[ids.ID]*blockState{ blockID: { onAcceptState: mockOnAcceptState, @@ -769,12 +762,7 @@ func TestBlockAccept(t *testing.T) { state: mockManagerState, mempool: mempool, metrics: metrics, - backend: &executor.Backend{ - Ctx: &snow.Context{ - SharedMemory: mockSharedMemory, - Log: logging.NoLog{}, - }, - }, + backend: defaultTestBackend(false, mockSharedMemory), blkIDToState: map[ids.ID]*blockState{ blockID: { onAcceptState: mockOnAcceptState, @@ -869,13 +857,8 @@ func TestBlockReject(t *testing.T) { lastAccepted: lastAcceptedID, mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{ - Bootstrapped: true, - Ctx: &snow.Context{ - Log: logging.NoLog{}, - }, - }, - state: mockState, + backend: defaultTestBackend(true, nil), + state: mockState, blkIDToState: map[ids.ID]*blockState{ blockID: {}, }, @@ -927,13 +910,8 @@ func TestBlockReject(t *testing.T) { lastAccepted: lastAcceptedID, mempool: mempool, metrics: metrics.NewMockMetrics(ctrl), - backend: &executor.Backend{ - Bootstrapped: true, - Ctx: &snow.Context{ - Log: logging.NoLog{}, - }, - }, - state: mockState, + backend: defaultTestBackend(true, nil), + state: mockState, blkIDToState: map[ids.ID]*blockState{ blockID: {}, }, @@ -981,6 +959,7 @@ func TestBlockStatus(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), lastAccepted: blockID, }, } @@ -996,6 +975,7 @@ func TestBlockStatus(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{ blockID: {}, }, @@ -1017,6 +997,7 @@ func TestBlockStatus(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{}, state: mockState, }, @@ -1037,6 +1018,7 @@ func TestBlockStatus(t *testing.T) { return &Block{ Block: mockBlock, manager: &manager{ + backend: defaultTestBackend(false, nil), blkIDToState: map[ids.ID]*blockState{}, state: mockState, }, @@ -1055,3 +1037,18 @@ func TestBlockStatus(t *testing.T) { }) } } + +func defaultTestBackend(bootstrapped bool, sharedMemory atomic.SharedMemory) *executor.Backend { + return &executor.Backend{ + Bootstrapped: bootstrapped, + Ctx: &snow.Context{ + SharedMemory: sharedMemory, + Log: logging.NoLog{}, + }, + Config: &config.Config{ + EUpgradeTime: mockable.MaxTime, + TxFee: 0, + CreateAssetTxFee: 0, + }, + } +} diff --git a/vms/avm/block/executor/manager_test.go b/vms/avm/block/executor/manager_test.go index 275bbabc9bac..14484fcbb559 100644 --- a/vms/avm/block/executor/manager_test.go +++ b/vms/avm/block/executor/manager_test.go @@ -16,7 +16,6 @@ import ( "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/state" "github.com/ava-labs/avalanchego/vms/avm/txs" - "github.com/ava-labs/avalanchego/vms/avm/txs/executor" ) var ( @@ -123,7 +122,7 @@ func TestManagerVerifyTx(t *testing.T) { }, managerF: func(*gomock.Controller) *manager { return &manager{ - backend: &executor.Backend{}, + backend: defaultTestBackend(false, nil), } }, expectedErr: ErrChainNotSynced, @@ -139,9 +138,7 @@ func TestManagerVerifyTx(t *testing.T) { }, managerF: func(*gomock.Controller) *manager { return &manager{ - backend: &executor.Backend{ - Bootstrapped: true, - }, + backend: defaultTestBackend(true, nil), } }, expectedErr: errTestSyntacticVerifyFail, @@ -167,9 +164,7 @@ func TestManagerVerifyTx(t *testing.T) { state.EXPECT().GetTimestamp().Return(time.Time{}) return &manager{ - backend: &executor.Backend{ - Bootstrapped: true, - }, + backend: defaultTestBackend(true, nil), state: state, lastAccepted: lastAcceptedID, } @@ -199,9 +194,7 @@ func TestManagerVerifyTx(t *testing.T) { state.EXPECT().GetTimestamp().Return(time.Time{}) return &manager{ - backend: &executor.Backend{ - Bootstrapped: true, - }, + backend: defaultTestBackend(true, nil), state: state, lastAccepted: lastAcceptedID, } @@ -231,9 +224,7 @@ func TestManagerVerifyTx(t *testing.T) { state.EXPECT().GetTimestamp().Return(time.Time{}) return &manager{ - backend: &executor.Backend{ - Bootstrapped: true, - }, + backend: defaultTestBackend(true, nil), state: state, lastAccepted: lastAcceptedID, } diff --git a/vms/avm/config/config.go b/vms/avm/config/config.go index 08f6ab04240a..0d026eb05dbb 100644 --- a/vms/avm/config/config.go +++ b/vms/avm/config/config.go @@ -3,6 +3,8 @@ package config +import "time" + // Struct collecting all the foundational parameters of the AVM type Config struct { // Fee that is burned by every non-asset creating transaction @@ -10,4 +12,11 @@ type Config struct { // Fee that must be burned by every asset creating transaction CreateAssetTxFee uint64 + + // Time of the E network upgrade + EUpgradeTime time.Time +} + +func (c *Config) IsEActivated(timestamp time.Time) bool { + return !timestamp.Before(c.EUpgradeTime) } diff --git a/vms/avm/environment_test.go b/vms/avm/environment_test.go index 9c4e5eb6a6f0..35b5b9d363da 100644 --- a/vms/avm/environment_test.go +++ b/vms/avm/environment_test.go @@ -8,6 +8,7 @@ import ( "encoding/json" "math/rand" "testing" + "time" "github.com/stretchr/testify/require" @@ -26,6 +27,7 @@ import ( "github.com/ava-labs/avalanchego/utils/linkedhashmap" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/sampler" + "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/avm/block/executor" "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/fxs" @@ -38,7 +40,14 @@ import ( keystoreutils "github.com/ava-labs/avalanchego/vms/components/keystore" ) +type fork uint8 + const ( + durango fork = iota + eUpgrade + + latest = durango + testTxFee uint64 = 1000 startBalance uint64 = 50000 @@ -68,6 +77,12 @@ var ( keys = secp256k1.TestKeys()[:3] // TODO: Remove [:3] addrs []ids.ShortID // addrs[i] corresponds to keys[i] + + noFeesTestConfig = &config.Config{ + EUpgradeTime: mockable.MaxTime, + TxFee: 0, + CreateAssetTxFee: 0, + } ) func init() { @@ -84,6 +99,7 @@ type user struct { } type envConfig struct { + fork fork isCustomFeeAsset bool keystoreUsers []*user vmStaticConfig *config.Config @@ -144,10 +160,7 @@ func setup(tb testing.TB, c *envConfig) *environment { require.NoError(keystoreUser.Close()) } - vmStaticConfig := config.Config{ - TxFee: testTxFee, - CreateAssetTxFee: testTxFee, - } + vmStaticConfig := staticConfig(tb, c.fork) if c.vmStaticConfig != nil { vmStaticConfig = *c.vmStaticConfig } @@ -220,6 +233,24 @@ func setup(tb testing.TB, c *envConfig) *environment { return env } +func staticConfig(tb testing.TB, f fork) config.Config { + c := config.Config{ + TxFee: testTxFee, + CreateAssetTxFee: testTxFee, + EUpgradeTime: mockable.MaxTime, + } + + switch f { + case eUpgrade: + c.EUpgradeTime = time.Time{} + case durango: + default: + require.FailNow(tb, "unhandled fork", f) + } + + return c +} + // Returns: // // 1. tx in genesis that creates asset diff --git a/vms/avm/index_test.go b/vms/avm/index_test.go index d5978e0ed37c..459d4230f32c 100644 --- a/vms/avm/index_test.go +++ b/vms/avm/index_test.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/index" @@ -30,7 +29,7 @@ func TestIndexTransaction_Ordered(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) @@ -74,7 +73,7 @@ func TestIndexTransaction_MultipleTransactions(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) @@ -122,7 +121,7 @@ func TestIndexTransaction_MultipleAddresses(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) @@ -164,7 +163,9 @@ func TestIndexTransaction_MultipleAddresses(t *testing.T) { func TestIndexer_Read(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + vmStaticConfig: noFeesTestConfig, + }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) env.vm.ctx.Lock.Unlock() diff --git a/vms/avm/service_test.go b/vms/avm/service_test.go index 9d1879871551..677a0193ba97 100644 --- a/vms/avm/service_test.go +++ b/vms/avm/service_test.go @@ -30,7 +30,6 @@ import ( "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/block/executor" - "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/state" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -46,7 +45,9 @@ import ( func TestServiceIssueTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -72,7 +73,9 @@ func TestServiceIssueTx(t *testing.T) { func TestServiceGetTxStatus(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -107,7 +110,9 @@ func TestServiceGetTxStatus(t *testing.T) { func TestServiceGetBalanceStrict(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { env.vm.ctx.Lock.Lock() require.NoError(env.vm.Shutdown(context.Background())) @@ -263,7 +268,9 @@ func TestServiceGetBalanceStrict(t *testing.T) { func TestServiceGetTxs(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) var err error env.vm.addressTxsIndexer, err = index.NewIndexer(env.vm.db, env.vm.ctx.Log, "", prometheus.NewRegistry(), false) require.NoError(err) @@ -305,7 +312,9 @@ func TestServiceGetTxs(t *testing.T) { func TestServiceGetAllBalances(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { env.vm.ctx.Lock.Lock() require.NoError(env.vm.Shutdown(context.Background())) @@ -503,7 +512,9 @@ func TestServiceGetAllBalances(t *testing.T) { func TestServiceGetTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -531,7 +542,9 @@ func TestServiceGetTx(t *testing.T) { func TestServiceGetTxJSON_BaseTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { env.vm.ctx.Lock.Lock() @@ -614,7 +627,9 @@ func TestServiceGetTxJSON_BaseTx(t *testing.T) { func TestServiceGetTxJSON_ExportTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { env.vm.ctx.Lock.Lock() @@ -699,7 +714,7 @@ func TestServiceGetTxJSON_CreateAssetTx(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -815,7 +830,7 @@ func TestServiceGetTxJSON_OperationTxWithNftxMintOp(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -914,7 +929,7 @@ func TestServiceGetTxJSON_OperationTxWithMultipleNftxMintOp(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -1052,7 +1067,7 @@ func TestServiceGetTxJSON_OperationTxWithSecpMintOp(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -1155,7 +1170,7 @@ func TestServiceGetTxJSON_OperationTxWithMultipleSecpMintOp(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -1301,7 +1316,7 @@ func TestServiceGetTxJSON_OperationTxWithPropertyFxMintOp(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -1401,7 +1416,7 @@ func TestServiceGetTxJSON_OperationTxWithPropertyFxMintOpMultiple(t *testing.T) require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -1780,7 +1795,9 @@ func buildOperationTxWithOp(chainID ids.ID, op ...*txs.Operation) *txs.Tx { func TestServiceGetNilTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -1797,7 +1814,9 @@ func TestServiceGetNilTx(t *testing.T) { func TestServiceGetUnknownTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -1812,7 +1831,9 @@ func TestServiceGetUnknownTx(t *testing.T) { } func TestServiceGetUTXOs(t *testing.T) { - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { env.vm.ctx.Lock.Lock() require.NoError(t, env.vm.Shutdown(context.Background())) @@ -2067,7 +2088,9 @@ func TestServiceGetUTXOs(t *testing.T) { func TestGetAssetDescription(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { @@ -2090,7 +2113,9 @@ func TestGetAssetDescription(t *testing.T) { func TestGetBalance(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { diff --git a/vms/avm/state_test.go b/vms/avm/state_test.go index b17604b2ba62..e71acf1251cb 100644 --- a/vms/avm/state_test.go +++ b/vms/avm/state_test.go @@ -24,6 +24,7 @@ func TestSetsAndGets(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ + fork: latest, additionalFxs: []*common.Fx{{ ID: ids.GenerateTestID(), Fx: &FxTest{ @@ -86,6 +87,7 @@ func TestSetsAndGets(t *testing.T) { func TestFundingNoAddresses(t *testing.T) { env := setup(t, &envConfig{ + fork: latest, additionalFxs: []*common.Fx{{ ID: ids.GenerateTestID(), Fx: &FxTest{ @@ -118,6 +120,7 @@ func TestFundingAddresses(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ + fork: latest, additionalFxs: []*common.Fx{{ ID: ids.GenerateTestID(), Fx: &FxTest{ diff --git a/vms/avm/txs/executor/syntactic_verifier_test.go b/vms/avm/txs/executor/syntactic_verifier_test.go index 8726e45477db..c5762a81c74b 100644 --- a/vms/avm/txs/executor/syntactic_verifier_test.go +++ b/vms/avm/txs/executor/syntactic_verifier_test.go @@ -14,6 +14,7 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" + "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -29,6 +30,7 @@ var ( feeConfig = config.Config{ TxFee: 2, CreateAssetTxFee: 3, + EUpgradeTime: mockable.MaxTime, } ) diff --git a/vms/avm/vm.go b/vms/avm/vm.go index fe302f97cf28..82080d377344 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -390,10 +390,6 @@ func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, erro return vm.state.GetBlockIDAtHeight(height) } -func (*VM) VerifyHeightIndex(context.Context) error { - return nil -} - /* ****************************************************************************** *********************************** DAG VM *********************************** diff --git a/vms/avm/vm_benchmark_test.go b/vms/avm/vm_benchmark_test.go index 713f809f7f5c..5befa7062dda 100644 --- a/vms/avm/vm_benchmark_test.go +++ b/vms/avm/vm_benchmark_test.go @@ -23,6 +23,7 @@ func BenchmarkLoadUser(b *testing.B) { require := require.New(b) env := setup(b, &envConfig{ + fork: latest, keystoreUsers: []*user{{ username: username, password: password, @@ -67,7 +68,7 @@ func BenchmarkLoadUser(b *testing.B) { func GetAllUTXOsBenchmark(b *testing.B, utxoCount int) { require := require.New(b) - env := setup(b, &envConfig{}) + env := setup(b, &envConfig{fork: latest}) defer func() { require.NoError(env.vm.Shutdown(context.Background())) env.vm.ctx.Lock.Unlock() diff --git a/vms/avm/vm_regression_test.go b/vms/avm/vm_regression_test.go index c6ac40df845d..0151ccaf6dab 100644 --- a/vms/avm/vm_regression_test.go +++ b/vms/avm/vm_regression_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" - "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" @@ -24,7 +23,7 @@ func TestVerifyFxUsage(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) env.vm.ctx.Lock.Unlock() defer func() { diff --git a/vms/avm/vm_test.go b/vms/avm/vm_test.go index d8aeaf3b8743..25824f4d0097 100644 --- a/vms/avm/vm_test.go +++ b/vms/avm/vm_test.go @@ -19,7 +19,6 @@ import ( "github.com/ava-labs/avalanchego/snow/snowtest" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" - "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -115,7 +114,9 @@ func TestFxInitializationFailure(t *testing.T) { func TestIssueTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) env.vm.ctx.Lock.Unlock() defer func() { env.vm.ctx.Lock.Lock() @@ -132,7 +133,7 @@ func TestIssueNFT(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) env.vm.ctx.Lock.Unlock() defer func() { @@ -233,7 +234,7 @@ func TestIssueProperty(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, additionalFxs: []*common.Fx{{ ID: propertyfx.ID, Fx: &propertyfx.Fx{}, @@ -326,6 +327,7 @@ func TestIssueTxWithFeeAsset(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ + fork: latest, isCustomFeeAsset: true, }) env.vm.ctx.Lock.Unlock() @@ -344,6 +346,7 @@ func TestIssueTxWithAnotherAsset(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ + fork: latest, isCustomFeeAsset: true, }) env.vm.ctx.Lock.Unlock() @@ -403,7 +406,9 @@ func TestIssueTxWithAnotherAsset(t *testing.T) { } func TestVMFormat(t *testing.T) { - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { require.NoError(t, env.vm.Shutdown(context.Background())) env.vm.ctx.Lock.Unlock() @@ -432,6 +437,7 @@ func TestTxAcceptAfterParseTx(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ + fork: latest, notLinearized: true, }) defer func() { @@ -520,7 +526,7 @@ func TestIssueImportTx(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) @@ -620,7 +626,7 @@ func TestForceAcceptImportTx(t *testing.T) { require := require.New(t) env := setup(t, &envConfig{ - vmStaticConfig: &config.Config{}, + vmStaticConfig: noFeesTestConfig, notLinearized: true, }) defer func() { @@ -697,7 +703,9 @@ func TestImportTxNotState(t *testing.T) { func TestIssueExportTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) env.vm.ctx.Lock.Unlock() @@ -772,7 +780,9 @@ func TestIssueExportTx(t *testing.T) { func TestClearForceAcceptedExportTx(t *testing.T) { require := require.New(t) - env := setup(t, &envConfig{}) + env := setup(t, &envConfig{ + fork: latest, + }) defer func() { require.NoError(env.vm.Shutdown(context.Background())) env.vm.ctx.Lock.Unlock() diff --git a/vms/avm/wallet_service_test.go b/vms/avm/wallet_service_test.go index 7ffdccdaaa20..eeb214fba9bd 100644 --- a/vms/avm/wallet_service_test.go +++ b/vms/avm/wallet_service_test.go @@ -18,6 +18,7 @@ func TestWalletService_SendMultiple(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { env := setup(t, &envConfig{ + fork: latest, isCustomFeeAsset: !tc.avaxAsset, keystoreUsers: []*user{{ username: username, diff --git a/vms/example/xsvm/vm.go b/vms/example/xsvm/vm.go index 38f25393c39b..ef59e6c51657 100644 --- a/vms/example/xsvm/vm.go +++ b/vms/example/xsvm/vm.go @@ -168,10 +168,6 @@ func (vm *VM) BuildBlockWithContext(ctx context.Context, blockContext *smblock.C return vm.builder.BuildBlock(ctx, blockContext) } -func (*VM) VerifyHeightIndex(context.Context) error { - return nil -} - func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) { return state.GetBlockIDByHeight(vm.db, height) } diff --git a/vms/metervm/block_metrics.go b/vms/metervm/block_metrics.go index 160d0eee50ad..0a6473f617bd 100644 --- a/vms/metervm/block_metrics.go +++ b/vms/metervm/block_metrics.go @@ -24,7 +24,6 @@ type blockMetrics struct { accept, reject, // Height metrics - verifyHeightIndex, getBlockIDAtHeight, // Block verification with context metrics shouldVerifyWithContext, @@ -69,7 +68,6 @@ func (m *blockMetrics) Initialize( m.shouldVerifyWithContext = newAverager(namespace, "should_verify_with_context", reg, &errs) m.verifyWithContext = newAverager(namespace, "verify_with_context", reg, &errs) m.verifyWithContextErr = newAverager(namespace, "verify_with_context_err", reg, &errs) - m.verifyHeightIndex = newAverager(namespace, "verify_height_index", reg, &errs) m.getBlockIDAtHeight = newAverager(namespace, "get_block_id_at_height", reg, &errs) if supportsBlockBuildingWithContext { diff --git a/vms/metervm/block_vm.go b/vms/metervm/block_vm.go index 73e949180a96..7c93b9078577 100644 --- a/vms/metervm/block_vm.go +++ b/vms/metervm/block_vm.go @@ -150,14 +150,6 @@ func (vm *blockVM) LastAccepted(ctx context.Context) (ids.ID, error) { return lastAcceptedID, err } -func (vm *blockVM) VerifyHeightIndex(ctx context.Context) error { - start := vm.clock.Time() - err := vm.ChainVM.VerifyHeightIndex(ctx) - end := vm.clock.Time() - vm.blockMetrics.verifyHeightIndex.Observe(float64(end.Sub(start))) - return err -} - func (vm *blockVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) { start := vm.clock.Time() blockID, err := vm.ChainVM.GetBlockIDAtHeight(ctx, height) diff --git a/vms/platformvm/block/builder/helpers_test.go b/vms/platformvm/block/builder/helpers_test.go index 6c1471a8b2de..8a410ae7ed2c 100644 --- a/vms/platformvm/block/builder/helpers_test.go +++ b/vms/platformvm/block/builder/helpers_test.go @@ -5,7 +5,6 @@ package builder import ( "context" - "fmt" "testing" "time" @@ -64,6 +63,7 @@ const ( banff cortina durango + eUpgrade latestFork = durango ) @@ -305,34 +305,7 @@ func defaultState( } func defaultConfig(t *testing.T, f fork) *config.Config { - var ( - apricotPhase3Time = mockable.MaxTime - apricotPhase5Time = mockable.MaxTime - banffTime = mockable.MaxTime - cortinaTime = mockable.MaxTime - durangoTime = mockable.MaxTime - ) - - switch f { - case durango: - durangoTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case cortina: - cortinaTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case banff: - banffTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case apricotPhase5: - apricotPhase5Time = defaultValidateEndTime - fallthrough - case apricotPhase3: - apricotPhase3Time = defaultValidateEndTime - default: - require.NoError(t, fmt.Errorf("unhandled fork %d", f)) - } - - return &config.Config{ + c := &config.Config{ Chains: chains.TestManager, UptimeLockedCalculator: uptime.NewLockedCalculator(), Validators: validators.NewManager(), @@ -350,12 +323,37 @@ func defaultConfig(t *testing.T, f fork) *config.Config { MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaAvax, }, - ApricotPhase3Time: apricotPhase3Time, - ApricotPhase5Time: apricotPhase5Time, - BanffTime: banffTime, - CortinaTime: cortinaTime, - DurangoTime: durangoTime, + ApricotPhase3Time: mockable.MaxTime, + ApricotPhase5Time: mockable.MaxTime, + BanffTime: mockable.MaxTime, + CortinaTime: mockable.MaxTime, + DurangoTime: mockable.MaxTime, + EUpgradeTime: mockable.MaxTime, } + + switch f { + case eUpgrade: + c.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests + fallthrough + case durango: + c.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case cortina: + c.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case banff: + c.BanffTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case apricotPhase5: + c.ApricotPhase5Time = defaultValidateEndTime + fallthrough + case apricotPhase3: + c.ApricotPhase3Time = defaultValidateEndTime + default: + require.FailNow(t, "unhandled fork", f) + } + + return c } func defaultClock() *mockable.Clock { diff --git a/vms/platformvm/block/executor/helpers_test.go b/vms/platformvm/block/executor/helpers_test.go index 4f016808f3d4..18e402d5ace3 100644 --- a/vms/platformvm/block/executor/helpers_test.go +++ b/vms/platformvm/block/executor/helpers_test.go @@ -65,6 +65,7 @@ const ( banff cortina durango + eUpgrade ) var ( @@ -329,34 +330,7 @@ func defaultState( } func defaultConfig(t *testing.T, f fork) *config.Config { - var ( - apricotPhase3Time = mockable.MaxTime - apricotPhase5Time = mockable.MaxTime - banffTime = mockable.MaxTime - cortinaTime = mockable.MaxTime - durangoTime = mockable.MaxTime - ) - - switch f { - case durango: - durangoTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case cortina: - cortinaTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case banff: - banffTime = time.Time{} // neglecting fork ordering for this package's tests - fallthrough - case apricotPhase5: - apricotPhase5Time = defaultValidateEndTime - fallthrough - case apricotPhase3: - apricotPhase3Time = defaultValidateEndTime - default: - require.NoError(t, fmt.Errorf("unhandled fork %d", f)) - } - - return &config.Config{ + c := &config.Config{ Chains: chains.TestManager, UptimeLockedCalculator: uptime.NewLockedCalculator(), Validators: validators.NewManager(), @@ -374,12 +348,37 @@ func defaultConfig(t *testing.T, f fork) *config.Config { MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaAvax, }, - ApricotPhase3Time: apricotPhase3Time, - ApricotPhase5Time: apricotPhase5Time, - BanffTime: banffTime, - CortinaTime: cortinaTime, - DurangoTime: durangoTime, + ApricotPhase3Time: mockable.MaxTime, + ApricotPhase5Time: mockable.MaxTime, + BanffTime: mockable.MaxTime, + CortinaTime: mockable.MaxTime, + DurangoTime: mockable.MaxTime, + EUpgradeTime: mockable.MaxTime, } + + switch f { + case eUpgrade: + c.EUpgradeTime = time.Time{} // neglecting fork ordering this for package tests + fallthrough + case durango: + c.DurangoTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case cortina: + c.CortinaTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case banff: + c.BanffTime = time.Time{} // neglecting fork ordering for this package's tests + fallthrough + case apricotPhase5: + c.ApricotPhase5Time = defaultValidateEndTime + fallthrough + case apricotPhase3: + c.ApricotPhase3Time = defaultValidateEndTime + default: + require.FailNow(t, "unhandled fork", f) + } + + return c } func defaultClock() *mockable.Clock { diff --git a/vms/platformvm/config/config.go b/vms/platformvm/config/config.go index 50628c422afd..0c5fcf15a475 100644 --- a/vms/platformvm/config/config.go +++ b/vms/platformvm/config/config.go @@ -107,6 +107,9 @@ type Config struct { // Time of the Durango network upgrade DurangoTime time.Time + // Time of the E network upgrade + EUpgradeTime time.Time + // UseCurrentHeight forces [GetMinimumHeight] to return the current height // of the P-Chain instead of the oldest block in the [recentlyAccepted] // window. @@ -137,6 +140,10 @@ func (c *Config) IsDurangoActivated(timestamp time.Time) bool { return !timestamp.Before(c.DurangoTime) } +func (c *Config) IsEActivated(timestamp time.Time) bool { + return !timestamp.Before(c.EUpgradeTime) +} + func (c *Config) GetCreateBlockchainTxFee(timestamp time.Time) uint64 { if c.IsApricotPhase3Activated(timestamp) { return c.CreateBlockchainTxFee diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index 32007b4fc928..45360a13b764 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/uptime" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils" @@ -47,28 +48,26 @@ var ( errValidatorSetAlreadyPopulated = errors.New("validator set already populated") errIsNotSubnet = errors.New("is not a subnet") - BlockIDPrefix = []byte("blockID") - BlockPrefix = []byte("block") - ValidatorsPrefix = []byte("validators") - CurrentPrefix = []byte("current") - PendingPrefix = []byte("pending") - ValidatorPrefix = []byte("validator") - DelegatorPrefix = []byte("delegator") - SubnetValidatorPrefix = []byte("subnetValidator") - SubnetDelegatorPrefix = []byte("subnetDelegator") - NestedValidatorWeightDiffsPrefix = []byte("validatorDiffs") - NestedValidatorPublicKeyDiffsPrefix = []byte("publicKeyDiffs") - FlatValidatorWeightDiffsPrefix = []byte("flatValidatorDiffs") - FlatValidatorPublicKeyDiffsPrefix = []byte("flatPublicKeyDiffs") - TxPrefix = []byte("tx") - RewardUTXOsPrefix = []byte("rewardUTXOs") - UTXOPrefix = []byte("utxo") - SubnetPrefix = []byte("subnet") - SubnetOwnerPrefix = []byte("subnetOwner") - TransformedSubnetPrefix = []byte("transformedSubnet") - SupplyPrefix = []byte("supply") - ChainPrefix = []byte("chain") - SingletonPrefix = []byte("singleton") + BlockIDPrefix = []byte("blockID") + BlockPrefix = []byte("block") + ValidatorsPrefix = []byte("validators") + CurrentPrefix = []byte("current") + PendingPrefix = []byte("pending") + ValidatorPrefix = []byte("validator") + DelegatorPrefix = []byte("delegator") + SubnetValidatorPrefix = []byte("subnetValidator") + SubnetDelegatorPrefix = []byte("subnetDelegator") + ValidatorWeightDiffsPrefix = []byte("flatValidatorDiffs") + ValidatorPublicKeyDiffsPrefix = []byte("flatPublicKeyDiffs") + TxPrefix = []byte("tx") + RewardUTXOsPrefix = []byte("rewardUTXOs") + UTXOPrefix = []byte("utxo") + SubnetPrefix = []byte("subnet") + SubnetOwnerPrefix = []byte("subnetOwner") + TransformedSubnetPrefix = []byte("transformedSubnet") + SupplyPrefix = []byte("supply") + ChainPrefix = []byte("chain") + SingletonPrefix = []byte("singleton") TimestampKey = []byte("timestamp") CurrentSupplyKey = []byte("current supply") @@ -180,6 +179,16 @@ type State interface { Close() error } +// Prior to https://github.com/ava-labs/avalanchego/pull/1719, blocks were +// stored as a map from blkID to stateBlk. Nodes synced prior to this PR may +// still have blocks partially stored using this legacy format. +// +// TODO: Remove after v1.12.x is activated +type stateBlk struct { + Bytes []byte `serialize:"true"` + Status choices.Status `serialize:"true"` +} + /* * VMDB * |-. validators @@ -209,17 +218,9 @@ type State interface { * | | '-. subnetDelegator * | | '-. list * | | '-- txID -> nil - * | |-. nested weight diffs TODO: Remove once only the flat db is needed - * | | '-. height+subnet - * | | '-. list - * | | '-- nodeID -> weightChange - * | |-. nested pub key diffs TODO: Remove once only the flat db is needed - * | | '-. height - * | | '-. list - * | | '-- nodeID -> compressed public key - * | |-. flat weight diffs + * | |-. weight diffs * | | '-- subnet+height+nodeID -> weightChange - * | '-. flat pub key diffs + * | '-. pub key diffs * | '-- subnet+height+nodeID -> uncompressed public key or nil * |-. blockIDs * | '-- height -> blockID @@ -293,10 +294,8 @@ type state struct { pendingSubnetDelegatorBaseDB database.Database pendingSubnetDelegatorList linkeddb.LinkedDB - nestedValidatorWeightDiffsDB database.Database - nestedValidatorPublicKeyDiffsDB database.Database - flatValidatorWeightDiffsDB database.Database - flatValidatorPublicKeyDiffsDB database.Database + validatorWeightDiffsDB database.Database + validatorPublicKeyDiffsDB database.Database addedTxs map[ids.ID]*txAndStatus // map of txID -> {*txs.Tx, Status} txCache cache.Cacher[ids.ID, *txAndStatus] // txID -> {*txs.Tx, Status}. If the entry is nil, it isn't in the database @@ -338,8 +337,9 @@ type state struct { currentSupply, persistedCurrentSupply uint64 // [lastAccepted] is the most recently accepted block. lastAccepted, persistedLastAccepted ids.ID - indexedHeights *heightRange - singletonDB database.Database + // TODO: Remove indexedHeights once v1.11.3 has been released. + indexedHeights *heightRange + singletonDB database.Database } // heightRange is used to track which heights are safe to use the native DB @@ -373,11 +373,6 @@ func (v *ValidatorWeightDiff) Add(negative bool, amount uint64) error { return nil } -type heightWithSubnet struct { - Height uint64 `serialize:"true"` - SubnetID ids.ID `serialize:"true"` -} - type txBytesAndStatus struct { Tx []byte `serialize:"true"` Status status.Status `serialize:"true"` @@ -490,10 +485,8 @@ func newState( pendingSubnetValidatorBaseDB := prefixdb.New(SubnetValidatorPrefix, pendingValidatorsDB) pendingSubnetDelegatorBaseDB := prefixdb.New(SubnetDelegatorPrefix, pendingValidatorsDB) - nestedValidatorWeightDiffsDB := prefixdb.New(NestedValidatorWeightDiffsPrefix, validatorsDB) - nestedValidatorPublicKeyDiffsDB := prefixdb.New(NestedValidatorPublicKeyDiffsPrefix, validatorsDB) - flatValidatorWeightDiffsDB := prefixdb.New(FlatValidatorWeightDiffsPrefix, validatorsDB) - flatValidatorPublicKeyDiffsDB := prefixdb.New(FlatValidatorPublicKeyDiffsPrefix, validatorsDB) + validatorWeightDiffsDB := prefixdb.New(ValidatorWeightDiffsPrefix, validatorsDB) + validatorPublicKeyDiffsDB := prefixdb.New(ValidatorPublicKeyDiffsPrefix, validatorsDB) txCache, err := metercacher.New( "tx_cache", @@ -591,29 +584,27 @@ func newState( currentStakers: newBaseStakers(), pendingStakers: newBaseStakers(), - validatorsDB: validatorsDB, - currentValidatorsDB: currentValidatorsDB, - currentValidatorBaseDB: currentValidatorBaseDB, - currentValidatorList: linkeddb.NewDefault(currentValidatorBaseDB), - currentDelegatorBaseDB: currentDelegatorBaseDB, - currentDelegatorList: linkeddb.NewDefault(currentDelegatorBaseDB), - currentSubnetValidatorBaseDB: currentSubnetValidatorBaseDB, - currentSubnetValidatorList: linkeddb.NewDefault(currentSubnetValidatorBaseDB), - currentSubnetDelegatorBaseDB: currentSubnetDelegatorBaseDB, - currentSubnetDelegatorList: linkeddb.NewDefault(currentSubnetDelegatorBaseDB), - pendingValidatorsDB: pendingValidatorsDB, - pendingValidatorBaseDB: pendingValidatorBaseDB, - pendingValidatorList: linkeddb.NewDefault(pendingValidatorBaseDB), - pendingDelegatorBaseDB: pendingDelegatorBaseDB, - pendingDelegatorList: linkeddb.NewDefault(pendingDelegatorBaseDB), - pendingSubnetValidatorBaseDB: pendingSubnetValidatorBaseDB, - pendingSubnetValidatorList: linkeddb.NewDefault(pendingSubnetValidatorBaseDB), - pendingSubnetDelegatorBaseDB: pendingSubnetDelegatorBaseDB, - pendingSubnetDelegatorList: linkeddb.NewDefault(pendingSubnetDelegatorBaseDB), - nestedValidatorWeightDiffsDB: nestedValidatorWeightDiffsDB, - nestedValidatorPublicKeyDiffsDB: nestedValidatorPublicKeyDiffsDB, - flatValidatorWeightDiffsDB: flatValidatorWeightDiffsDB, - flatValidatorPublicKeyDiffsDB: flatValidatorPublicKeyDiffsDB, + validatorsDB: validatorsDB, + currentValidatorsDB: currentValidatorsDB, + currentValidatorBaseDB: currentValidatorBaseDB, + currentValidatorList: linkeddb.NewDefault(currentValidatorBaseDB), + currentDelegatorBaseDB: currentDelegatorBaseDB, + currentDelegatorList: linkeddb.NewDefault(currentDelegatorBaseDB), + currentSubnetValidatorBaseDB: currentSubnetValidatorBaseDB, + currentSubnetValidatorList: linkeddb.NewDefault(currentSubnetValidatorBaseDB), + currentSubnetDelegatorBaseDB: currentSubnetDelegatorBaseDB, + currentSubnetDelegatorList: linkeddb.NewDefault(currentSubnetDelegatorBaseDB), + pendingValidatorsDB: pendingValidatorsDB, + pendingValidatorBaseDB: pendingValidatorBaseDB, + pendingValidatorList: linkeddb.NewDefault(pendingValidatorBaseDB), + pendingDelegatorBaseDB: pendingDelegatorBaseDB, + pendingDelegatorList: linkeddb.NewDefault(pendingDelegatorBaseDB), + pendingSubnetValidatorBaseDB: pendingSubnetValidatorBaseDB, + pendingSubnetValidatorList: linkeddb.NewDefault(pendingSubnetValidatorBaseDB), + pendingSubnetDelegatorBaseDB: pendingSubnetDelegatorBaseDB, + pendingSubnetDelegatorList: linkeddb.NewDefault(pendingSubnetDelegatorBaseDB), + validatorWeightDiffsDB: validatorWeightDiffsDB, + validatorPublicKeyDiffsDB: validatorPublicKeyDiffsDB, addedTxs: make(map[ids.ID]*txAndStatus), txDB: prefixdb.New(TxPrefix, baseDB), @@ -1053,16 +1044,14 @@ func (s *state) ApplyValidatorWeightDiffs( endHeight uint64, subnetID ids.ID, ) error { - diffIter := s.flatValidatorWeightDiffsDB.NewIteratorWithStartAndPrefix( + diffIter := s.validatorWeightDiffsDB.NewIteratorWithStartAndPrefix( marshalStartDiffKey(subnetID, startHeight), subnetID[:], ) defer diffIter.Release() prevHeight := startHeight + 1 - // TODO: Remove the index continuity checks once we are guaranteed nodes can - // not rollback to not support the new indexing mechanism. - for diffIter.Next() && s.indexedHeights != nil && s.indexedHeights.LowerBound <= endHeight { + for diffIter.Next() { if err := ctx.Err(); err != nil { return err } @@ -1100,50 +1089,7 @@ func (s *state) ApplyValidatorWeightDiffs( return err } } - if err := diffIter.Error(); err != nil { - return err - } - - // TODO: Remove this once it is assumed that all subnet validators have - // adopted the new indexing. - for height := prevHeight - 1; height >= endHeight; height-- { - if err := ctx.Err(); err != nil { - return err - } - - prefixStruct := heightWithSubnet{ - Height: height, - SubnetID: subnetID, - } - prefixBytes, err := block.GenesisCodec.Marshal(block.CodecVersion, prefixStruct) - if err != nil { - return err - } - - rawDiffDB := prefixdb.New(prefixBytes, s.nestedValidatorWeightDiffsDB) - diffDB := linkeddb.NewDefault(rawDiffDB) - diffIter := diffDB.NewIterator() - defer diffIter.Release() - - for diffIter.Next() { - nodeID, err := ids.ToNodeID(diffIter.Key()) - if err != nil { - return err - } - - weightDiff := ValidatorWeightDiff{} - _, err = block.GenesisCodec.Unmarshal(diffIter.Value(), &weightDiff) - if err != nil { - return err - } - - if err := applyWeightDiff(validators, nodeID, &weightDiff); err != nil { - return err - } - } - } - - return nil + return diffIter.Error() } func applyWeightDiff( @@ -1189,7 +1135,7 @@ func (s *state) ApplyValidatorPublicKeyDiffs( startHeight uint64, endHeight uint64, ) error { - diffIter := s.flatValidatorPublicKeyDiffsDB.NewIteratorWithStartAndPrefix( + diffIter := s.validatorPublicKeyDiffsDB.NewIteratorWithStartAndPrefix( marshalStartDiffKey(constants.PrimaryNetworkID, startHeight), constants.PrimaryNetworkID[:], ) @@ -1854,7 +1800,7 @@ func (s *state) GetStatelessBlock(blockID ids.ID) (block.Block, error) { return nil, err } - blk, err := block.Parse(block.GenesisCodec, blkBytes) + blk, _, err := parseStoredBlock(blkBytes) if err != nil { return nil, err } @@ -1891,10 +1837,6 @@ func (s *state) GetBlockIDAtHeight(height uint64) (ids.ID, error) { } func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecVersion uint16) error { - heightBytes := database.PackUInt64(height) - rawNestedPublicKeyDiffDB := prefixdb.New(heightBytes, s.nestedValidatorPublicKeyDiffsDB) - nestedPKDiffDB := linkeddb.NewDefault(rawNestedPublicKeyDiffDB) - for subnetID, validatorDiffs := range s.currentStakers.validatorDiffs { delete(s.currentStakers.validatorDiffs, subnetID) @@ -1906,17 +1848,6 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV delegatorDB = s.currentDelegatorList } - prefixStruct := heightWithSubnet{ - Height: height, - SubnetID: subnetID, - } - prefixBytes, err := block.GenesisCodec.Marshal(block.CodecVersion, prefixStruct) - if err != nil { - return fmt.Errorf("failed to create prefix bytes: %w", err) - } - rawNestedWeightDiffDB := prefixdb.New(prefixBytes, s.nestedValidatorWeightDiffsDB) - nestedWeightDiffDB := linkeddb.NewDefault(rawNestedWeightDiffDB) - // Record the change in weight and/or public key for each validator. for nodeID, validatorDiff := range validatorDiffs { // Copy [nodeID] so it doesn't get overwritten next iteration. @@ -1936,7 +1867,7 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV // Record that the public key for the validator is being // added. This means the prior value for the public key was // nil. - err := s.flatValidatorPublicKeyDiffsDB.Put( + err := s.validatorPublicKeyDiffsDB.Put( marshalDiffKey(constants.PrimaryNetworkID, height, nodeID), nil, ) @@ -1985,22 +1916,13 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV // Note: We store the uncompressed public key here as it is // significantly more efficient to parse when applying // diffs. - err := s.flatValidatorPublicKeyDiffsDB.Put( + err := s.validatorPublicKeyDiffsDB.Put( marshalDiffKey(constants.PrimaryNetworkID, height, nodeID), bls.PublicKeyToUncompressedBytes(staker.PublicKey), ) if err != nil { return err } - - // TODO: Remove this once we no longer support version - // rollbacks. - // - // Note: We store the compressed public key here. - pkBytes := bls.PublicKeyToCompressedBytes(staker.PublicKey) - if err := nestedPKDiffDB.Put(nodeID.Bytes(), pkBytes); err != nil { - return err - } } if err := validatorDB.Delete(staker.TxID[:]); err != nil { @@ -2025,7 +1947,7 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV continue } - err = s.flatValidatorWeightDiffsDB.Put( + err = s.validatorWeightDiffsDB.Put( marshalDiffKey(subnetID, height, nodeID), marshalWeightDiff(weightDiff), ) @@ -2033,15 +1955,6 @@ func (s *state) writeCurrentStakers(updateValidators bool, height uint64, codecV return err } - // TODO: Remove this once we no longer support version rollbacks. - weightDiffBytes, err := block.GenesisCodec.Marshal(block.CodecVersion, weightDiff) - if err != nil { - return fmt.Errorf("failed to serialize validator weight diff: %w", err) - } - if err := nestedWeightDiffDB.Put(nodeID.Bytes(), weightDiffBytes); err != nil { - return err - } - // TODO: Move the validator set management out of the state package if !updateValidators { continue @@ -2347,7 +2260,6 @@ func (s *state) writeMetadata() error { } s.persistedLastAccepted = s.lastAccepted } - if s.indexedHeights != nil { indexedHeightsBytes, err := block.GenesisCodec.Marshal(block.CodecVersion, s.indexedHeights) if err != nil { @@ -2357,6 +2269,26 @@ func (s *state) writeMetadata() error { return fmt.Errorf("failed to write indexed range: %w", err) } } - return nil } + +// Returns the block and whether it is a [stateBlk]. +// Invariant: blkBytes is safe to parse with blocks.GenesisCodec +// +// TODO: Remove after v1.12.x is activated +func parseStoredBlock(blkBytes []byte) (block.Block, bool, error) { + // Attempt to parse as blocks.Block + blk, err := block.Parse(block.GenesisCodec, blkBytes) + if err == nil { + return blk, false, nil + } + + // Fallback to [stateBlk] + blkState := stateBlk{} + if _, err := block.GenesisCodec.Unmarshal(blkBytes, &blkState); err != nil { + return nil, false, err + } + + blk, err = block.Parse(block.GenesisCodec, blkState.Bytes) + return blk, true, err +} diff --git a/vms/platformvm/state/state_test.go b/vms/platformvm/state/state_test.go index e5eda2256f12..b0f6afa596f9 100644 --- a/vms/platformvm/state/state_test.go +++ b/vms/platformvm/state/state_test.go @@ -18,6 +18,7 @@ import ( "github.com/ava-labs/avalanchego/database/memdb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/bls" @@ -163,7 +164,7 @@ func TestPersistStakers(t *testing.T) { r.Equal(lastUpdated, staker.StartTime) }, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { - weightDiffBytes, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + weightDiffBytes, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.NoError(err) weightDiff, err := unmarshalWeightDiff(weightDiffBytes) r.NoError(err) @@ -172,7 +173,7 @@ func TestPersistStakers(t *testing.T) { Amount: staker.Weight, }, weightDiff) - blsDiffBytes, err := s.flatValidatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + blsDiffBytes, err := s.validatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) if staker.SubnetID == constants.PrimaryNetworkID { r.NoError(err) r.Nil(blsDiffBytes) @@ -261,7 +262,7 @@ func TestPersistStakers(t *testing.T) { checkValidatorUptimes: func(*require.Assertions, *state, *Staker) {}, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { // validator's weight must increase of delegator's weight amount - weightDiffBytes, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + weightDiffBytes, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.NoError(err) weightDiff, err := unmarshalWeightDiff(weightDiffBytes) r.NoError(err) @@ -317,10 +318,10 @@ func TestPersistStakers(t *testing.T) { }, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { // pending validators weight diff and bls diffs are not stored - _, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + _, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.ErrorIs(err, database.ErrNotFound) - _, err = s.flatValidatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + _, err = s.validatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.ErrorIs(err, database.ErrNotFound) }, }, @@ -438,7 +439,7 @@ func TestPersistStakers(t *testing.T) { r.ErrorIs(err, database.ErrNotFound) }, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { - weightDiffBytes, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + weightDiffBytes, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.NoError(err) weightDiff, err := unmarshalWeightDiff(weightDiffBytes) r.NoError(err) @@ -447,7 +448,7 @@ func TestPersistStakers(t *testing.T) { Amount: staker.Weight, }, weightDiff) - blsDiffBytes, err := s.flatValidatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + blsDiffBytes, err := s.validatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) if staker.SubnetID == constants.PrimaryNetworkID { r.NoError(err) r.Equal(bls.PublicKeyFromValidUncompressedBytes(blsDiffBytes), staker.PublicKey) @@ -536,7 +537,7 @@ func TestPersistStakers(t *testing.T) { checkValidatorUptimes: func(*require.Assertions, *state, *Staker) {}, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { // validator's weight must decrease of delegator's weight amount - weightDiffBytes, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + weightDiffBytes, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.NoError(err) weightDiff, err := unmarshalWeightDiff(weightDiffBytes) r.NoError(err) @@ -592,10 +593,10 @@ func TestPersistStakers(t *testing.T) { r.ErrorIs(err, database.ErrNotFound) }, checkDiffs: func(r *require.Assertions, s *state, staker *Staker, height uint64) { - _, err := s.flatValidatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + _, err := s.validatorWeightDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.ErrorIs(err, database.ErrNotFound) - _, err = s.flatValidatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) + _, err = s.validatorPublicKeyDiffsDB.Get(marshalDiffKey(staker.SubnetID, height, staker.NodeID)) r.ErrorIs(err, database.ErrNotFound) }, }, @@ -1293,6 +1294,116 @@ func requireEqualPublicKeysValidatorSet( } } +func TestParsedStateBlock(t *testing.T) { + require := require.New(t) + + var blks []block.Block + + { + blk, err := block.NewApricotAbortBlock(ids.GenerateTestID(), 1000) + require.NoError(err) + blks = append(blks, blk) + } + + { + blk, err := block.NewApricotAtomicBlock(ids.GenerateTestID(), 1000, &txs.Tx{ + Unsigned: &txs.AdvanceTimeTx{ + Time: 1000, + }, + }) + require.NoError(err) + blks = append(blks, blk) + } + + { + blk, err := block.NewApricotCommitBlock(ids.GenerateTestID(), 1000) + require.NoError(err) + blks = append(blks, blk) + } + + { + tx := &txs.Tx{ + Unsigned: &txs.RewardValidatorTx{ + TxID: ids.GenerateTestID(), + }, + } + require.NoError(tx.Initialize(txs.Codec)) + blk, err := block.NewApricotProposalBlock(ids.GenerateTestID(), 1000, tx) + require.NoError(err) + blks = append(blks, blk) + } + + { + tx := &txs.Tx{ + Unsigned: &txs.RewardValidatorTx{ + TxID: ids.GenerateTestID(), + }, + } + require.NoError(tx.Initialize(txs.Codec)) + blk, err := block.NewApricotStandardBlock(ids.GenerateTestID(), 1000, []*txs.Tx{tx}) + require.NoError(err) + blks = append(blks, blk) + } + + { + blk, err := block.NewBanffAbortBlock(time.Now(), ids.GenerateTestID(), 1000) + require.NoError(err) + blks = append(blks, blk) + } + + { + blk, err := block.NewBanffCommitBlock(time.Now(), ids.GenerateTestID(), 1000) + require.NoError(err) + blks = append(blks, blk) + } + + { + tx := &txs.Tx{ + Unsigned: &txs.RewardValidatorTx{ + TxID: ids.GenerateTestID(), + }, + } + require.NoError(tx.Initialize(txs.Codec)) + + blk, err := block.NewBanffProposalBlock(time.Now(), ids.GenerateTestID(), 1000, tx, []*txs.Tx{}) + require.NoError(err) + blks = append(blks, blk) + } + + { + tx := &txs.Tx{ + Unsigned: &txs.RewardValidatorTx{ + TxID: ids.GenerateTestID(), + }, + } + require.NoError(tx.Initialize(txs.Codec)) + + blk, err := block.NewBanffStandardBlock(time.Now(), ids.GenerateTestID(), 1000, []*txs.Tx{tx}) + require.NoError(err) + blks = append(blks, blk) + } + + for _, blk := range blks { + stBlk := stateBlk{ + Bytes: blk.Bytes(), + Status: choices.Accepted, + } + + stBlkBytes, err := block.GenesisCodec.Marshal(block.CodecVersion, &stBlk) + require.NoError(err) + + gotBlk, isStateBlk, err := parseStoredBlock(stBlkBytes) + require.NoError(err) + require.True(isStateBlk) + require.Equal(blk.ID(), gotBlk.ID()) + + gotBlk, isStateBlk, err = parseStoredBlock(blk.Bytes()) + require.NoError(err) + require.False(isStateBlk) + require.Equal(blk.ID(), gotBlk.ID()) + } +} + func TestStateSubnetOwner(t *testing.T) { require := require.New(t) diff --git a/vms/platformvm/txs/executor/helpers_test.go b/vms/platformvm/txs/executor/helpers_test.go index 643060ddbdb3..a4238546aef6 100644 --- a/vms/platformvm/txs/executor/helpers_test.go +++ b/vms/platformvm/txs/executor/helpers_test.go @@ -56,6 +56,7 @@ const ( banff cortina durango + eUpgrade ) var ( @@ -280,34 +281,7 @@ func defaultState( } func defaultConfig(t *testing.T, f fork) *config.Config { - var ( - apricotPhase3Time = mockable.MaxTime - apricotPhase5Time = mockable.MaxTime - banffTime = mockable.MaxTime - cortinaTime = mockable.MaxTime - durangoTime = mockable.MaxTime - ) - - switch f { - case durango: - durangoTime = defaultValidateStartTime.Add(-2 * time.Second) - fallthrough - case cortina: - cortinaTime = defaultValidateStartTime.Add(-2 * time.Second) - fallthrough - case banff: - banffTime = defaultValidateStartTime.Add(-2 * time.Second) - fallthrough - case apricotPhase5: - apricotPhase5Time = defaultValidateEndTime - fallthrough - case apricotPhase3: - apricotPhase3Time = defaultValidateEndTime - default: - require.NoError(t, fmt.Errorf("unhandled fork %d", f)) - } - - return &config.Config{ + c := &config.Config{ Chains: chains.TestManager, UptimeLockedCalculator: uptime.NewLockedCalculator(), Validators: validators.NewManager(), @@ -325,12 +299,37 @@ func defaultConfig(t *testing.T, f fork) *config.Config { MintingPeriod: 365 * 24 * time.Hour, SupplyCap: 720 * units.MegaAvax, }, - ApricotPhase3Time: apricotPhase3Time, - ApricotPhase5Time: apricotPhase5Time, - BanffTime: banffTime, - CortinaTime: cortinaTime, - DurangoTime: durangoTime, + ApricotPhase3Time: mockable.MaxTime, + ApricotPhase5Time: mockable.MaxTime, + BanffTime: mockable.MaxTime, + CortinaTime: mockable.MaxTime, + DurangoTime: mockable.MaxTime, + EUpgradeTime: mockable.MaxTime, } + + switch f { + case eUpgrade: + c.EUpgradeTime = defaultValidateStartTime.Add(-2 * time.Second) + fallthrough + case durango: + c.DurangoTime = defaultValidateStartTime.Add(-2 * time.Second) + fallthrough + case cortina: + c.CortinaTime = defaultValidateStartTime.Add(-2 * time.Second) + fallthrough + case banff: + c.BanffTime = defaultValidateStartTime.Add(-2 * time.Second) + fallthrough + case apricotPhase5: + c.ApricotPhase5Time = defaultValidateEndTime + fallthrough + case apricotPhase3: + c.ApricotPhase3Time = defaultValidateEndTime + default: + require.FailNow(t, "unhandled fork", f) + } + + return c } func defaultClock(f fork) *mockable.Clock { diff --git a/vms/platformvm/txs/executor/staker_tx_verification_test.go b/vms/platformvm/txs/executor/staker_tx_verification_test.go index abe1dda3bbfc..24e1df2a0db6 100644 --- a/vms/platformvm/txs/executor/staker_tx_verification_test.go +++ b/vms/platformvm/txs/executor/staker_tx_verification_test.go @@ -109,10 +109,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { name: "fail syntactic verification", backendF: func(*gomock.Controller) *Backend { return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), } }, stateF: func(*gomock.Controller) state.Chain { @@ -130,10 +128,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { name: "not bootstrapped", backendF: func(*gomock.Controller) *Backend { return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: &utils.Atomic[bool]{}, } }, @@ -156,11 +152,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - CortinaTime: activeForkTime, - DurangoTime: mockable.MaxTime, - }, + Ctx: ctx, + Config: defaultTestConfig(t, cortina, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -183,10 +176,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -212,10 +203,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -241,10 +230,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -271,10 +258,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -304,10 +289,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -337,10 +320,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -372,10 +353,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -401,10 +380,8 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { bootstrapped := &utils.Atomic[bool]{} bootstrapped.Set(true) return &Backend{ - Ctx: ctx, - Config: &config.Config{ - DurangoTime: activeForkTime, // activate latest fork - }, + Ctx: ctx, + Config: defaultTestConfig(t, durango, activeForkTime), Bootstrapped: bootstrapped, } }, @@ -445,12 +422,12 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { gomock.Any(), ).Return(ErrFlowCheckFailed) + cfg := defaultTestConfig(t, durango, activeForkTime) + cfg.AddSubnetValidatorFee = 1 + return &Backend{ - FlowChecker: flowChecker, - Config: &config.Config{ - AddSubnetValidatorFee: 1, - DurangoTime: activeForkTime, // activate latest fork, - }, + FlowChecker: flowChecker, + Config: cfg, Ctx: ctx, Bootstrapped: bootstrapped, } @@ -491,12 +468,12 @@ func TestVerifyAddPermissionlessValidatorTx(t *testing.T) { gomock.Any(), ).Return(nil) + cfg := defaultTestConfig(t, durango, activeForkTime) + cfg.AddSubnetValidatorFee = 1 + return &Backend{ - FlowChecker: flowChecker, - Config: &config.Config{ - AddSubnetValidatorFee: 1, - DurangoTime: activeForkTime, // activate latest fork, - }, + FlowChecker: flowChecker, + Config: cfg, Ctx: ctx, Bootstrapped: bootstrapped, } diff --git a/vms/platformvm/txs/executor/standard_tx_executor_test.go b/vms/platformvm/txs/executor/standard_tx_executor_test.go index e7906149a88d..8ecbd1099812 100644 --- a/vms/platformvm/txs/executor/standard_tx_executor_test.go +++ b/vms/platformvm/txs/executor/standard_tx_executor_test.go @@ -20,6 +20,7 @@ import ( "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/hashing" + "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/utils/units" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" @@ -1502,11 +1503,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state.EXPECT().AddUTXO(gomock.Any()).Times(len(env.unsignedTx.Outs)) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1529,11 +1526,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state = state.NewMockDiff(ctrl) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1557,11 +1550,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state.EXPECT().GetPendingValidator(env.unsignedTx.Subnet, env.unsignedTx.NodeID).Return(nil, database.ErrNotFound) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1588,11 +1577,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state.EXPECT().GetCurrentValidator(env.unsignedTx.Subnet, env.unsignedTx.NodeID).Return(&staker, nil).Times(1) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1617,11 +1602,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state.EXPECT().GetCurrentValidator(env.unsignedTx.Subnet, env.unsignedTx.NodeID).Return(env.staker, nil) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1645,11 +1626,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.state.EXPECT().GetSubnetOwner(env.unsignedTx.Subnet).Return(nil, database.ErrNotFound) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1675,11 +1652,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { env.fx.EXPECT().VerifyPermission(gomock.Any(), env.unsignedTx.SubnetAuth, env.tx.Creds[len(env.tx.Creds)-1], subnetOwner).Return(errTest) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1708,11 +1681,7 @@ func TestStandardExecutorRemoveSubnetValidatorTx(t *testing.T) { ).Return(errTest) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1865,11 +1834,7 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { env.state = state.NewMockDiff(ctrl) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1892,11 +1857,7 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { env.state.EXPECT().GetTimestamp().Return(env.latestForkTime) e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - }, + Config: defaultTestConfig(t, durango, env.latestForkTime), Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1918,14 +1879,13 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { env.tx.Creds = nil env.state = state.NewMockDiff(ctrl) env.state.EXPECT().GetTimestamp().Return(env.latestForkTime) + + cfg := defaultTestConfig(t, durango, env.latestForkTime) + cfg.MaxStakeDuration = math.MaxInt64 + e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - MaxStakeDuration: math.MaxInt64, - }, + Config: cfg, Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1952,14 +1912,13 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { env.flowChecker.EXPECT().VerifySpend( gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), ).Return(ErrFlowCheckFailed) + + cfg := defaultTestConfig(t, durango, env.latestForkTime) + cfg.MaxStakeDuration = math.MaxInt64 + e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - MaxStakeDuration: math.MaxInt64, - }, + Config: cfg, Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -1991,14 +1950,13 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { env.state.EXPECT().SetCurrentSupply(env.unsignedTx.Subnet, env.unsignedTx.InitialSupply) env.state.EXPECT().DeleteUTXO(gomock.Any()).Times(len(env.unsignedTx.Ins)) env.state.EXPECT().AddUTXO(gomock.Any()).Times(len(env.unsignedTx.Outs)) + + cfg := defaultTestConfig(t, durango, env.latestForkTime) + cfg.MaxStakeDuration = math.MaxInt64 + e := &StandardTxExecutor{ Backend: &Backend{ - Config: &config.Config{ - BanffTime: env.latestForkTime, - CortinaTime: env.latestForkTime, - DurangoTime: env.latestForkTime, - MaxStakeDuration: math.MaxInt64, - }, + Config: cfg, Bootstrapped: &utils.Atomic[bool]{}, Fx: env.fx, FlowChecker: env.flowChecker, @@ -2024,3 +1982,38 @@ func TestStandardExecutorTransformSubnetTx(t *testing.T) { }) } } + +func defaultTestConfig(t *testing.T, f fork, tm time.Time) *config.Config { + c := &config.Config{ + ApricotPhase3Time: mockable.MaxTime, + ApricotPhase5Time: mockable.MaxTime, + BanffTime: mockable.MaxTime, + CortinaTime: mockable.MaxTime, + DurangoTime: mockable.MaxTime, + EUpgradeTime: mockable.MaxTime, + } + + switch f { + case eUpgrade: + c.EUpgradeTime = tm + fallthrough + case durango: + c.DurangoTime = tm + fallthrough + case cortina: + c.CortinaTime = tm + fallthrough + case banff: + c.BanffTime = tm + fallthrough + case apricotPhase5: + c.ApricotPhase5Time = tm + fallthrough + case apricotPhase3: + c.ApricotPhase3Time = tm + default: + require.FailNow(t, "unhandled fork", f) + } + + return c +} diff --git a/vms/platformvm/validator_set_property_test.go b/vms/platformvm/validator_set_property_test.go index 4ade828c33e7..f0a257ebfe03 100644 --- a/vms/platformvm/validator_set_property_test.go +++ b/vms/platformvm/validator_set_property_test.go @@ -629,6 +629,7 @@ func buildVM(t *testing.T) (*VM, ids.ID, error) { ApricotPhase5Time: forkTime, BanffTime: forkTime, CortinaTime: forkTime, + EUpgradeTime: mockable.MaxTime, }} vm.clock.Set(forkTime.Add(time.Second)) diff --git a/vms/platformvm/vm.go b/vms/platformvm/vm.go index d985b408be05..39896377aba2 100644 --- a/vms/platformvm/vm.go +++ b/vms/platformvm/vm.go @@ -503,10 +503,6 @@ func (vm *VM) Logger() logging.Logger { return vm.ctx.Log } -func (*VM) VerifyHeightIndex(_ context.Context) error { - return nil -} - func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) { return vm.state.GetBlockIDAtHeight(height) } diff --git a/vms/platformvm/vm_regression_test.go b/vms/platformvm/vm_regression_test.go index d30dd2e4d11b..7ea72c61800f 100644 --- a/vms/platformvm/vm_regression_test.go +++ b/vms/platformvm/vm_regression_test.go @@ -380,6 +380,7 @@ func TestUnverifiedParentPanicRegression(t *testing.T) { BanffTime: latestForkTime, CortinaTime: mockable.MaxTime, DurangoTime: mockable.MaxTime, + EUpgradeTime: mockable.MaxTime, }} ctx := snowtest.Context(t, snowtest.PChainID) diff --git a/vms/platformvm/vm_test.go b/vms/platformvm/vm_test.go index 326ff665e002..d8780c44e7c4 100644 --- a/vms/platformvm/vm_test.go +++ b/vms/platformvm/vm_test.go @@ -6,7 +6,6 @@ package platformvm import ( "bytes" "context" - "fmt" "testing" "time" @@ -77,6 +76,7 @@ const ( banff cortina durango + eUpgrade latestFork = durango @@ -211,12 +211,16 @@ func defaultVM(t *testing.T, f fork) (*VM, database.Database, *mutableSharedMemo banffTime = mockable.MaxTime cortinaTime = mockable.MaxTime durangoTime = mockable.MaxTime + eUpgradeTime = mockable.MaxTime ) // always reset latestForkTime (a package level variable) // to ensure test independence latestForkTime = defaultGenesisTime.Add(time.Second) switch f { + case eUpgrade: + eUpgradeTime = latestForkTime + fallthrough case durango: durangoTime = latestForkTime fallthrough @@ -232,7 +236,7 @@ func defaultVM(t *testing.T, f fork) (*VM, database.Database, *mutableSharedMemo case apricotPhase3: apricotPhase3Time = latestForkTime default: - require.NoError(fmt.Errorf("unhandled fork %d", f)) + require.FailNow("unhandled fork", f) } vm := &VM{Config: config.Config{ @@ -255,6 +259,7 @@ func defaultVM(t *testing.T, f fork) (*VM, database.Database, *mutableSharedMemo BanffTime: banffTime, CortinaTime: cortinaTime, DurangoTime: durangoTime, + EUpgradeTime: eUpgradeTime, }} db := memdb.New() @@ -1125,6 +1130,7 @@ func TestRestartFullyAccepted(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} firstCtx := snowtest.Context(t, snowtest.PChainID) @@ -1212,6 +1218,7 @@ func TestRestartFullyAccepted(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} secondCtx := snowtest.Context(t, snowtest.PChainID) @@ -1262,6 +1269,7 @@ func TestBootstrapPartiallyAccepted(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} initialClkTime := latestForkTime.Add(time.Second) @@ -1600,6 +1608,7 @@ func TestUnverifiedParent(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} initialClkTime := latestForkTime.Add(time.Second) @@ -1760,6 +1769,7 @@ func TestUptimeDisallowedWithRestart(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} firstCtx := snowtest.Context(t, snowtest.PChainID) @@ -1808,6 +1818,7 @@ func TestUptimeDisallowedWithRestart(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} secondCtx := snowtest.Context(t, snowtest.PChainID) @@ -1907,6 +1918,7 @@ func TestUptimeDisallowedAfterNeverConnecting(t *testing.T) { BanffTime: latestForkTime, CortinaTime: latestForkTime, DurangoTime: latestForkTime, + EUpgradeTime: mockable.MaxTime, }} ctx := snowtest.Context(t, snowtest.PChainID) diff --git a/vms/proposervm/batched_vm_test.go b/vms/proposervm/batched_vm_test.go index 3564b0b85b8f..a95e9d5e164d 100644 --- a/vms/proposervm/batched_vm_test.go +++ b/vms/proposervm/batched_vm_test.go @@ -1031,9 +1031,6 @@ func initTestRemoteProposerVM( return nil, errUnknownBlock } } - coreVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } proVM := New( coreVM, diff --git a/vms/proposervm/block_server.go b/vms/proposervm/block_server.go deleted file mode 100644 index 6a056c8bc827..000000000000 --- a/vms/proposervm/block_server.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package proposervm - -import ( - "context" - - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/consensus/snowman" - "github.com/ava-labs/avalanchego/vms/proposervm/indexer" -) - -var _ indexer.BlockServer = (*VM)(nil) - -// Note: this is a contention heavy call that should be avoided -// for frequent/repeated indexer ops -func (vm *VM) GetFullPostForkBlock(ctx context.Context, blkID ids.ID) (snowman.Block, error) { - vm.ctx.Lock.Lock() - defer vm.ctx.Lock.Unlock() - - return vm.getPostForkBlock(ctx, blkID) -} - -func (vm *VM) Commit() error { - vm.ctx.Lock.Lock() - defer vm.ctx.Lock.Unlock() - - return vm.db.Commit() -} diff --git a/vms/proposervm/height_indexed_vm.go b/vms/proposervm/height_indexed_vm.go index a29334f6d8dd..49c38a7df07f 100644 --- a/vms/proposervm/height_indexed_vm.go +++ b/vms/proposervm/height_indexed_vm.go @@ -11,64 +11,12 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/engine/snowman/block" ) const pruneCommitPeriod = 1024 -// shouldHeightIndexBeRepaired checks if index needs repairing and stores a -// checkpoint if repairing is needed. -// -// vm.ctx.Lock should be held -func (vm *VM) shouldHeightIndexBeRepaired(ctx context.Context) (bool, error) { - _, err := vm.State.GetCheckpoint() - if err != database.ErrNotFound { - return true, err - } - - // no checkpoint. Either index is complete or repair was never attempted. - // index is complete iff lastAcceptedBlock is indexed - latestProBlkID, err := vm.State.GetLastAccepted() - if err == database.ErrNotFound { - return false, nil - } - if err != nil { - return false, err - } - - lastAcceptedBlk, err := vm.getPostForkBlock(ctx, latestProBlkID) - if err != nil { - // Could not retrieve last accepted block. - return false, err - } - - _, err = vm.State.GetBlockIDAtHeight(lastAcceptedBlk.Height()) - if err != database.ErrNotFound { - return false, err - } - - // Index needs repairing. Mark the checkpoint so that, in case new blocks - // are accepted after the lock is released here but before indexing has - // started, we do not miss rebuilding the full index. - return true, vm.State.SetCheckpoint(latestProBlkID) -} - -// vm.ctx.Lock should be held -func (vm *VM) VerifyHeightIndex(context.Context) error { - if !vm.hIndexer.IsRepaired() { - return block.ErrIndexIncomplete - } - return nil -} - // vm.ctx.Lock should be held func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) { - if !vm.hIndexer.IsRepaired() { - return ids.Empty, block.ErrIndexIncomplete - } - - // The indexer will only report that the index has been repaired if the - // underlying VM supports indexing. switch forkHeight, err := vm.State.GetForkHeight(); err { case nil: if height < forkHeight { @@ -85,32 +33,7 @@ func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, er } } -// As postFork blocks/options are accepted, height index is updated even if its -// repairing is ongoing. vm.ctx.Lock should be held func (vm *VM) updateHeightIndex(height uint64, blkID ids.ID) error { - _, err := vm.State.GetCheckpoint() - switch err { - case nil: - // Index rebuilding is ongoing. We can update the index with the current - // block. - - case database.ErrNotFound: - // No checkpoint means indexing has either not started or is already - // done. - if !vm.hIndexer.IsRepaired() { - return nil - } - - // Indexing must have finished. We can update the index with the current - // block. - - default: - return fmt.Errorf("failed to load index checkpoint: %w", err) - } - return vm.storeHeightEntry(height, blkID) -} - -func (vm *VM) storeHeightEntry(height uint64, blkID ids.ID) error { forkHeight, err := vm.State.GetForkHeight() switch err { case nil: diff --git a/vms/proposervm/indexer/block_server.go b/vms/proposervm/indexer/block_server.go deleted file mode 100644 index fcecaf9e9fcf..000000000000 --- a/vms/proposervm/indexer/block_server.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package indexer - -import ( - "context" - - "github.com/ava-labs/avalanchego/database/versiondb" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/consensus/snowman" -) - -// BlockServer represents all requests heightIndexer can issue -// against ProposerVM. All methods must be thread-safe. -type BlockServer interface { - versiondb.Commitable - - // Note: this is a contention heavy call that should be avoided - // for frequent/repeated indexer ops - GetFullPostForkBlock(ctx context.Context, blkID ids.ID) (snowman.Block, error) -} diff --git a/vms/proposervm/indexer/block_server_test.go b/vms/proposervm/indexer/block_server_test.go deleted file mode 100644 index a973d66a05a9..000000000000 --- a/vms/proposervm/indexer/block_server_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package indexer - -import ( - "context" - "errors" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/consensus/snowman" -) - -var ( - errGetWrappingBlk = errors.New("unexpectedly called GetWrappingBlk") - errCommit = errors.New("unexpectedly called Commit") - - _ BlockServer = (*TestBlockServer)(nil) -) - -// TestBatchedVM is a BatchedVM that is useful for testing. -type TestBlockServer struct { - T *testing.T - - CantGetFullPostForkBlock bool - CantCommit bool - - GetFullPostForkBlockF func(ctx context.Context, blkID ids.ID) (snowman.Block, error) - CommitF func() error -} - -func (tsb *TestBlockServer) GetFullPostForkBlock(ctx context.Context, blkID ids.ID) (snowman.Block, error) { - if tsb.GetFullPostForkBlockF != nil { - return tsb.GetFullPostForkBlockF(ctx, blkID) - } - if tsb.CantGetFullPostForkBlock && tsb.T != nil { - require.FailNow(tsb.T, errGetWrappingBlk.Error()) - } - return nil, errGetWrappingBlk -} - -func (tsb *TestBlockServer) Commit() error { - if tsb.CommitF != nil { - return tsb.CommitF() - } - if tsb.CantCommit && tsb.T != nil { - require.FailNow(tsb.T, errCommit.Error()) - } - return errCommit -} diff --git a/vms/proposervm/indexer/height_indexer.go b/vms/proposervm/indexer/height_indexer.go deleted file mode 100644 index c0a1e4155b3b..000000000000 --- a/vms/proposervm/indexer/height_indexer.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package indexer - -import ( - "context" - "fmt" - "time" - - "go.uber.org/zap" - - "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils" - "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/proposervm/state" -) - -// default number of heights to index before committing -const ( - defaultCommitFrequency = 1024 - // Sleep [sleepDurationMultiplier]x (10x) the amount of time we spend - // processing the block to ensure the async indexing does not bottleneck the - // node. - sleepDurationMultiplier = 10 -) - -var _ HeightIndexer = (*heightIndexer)(nil) - -type HeightIndexer interface { - // Returns whether the height index is fully repaired. - IsRepaired() bool - - // MarkRepaired atomically sets the indexing repaired state. - MarkRepaired(isRepaired bool) - - // Resumes repairing of the height index from the checkpoint. - RepairHeightIndex(context.Context) error -} - -func NewHeightIndexer( - server BlockServer, - log logging.Logger, - indexState state.State, -) HeightIndexer { - return newHeightIndexer(server, log, indexState) -} - -func newHeightIndexer( - server BlockServer, - log logging.Logger, - indexState state.State, -) *heightIndexer { - return &heightIndexer{ - server: server, - log: log, - state: indexState, - commitFrequency: defaultCommitFrequency, - } -} - -type heightIndexer struct { - server BlockServer - log logging.Logger - - jobDone utils.Atomic[bool] - state state.State - - commitFrequency int -} - -func (hi *heightIndexer) IsRepaired() bool { - return hi.jobDone.Get() -} - -func (hi *heightIndexer) MarkRepaired(repaired bool) { - hi.jobDone.Set(repaired) -} - -// RepairHeightIndex ensures the height -> proBlkID height block index is well formed. -// Starting from the checkpoint, it will go back to snowman++ activation fork -// or genesis. PreFork blocks will be handled by innerVM height index. -// RepairHeightIndex can take a non-trivial time to complete; hence we make sure -// the process has limited memory footprint, can be resumed from periodic checkpoints -// and works asynchronously without blocking the VM. -func (hi *heightIndexer) RepairHeightIndex(ctx context.Context) error { - startBlkID, err := hi.state.GetCheckpoint() - if err == database.ErrNotFound { - hi.MarkRepaired(true) - return nil // nothing to do - } - if err != nil { - return err - } - - // retrieve checkpoint height. We explicitly track block height - // in doRepair to avoid heavier DB reads. - startBlk, err := hi.server.GetFullPostForkBlock(ctx, startBlkID) - if err != nil { - return err - } - - startHeight := startBlk.Height() - if err := hi.doRepair(ctx, startBlkID, startHeight); err != nil { - return fmt.Errorf("could not repair height index: %w", err) - } - if err := hi.flush(); err != nil { - return fmt.Errorf("could not write final height index update: %w", err) - } - return nil -} - -// if height index needs repairing, doRepair would do that. It -// iterates back via parents, checking and rebuilding height indexing. -// Note: batch commit is deferred to doRepair caller -func (hi *heightIndexer) doRepair(ctx context.Context, currentProBlkID ids.ID, lastIndexedHeight uint64) error { - var ( - start = time.Now() - lastLogTime = start - indexedBlks int - lastIndexedBlks int - ) - for { - if err := ctx.Err(); err != nil { - return err - } - - processingStart := time.Now() - currentAcceptedBlk, _, err := hi.state.GetBlock(currentProBlkID) - if err == database.ErrNotFound { - // We have visited all the proposerVM blocks. Because we previously - // verified that we needed to perform a repair, we know that this - // will not happen on the first iteration. This guarantees that - // forkHeight will be correctly initialized. - forkHeight := lastIndexedHeight + 1 - if err := hi.state.SetForkHeight(forkHeight); err != nil { - return err - } - if err := hi.state.DeleteCheckpoint(); err != nil { - return err - } - hi.MarkRepaired(true) - - // it will commit on exit - hi.log.Info("indexing finished", - zap.Int("numIndexedBlocks", indexedBlks), - zap.Duration("duration", time.Since(start)), - zap.Uint64("forkHeight", forkHeight), - ) - return nil - } - if err != nil { - return err - } - - // Keep memory footprint under control by committing when a size threshold is reached - if indexedBlks-lastIndexedBlks > hi.commitFrequency { - // Note: checkpoint must be the lowest block in the batch. This ensures that - // checkpoint is the highest un-indexed block from which process would restart. - if err := hi.state.SetCheckpoint(currentProBlkID); err != nil { - return err - } - - if err := hi.flush(); err != nil { - return err - } - - hi.log.Debug("indexed blocks", - zap.Int("numIndexBlocks", indexedBlks), - ) - lastIndexedBlks = indexedBlks - } - - // Rebuild height block index. - if err := hi.state.SetBlockIDAtHeight(lastIndexedHeight, currentProBlkID); err != nil { - return err - } - - // Periodically log progress - indexedBlks++ - now := time.Now() - if now.Sub(lastLogTime) > 15*time.Second { - lastLogTime = now - hi.log.Info("indexed blocks", - zap.Int("numIndexBlocks", indexedBlks), - zap.Uint64("lastIndexedHeight", lastIndexedHeight), - ) - } - - // keep checking the parent - currentProBlkID = currentAcceptedBlk.ParentID() - lastIndexedHeight-- - - processingDuration := time.Since(processingStart) - // Sleep [sleepDurationMultiplier]x (5x) the amount of time we spend processing the block - // to ensure the indexing does not bottleneck the node. - time.Sleep(processingDuration * sleepDurationMultiplier) - } -} - -// flush writes the commits to the underlying DB -func (hi *heightIndexer) flush() error { - if err := hi.state.Commit(); err != nil { - return err - } - return hi.server.Commit() -} diff --git a/vms/proposervm/indexer/height_indexer_test.go b/vms/proposervm/indexer/height_indexer_test.go deleted file mode 100644 index b40f63994e5c..000000000000 --- a/vms/proposervm/indexer/height_indexer_test.go +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package indexer - -import ( - "context" - "math/rand" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/avalanchego/database/memdb" - "github.com/ava-labs/avalanchego/database/versiondb" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow/choices" - "github.com/ava-labs/avalanchego/snow/consensus/snowman" - "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/proposervm/block" - "github.com/ava-labs/avalanchego/vms/proposervm/state" -) - -func TestHeightBlockIndexPostFork(t *testing.T) { - require := require.New(t) - - db := memdb.New() - vdb := versiondb.New(db) - storedState, err := state.New(vdb) - require.NoError(err) - - // Build a chain of post fork blocks - var ( - blkNumber = uint64(10) - lastBlkID = ids.Empty.Prefix(0) // initially set to a dummyGenesisID - proBlks = make(map[ids.ID]snowman.Block) - ) - - for blkHeight := uint64(1); blkHeight <= blkNumber; blkHeight++ { - blockBytes := ids.Empty.Prefix(blkHeight + blkNumber + 1) - dummyTS := time.Time{} - dummyPCH := uint64(2022) - - // store postForkStatelessBlk in State ... - postForkStatelessBlk, err := block.BuildUnsigned( - lastBlkID, - dummyTS, - dummyPCH, - blockBytes[:], - ) - require.NoError(err) - require.NoError(storedState.PutBlock(postForkStatelessBlk, choices.Accepted)) - - // ... and create a corresponding test block just for block server - postForkBlk := &snowman.TestBlock{ - TestDecidable: choices.TestDecidable{ - IDV: postForkStatelessBlk.ID(), - StatusV: choices.Accepted, - }, - HeightV: blkHeight, - } - proBlks[postForkBlk.ID()] = postForkBlk - - lastBlkID = postForkStatelessBlk.ID() - } - - blkSrv := &TestBlockServer{ - CantGetFullPostForkBlock: true, - CantCommit: true, - - GetFullPostForkBlockF: func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - blk, found := proBlks[blkID] - if !found { - return nil, database.ErrNotFound - } - return blk, nil - }, - CommitF: func() error { - return nil - }, - } - - hIndex := newHeightIndexer(blkSrv, - logging.NoLog{}, - storedState, - ) - hIndex.commitFrequency = 0 // commit each block - - // checkpoint last accepted block and show the whole chain in reindexed - require.NoError(hIndex.state.SetCheckpoint(lastBlkID)) - require.NoError(hIndex.RepairHeightIndex(context.Background())) - require.True(hIndex.IsRepaired()) - - // check that height index is fully built - loadedForkHeight, err := storedState.GetForkHeight() - require.NoError(err) - require.Equal(uint64(1), loadedForkHeight) - for height := uint64(1); height <= blkNumber; height++ { - _, err := storedState.GetBlockIDAtHeight(height) - require.NoError(err) - } -} - -func TestHeightBlockIndexAcrossFork(t *testing.T) { - require := require.New(t) - - db := memdb.New() - vdb := versiondb.New(db) - storedState, err := state.New(vdb) - require.NoError(err) - - // Build a chain of post fork blocks - var ( - blkNumber = uint64(10) - forkHeight = blkNumber / 2 - lastBlkID = ids.Empty.Prefix(0) // initially set to a last pre fork blk - proBlks = make(map[ids.ID]snowman.Block) - ) - - for blkHeight := forkHeight; blkHeight <= blkNumber; blkHeight++ { - blockBytes := ids.Empty.Prefix(blkHeight + blkNumber + 1) - dummyTS := time.Time{} - dummyPCH := uint64(2022) - - // store postForkStatelessBlk in State ... - postForkStatelessBlk, err := block.BuildUnsigned( - lastBlkID, - dummyTS, - dummyPCH, - blockBytes[:], - ) - require.NoError(err) - require.NoError(storedState.PutBlock(postForkStatelessBlk, choices.Accepted)) - - // ... and create a corresponding test block just for block server - postForkBlk := &snowman.TestBlock{ - TestDecidable: choices.TestDecidable{ - IDV: postForkStatelessBlk.ID(), - StatusV: choices.Accepted, - }, - HeightV: blkHeight, - } - proBlks[postForkBlk.ID()] = postForkBlk - - lastBlkID = postForkStatelessBlk.ID() - } - - blkSrv := &TestBlockServer{ - CantGetFullPostForkBlock: true, - CantCommit: true, - - GetFullPostForkBlockF: func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - blk, found := proBlks[blkID] - if !found { - return nil, database.ErrNotFound - } - return blk, nil - }, - CommitF: func() error { - return nil - }, - } - - hIndex := newHeightIndexer(blkSrv, - logging.NoLog{}, - storedState, - ) - hIndex.commitFrequency = 0 // commit each block - - // checkpoint last accepted block and show the whole chain in reindexed - require.NoError(hIndex.state.SetCheckpoint(lastBlkID)) - require.NoError(hIndex.RepairHeightIndex(context.Background())) - require.True(hIndex.IsRepaired()) - - // check that height index is fully built - loadedForkHeight, err := storedState.GetForkHeight() - require.NoError(err) - require.Equal(forkHeight, loadedForkHeight) - for height := uint64(0); height < forkHeight; height++ { - _, err := storedState.GetBlockIDAtHeight(height) - require.ErrorIs(err, database.ErrNotFound) - } - for height := forkHeight; height <= blkNumber; height++ { - _, err := storedState.GetBlockIDAtHeight(height) - require.NoError(err) - } -} - -func TestHeightBlockIndexResumeFromCheckPoint(t *testing.T) { - require := require.New(t) - - db := memdb.New() - vdb := versiondb.New(db) - storedState, err := state.New(vdb) - require.NoError(err) - - // Build a chain of post fork blocks - var ( - blkNumber = uint64(10) - forkHeight = blkNumber / 2 - lastBlkID = ids.Empty.Prefix(0) // initially set to a last pre fork blk - proBlks = make(map[ids.ID]snowman.Block) - ) - - for blkHeight := forkHeight; blkHeight <= blkNumber; blkHeight++ { - blockBytes := ids.Empty.Prefix(blkHeight + blkNumber + 1) - dummyTS := time.Time{} - dummyPCH := uint64(2022) - - // store postForkStatelessBlk in State ... - postForkStatelessBlk, err := block.BuildUnsigned( - lastBlkID, - dummyTS, - dummyPCH, - blockBytes[:], - ) - require.NoError(err) - require.NoError(storedState.PutBlock(postForkStatelessBlk, choices.Accepted)) - - // ... and create a corresponding test block just for block server - postForkBlk := &snowman.TestBlock{ - TestDecidable: choices.TestDecidable{ - IDV: postForkStatelessBlk.ID(), - StatusV: choices.Accepted, - }, - HeightV: blkHeight, - } - proBlks[postForkBlk.ID()] = postForkBlk - - lastBlkID = postForkStatelessBlk.ID() - } - - blkSrv := &TestBlockServer{ - CantGetFullPostForkBlock: true, - CantCommit: true, - - GetFullPostForkBlockF: func(_ context.Context, blkID ids.ID) (snowman.Block, error) { - blk, found := proBlks[blkID] - if !found { - return nil, database.ErrNotFound - } - return blk, nil - }, - CommitF: func() error { - return nil - }, - } - - hIndex := newHeightIndexer(blkSrv, - logging.NoLog{}, - storedState, - ) - hIndex.commitFrequency = 0 // commit each block - - // pick a random block in the chain and checkpoint it;... - rndPostForkHeight := rand.Intn(int(blkNumber-forkHeight)) + int(forkHeight) // #nosec G404 - var checkpointBlk snowman.Block - for _, blk := range proBlks { - if blk.Height() != uint64(rndPostForkHeight) { - continue // not the blk we are looking for - } - - checkpointBlk = blk - require.NoError(hIndex.state.SetCheckpoint(checkpointBlk.ID())) - break - } - - // perform repair and show index is built - require.NoError(hIndex.RepairHeightIndex(context.Background())) - require.True(hIndex.IsRepaired()) - - // check that height index is fully built - loadedForkHeight, err := storedState.GetForkHeight() - require.NoError(err) - require.Equal(forkHeight, loadedForkHeight) - for height := forkHeight; height <= checkpointBlk.Height(); height++ { - _, err := storedState.GetBlockIDAtHeight(height) - require.NoError(err) - } -} diff --git a/vms/proposervm/state/block_height_index.go b/vms/proposervm/state/block_height_index.go index b60fca0c363d..4a7ed4362c68 100644 --- a/vms/proposervm/state/block_height_index.go +++ b/vms/proposervm/state/block_height_index.go @@ -19,8 +19,7 @@ var ( heightPrefix = []byte("height") metadataPrefix = []byte("metadata") - forkKey = []byte("fork") - checkpointKey = []byte("checkpoint") + forkKey = []byte("fork") ) type HeightIndexGetter interface { @@ -40,23 +39,11 @@ type HeightIndexWriter interface { DeleteBlockIDAtHeight(height uint64) error } -// A checkpoint is the blockID of the next block to be considered -// for height indexing. We store checkpoints to be able to duly resume -// long-running re-indexing ops. -type HeightIndexBatchSupport interface { - versiondb.Commitable - - GetCheckpoint() (ids.ID, error) - SetCheckpoint(blkID ids.ID) error - DeleteCheckpoint() error -} - // HeightIndex contains mapping of blockHeights to accepted proposer block IDs // along with some metadata (fork height and checkpoint). type HeightIndex interface { HeightIndexWriter HeightIndexGetter - HeightIndexBatchSupport } type heightIndex struct { @@ -127,15 +114,3 @@ func (hi *heightIndex) GetForkHeight() (uint64, error) { func (hi *heightIndex) SetForkHeight(height uint64) error { return database.PutUInt64(hi.metadataDB, forkKey, height) } - -func (hi *heightIndex) GetCheckpoint() (ids.ID, error) { - return database.GetID(hi.metadataDB, checkpointKey) -} - -func (hi *heightIndex) SetCheckpoint(blkID ids.ID) error { - return database.PutID(hi.metadataDB, checkpointKey, blkID) -} - -func (hi *heightIndex) DeleteCheckpoint() error { - return hi.metadataDB.Delete(checkpointKey) -} diff --git a/vms/proposervm/state/mock_state.go b/vms/proposervm/state/mock_state.go index ab2fc8aeb0af..a70fa26ef39e 100644 --- a/vms/proposervm/state/mock_state.go +++ b/vms/proposervm/state/mock_state.go @@ -41,20 +41,6 @@ func (m *MockState) EXPECT() *MockStateMockRecorder { return m.recorder } -// Commit mocks base method. -func (m *MockState) Commit() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Commit") - ret0, _ := ret[0].(error) - return ret0 -} - -// Commit indicates an expected call of Commit. -func (mr *MockStateMockRecorder) Commit() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockState)(nil).Commit)) -} - // DeleteBlock mocks base method. func (m *MockState) DeleteBlock(arg0 ids.ID) error { m.ctrl.T.Helper() @@ -83,20 +69,6 @@ func (mr *MockStateMockRecorder) DeleteBlockIDAtHeight(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBlockIDAtHeight", reflect.TypeOf((*MockState)(nil).DeleteBlockIDAtHeight), arg0) } -// DeleteCheckpoint mocks base method. -func (m *MockState) DeleteCheckpoint() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteCheckpoint") - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteCheckpoint indicates an expected call of DeleteCheckpoint. -func (mr *MockStateMockRecorder) DeleteCheckpoint() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCheckpoint", reflect.TypeOf((*MockState)(nil).DeleteCheckpoint)) -} - // DeleteLastAccepted mocks base method. func (m *MockState) DeleteLastAccepted() error { m.ctrl.T.Helper() @@ -156,21 +128,6 @@ func (mr *MockStateMockRecorder) GetBlockIDAtHeight(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBlockIDAtHeight", reflect.TypeOf((*MockState)(nil).GetBlockIDAtHeight), arg0) } -// GetCheckpoint mocks base method. -func (m *MockState) GetCheckpoint() (ids.ID, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetCheckpoint") - ret0, _ := ret[0].(ids.ID) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCheckpoint indicates an expected call of GetCheckpoint. -func (mr *MockStateMockRecorder) GetCheckpoint() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCheckpoint", reflect.TypeOf((*MockState)(nil).GetCheckpoint)) -} - // GetForkHeight mocks base method. func (m *MockState) GetForkHeight() (uint64, error) { m.ctrl.T.Helper() @@ -288,20 +245,6 @@ func (mr *MockStateMockRecorder) SetBlockIDAtHeight(arg0, arg1 any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockIDAtHeight", reflect.TypeOf((*MockState)(nil).SetBlockIDAtHeight), arg0, arg1) } -// SetCheckpoint mocks base method. -func (m *MockState) SetCheckpoint(arg0 ids.ID) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetCheckpoint", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetCheckpoint indicates an expected call of SetCheckpoint. -func (mr *MockStateMockRecorder) SetCheckpoint(arg0 any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCheckpoint", reflect.TypeOf((*MockState)(nil).SetCheckpoint), arg0) -} - // SetForkHeight mocks base method. func (m *MockState) SetForkHeight(arg0 uint64) error { m.ctrl.T.Helper() diff --git a/vms/proposervm/state_syncable_vm.go b/vms/proposervm/state_syncable_vm.go index 08a321cab7bb..12f61e057396 100644 --- a/vms/proposervm/state_syncable_vm.go +++ b/vms/proposervm/state_syncable_vm.go @@ -19,12 +19,6 @@ func (vm *VM) StateSyncEnabled(ctx context.Context) (bool, error) { return false, nil } - // if vm implements Snowman++, a block height index must be available - // to support state sync - if vm.VerifyHeightIndex(ctx) != nil { - return false, nil - } - return vm.ssVM.StateSyncEnabled(ctx) } @@ -100,12 +94,6 @@ func (vm *VM) GetStateSummary(ctx context.Context, height uint64) (block.StateSu // Note: building state summary requires a well formed height index. func (vm *VM) buildStateSummary(ctx context.Context, innerSummary block.StateSummary) (block.StateSummary, error) { - // if vm implements Snowman++, a block height index must be available - // to support state sync - if err := vm.VerifyHeightIndex(ctx); err != nil { - return nil, fmt.Errorf("could not build state summary: %w", err) - } - forkHeight, err := vm.GetForkHeight() switch err { case nil: diff --git a/vms/proposervm/state_syncable_vm_test.go b/vms/proposervm/state_syncable_vm_test.go index 0fa24de139d1..d03f3c3d1c58 100644 --- a/vms/proposervm/state_syncable_vm_test.go +++ b/vms/proposervm/state_syncable_vm_test.go @@ -39,11 +39,6 @@ func helperBuildStateSyncTestObjects(t *testing.T) (*fullVM, *VM) { }, } - // signal height index is complete - innerVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } - // load innerVM expectations innerGenesisBlk := &snowman.TestBlock{ TestDecidable: choices.TestDecidable{ @@ -58,9 +53,6 @@ func helperBuildStateSyncTestObjects(t *testing.T) (*fullVM, *VM) { ) error { return nil } - innerVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } innerVM.LastAcceptedF = func(context.Context) (ids.ID, error) { return innerGenesisBlk.ID(), nil } @@ -109,7 +101,6 @@ func TestStateSyncEnabled(t *testing.T) { }() // ProposerVM State Sync disabled if innerVM State sync is disabled - vm.hIndexer.MarkRepaired(true) innerVM.StateSyncEnabledF = func(context.Context) (bool, error) { return false, nil } @@ -172,7 +163,6 @@ func TestStateSyncGetOngoingSyncStateSummary(t *testing.T) { require.Equal(innerSummary.Bytes(), summary.Bytes()) // Post fork summary case - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // store post fork block associated with summary @@ -257,7 +247,6 @@ func TestStateSyncGetLastStateSummary(t *testing.T) { require.Equal(innerSummary.Bytes(), summary.Bytes()) // Post fork summary case - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // store post fork block associated with summary @@ -345,7 +334,6 @@ func TestStateSyncGetStateSummary(t *testing.T) { require.Equal(innerSummary.Bytes(), summary.Bytes()) // Post fork summary case - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // store post fork block associated with summary @@ -418,7 +406,6 @@ func TestParseStateSummary(t *testing.T) { require.Equal(summary.Bytes(), parsedSummary.Bytes()) // Get a post fork block than parse it - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // store post fork block associated with summary @@ -477,7 +464,6 @@ func TestStateSummaryAccept(t *testing.T) { BytesV: []byte{'i', 'n', 'n', 'e', 'r'}, } - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // store post fork block associated with summary @@ -545,7 +531,6 @@ func TestStateSummaryAcceptOlderBlock(t *testing.T) { BytesV: []byte{'i', 'n', 'n', 'e', 'r'}, } - vm.hIndexer.MarkRepaired(true) require.NoError(vm.SetForkHeight(innerSummary.Height() - 1)) // Set the last accepted block height to be higher that the state summary @@ -598,54 +583,3 @@ func TestStateSummaryAcceptOlderBlock(t *testing.T) { require.NoError(err) require.Equal(block.StateSyncSkipped, status) } - -func TestNoStateSummariesServedWhileRepairingHeightIndex(t *testing.T) { - require := require.New(t) - - // Note: by default proVM is built such that heightIndex will be considered complete - var ( - activationTime = time.Unix(0, 0) - durangoTime = activationTime - ) - coreVM, _, proVM, _, _ := initTestProposerVM(t, activationTime, durangoTime, 0) - defer func() { - require.NoError(proVM.Shutdown(context.Background())) - }() - - require.NoError(proVM.VerifyHeightIndex(context.Background())) - - // let coreVM be always ready to serve summaries - summaryHeight := uint64(2022) - coreStateSummary := &block.TestStateSummary{ - T: t, - IDV: ids.ID{'a', 'a', 'a', 'a'}, - HeightV: summaryHeight, - BytesV: []byte{'c', 'o', 'r', 'e', 'S', 'u', 'm', 'm', 'a', 'r', 'y'}, - } - coreVM.GetLastStateSummaryF = func(context.Context) (block.StateSummary, error) { - return coreStateSummary, nil - } - coreVM.GetStateSummaryF = func(_ context.Context, height uint64) (block.StateSummary, error) { - require.Equal(summaryHeight, height) - return coreStateSummary, nil - } - - // set height index to reindexing - proVM.hIndexer.MarkRepaired(false) - err := proVM.VerifyHeightIndex(context.Background()) - require.ErrorIs(err, block.ErrIndexIncomplete) - - _, err = proVM.GetLastStateSummary(context.Background()) - require.ErrorIs(err, block.ErrIndexIncomplete) - - _, err = proVM.GetStateSummary(context.Background(), summaryHeight) - require.ErrorIs(err, block.ErrIndexIncomplete) - - // declare height index complete - proVM.hIndexer.MarkRepaired(true) - require.NoError(proVM.VerifyHeightIndex(context.Background())) - - summary, err := proVM.GetLastStateSummary(context.Background()) - require.NoError(err) - require.Equal(summaryHeight, summary.Height()) -} diff --git a/vms/proposervm/vm.go b/vms/proposervm/vm.go index e2564d77b63c..bb5cd26c2e37 100644 --- a/vms/proposervm/vm.go +++ b/vms/proposervm/vm.go @@ -28,7 +28,6 @@ import ( "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/avalanchego/vms/proposervm/indexer" "github.com/ava-labs/avalanchego/vms/proposervm/proposer" "github.com/ava-labs/avalanchego/vms/proposervm/scheduler" "github.com/ava-labs/avalanchego/vms/proposervm/state" @@ -59,8 +58,6 @@ var ( fujiXChainID = ids.FromStringOrPanic("2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm") dbPrefix = []byte("proposervm") - - errHeightIndexInvalidWhilePruning = errors.New("height index invalid while pruning old blocks") ) func cachedBlockSize(_ ids.ID, blk snowman.Block) int { @@ -75,7 +72,6 @@ type VM struct { ssVM block.StateSyncableVM state.State - hIndexer indexer.HeightIndexer proposer.Windower tree.Tree @@ -177,13 +173,6 @@ func (vm *VM) Initialize( } vm.innerBlkCache = innerBlkCache - indexerDB := versiondb.New(vm.db) - indexerState, err := state.New(indexerDB) - if err != nil { - return err - } - vm.hIndexer = indexer.NewHeightIndexer(vm, vm.ctx.Log, indexerState) - scheduler, vmToEngine := scheduler.New(vm.ctx.Log, toEngine) vm.Scheduler = scheduler vm.toScheduler = vmToEngine @@ -213,7 +202,7 @@ func (vm *VM) Initialize( return err } - if err := vm.repair(detachedCtx); err != nil { + if err := vm.repairAcceptedChainByHeight(ctx); err != nil { return err } @@ -437,174 +426,6 @@ func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error) { return lastAccepted, err } -// repair makes sure that vm and innerVM chains are in sync. -// Moreover it fixes vm's height index if defined. -func (vm *VM) repair(ctx context.Context) error { - switch err := vm.ChainVM.VerifyHeightIndex(ctx); err { - case nil: - // InnerVM height index is complete. We can immediately verify - // and repair this VM height index. - shouldRepair, err := vm.shouldHeightIndexBeRepaired(ctx) - if err != nil { - return err - } - if !shouldRepair { - vm.ctx.Log.Info("block height index was successfully verified") - vm.hIndexer.MarkRepaired(true) - return vm.repairAcceptedChainByHeight(ctx) - } - case block.ErrIndexIncomplete: - default: - return err - } - - if vm.NumHistoricalBlocks != 0 { - vm.ctx.Log.Fatal("block height index must be valid when pruning historical blocks") - return errHeightIndexInvalidWhilePruning - } - - // innerVM height index is incomplete. Sync vm and innerVM chains first. - if err := vm.repairAcceptedChainByIteration(ctx); err != nil { - return err - } - - // asynchronously rebuild height index, if needed - go func() { - // Poll until the underlying chain's index is complete or shutdown is - // called. - ticker := time.NewTicker(checkIndexedFrequency) - defer ticker.Stop() - for { - // The underlying VM expects the lock to be held here. - vm.ctx.Lock.Lock() - err := vm.ChainVM.VerifyHeightIndex(ctx) - vm.ctx.Lock.Unlock() - - if err == nil { - // innerVM indexing complete. Let's re-index this VM - break - } - if err != block.ErrIndexIncomplete { - vm.ctx.Log.Error("block height indexing failed", - zap.Error(err), - ) - return - } - - // innerVM index is incomplete. Wait for completion and retry - select { - case <-vm.context.Done(): - return - case <-ticker.C: - } - } - - vm.ctx.Lock.Lock() - shouldRepair, err := vm.shouldHeightIndexBeRepaired(ctx) - vm.ctx.Lock.Unlock() - - if err != nil { - vm.ctx.Log.Error("could not verify height indexing status", - zap.Error(err), - ) - return - } - if !shouldRepair { - vm.ctx.Log.Info("block height indexing is already complete") - vm.hIndexer.MarkRepaired(true) - return - } - - err = vm.hIndexer.RepairHeightIndex(vm.context) - if err == nil { - vm.ctx.Log.Info("block height indexing finished") - return - } - - // Note that we don't check if `err` is `context.Canceled` here because - // repairing the height index may have returned a non-standard error - // due to the chain shutting down. - if vm.context.Err() == nil { - // The context wasn't closed, so the chain hasn't been shutdown. - // This must have been an unexpected error. - vm.ctx.Log.Error("block height indexing failed", - zap.Error(err), - ) - } - }() - return nil -} - -func (vm *VM) repairAcceptedChainByIteration(ctx context.Context) error { - lastAcceptedID, err := vm.GetLastAccepted() - if err == database.ErrNotFound { - // If the last accepted block isn't indexed yet, then the underlying - // chain is the only chain and there is nothing to repair. - return nil - } - if err != nil { - return err - } - - // Revert accepted blocks that weren't committed to the database. - for { - lastAccepted, err := vm.getPostForkBlock(ctx, lastAcceptedID) - if err == database.ErrNotFound { - // If the post fork block can't be found, it's because we're - // reverting past the fork boundary. If this is the case, then there - // is only one database to keep consistent, so there is nothing to - // repair anymore. - if err := vm.State.DeleteLastAccepted(); err != nil { - return err - } - if err := vm.State.DeleteCheckpoint(); err != nil { - return err - } - return vm.db.Commit() - } - if err != nil { - return err - } - - shouldBeAccepted := lastAccepted.getInnerBlk() - - // If the inner block is accepted, then we don't need to revert any more - // blocks. - if shouldBeAccepted.Status() == choices.Accepted { - return vm.db.Commit() - } - - // Mark the last accepted block as processing - rather than accepted. - lastAccepted.setStatus(choices.Processing) - if err := vm.State.PutBlock(lastAccepted.getStatelessBlk(), choices.Processing); err != nil { - return err - } - - // Advance to the parent block - previousLastAcceptedID := lastAcceptedID - lastAcceptedID = lastAccepted.Parent() - if err := vm.State.SetLastAccepted(lastAcceptedID); err != nil { - return err - } - - // If the indexer checkpoint was previously pointing to the last - // accepted block, roll it back to the new last accepted block. - checkpoint, err := vm.State.GetCheckpoint() - if err == database.ErrNotFound { - continue - } - if err != nil { - return err - } - if previousLastAcceptedID != checkpoint { - continue - } - if err := vm.State.SetCheckpoint(lastAcceptedID); err != nil { - return err - } - } -} - func (vm *VM) repairAcceptedChainByHeight(ctx context.Context) error { innerLastAcceptedID, err := vm.ChainVM.LastAccepted(ctx) if err != nil { diff --git a/vms/proposervm/vm_regression_test.go b/vms/proposervm/vm_regression_test.go deleted file mode 100644 index ac34df120641..000000000000 --- a/vms/proposervm/vm_regression_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package proposervm - -import ( - "context" - "errors" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/avalanchego/database/memdb" - "github.com/ava-labs/avalanchego/database/prefixdb" - "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/snow/engine/snowman/block" - "github.com/ava-labs/avalanchego/snow/snowtest" -) - -func TestProposerVMInitializeShouldFailIfInnerVMCantVerifyItsHeightIndex(t *testing.T) { - require := require.New(t) - - innerVM := &fullVM{ - TestVM: &block.TestVM{ - TestVM: common.TestVM{ - T: t, - }, - }, - } - - // let innerVM fail verifying its height index with - // a non-special error (like block.ErrIndexIncomplete) - customError := errors.New("custom error") - innerVM.VerifyHeightIndexF = func(_ context.Context) error { - return customError - } - - innerVM.InitializeF = func(context.Context, *snow.Context, database.Database, - []byte, []byte, []byte, chan<- common.Message, - []*common.Fx, common.AppSender, - ) error { - return nil - } - - proVM := New( - innerVM, - Config{ - ActivationTime: time.Unix(0, 0), - DurangoTime: time.Unix(0, 0), - MinimumPChainHeight: 0, - MinBlkDelay: DefaultMinBlockDelay, - NumHistoricalBlocks: DefaultNumHistoricalBlocks, - StakingLeafSigner: pTestSigner, - StakingCertLeaf: pTestCert, - }, - ) - - defer func() { - // avoids leaking goroutines - require.NoError(proVM.Shutdown(context.Background())) - }() - - ctx := snowtest.Context(t, snowtest.CChainID) - initialState := []byte("genesis state") - - err := proVM.Initialize( - context.Background(), - ctx, - prefixdb.New([]byte{}, memdb.New()), - initialState, - nil, - nil, - nil, - nil, - nil, - ) - require.ErrorIs(err, customError) -} diff --git a/vms/proposervm/vm_test.go b/vms/proposervm/vm_test.go index 688f44e10ef0..d28d51ba9ffc 100644 --- a/vms/proposervm/vm_test.go +++ b/vms/proposervm/vm_test.go @@ -190,11 +190,6 @@ func initTestProposerVM( db := prefixdb.New([]byte{0}, memdb.New()) - // signal height index is complete - coreVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } - require.NoError(proVM.Initialize( context.Background(), ctx, @@ -1000,9 +995,6 @@ func TestExpiredBuildBlock(t *testing.T) { toScheduler = toEngineChan return nil } - coreVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } // make sure that DBs are compressed correctly require.NoError(proVM.Initialize( @@ -1290,9 +1282,6 @@ func TestInnerVMRollback(t *testing.T) { ) error { return nil } - coreVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } db := memdb.New() @@ -1382,9 +1371,6 @@ func TestInnerVMRollback(t *testing.T) { // Restart the node and have the inner VM rollback state. require.NoError(proVM.Shutdown(context.Background())) coreBlk.StatusV = choices.Processing - coreVM.VerifyHeightIndexF = func(context.Context) error { - return nil - } proVM = New( coreVM, @@ -1856,9 +1842,6 @@ func TestRejectedHeightNotIndexed(t *testing.T) { TestVM: common.TestVM{ T: t, }, - VerifyHeightIndexF: func(context.Context) error { - return nil - }, GetBlockIDAtHeightF: func(_ context.Context, height uint64) (ids.ID, error) { if height >= uint64(len(coreHeights)) { return ids.ID{}, errTooHigh @@ -1968,14 +1951,6 @@ func TestRejectedHeightNotIndexed(t *testing.T) { require.NoError(proVM.SetPreference(context.Background(), coreGenBlk.IDV)) - ctx.Lock.Lock() - for proVM.VerifyHeightIndex(context.Background()) != nil { - ctx.Lock.Unlock() - time.Sleep(time.Millisecond) - ctx.Lock.Lock() - } - ctx.Lock.Unlock() - // create inner block X and outer block A xBlock := &snowman.TestBlock{ TestDecidable: choices.TestDecidable{ @@ -2066,9 +2041,6 @@ func TestRejectedOptionHeightNotIndexed(t *testing.T) { TestVM: common.TestVM{ T: t, }, - VerifyHeightIndexF: func(context.Context) error { - return nil - }, GetBlockIDAtHeightF: func(_ context.Context, height uint64) (ids.ID, error) { if height >= uint64(len(coreHeights)) { return ids.ID{}, errTooHigh @@ -2178,14 +2150,6 @@ func TestRejectedOptionHeightNotIndexed(t *testing.T) { require.NoError(proVM.SetPreference(context.Background(), coreGenBlk.IDV)) - ctx.Lock.Lock() - for proVM.VerifyHeightIndex(context.Background()) != nil { - ctx.Lock.Unlock() - time.Sleep(time.Millisecond) - ctx.Lock.Lock() - } - ctx.Lock.Unlock() - xBlockID := ids.GenerateTestID() xBlock := &TestOptionsBlock{ TestBlock: snowman.TestBlock{ @@ -2293,7 +2257,6 @@ func TestVMInnerBlkCache(t *testing.T) { gomock.Any(), gomock.Any(), ).Return(nil) - innerVM.EXPECT().VerifyHeightIndex(gomock.Any()).Return(nil) innerVM.EXPECT().Shutdown(gomock.Any()).Return(nil) { @@ -2534,7 +2497,6 @@ func TestVM_VerifyBlockWithContext(t *testing.T) { gomock.Any(), gomock.Any(), ).Return(nil) - innerVM.EXPECT().VerifyHeightIndex(gomock.Any()).Return(nil) innerVM.EXPECT().Shutdown(gomock.Any()).Return(nil) { @@ -2692,9 +2654,6 @@ func TestHistoricalBlockDeletion(t *testing.T) { } return nil, errUnknownBlock }, - VerifyHeightIndexF: func(context.Context) error { - return nil - }, GetBlockIDAtHeightF: func(_ context.Context, height uint64) (ids.ID, error) { if height >= uint64(len(acceptedBlocks)) { return ids.ID{}, errTooHigh @@ -2751,7 +2710,6 @@ func TestHistoricalBlockDeletion(t *testing.T) { require.NoError(proVM.SetState(context.Background(), snow.NormalOp)) require.NoError(proVM.SetPreference(context.Background(), lastAcceptedID)) - require.NoError(proVM.VerifyHeightIndex(context.Background())) issueBlock := func() { lastAcceptedBlock := acceptedBlocks[currentHeight] @@ -2852,7 +2810,6 @@ func TestHistoricalBlockDeletion(t *testing.T) { require.NoError(proVM.SetState(context.Background(), snow.NormalOp)) require.NoError(proVM.SetPreference(context.Background(), lastAcceptedID)) - require.NoError(proVM.VerifyHeightIndex(context.Background())) // Verify that old blocks were pruned during startup requireNumHeights(numHistoricalBlocks) @@ -2900,7 +2857,6 @@ func TestHistoricalBlockDeletion(t *testing.T) { require.NoError(proVM.SetState(context.Background(), snow.NormalOp)) require.NoError(proVM.SetPreference(context.Background(), lastAcceptedID)) - require.NoError(proVM.VerifyHeightIndex(context.Background())) // The height index shouldn't be modified at this point requireNumHeights(numHistoricalBlocks) diff --git a/vms/rpcchainvm/errors.go b/vms/rpcchainvm/errors.go index 4b434b51d425..37d043fe2797 100644 --- a/vms/rpcchainvm/errors.go +++ b/vms/rpcchainvm/errors.go @@ -14,13 +14,11 @@ var ( errEnumToError = map[vmpb.Error]error{ vmpb.Error_ERROR_CLOSED: database.ErrClosed, vmpb.Error_ERROR_NOT_FOUND: database.ErrNotFound, - vmpb.Error_ERROR_HEIGHT_INDEX_INCOMPLETE: block.ErrIndexIncomplete, vmpb.Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED: block.ErrStateSyncableVMNotImplemented, } errorToErrEnum = map[error]vmpb.Error{ database.ErrClosed: vmpb.Error_ERROR_CLOSED, database.ErrNotFound: vmpb.Error_ERROR_NOT_FOUND, - block.ErrIndexIncomplete: vmpb.Error_ERROR_HEIGHT_INDEX_INCOMPLETE, block.ErrStateSyncableVMNotImplemented: vmpb.Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED, } ) diff --git a/vms/rpcchainvm/vm_client.go b/vms/rpcchainvm/vm_client.go index aa04477d62d4..04a3c8fd308f 100644 --- a/vms/rpcchainvm/vm_client.go +++ b/vms/rpcchainvm/vm_client.go @@ -667,14 +667,6 @@ func (vm *VMClient) batchedParseBlock(ctx context.Context, blksBytes [][]byte) ( return res, nil } -func (vm *VMClient) VerifyHeightIndex(ctx context.Context) error { - resp, err := vm.client.VerifyHeightIndex(ctx, &emptypb.Empty{}) - if err != nil { - return err - } - return errEnumToError[resp.Err] -} - func (vm *VMClient) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) { resp, err := vm.client.GetBlockIDAtHeight( ctx, diff --git a/vms/rpcchainvm/vm_server.go b/vms/rpcchainvm/vm_server.go index 866c58a85844..96132792725d 100644 --- a/vms/rpcchainvm/vm_server.go +++ b/vms/rpcchainvm/vm_server.go @@ -627,13 +627,6 @@ func (vm *VMServer) BatchedParseBlock( }, nil } -func (vm *VMServer) VerifyHeightIndex(ctx context.Context, _ *emptypb.Empty) (*vmpb.VerifyHeightIndexResponse, error) { - err := vm.vm.VerifyHeightIndex(ctx) - return &vmpb.VerifyHeightIndexResponse{ - Err: errorToErrEnum[err], - }, errorToRPCError(err) -} - func (vm *VMServer) GetBlockIDAtHeight( ctx context.Context, req *vmpb.GetBlockIDAtHeightRequest, diff --git a/vms/tracedvm/block_vm.go b/vms/tracedvm/block_vm.go index b32b3bcd4593..13bb1a5d7b7c 100644 --- a/vms/tracedvm/block_vm.go +++ b/vms/tracedvm/block_vm.go @@ -50,7 +50,6 @@ type blockVM struct { getAncestorsTag string batchedParseBlockTag string // HeightIndexedChainVM tags - verifyHeightIndexTag string getBlockIDAtHeightTag string // StateSyncableVM tags stateSyncEnabledTag string @@ -85,7 +84,6 @@ func NewBlockVM(vm block.ChainVM, name string, tracer trace.Tracer) block.ChainV buildBlockWithContextTag: name + ".buildBlockWithContext", getAncestorsTag: name + ".getAncestors", batchedParseBlockTag: name + ".batchedParseBlock", - verifyHeightIndexTag: name + ".verifyHeightIndex", getBlockIDAtHeightTag: name + ".getBlockIDAtHeight", stateSyncEnabledTag: name + ".stateSyncEnabled", getOngoingSyncStateSummaryTag: name + ".getOngoingSyncStateSummary", @@ -176,13 +174,6 @@ func (vm *blockVM) LastAccepted(ctx context.Context) (ids.ID, error) { return vm.ChainVM.LastAccepted(ctx) } -func (vm *blockVM) VerifyHeightIndex(ctx context.Context) error { - ctx, span := vm.tracer.Start(ctx, vm.verifyHeightIndexTag) - defer span.End() - - return vm.ChainVM.VerifyHeightIndex(ctx) -} - func (vm *blockVM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error) { ctx, span := vm.tracer.Start(ctx, vm.getBlockIDAtHeightTag, oteltrace.WithAttributes( attribute.Int64("height", int64(height)), diff --git a/wallet/chain/p/backend.go b/wallet/chain/p/backend.go index 5b8001808ceb..ed8e6a4f8830 100644 --- a/wallet/chain/p/backend.go +++ b/wallet/chain/p/backend.go @@ -4,6 +4,7 @@ package p import ( + "context" "sync" "github.com/ava-labs/avalanchego/database" @@ -13,31 +14,31 @@ import ( "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/fx" "github.com/ava-labs/avalanchego/vms/platformvm/txs" + "github.com/ava-labs/avalanchego/wallet/chain/p/builder" + "github.com/ava-labs/avalanchego/wallet/chain/p/signer" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" - - stdcontext "context" ) var _ Backend = (*backend)(nil) // Backend defines the full interface required to support a P-chain wallet. type Backend interface { - common.ChainUTXOs - BuilderBackend - SignerBackend + builder.Backend + signer.Backend - AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error + AcceptTx(ctx context.Context, tx *txs.Tx) error } type backend struct { - Context common.ChainUTXOs + context *builder.Context + subnetOwnerLock sync.RWMutex subnetOwner map[ids.ID]fx.Owner // subnetID -> owner } -func NewBackend(ctx Context, utxos common.ChainUTXOs, subnetTxs map[ids.ID]*txs.Tx) Backend { +func NewBackend(context *builder.Context, utxos common.ChainUTXOs, subnetTxs map[ids.ID]*txs.Tx) Backend { subnetOwner := make(map[ids.ID]fx.Owner) for txID, tx := range subnetTxs { // first get owners from the CreateSubnetTx createSubnetTx, ok := tx.Unsigned.(*txs.CreateSubnetTx) @@ -54,13 +55,13 @@ func NewBackend(ctx Context, utxos common.ChainUTXOs, subnetTxs map[ids.ID]*txs. subnetOwner[transferSubnetOwnershipTx.Subnet] = transferSubnetOwnershipTx.Owner } return &backend{ - Context: ctx, ChainUTXOs: utxos, + context: context, subnetOwner: subnetOwner, } } -func (b *backend) AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error { +func (b *backend) AcceptTx(ctx context.Context, tx *txs.Tx) error { txID := tx.ID() err := tx.Unsigned.Visit(&backendVisitor{ b: b, @@ -75,7 +76,7 @@ func (b *backend) AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error { return b.addUTXOs(ctx, constants.PlatformChainID, producedUTXOSlice) } -func (b *backend) addUTXOs(ctx stdcontext.Context, destinationChainID ids.ID, utxos []*avax.UTXO) error { +func (b *backend) addUTXOs(ctx context.Context, destinationChainID ids.ID, utxos []*avax.UTXO) error { for _, utxo := range utxos { if err := b.AddUTXO(ctx, destinationChainID, utxo); err != nil { return err @@ -84,7 +85,7 @@ func (b *backend) addUTXOs(ctx stdcontext.Context, destinationChainID ids.ID, ut return nil } -func (b *backend) removeUTXOs(ctx stdcontext.Context, sourceChain ids.ID, utxoIDs set.Set[ids.ID]) error { +func (b *backend) removeUTXOs(ctx context.Context, sourceChain ids.ID, utxoIDs set.Set[ids.ID]) error { for utxoID := range utxoIDs { if err := b.RemoveUTXO(ctx, sourceChain, utxoID); err != nil { return err @@ -93,7 +94,7 @@ func (b *backend) removeUTXOs(ctx stdcontext.Context, sourceChain ids.ID, utxoID return nil } -func (b *backend) GetSubnetOwner(_ stdcontext.Context, subnetID ids.ID) (fx.Owner, error) { +func (b *backend) GetSubnetOwner(_ context.Context, subnetID ids.ID) (fx.Owner, error) { b.subnetOwnerLock.RLock() defer b.subnetOwnerLock.RUnlock() diff --git a/wallet/chain/p/backend_visitor.go b/wallet/chain/p/backend_visitor.go index d8b118fa21b7..c7cec9544da1 100644 --- a/wallet/chain/p/backend_visitor.go +++ b/wallet/chain/p/backend_visitor.go @@ -4,29 +4,34 @@ package p import ( + "context" + "errors" + "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm/txs" - - stdcontext "context" ) -var _ txs.Visitor = (*backendVisitor)(nil) +var ( + _ txs.Visitor = (*backendVisitor)(nil) + + ErrUnsupportedTxType = errors.New("unsupported tx type") +) // backendVisitor handles accepting of transactions for the backend type backendVisitor struct { b *backend - ctx stdcontext.Context + ctx context.Context txID ids.ID } func (*backendVisitor) AdvanceTimeTx(*txs.AdvanceTimeTx) error { - return errUnsupportedTxType + return ErrUnsupportedTxType } func (*backendVisitor) RewardValidatorTx(*txs.RewardValidatorTx) error { - return errUnsupportedTxType + return ErrUnsupportedTxType } func (b *backendVisitor) AddValidatorTx(tx *txs.AddValidatorTx) error { diff --git a/wallet/chain/p/builder.go b/wallet/chain/p/builder/builder.go similarity index 91% rename from wallet/chain/p/builder.go rename to wallet/chain/p/builder/builder.go index fff2b5860201..e142342dc483 100644 --- a/wallet/chain/p/builder.go +++ b/wallet/chain/p/builder/builder.go @@ -1,9 +1,10 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package p +package builder import ( + "context" "errors" "fmt" "time" @@ -20,15 +21,14 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" - - stdcontext "context" ) var ( - errNoChangeAddress = errors.New("no possible change address") - errUnknownOwnerType = errors.New("unknown owner type") - errInsufficientAuthorization = errors.New("insufficient authorization") - errInsufficientFunds = errors.New("insufficient funds") + ErrNoChangeAddress = errors.New("no possible change address") + ErrUnknownOutputType = errors.New("unknown output type") + ErrUnknownOwnerType = errors.New("unknown owner type") + ErrInsufficientAuthorization = errors.New("insufficient authorization") + ErrInsufficientFunds = errors.New("insufficient funds") _ Builder = (*builder)(nil) ) @@ -36,6 +36,10 @@ var ( // Builder provides a convenient interface for building unsigned P-chain // transactions. type Builder interface { + // Context returns the configuration of the chain that this builder uses to + // create transactions. + Context() *Context + // GetBalance calculates the amount of each asset that this builder has // control over. GetBalance( @@ -254,32 +258,39 @@ type Builder interface { ) (*txs.AddPermissionlessDelegatorTx, error) } -// BuilderBackend specifies the required information needed to build unsigned -// P-chain transactions. -type BuilderBackend interface { - Context - UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) - GetSubnetOwner(ctx stdcontext.Context, subnetID ids.ID) (fx.Owner, error) +type Backend interface { + UTXOs(ctx context.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) + GetSubnetOwner(ctx context.Context, subnetID ids.ID) (fx.Owner, error) } type builder struct { addrs set.Set[ids.ShortID] - backend BuilderBackend + context *Context + backend Backend } -// NewBuilder returns a new transaction builder. +// New returns a new transaction builder. // // - [addrs] is the set of addresses that the builder assumes can be used when // signing the transactions in the future. -// - [backend] provides the required access to the chain's context and state -// to build out the transactions. -func NewBuilder(addrs set.Set[ids.ShortID], backend BuilderBackend) Builder { +// - [context] provides the chain's configuration. +// - [backend] provides the chain's state. +func New( + addrs set.Set[ids.ShortID], + context *Context, + backend Backend, +) Builder { return &builder{ addrs: addrs, + context: context, backend: backend, } } +func (b *builder) Context() *Context { + return b.context +} + func (b *builder) GetBalance( options ...common.Option, ) (map[ids.ID]uint64, error) { @@ -300,7 +311,7 @@ func (b *builder) NewBaseTx( options ...common.Option, ) (*txs.BaseTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } for _, out := range outputs { assetID := out.AssetID() @@ -321,7 +332,7 @@ func (b *builder) NewBaseTx( avax.SortTransferableOutputs(outputs, txs.Codec) // sort the outputs tx := &txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -336,9 +347,9 @@ func (b *builder) NewAddValidatorTx( shares uint32, options ...common.Option, ) (*txs.AddValidatorTx, error) { - avaxAssetID := b.backend.AVAXAssetID() + avaxAssetID := b.context.AVAXAssetID toBurn := map[ids.ID]uint64{ - avaxAssetID: b.backend.AddPrimaryNetworkValidatorFee(), + avaxAssetID: b.context.AddPrimaryNetworkValidatorFee, } toStake := map[ids.ID]uint64{ avaxAssetID: vdr.Wght, @@ -352,7 +363,7 @@ func (b *builder) NewAddValidatorTx( utils.Sort(rewardsOwner.Addrs) tx := &txs.AddValidatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: baseOutputs, @@ -371,7 +382,7 @@ func (b *builder) NewAddSubnetValidatorTx( options ...common.Option, ) (*txs.AddSubnetValidatorTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.AddSubnetValidatorFee(), + b.context.AVAXAssetID: b.context.AddSubnetValidatorFee, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -387,7 +398,7 @@ func (b *builder) NewAddSubnetValidatorTx( tx := &txs.AddSubnetValidatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -405,7 +416,7 @@ func (b *builder) NewRemoveSubnetValidatorTx( options ...common.Option, ) (*txs.RemoveSubnetValidatorTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -421,7 +432,7 @@ func (b *builder) NewRemoveSubnetValidatorTx( tx := &txs.RemoveSubnetValidatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -439,12 +450,12 @@ func (b *builder) NewAddDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddDelegatorTx, error) { - avaxAssetID := b.backend.AVAXAssetID() + avaxAssetID := b.context.AVAXAssetID toBurn := map[ids.ID]uint64{ - avaxAssetID: b.backend.AddPrimaryNetworkDelegatorFee(), + avaxAssetID: b.context.AddPrimaryNetworkDelegatorFee, } toStake := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): vdr.Wght, + avaxAssetID: vdr.Wght, } ops := common.NewOptions(options) inputs, baseOutputs, stakeOutputs, err := b.spend(toBurn, toStake, ops) @@ -455,7 +466,7 @@ func (b *builder) NewAddDelegatorTx( utils.Sort(rewardsOwner.Addrs) tx := &txs.AddDelegatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: baseOutputs, @@ -477,7 +488,7 @@ func (b *builder) NewCreateChainTx( options ...common.Option, ) (*txs.CreateChainTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.CreateBlockchainTxFee(), + b.context.AVAXAssetID: b.context.CreateBlockchainTxFee, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -494,7 +505,7 @@ func (b *builder) NewCreateChainTx( utils.Sort(fxIDs) tx := &txs.CreateChainTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -515,7 +526,7 @@ func (b *builder) NewCreateSubnetTx( options ...common.Option, ) (*txs.CreateSubnetTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.CreateSubnetTxFee(), + b.context.AVAXAssetID: b.context.CreateSubnetTxFee, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -527,7 +538,7 @@ func (b *builder) NewCreateSubnetTx( utils.Sort(owner.Addrs) tx := &txs.CreateSubnetTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -544,7 +555,7 @@ func (b *builder) NewTransferSubnetOwnershipTx( options ...common.Option, ) (*txs.TransferSubnetOwnershipTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -561,7 +572,7 @@ func (b *builder) NewTransferSubnetOwnershipTx( utils.Sort(owner.Addrs) tx := &txs.TransferSubnetOwnershipTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -588,8 +599,8 @@ func (b *builder) NewImportTx( var ( addrs = ops.Addresses(b.addrs) minIssuanceTime = ops.MinIssuanceTime() - avaxAssetID = b.backend.AVAXAssetID() - txFee = b.backend.BaseTxFee() + avaxAssetID = b.context.AVAXAssetID + txFee = b.context.BaseTxFee importedInputs = make([]*avax.TransferableInput, 0, len(utxos)) importedAmounts = make(map[ids.ID]uint64) @@ -630,7 +641,7 @@ func (b *builder) NewImportTx( if len(importedInputs) == 0 { return nil, fmt.Errorf( "%w: no UTXOs available to import", - errInsufficientFunds, + ErrInsufficientFunds, ) } @@ -669,7 +680,7 @@ func (b *builder) NewImportTx( avax.SortTransferableOutputs(outputs, txs.Codec) // sort imported outputs tx := &txs.ImportTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -687,7 +698,7 @@ func (b *builder) NewExportTx( options ...common.Option, ) (*txs.ExportTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } for _, out := range outputs { assetID := out.AssetID() @@ -708,7 +719,7 @@ func (b *builder) NewExportTx( avax.SortTransferableOutputs(outputs, txs.Codec) // sort exported outputs tx := &txs.ExportTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: changeOutputs, @@ -738,8 +749,8 @@ func (b *builder) NewTransformSubnetTx( options ...common.Option, ) (*txs.TransformSubnetTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.TransformSubnetTxFee(), - assetID: maxSupply - initialSupply, + b.context.AVAXAssetID: b.context.TransformSubnetTxFee, + assetID: maxSupply - initialSupply, } toStake := map[ids.ID]uint64{} ops := common.NewOptions(options) @@ -755,7 +766,7 @@ func (b *builder) NewTransformSubnetTx( tx := &txs.TransformSubnetTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: outputs, @@ -789,12 +800,12 @@ func (b *builder) NewAddPermissionlessValidatorTx( shares uint32, options ...common.Option, ) (*txs.AddPermissionlessValidatorTx, error) { - avaxAssetID := b.backend.AVAXAssetID() + avaxAssetID := b.context.AVAXAssetID toBurn := map[ids.ID]uint64{} if vdr.Subnet == constants.PrimaryNetworkID { - toBurn[avaxAssetID] = b.backend.AddPrimaryNetworkValidatorFee() + toBurn[avaxAssetID] = b.context.AddPrimaryNetworkValidatorFee } else { - toBurn[avaxAssetID] = b.backend.AddSubnetValidatorFee() + toBurn[avaxAssetID] = b.context.AddSubnetValidatorFee } toStake := map[ids.ID]uint64{ assetID: vdr.Wght, @@ -809,7 +820,7 @@ func (b *builder) NewAddPermissionlessValidatorTx( utils.Sort(delegationRewardsOwner.Addrs) tx := &txs.AddPermissionlessValidatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: baseOutputs, @@ -832,12 +843,12 @@ func (b *builder) NewAddPermissionlessDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddPermissionlessDelegatorTx, error) { - avaxAssetID := b.backend.AVAXAssetID() + avaxAssetID := b.context.AVAXAssetID toBurn := map[ids.ID]uint64{} if vdr.Subnet == constants.PrimaryNetworkID { - toBurn[avaxAssetID] = b.backend.AddPrimaryNetworkDelegatorFee() + toBurn[avaxAssetID] = b.context.AddPrimaryNetworkDelegatorFee } else { - toBurn[avaxAssetID] = b.backend.AddSubnetDelegatorFee() + toBurn[avaxAssetID] = b.context.AddSubnetDelegatorFee } toStake := map[ids.ID]uint64{ assetID: vdr.Wght, @@ -851,7 +862,7 @@ func (b *builder) NewAddPermissionlessDelegatorTx( utils.Sort(rewardsOwner.Addrs) tx := &txs.AddPermissionlessDelegatorTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), + NetworkID: b.context.NetworkID, BlockchainID: constants.PlatformChainID, Ins: inputs, Outs: baseOutputs, @@ -895,7 +906,7 @@ func (b *builder) getBalance( out, ok := outIntf.(*secp256k1fx.TransferOutput) if !ok { - return nil, errUnknownOutputType + return nil, ErrUnknownOutputType } _, ok = common.MatchOwners(&out.OutputOwners, addrs, minIssuanceTime) @@ -944,7 +955,7 @@ func (b *builder) spend( addr, ok := addrs.Peek() if !ok { - return nil, nil, nil, errNoChangeAddress + return nil, nil, nil, ErrNoChangeAddress } changeOwner := options.ChangeOwner(&secp256k1fx.OutputOwners{ Threshold: 1, @@ -977,7 +988,7 @@ func (b *builder) spend( out, ok := lockedOut.TransferableOut.(*secp256k1fx.TransferOutput) if !ok { - return nil, nil, nil, errUnknownOutputType + return nil, nil, nil, ErrUnknownOutputType } inputSigIndices, ok := common.MatchOwners(&out.OutputOwners, addrs, minIssuanceTime) @@ -1058,7 +1069,7 @@ func (b *builder) spend( out, ok := outIntf.(*secp256k1fx.TransferOutput) if !ok { - return nil, nil, nil, errUnknownOutputType + return nil, nil, nil, ErrUnknownOutputType } inputSigIndices, ok := common.MatchOwners(&out.OutputOwners, addrs, minIssuanceTime) @@ -1118,7 +1129,7 @@ func (b *builder) spend( if amount != 0 { return nil, nil, nil, fmt.Errorf( "%w: provided UTXOs need %d more units of asset %q to stake", - errInsufficientFunds, + ErrInsufficientFunds, amount, assetID, ) @@ -1128,7 +1139,7 @@ func (b *builder) spend( if amount != 0 { return nil, nil, nil, fmt.Errorf( "%w: provided UTXOs need %d more units of asset %q", - errInsufficientFunds, + ErrInsufficientFunds, amount, assetID, ) @@ -1152,7 +1163,7 @@ func (b *builder) authorizeSubnet(subnetID ids.ID, options *common.Options) (*se } owner, ok := ownerIntf.(*secp256k1fx.OutputOwners) if !ok { - return nil, errUnknownOwnerType + return nil, ErrUnknownOwnerType } addrs := options.Addresses(b.addrs) @@ -1160,7 +1171,7 @@ func (b *builder) authorizeSubnet(subnetID ids.ID, options *common.Options) (*se inputSigIndices, ok := common.MatchOwners(owner, addrs, minIssuanceTime) if !ok { // We can't authorize the subnet - return nil, errInsufficientAuthorization + return nil, ErrInsufficientAuthorization } return &secp256k1fx.Input{ SigIndices: inputSigIndices, @@ -1168,7 +1179,7 @@ func (b *builder) authorizeSubnet(subnetID ids.ID, options *common.Options) (*se } func (b *builder) initCtx(tx txs.UnsignedTx) error { - ctx, err := newSnowContext(b.backend) + ctx, err := NewSnowContext(b.context.NetworkID, b.context.AVAXAssetID) if err != nil { return err } diff --git a/wallet/chain/p/builder_with_options.go b/wallet/chain/p/builder/builder_with_options.go similarity index 81% rename from wallet/chain/p/builder_with_options.go rename to wallet/chain/p/builder/builder_with_options.go index a402355b9e01..d831e0c76daa 100644 --- a/wallet/chain/p/builder_with_options.go +++ b/wallet/chain/p/builder/builder_with_options.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package p +package builder import ( "time" @@ -17,28 +17,32 @@ import ( var _ Builder = (*builderWithOptions)(nil) type builderWithOptions struct { - Builder + builder Builder options []common.Option } -// NewBuilderWithOptions returns a new transaction builder that will use the -// given options by default. +// NewWithOptions returns a new builder that will use the given options by +// default. // // - [builder] is the builder that will be called to perform the underlying // operations. // - [options] will be provided to the builder in addition to the options // provided in the method calls. -func NewBuilderWithOptions(builder Builder, options ...common.Option) Builder { +func NewWithOptions(builder Builder, options ...common.Option) Builder { return &builderWithOptions{ - Builder: builder, + builder: builder, options: options, } } +func (b *builderWithOptions) Context() *Context { + return b.builder.Context() +} + func (b *builderWithOptions) GetBalance( options ...common.Option, ) (map[ids.ID]uint64, error) { - return b.Builder.GetBalance( + return b.builder.GetBalance( common.UnionOptions(b.options, options)..., ) } @@ -47,19 +51,29 @@ func (b *builderWithOptions) GetImportableBalance( chainID ids.ID, options ...common.Option, ) (map[ids.ID]uint64, error) { - return b.Builder.GetImportableBalance( + return b.builder.GetImportableBalance( chainID, common.UnionOptions(b.options, options)..., ) } +func (b *builderWithOptions) NewBaseTx( + outputs []*avax.TransferableOutput, + options ...common.Option, +) (*txs.BaseTx, error) { + return b.builder.NewBaseTx( + outputs, + common.UnionOptions(b.options, options)..., + ) +} + func (b *builderWithOptions) NewAddValidatorTx( vdr *txs.Validator, rewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (*txs.AddValidatorTx, error) { - return b.Builder.NewAddValidatorTx( + return b.builder.NewAddValidatorTx( vdr, rewardsOwner, shares, @@ -71,18 +85,18 @@ func (b *builderWithOptions) NewAddSubnetValidatorTx( vdr *txs.SubnetValidator, options ...common.Option, ) (*txs.AddSubnetValidatorTx, error) { - return b.Builder.NewAddSubnetValidatorTx( + return b.builder.NewAddSubnetValidatorTx( vdr, common.UnionOptions(b.options, options)..., ) } -func (b *builderWithOptions) RemoveSubnetValidatorTx( +func (b *builderWithOptions) NewRemoveSubnetValidatorTx( nodeID ids.NodeID, subnetID ids.ID, options ...common.Option, ) (*txs.RemoveSubnetValidatorTx, error) { - return b.Builder.NewRemoveSubnetValidatorTx( + return b.builder.NewRemoveSubnetValidatorTx( nodeID, subnetID, common.UnionOptions(b.options, options)..., @@ -94,7 +108,7 @@ func (b *builderWithOptions) NewAddDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddDelegatorTx, error) { - return b.Builder.NewAddDelegatorTx( + return b.builder.NewAddDelegatorTx( vdr, rewardsOwner, common.UnionOptions(b.options, options)..., @@ -109,7 +123,7 @@ func (b *builderWithOptions) NewCreateChainTx( chainName string, options ...common.Option, ) (*txs.CreateChainTx, error) { - return b.Builder.NewCreateChainTx( + return b.builder.NewCreateChainTx( subnetID, genesis, vmID, @@ -123,7 +137,7 @@ func (b *builderWithOptions) NewCreateSubnetTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.CreateSubnetTx, error) { - return b.Builder.NewCreateSubnetTx( + return b.builder.NewCreateSubnetTx( owner, common.UnionOptions(b.options, options)..., ) @@ -134,7 +148,7 @@ func (b *builderWithOptions) NewTransferSubnetOwnershipTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.TransferSubnetOwnershipTx, error) { - return b.Builder.NewTransferSubnetOwnershipTx( + return b.builder.NewTransferSubnetOwnershipTx( subnetID, owner, common.UnionOptions(b.options, options)..., @@ -146,7 +160,7 @@ func (b *builderWithOptions) NewImportTx( to *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.ImportTx, error) { - return b.Builder.NewImportTx( + return b.builder.NewImportTx( sourceChainID, to, common.UnionOptions(b.options, options)..., @@ -158,7 +172,7 @@ func (b *builderWithOptions) NewExportTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.ExportTx, error) { - return b.Builder.NewExportTx( + return b.builder.NewExportTx( chainID, outputs, common.UnionOptions(b.options, options)..., @@ -182,7 +196,7 @@ func (b *builderWithOptions) NewTransformSubnetTx( uptimeRequirement uint32, options ...common.Option, ) (*txs.TransformSubnetTx, error) { - return b.Builder.NewTransformSubnetTx( + return b.builder.NewTransformSubnetTx( subnetID, assetID, initialSupply, @@ -210,7 +224,7 @@ func (b *builderWithOptions) NewAddPermissionlessValidatorTx( shares uint32, options ...common.Option, ) (*txs.AddPermissionlessValidatorTx, error) { - return b.Builder.NewAddPermissionlessValidatorTx( + return b.builder.NewAddPermissionlessValidatorTx( vdr, signer, assetID, @@ -227,7 +241,7 @@ func (b *builderWithOptions) NewAddPermissionlessDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.AddPermissionlessDelegatorTx, error) { - return b.Builder.NewAddPermissionlessDelegatorTx( + return b.builder.NewAddPermissionlessDelegatorTx( vdr, assetID, rewardsOwner, diff --git a/wallet/chain/p/builder/context.go b/wallet/chain/p/builder/context.go new file mode 100644 index 000000000000..f0da23fdc5f9 --- /dev/null +++ b/wallet/chain/p/builder/context.go @@ -0,0 +1,82 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package builder + +import ( + "context" + + "github.com/ava-labs/avalanchego/api/info" + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/logging" + "github.com/ava-labs/avalanchego/vms/avm" +) + +const Alias = "P" + +type Context struct { + NetworkID uint32 + AVAXAssetID ids.ID + BaseTxFee uint64 + CreateSubnetTxFee uint64 + TransformSubnetTxFee uint64 + CreateBlockchainTxFee uint64 + AddPrimaryNetworkValidatorFee uint64 + AddPrimaryNetworkDelegatorFee uint64 + AddSubnetValidatorFee uint64 + AddSubnetDelegatorFee uint64 +} + +func NewContextFromURI(ctx context.Context, uri string) (*Context, error) { + infoClient := info.NewClient(uri) + xChainClient := avm.NewClient(uri, "X") + return NewContextFromClients(ctx, infoClient, xChainClient) +} + +func NewContextFromClients( + ctx context.Context, + infoClient info.Client, + xChainClient avm.Client, +) (*Context, error) { + networkID, err := infoClient.GetNetworkID(ctx) + if err != nil { + return nil, err + } + + asset, err := xChainClient.GetAssetDescription(ctx, "AVAX") + if err != nil { + return nil, err + } + + txFees, err := infoClient.GetTxFee(ctx) + if err != nil { + return nil, err + } + + return &Context{ + NetworkID: networkID, + AVAXAssetID: asset.AssetID, + BaseTxFee: uint64(txFees.TxFee), + CreateSubnetTxFee: uint64(txFees.CreateSubnetTxFee), + TransformSubnetTxFee: uint64(txFees.TransformSubnetTxFee), + CreateBlockchainTxFee: uint64(txFees.CreateBlockchainTxFee), + AddPrimaryNetworkValidatorFee: uint64(txFees.AddPrimaryNetworkValidatorFee), + AddPrimaryNetworkDelegatorFee: uint64(txFees.AddPrimaryNetworkDelegatorFee), + AddSubnetValidatorFee: uint64(txFees.AddSubnetValidatorFee), + AddSubnetDelegatorFee: uint64(txFees.AddSubnetDelegatorFee), + }, nil +} + +func NewSnowContext(networkID uint32, avaxAssetID ids.ID) (*snow.Context, error) { + lookup := ids.NewAliaser() + return &snow.Context{ + NetworkID: networkID, + SubnetID: constants.PrimaryNetworkID, + ChainID: constants.PlatformChainID, + AVAXAssetID: avaxAssetID, + Log: logging.NoLog{}, + BCLookup: lookup, + }, lookup.Alias(constants.PlatformChainID, Alias) +} diff --git a/wallet/chain/p/builder_test.go b/wallet/chain/p/builder_test.go index 409c524ba938..9f73b9e399b9 100644 --- a/wallet/chain/p/builder_test.go +++ b/wallet/chain/p/builder_test.go @@ -21,6 +21,7 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/stakeable" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/p/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) @@ -32,22 +33,22 @@ var ( avaxAssetID = ids.Empty.Prefix(1789) subnetAssetID = ids.Empty.Prefix(2024) - testCtx = NewContext( - constants.UnitTestID, - avaxAssetID, - units.MicroAvax, // BaseTxFee - 19*units.MicroAvax, // CreateSubnetTxFee - 789*units.MicroAvax, // TransformSubnetTxFee - 1234*units.MicroAvax, // CreateBlockchainTxFee - 19*units.MilliAvax, // AddPrimaryNetworkValidatorFee - 765*units.MilliAvax, // AddPrimaryNetworkDelegatorFee - 1010*units.MilliAvax, // AddSubnetValidatorFee - 9*units.Avax, // AddSubnetDelegatorFee - ) + testContext = &builder.Context{ + NetworkID: constants.UnitTestID, + AVAXAssetID: avaxAssetID, + BaseTxFee: units.MicroAvax, + CreateSubnetTxFee: 19 * units.MicroAvax, + TransformSubnetTxFee: 789 * units.MicroAvax, + CreateBlockchainTxFee: 1234 * units.MicroAvax, + AddPrimaryNetworkValidatorFee: 19 * units.MilliAvax, + AddPrimaryNetworkDelegatorFee: 765 * units.MilliAvax, + AddSubnetValidatorFee: 1010 * units.MilliAvax, + AddSubnetDelegatorFee: 9 * units.Avax, + } ) -// These tests create and sign a tx, then verify that utxos included -// in the tx are exactly necessary to pay fees for it +// These tests create a tx, then verify that utxos included in the tx are +// exactly necessary to pay fees for it. func TestBaseTx(t *testing.T) { var ( @@ -59,11 +60,11 @@ func TestBaseTx(t *testing.T) { chainUTXOs = common.NewDeterministicChainUTXOs(require, map[ids.ID][]*avax.UTXO{ constants.PlatformChainID: utxos, }) - backend = NewBackend(testCtx, chainUTXOs, nil) + backend = NewBackend(testContext, chainUTXOs, nil) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction outputsToMove = []*avax.TransferableOutput{{ @@ -87,7 +88,7 @@ func TestBaseTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 2) - expectedConsumed := testCtx.BaseTxFee() + outputsToMove[0].Out.Amount() + expectedConsumed := testContext.BaseTxFee + outputsToMove[0].Out.Amount() consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) require.Equal(outputsToMove[0], outs[1]) @@ -119,11 +120,11 @@ func TestAddSubnetValidatorTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) // data to build the transaction subnetValidator = &txs.SubnetValidator{ @@ -145,7 +146,7 @@ func TestAddSubnetValidatorTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 1) - expectedConsumed := testCtx.AddSubnetValidatorFee() + expectedConsumed := testContext.AddSubnetValidatorFee consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -176,11 +177,11 @@ func TestRemoveSubnetValidatorTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) ) // build the transaction @@ -196,7 +197,7 @@ func TestRemoveSubnetValidatorTx(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -227,10 +228,10 @@ func TestCreateChainTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) // data to build the transaction genesisBytes = []byte{'a', 'b', 'c'} @@ -255,7 +256,7 @@ func TestCreateChainTx(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.CreateBlockchainTxFee() + expectedConsumed := testContext.CreateBlockchainTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -286,11 +287,11 @@ func TestCreateSubnetTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) ) // build the transaction @@ -303,7 +304,7 @@ func TestCreateSubnetTx(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.CreateSubnetTxFee() + expectedConsumed := testContext.CreateSubnetTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -334,11 +335,11 @@ func TestTransferSubnetOwnershipTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) ) // build the transaction @@ -354,7 +355,7 @@ func TestTransferSubnetOwnershipTx(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -373,11 +374,11 @@ func TestImportTx(t *testing.T) { sourceChainID: importedUTXOs, }) - backend = NewBackend(testCtx, chainUTXOs, nil) + backend = NewBackend(testContext, chainUTXOs, nil) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction importKey = testKeys[0] @@ -404,7 +405,7 @@ func TestImportTx(t *testing.T) { require.Len(importedIns, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := importedIns[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -419,11 +420,11 @@ func TestExportTx(t *testing.T) { chainUTXOs = common.NewDeterministicChainUTXOs(require, map[ids.ID][]*avax.UTXO{ constants.PlatformChainID: utxos, }) - backend = NewBackend(testCtx, chainUTXOs, nil) + backend = NewBackend(testContext, chainUTXOs, nil) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction subnetID = ids.GenerateTestID() @@ -452,7 +453,7 @@ func TestExportTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + exportedOutputs[0].Out.Amount() + expectedConsumed := testContext.BaseTxFee + exportedOutputs[0].Out.Amount() consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) require.Equal(utx.ExportedOutputs, exportedOutputs) @@ -484,11 +485,11 @@ func TestTransformSubnetTx(t *testing.T) { }, } - backend = NewBackend(testCtx, chainUTXOs, subnets) + backend = NewBackend(testContext, chainUTXOs, subnets) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr, subnetAuthAddr), backend) + builder = builder.New(set.Of(utxoAddr, subnetAuthAddr), testContext, backend) // data to build the transaction initialSupply = 40 * units.MegaAvax @@ -523,7 +524,7 @@ func TestTransformSubnetTx(t *testing.T) { expectedConsumedSubnetAsset := maxSupply - initialSupply consumedSubnetAsset := ins[0].In.Amount() - outs[1].Out.Amount() require.Equal(expectedConsumedSubnetAsset, consumedSubnetAsset) - expectedConsumed := testCtx.TransformSubnetTxFee() + expectedConsumed := testContext.TransformSubnetTxFee consumed := ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -538,13 +539,13 @@ func TestAddPermissionlessValidatorTx(t *testing.T) { chainUTXOs = common.NewDeterministicChainUTXOs(require, map[ids.ID][]*avax.UTXO{ constants.PlatformChainID: utxos, }) - backend = NewBackend(testCtx, chainUTXOs, nil) + backend = NewBackend(testContext, chainUTXOs, nil) // builder utxoAddr = utxosKey.Address() rewardKey = testKeys[0] rewardAddr = rewardKey.Address() - builder = NewBuilder(set.Of(utxoAddr, rewardAddr), backend) + builder = builder.New(set.Of(utxoAddr, rewardAddr), testContext, backend) // data to build the transaction validationRewardsOwner = &secp256k1fx.OutputOwners{ @@ -593,7 +594,7 @@ func TestAddPermissionlessValidatorTx(t *testing.T) { expectedConsumedSubnetAsset := utx.Validator.Weight() consumedSubnetAsset := staked[0].Out.Amount() + staked[1].Out.Amount() require.Equal(expectedConsumedSubnetAsset, consumedSubnetAsset) - expectedConsumed := testCtx.AddPrimaryNetworkValidatorFee() + expectedConsumed := testContext.AddPrimaryNetworkValidatorFee consumed := ins[1].In.Amount() + ins[3].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -608,13 +609,13 @@ func TestAddPermissionlessDelegatorTx(t *testing.T) { chainUTXOs = common.NewDeterministicChainUTXOs(require, map[ids.ID][]*avax.UTXO{ constants.PlatformChainID: utxos, }) - backend = NewBackend(testCtx, chainUTXOs, nil) + backend = NewBackend(testContext, chainUTXOs, nil) // builder utxoAddr = utxosKey.Address() rewardKey = testKeys[0] rewardAddr = rewardKey.Address() - builder = NewBuilder(set.Of(utxoAddr, rewardAddr), backend) + builder = builder.New(set.Of(utxoAddr, rewardAddr), testContext, backend) // data to build the transaction rewardsOwner = &secp256k1fx.OutputOwners{ @@ -651,7 +652,7 @@ func TestAddPermissionlessDelegatorTx(t *testing.T) { expectedConsumedSubnetAsset := utx.Validator.Weight() consumedSubnetAsset := staked[0].Out.Amount() + staked[1].Out.Amount() require.Equal(expectedConsumedSubnetAsset, consumedSubnetAsset) - expectedConsumed := testCtx.AddPrimaryNetworkDelegatorFee() + expectedConsumed := testContext.AddPrimaryNetworkDelegatorFee consumed := ins[1].In.Amount() + ins[3].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } diff --git a/wallet/chain/p/context.go b/wallet/chain/p/context.go deleted file mode 100644 index 2511a19a9dbf..000000000000 --- a/wallet/chain/p/context.go +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -package p - -import ( - "github.com/ava-labs/avalanchego/api/info" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/avm" - - stdcontext "context" -) - -const Alias = "P" - -var _ Context = (*context)(nil) - -type Context interface { - NetworkID() uint32 - AVAXAssetID() ids.ID - BaseTxFee() uint64 - CreateSubnetTxFee() uint64 - TransformSubnetTxFee() uint64 - CreateBlockchainTxFee() uint64 - AddPrimaryNetworkValidatorFee() uint64 - AddPrimaryNetworkDelegatorFee() uint64 - AddSubnetValidatorFee() uint64 - AddSubnetDelegatorFee() uint64 -} - -type context struct { - networkID uint32 - avaxAssetID ids.ID - baseTxFee uint64 - createSubnetTxFee uint64 - transformSubnetTxFee uint64 - createBlockchainTxFee uint64 - addPrimaryNetworkValidatorFee uint64 - addPrimaryNetworkDelegatorFee uint64 - addSubnetValidatorFee uint64 - addSubnetDelegatorFee uint64 -} - -func NewContextFromURI(ctx stdcontext.Context, uri string) (Context, error) { - infoClient := info.NewClient(uri) - xChainClient := avm.NewClient(uri, "X") - return NewContextFromClients(ctx, infoClient, xChainClient) -} - -func NewContextFromClients( - ctx stdcontext.Context, - infoClient info.Client, - xChainClient avm.Client, -) (Context, error) { - networkID, err := infoClient.GetNetworkID(ctx) - if err != nil { - return nil, err - } - - asset, err := xChainClient.GetAssetDescription(ctx, "AVAX") - if err != nil { - return nil, err - } - - txFees, err := infoClient.GetTxFee(ctx) - if err != nil { - return nil, err - } - - return NewContext( - networkID, - asset.AssetID, - uint64(txFees.TxFee), - uint64(txFees.CreateSubnetTxFee), - uint64(txFees.TransformSubnetTxFee), - uint64(txFees.CreateBlockchainTxFee), - uint64(txFees.AddPrimaryNetworkValidatorFee), - uint64(txFees.AddPrimaryNetworkDelegatorFee), - uint64(txFees.AddSubnetValidatorFee), - uint64(txFees.AddSubnetDelegatorFee), - ), nil -} - -func NewContext( - networkID uint32, - avaxAssetID ids.ID, - baseTxFee uint64, - createSubnetTxFee uint64, - transformSubnetTxFee uint64, - createBlockchainTxFee uint64, - addPrimaryNetworkValidatorFee uint64, - addPrimaryNetworkDelegatorFee uint64, - addSubnetValidatorFee uint64, - addSubnetDelegatorFee uint64, -) Context { - return &context{ - networkID: networkID, - avaxAssetID: avaxAssetID, - baseTxFee: baseTxFee, - createSubnetTxFee: createSubnetTxFee, - transformSubnetTxFee: transformSubnetTxFee, - createBlockchainTxFee: createBlockchainTxFee, - addPrimaryNetworkValidatorFee: addPrimaryNetworkValidatorFee, - addPrimaryNetworkDelegatorFee: addPrimaryNetworkDelegatorFee, - addSubnetValidatorFee: addSubnetValidatorFee, - addSubnetDelegatorFee: addSubnetDelegatorFee, - } -} - -func (c *context) NetworkID() uint32 { - return c.networkID -} - -func (c *context) AVAXAssetID() ids.ID { - return c.avaxAssetID -} - -func (c *context) BaseTxFee() uint64 { - return c.baseTxFee -} - -func (c *context) CreateSubnetTxFee() uint64 { - return c.createSubnetTxFee -} - -func (c *context) TransformSubnetTxFee() uint64 { - return c.transformSubnetTxFee -} - -func (c *context) CreateBlockchainTxFee() uint64 { - return c.createBlockchainTxFee -} - -func (c *context) AddPrimaryNetworkValidatorFee() uint64 { - return c.addPrimaryNetworkValidatorFee -} - -func (c *context) AddPrimaryNetworkDelegatorFee() uint64 { - return c.addPrimaryNetworkDelegatorFee -} - -func (c *context) AddSubnetValidatorFee() uint64 { - return c.addSubnetValidatorFee -} - -func (c *context) AddSubnetDelegatorFee() uint64 { - return c.addSubnetDelegatorFee -} - -func newSnowContext(c Context) (*snow.Context, error) { - lookup := ids.NewAliaser() - return &snow.Context{ - NetworkID: c.NetworkID(), - SubnetID: constants.PrimaryNetworkID, - ChainID: constants.PlatformChainID, - AVAXAssetID: c.AVAXAssetID(), - Log: logging.NoLog{}, - BCLookup: lookup, - }, lookup.Alias(constants.PlatformChainID, Alias) -} diff --git a/wallet/chain/p/signer.go b/wallet/chain/p/signer/signer.go similarity index 89% rename from wallet/chain/p/signer.go rename to wallet/chain/p/signer/signer.go index bedbbdbf562a..08b3a9d9963b 100644 --- a/wallet/chain/p/signer.go +++ b/wallet/chain/p/signer/signer.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package p +package signer import ( "github.com/ava-labs/avalanchego/ids" @@ -27,17 +27,17 @@ type Signer interface { Sign(ctx stdcontext.Context, tx *txs.Tx) error } -type SignerBackend interface { +type Backend interface { GetUTXO(ctx stdcontext.Context, chainID, utxoID ids.ID) (*avax.UTXO, error) GetSubnetOwner(ctx stdcontext.Context, subnetID ids.ID) (fx.Owner, error) } type txSigner struct { kc keychain.Keychain - backend SignerBackend + backend Backend } -func NewSigner(kc keychain.Keychain, backend SignerBackend) Signer { +func New(kc keychain.Keychain, backend Backend) Signer { return &txSigner{ kc: kc, backend: backend, @@ -45,7 +45,7 @@ func NewSigner(kc keychain.Keychain, backend SignerBackend) Signer { } func (s *txSigner) Sign(ctx stdcontext.Context, tx *txs.Tx) error { - return tx.Unsigned.Visit(&signerVisitor{ + return tx.Unsigned.Visit(&visitor{ kc: s.kc, backend: s.backend, ctx: ctx, diff --git a/wallet/chain/p/signer_visitor.go b/wallet/chain/p/signer/visitor.go similarity index 77% rename from wallet/chain/p/signer_visitor.go rename to wallet/chain/p/signer/visitor.go index 7c9dd4cb95ca..5dd4abe2b7d2 100644 --- a/wallet/chain/p/signer_visitor.go +++ b/wallet/chain/p/signer/visitor.go @@ -1,9 +1,10 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package p +package signer import ( + "context" "errors" "fmt" @@ -18,40 +19,39 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/stakeable" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - - stdcontext "context" ) var ( - _ txs.Visitor = (*signerVisitor)(nil) + _ txs.Visitor = (*visitor)(nil) - errUnsupportedTxType = errors.New("unsupported tx type") - errUnknownInputType = errors.New("unknown input type") - errUnknownCredentialType = errors.New("unknown credential type") - errUnknownOutputType = errors.New("unknown output type") - errUnknownSubnetAuthType = errors.New("unknown subnet auth type") - errInvalidUTXOSigIndex = errors.New("invalid UTXO signature index") + ErrUnsupportedTxType = errors.New("unsupported tx type") + ErrUnknownInputType = errors.New("unknown input type") + ErrUnknownOutputType = errors.New("unknown output type") + ErrInvalidUTXOSigIndex = errors.New("invalid UTXO signature index") + ErrUnknownSubnetAuthType = errors.New("unknown subnet auth type") + ErrUnknownOwnerType = errors.New("unknown owner type") + ErrUnknownCredentialType = errors.New("unknown credential type") emptySig [secp256k1.SignatureLen]byte ) -// signerVisitor handles signing transactions for the signer -type signerVisitor struct { +// visitor handles signing transactions for the signer +type visitor struct { kc keychain.Keychain - backend SignerBackend - ctx stdcontext.Context + backend Backend + ctx context.Context tx *txs.Tx } -func (*signerVisitor) AdvanceTimeTx(*txs.AdvanceTimeTx) error { - return errUnsupportedTxType +func (*visitor) AdvanceTimeTx(*txs.AdvanceTimeTx) error { + return ErrUnsupportedTxType } -func (*signerVisitor) RewardValidatorTx(*txs.RewardValidatorTx) error { - return errUnsupportedTxType +func (*visitor) RewardValidatorTx(*txs.RewardValidatorTx) error { + return ErrUnsupportedTxType } -func (s *signerVisitor) BaseTx(tx *txs.BaseTx) error { +func (s *visitor) BaseTx(tx *txs.BaseTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -59,7 +59,7 @@ func (s *signerVisitor) BaseTx(tx *txs.BaseTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) AddValidatorTx(tx *txs.AddValidatorTx) error { +func (s *visitor) AddValidatorTx(tx *txs.AddValidatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -67,7 +67,7 @@ func (s *signerVisitor) AddValidatorTx(tx *txs.AddValidatorTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) AddSubnetValidatorTx(tx *txs.AddSubnetValidatorTx) error { +func (s *visitor) AddSubnetValidatorTx(tx *txs.AddSubnetValidatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -80,7 +80,7 @@ func (s *signerVisitor) AddSubnetValidatorTx(tx *txs.AddSubnetValidatorTx) error return sign(s.tx, false, txSigners) } -func (s *signerVisitor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { +func (s *visitor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -88,7 +88,7 @@ func (s *signerVisitor) AddDelegatorTx(tx *txs.AddDelegatorTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) CreateChainTx(tx *txs.CreateChainTx) error { +func (s *visitor) CreateChainTx(tx *txs.CreateChainTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -101,7 +101,7 @@ func (s *signerVisitor) CreateChainTx(tx *txs.CreateChainTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) CreateSubnetTx(tx *txs.CreateSubnetTx) error { +func (s *visitor) CreateSubnetTx(tx *txs.CreateSubnetTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -109,7 +109,7 @@ func (s *signerVisitor) CreateSubnetTx(tx *txs.CreateSubnetTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) ImportTx(tx *txs.ImportTx) error { +func (s *visitor) ImportTx(tx *txs.ImportTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -122,7 +122,7 @@ func (s *signerVisitor) ImportTx(tx *txs.ImportTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) ExportTx(tx *txs.ExportTx) error { +func (s *visitor) ExportTx(tx *txs.ExportTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -130,7 +130,7 @@ func (s *signerVisitor) ExportTx(tx *txs.ExportTx) error { return sign(s.tx, false, txSigners) } -func (s *signerVisitor) RemoveSubnetValidatorTx(tx *txs.RemoveSubnetValidatorTx) error { +func (s *visitor) RemoveSubnetValidatorTx(tx *txs.RemoveSubnetValidatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -143,7 +143,7 @@ func (s *signerVisitor) RemoveSubnetValidatorTx(tx *txs.RemoveSubnetValidatorTx) return sign(s.tx, true, txSigners) } -func (s *signerVisitor) TransferSubnetOwnershipTx(tx *txs.TransferSubnetOwnershipTx) error { +func (s *visitor) TransferSubnetOwnershipTx(tx *txs.TransferSubnetOwnershipTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -156,7 +156,7 @@ func (s *signerVisitor) TransferSubnetOwnershipTx(tx *txs.TransferSubnetOwnershi return sign(s.tx, true, txSigners) } -func (s *signerVisitor) TransformSubnetTx(tx *txs.TransformSubnetTx) error { +func (s *visitor) TransformSubnetTx(tx *txs.TransformSubnetTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -169,7 +169,7 @@ func (s *signerVisitor) TransformSubnetTx(tx *txs.TransformSubnetTx) error { return sign(s.tx, true, txSigners) } -func (s *signerVisitor) AddPermissionlessValidatorTx(tx *txs.AddPermissionlessValidatorTx) error { +func (s *visitor) AddPermissionlessValidatorTx(tx *txs.AddPermissionlessValidatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -177,7 +177,7 @@ func (s *signerVisitor) AddPermissionlessValidatorTx(tx *txs.AddPermissionlessVa return sign(s.tx, true, txSigners) } -func (s *signerVisitor) AddPermissionlessDelegatorTx(tx *txs.AddPermissionlessDelegatorTx) error { +func (s *visitor) AddPermissionlessDelegatorTx(tx *txs.AddPermissionlessDelegatorTx) error { txSigners, err := s.getSigners(constants.PlatformChainID, tx.Ins) if err != nil { return err @@ -185,7 +185,7 @@ func (s *signerVisitor) AddPermissionlessDelegatorTx(tx *txs.AddPermissionlessDe return sign(s.tx, true, txSigners) } -func (s *signerVisitor) getSigners(sourceChainID ids.ID, ins []*avax.TransferableInput) ([][]keychain.Signer, error) { +func (s *visitor) getSigners(sourceChainID ids.ID, ins []*avax.TransferableInput) ([][]keychain.Signer, error) { txSigners := make([][]keychain.Signer, len(ins)) for credIndex, transferInput := range ins { inIntf := transferInput.In @@ -195,7 +195,7 @@ func (s *signerVisitor) getSigners(sourceChainID ids.ID, ins []*avax.Transferabl input, ok := inIntf.(*secp256k1fx.TransferInput) if !ok { - return nil, errUnknownInputType + return nil, ErrUnknownInputType } inputSigners := make([]keychain.Signer, len(input.SigIndices)) @@ -219,12 +219,12 @@ func (s *signerVisitor) getSigners(sourceChainID ids.ID, ins []*avax.Transferabl out, ok := outIntf.(*secp256k1fx.TransferOutput) if !ok { - return nil, errUnknownOutputType + return nil, ErrUnknownOutputType } for sigIndex, addrIndex := range input.SigIndices { if addrIndex >= uint32(len(out.Addrs)) { - return nil, errInvalidUTXOSigIndex + return nil, ErrInvalidUTXOSigIndex } addr := out.Addrs[addrIndex] @@ -240,10 +240,10 @@ func (s *signerVisitor) getSigners(sourceChainID ids.ID, ins []*avax.Transferabl return txSigners, nil } -func (s *signerVisitor) getSubnetSigners(subnetID ids.ID, subnetAuth verify.Verifiable) ([]keychain.Signer, error) { +func (s *visitor) getSubnetSigners(subnetID ids.ID, subnetAuth verify.Verifiable) ([]keychain.Signer, error) { subnetInput, ok := subnetAuth.(*secp256k1fx.Input) if !ok { - return nil, errUnknownSubnetAuthType + return nil, ErrUnknownSubnetAuthType } ownerIntf, err := s.backend.GetSubnetOwner(s.ctx, subnetID) @@ -256,13 +256,13 @@ func (s *signerVisitor) getSubnetSigners(subnetID ids.ID, subnetAuth verify.Veri } owner, ok := ownerIntf.(*secp256k1fx.OutputOwners) if !ok { - return nil, errUnknownOwnerType + return nil, ErrUnknownOwnerType } authSigners := make([]keychain.Signer, len(subnetInput.SigIndices)) for sigIndex, addrIndex := range subnetInput.SigIndices { if addrIndex >= uint32(len(owner.Addrs)) { - return nil, errInvalidUTXOSigIndex + return nil, ErrInvalidUTXOSigIndex } addr := owner.Addrs[addrIndex] @@ -299,7 +299,7 @@ func sign(tx *txs.Tx, signHash bool, txSigners [][]keychain.Signer) error { cred, ok := credIntf.(*secp256k1fx.Credential) if !ok { - return errUnknownCredentialType + return ErrUnknownCredentialType } if expectedLen := len(inputSigners); expectedLen != len(cred.Sigs) { cred.Sigs = make([][secp256k1.SignatureLen]byte, expectedLen) diff --git a/wallet/chain/p/wallet.go b/wallet/chain/p/wallet.go index 61655e0d157f..b96e6f3723e9 100644 --- a/wallet/chain/p/wallet.go +++ b/wallet/chain/p/wallet.go @@ -11,27 +11,28 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/platformvm" - "github.com/ava-labs/avalanchego/vms/platformvm/signer" "github.com/ava-labs/avalanchego/vms/platformvm/status" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/p/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" + + vmsigner "github.com/ava-labs/avalanchego/vms/platformvm/signer" + walletsigner "github.com/ava-labs/avalanchego/wallet/chain/p/signer" ) var ( - errNotCommitted = errors.New("not committed") + ErrNotCommitted = errors.New("not committed") _ Wallet = (*wallet)(nil) ) type Wallet interface { - Context - // Builder returns the builder that will be used to create the transactions. - Builder() Builder + Builder() builder.Builder // Signer returns the signer that will be used to sign the transactions. - Signer() Signer + Signer() walletsigner.Signer // IssueBaseTx creates, signs, and issues a new simple value transfer. // @@ -219,7 +220,7 @@ type Wallet interface { // the delegation reward will be sent to the validator's [rewardsOwner]. IssueAddPermissionlessValidatorTx( vdr *txs.SubnetValidator, - signer signer.Signer, + signer vmsigner.Signer, assetID ids.ID, validationRewardsOwner *secp256k1fx.OutputOwners, delegationRewardsOwner *secp256k1fx.OutputOwners, @@ -256,8 +257,8 @@ type Wallet interface { } func NewWallet( - builder Builder, - signer Signer, + builder builder.Builder, + signer walletsigner.Signer, client platformvm.Client, backend Backend, ) Wallet { @@ -271,16 +272,16 @@ func NewWallet( type wallet struct { Backend - builder Builder - signer Signer + builder builder.Builder + signer walletsigner.Signer client platformvm.Client } -func (w *wallet) Builder() Builder { +func (w *wallet) Builder() builder.Builder { return w.builder } -func (w *wallet) Signer() Signer { +func (w *wallet) Signer() walletsigner.Signer { return w.signer } @@ -447,7 +448,7 @@ func (w *wallet) IssueTransformSubnetTx( func (w *wallet) IssueAddPermissionlessValidatorTx( vdr *txs.SubnetValidator, - signer signer.Signer, + signer vmsigner.Signer, assetID ids.ID, validationRewardsOwner *secp256k1fx.OutputOwners, delegationRewardsOwner *secp256k1fx.OutputOwners, @@ -493,7 +494,7 @@ func (w *wallet) IssueUnsignedTx( ) (*txs.Tx, error) { ops := common.NewOptions(options) ctx := ops.Context() - tx, err := SignUnsigned(ctx, w.signer, utx) + tx, err := walletsigner.SignUnsigned(ctx, w.signer, utx) if err != nil { return nil, err } @@ -530,7 +531,7 @@ func (w *wallet) IssueTx( } if txStatus.Status != status.Committed { - return fmt.Errorf("%w: %s", errNotCommitted, txStatus.Reason) + return fmt.Errorf("%w: %s", ErrNotCommitted, txStatus.Reason) } return nil } diff --git a/wallet/chain/p/wallet_with_options.go b/wallet/chain/p/wallet_with_options.go index 4982e77f8a51..92965f2e4f1f 100644 --- a/wallet/chain/p/wallet_with_options.go +++ b/wallet/chain/p/wallet_with_options.go @@ -8,10 +8,13 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/components/avax" - "github.com/ava-labs/avalanchego/vms/platformvm/signer" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/p/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" + + vmsigner "github.com/ava-labs/avalanchego/vms/platformvm/signer" + walletsigner "github.com/ava-labs/avalanchego/wallet/chain/p/signer" ) var _ Wallet = (*walletWithOptions)(nil) @@ -21,28 +24,32 @@ func NewWalletWithOptions( options ...common.Option, ) Wallet { return &walletWithOptions{ - Wallet: wallet, + wallet: wallet, options: options, } } type walletWithOptions struct { - Wallet + wallet Wallet options []common.Option } -func (w *walletWithOptions) Builder() Builder { - return NewBuilderWithOptions( - w.Wallet.Builder(), +func (w *walletWithOptions) Builder() builder.Builder { + return builder.NewWithOptions( + w.wallet.Builder(), w.options..., ) } +func (w *walletWithOptions) Signer() walletsigner.Signer { + return w.wallet.Signer() +} + func (w *walletWithOptions) IssueBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueBaseTx( + return w.wallet.IssueBaseTx( outputs, common.UnionOptions(w.options, options)..., ) @@ -54,7 +61,7 @@ func (w *walletWithOptions) IssueAddValidatorTx( shares uint32, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueAddValidatorTx( + return w.wallet.IssueAddValidatorTx( vdr, rewardsOwner, shares, @@ -66,7 +73,7 @@ func (w *walletWithOptions) IssueAddSubnetValidatorTx( vdr *txs.SubnetValidator, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueAddSubnetValidatorTx( + return w.wallet.IssueAddSubnetValidatorTx( vdr, common.UnionOptions(w.options, options)..., ) @@ -77,7 +84,7 @@ func (w *walletWithOptions) IssueRemoveSubnetValidatorTx( subnetID ids.ID, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueRemoveSubnetValidatorTx( + return w.wallet.IssueRemoveSubnetValidatorTx( nodeID, subnetID, common.UnionOptions(w.options, options)..., @@ -89,7 +96,7 @@ func (w *walletWithOptions) IssueAddDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueAddDelegatorTx( + return w.wallet.IssueAddDelegatorTx( vdr, rewardsOwner, common.UnionOptions(w.options, options)..., @@ -104,7 +111,7 @@ func (w *walletWithOptions) IssueCreateChainTx( chainName string, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueCreateChainTx( + return w.wallet.IssueCreateChainTx( subnetID, genesis, vmID, @@ -118,7 +125,7 @@ func (w *walletWithOptions) IssueCreateSubnetTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueCreateSubnetTx( + return w.wallet.IssueCreateSubnetTx( owner, common.UnionOptions(w.options, options)..., ) @@ -129,7 +136,7 @@ func (w *walletWithOptions) IssueTransferSubnetOwnershipTx( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueTransferSubnetOwnershipTx( + return w.wallet.IssueTransferSubnetOwnershipTx( subnetID, owner, common.UnionOptions(w.options, options)..., @@ -141,7 +148,7 @@ func (w *walletWithOptions) IssueImportTx( to *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueImportTx( + return w.wallet.IssueImportTx( sourceChainID, to, common.UnionOptions(w.options, options)..., @@ -153,7 +160,7 @@ func (w *walletWithOptions) IssueExportTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueExportTx( + return w.wallet.IssueExportTx( chainID, outputs, common.UnionOptions(w.options, options)..., @@ -177,7 +184,7 @@ func (w *walletWithOptions) IssueTransformSubnetTx( uptimeRequirement uint32, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueTransformSubnetTx( + return w.wallet.IssueTransformSubnetTx( subnetID, assetID, initialSupply, @@ -198,14 +205,14 @@ func (w *walletWithOptions) IssueTransformSubnetTx( func (w *walletWithOptions) IssueAddPermissionlessValidatorTx( vdr *txs.SubnetValidator, - signer signer.Signer, + signer vmsigner.Signer, assetID ids.ID, validationRewardsOwner *secp256k1fx.OutputOwners, delegationRewardsOwner *secp256k1fx.OutputOwners, shares uint32, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueAddPermissionlessValidatorTx( + return w.wallet.IssueAddPermissionlessValidatorTx( vdr, signer, assetID, @@ -222,7 +229,7 @@ func (w *walletWithOptions) IssueAddPermissionlessDelegatorTx( rewardsOwner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueAddPermissionlessDelegatorTx( + return w.wallet.IssueAddPermissionlessDelegatorTx( vdr, assetID, rewardsOwner, @@ -234,7 +241,7 @@ func (w *walletWithOptions) IssueUnsignedTx( utx txs.UnsignedTx, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueUnsignedTx( + return w.wallet.IssueUnsignedTx( utx, common.UnionOptions(w.options, options)..., ) @@ -244,7 +251,7 @@ func (w *walletWithOptions) IssueTx( tx *txs.Tx, options ...common.Option, ) error { - return w.Wallet.IssueTx( + return w.wallet.IssueTx( tx, common.UnionOptions(w.options, options)..., ) diff --git a/wallet/chain/x/backend.go b/wallet/chain/x/backend.go index a87e799fa911..e73cb1620e31 100644 --- a/wallet/chain/x/backend.go +++ b/wallet/chain/x/backend.go @@ -4,10 +4,12 @@ package x import ( + "context" + "github.com/ava-labs/avalanchego/vms/avm/txs" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" + "github.com/ava-labs/avalanchego/wallet/chain/x/signer" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" - - stdcontext "context" ) var _ Backend = (*backend)(nil) @@ -15,25 +17,26 @@ var _ Backend = (*backend)(nil) // Backend defines the full interface required to support an X-chain wallet. type Backend interface { common.ChainUTXOs - BuilderBackend - SignerBackend + builder.Backend + signer.Backend - AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error + AcceptTx(ctx context.Context, tx *txs.Tx) error } type backend struct { - Context common.ChainUTXOs + + context *builder.Context } -func NewBackend(ctx Context, utxos common.ChainUTXOs) Backend { +func NewBackend(context *builder.Context, utxos common.ChainUTXOs) Backend { return &backend{ - Context: ctx, ChainUTXOs: utxos, + context: context, } } -func (b *backend) AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error { +func (b *backend) AcceptTx(ctx context.Context, tx *txs.Tx) error { err := tx.Unsigned.Visit(&backendVisitor{ b: b, ctx: ctx, @@ -43,7 +46,7 @@ func (b *backend) AcceptTx(ctx stdcontext.Context, tx *txs.Tx) error { return err } - chainID := b.Context.BlockchainID() + chainID := b.context.BlockchainID inputUTXOs := tx.Unsigned.InputUTXOs() for _, utxoID := range inputUTXOs { if utxoID.Symbol { diff --git a/wallet/chain/x/backend_visitor.go b/wallet/chain/x/backend_visitor.go index 0bf9ac040a97..4809bf2e06de 100644 --- a/wallet/chain/x/backend_visitor.go +++ b/wallet/chain/x/backend_visitor.go @@ -4,11 +4,11 @@ package x import ( + "context" + "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" - - stdcontext "context" ) var _ txs.Visitor = (*backendVisitor)(nil) @@ -16,7 +16,7 @@ var _ txs.Visitor = (*backendVisitor)(nil) // backendVisitor handles accepting of transactions for the backend type backendVisitor struct { b *backend - ctx stdcontext.Context + ctx context.Context txID ids.ID } diff --git a/wallet/chain/x/builder.go b/wallet/chain/x/builder/builder.go similarity index 91% rename from wallet/chain/x/builder.go rename to wallet/chain/x/builder/builder.go index 330ed69a2504..20411e6e4ce7 100644 --- a/wallet/chain/x/builder.go +++ b/wallet/chain/x/builder/builder.go @@ -1,9 +1,10 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package x +package builder import ( + "context" "errors" "fmt" @@ -18,8 +19,6 @@ import ( "github.com/ava-labs/avalanchego/vms/propertyfx" "github.com/ava-labs/avalanchego/vms/secp256k1fx" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" - - stdcontext "context" ) var ( @@ -27,9 +26,9 @@ var ( errInsufficientFunds = errors.New("insufficient funds") fxIndexToID = map[uint32]ids.ID{ - 0: secp256k1fx.ID, - 1: nftfx.ID, - 2: propertyfx.ID, + SECP256K1FxIndex: secp256k1fx.ID, + NFTFxIndex: nftfx.ID, + PropertyFxIndex: propertyfx.ID, } _ Builder = (*builder)(nil) @@ -38,6 +37,10 @@ var ( // Builder provides a convenient interface for building unsigned X-chain // transactions. type Builder interface { + // Context returns the configuration of the chain that this builder uses to + // create transactions. + Context() *Context + // GetFTBalance calculates the amount of each fungible asset that this // builder has control over. GetFTBalance( @@ -154,37 +157,43 @@ type Builder interface { ) (*txs.ExportTx, error) } -// BuilderBackend specifies the required information needed to build unsigned -// X-chain transactions. -type BuilderBackend interface { - Context - - UTXOs(ctx stdcontext.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) +type Backend interface { + UTXOs(ctx context.Context, sourceChainID ids.ID) ([]*avax.UTXO, error) } type builder struct { addrs set.Set[ids.ShortID] - backend BuilderBackend + context *Context + backend Backend } -// NewBuilder returns a new transaction builder. +// New returns a new transaction builder. // // - [addrs] is the set of addresses that the builder assumes can be used when // signing the transactions in the future. -// - [backend] provides the required access to the chain's context and state -// to build out the transactions. -func NewBuilder(addrs set.Set[ids.ShortID], backend BuilderBackend) Builder { +// - [context] provides the chain's configuration. +// - [backend] provides the chain's state. +func New( + addrs set.Set[ids.ShortID], + context *Context, + backend Backend, +) Builder { return &builder{ addrs: addrs, + context: context, backend: backend, } } +func (b *builder) Context() *Context { + return b.context +} + func (b *builder) GetFTBalance( options ...common.Option, ) (map[ids.ID]uint64, error) { ops := common.NewOptions(options) - return b.getBalance(b.backend.BlockchainID(), ops) + return b.getBalance(b.context.BlockchainID, ops) } func (b *builder) GetImportableBalance( @@ -200,7 +209,7 @@ func (b *builder) NewBaseTx( options ...common.Option, ) (*txs.BaseTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } for _, out := range outputs { assetID := out.AssetID() @@ -220,8 +229,8 @@ func (b *builder) NewBaseTx( avax.SortTransferableOutputs(outputs, Parser.Codec()) // sort the outputs tx := &txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), - BlockchainID: b.backend.BlockchainID(), + NetworkID: b.context.NetworkID, + BlockchainID: b.context.BlockchainID, Ins: inputs, Outs: outputs, Memo: ops.Memo(), @@ -237,7 +246,7 @@ func (b *builder) NewCreateAssetTx( options ...common.Option, ) (*txs.CreateAssetTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.CreateAssetTxFee(), + b.context.AVAXAssetID: b.context.CreateAssetTxFee, } ops := common.NewOptions(options) inputs, outputs, err := b.spend(toBurn, ops) @@ -260,8 +269,8 @@ func (b *builder) NewCreateAssetTx( utils.Sort(states) // sort the initial states tx := &txs.CreateAssetTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), - BlockchainID: b.backend.BlockchainID(), + NetworkID: b.context.NetworkID, + BlockchainID: b.context.BlockchainID, Ins: inputs, Outs: outputs, Memo: ops.Memo(), @@ -279,7 +288,7 @@ func (b *builder) NewOperationTx( options ...common.Option, ) (*txs.OperationTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } ops := common.NewOptions(options) inputs, outputs, err := b.spend(toBurn, ops) @@ -290,8 +299,8 @@ func (b *builder) NewOperationTx( txs.SortOperations(operations, Parser.Codec()) tx := &txs.OperationTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), - BlockchainID: b.backend.BlockchainID(), + NetworkID: b.context.NetworkID, + BlockchainID: b.context.BlockchainID, Ins: inputs, Outs: outputs, Memo: ops.Memo(), @@ -366,8 +375,8 @@ func (b *builder) NewImportTx( var ( addrs = ops.Addresses(b.addrs) minIssuanceTime = ops.MinIssuanceTime() - avaxAssetID = b.backend.AVAXAssetID() - txFee = b.backend.BaseTxFee() + avaxAssetID = b.context.AVAXAssetID + txFee = b.context.BaseTxFee importedInputs = make([]*avax.TransferableInput, 0, len(utxos)) importedAmounts = make(map[ids.ID]uint64) @@ -449,8 +458,8 @@ func (b *builder) NewImportTx( avax.SortTransferableOutputs(outputs, Parser.Codec()) tx := &txs.ImportTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), - BlockchainID: b.backend.BlockchainID(), + NetworkID: b.context.NetworkID, + BlockchainID: b.context.BlockchainID, Ins: inputs, Outs: outputs, Memo: ops.Memo(), @@ -467,7 +476,7 @@ func (b *builder) NewExportTx( options ...common.Option, ) (*txs.ExportTx, error) { toBurn := map[ids.ID]uint64{ - b.backend.AVAXAssetID(): b.backend.BaseTxFee(), + b.context.AVAXAssetID: b.context.BaseTxFee, } for _, out := range outputs { assetID := out.AssetID() @@ -487,8 +496,8 @@ func (b *builder) NewExportTx( avax.SortTransferableOutputs(outputs, Parser.Codec()) tx := &txs.ExportTx{ BaseTx: txs.BaseTx{BaseTx: avax.BaseTx{ - NetworkID: b.backend.NetworkID(), - BlockchainID: b.backend.BlockchainID(), + NetworkID: b.context.NetworkID, + BlockchainID: b.context.BlockchainID, Ins: inputs, Outs: changeOutputs, Memo: ops.Memo(), @@ -547,7 +556,7 @@ func (b *builder) spend( outputs []*avax.TransferableOutput, err error, ) { - utxos, err := b.backend.UTXOs(options.Context(), b.backend.BlockchainID()) + utxos, err := b.backend.UTXOs(options.Context(), b.context.BlockchainID) if err != nil { return nil, nil, err } @@ -642,7 +651,7 @@ func (b *builder) mintFTs( operations []*txs.Operation, err error, ) { - utxos, err := b.backend.UTXOs(options.Context(), b.backend.BlockchainID()) + utxos, err := b.backend.UTXOs(options.Context(), b.context.BlockchainID) if err != nil { return nil, err } @@ -705,7 +714,7 @@ func (b *builder) mintNFTs( operations []*txs.Operation, err error, ) { - utxos, err := b.backend.UTXOs(options.Context(), b.backend.BlockchainID()) + utxos, err := b.backend.UTXOs(options.Context(), b.context.BlockchainID) if err != nil { return nil, err } @@ -762,7 +771,7 @@ func (b *builder) mintProperty( operations []*txs.Operation, err error, ) { - utxos, err := b.backend.UTXOs(options.Context(), b.backend.BlockchainID()) + utxos, err := b.backend.UTXOs(options.Context(), b.context.BlockchainID) if err != nil { return nil, err } @@ -819,7 +828,7 @@ func (b *builder) burnProperty( operations []*txs.Operation, err error, ) { - utxos, err := b.backend.UTXOs(options.Context(), b.backend.BlockchainID()) + utxos, err := b.backend.UTXOs(options.Context(), b.context.BlockchainID) if err != nil { return nil, err } @@ -868,7 +877,11 @@ func (b *builder) burnProperty( } func (b *builder) initCtx(tx txs.UnsignedTx) error { - ctx, err := newSnowContext(b.backend) + ctx, err := NewSnowContext( + b.context.NetworkID, + b.context.BlockchainID, + b.context.AVAXAssetID, + ) if err != nil { return err } diff --git a/wallet/chain/x/builder_with_options.go b/wallet/chain/x/builder/builder_with_options.go similarity index 81% rename from wallet/chain/x/builder_with_options.go rename to wallet/chain/x/builder/builder_with_options.go index c2b65b05a630..a788ccee33c6 100644 --- a/wallet/chain/x/builder_with_options.go +++ b/wallet/chain/x/builder/builder_with_options.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package x +package builder import ( "github.com/ava-labs/avalanchego/ids" @@ -15,28 +15,32 @@ import ( var _ Builder = (*builderWithOptions)(nil) type builderWithOptions struct { - Builder + builder Builder options []common.Option } -// NewBuilderWithOptions returns a new transaction builder that will use the -// given options by default. +// NewWithOptions returns a new transaction builder that will use the given +// options by default. // // - [builder] is the builder that will be called to perform the underlying // operations. // - [options] will be provided to the builder in addition to the options // provided in the method calls. -func NewBuilderWithOptions(builder Builder, options ...common.Option) Builder { +func NewWithOptions(builder Builder, options ...common.Option) Builder { return &builderWithOptions{ - Builder: builder, + builder: builder, options: options, } } +func (b *builderWithOptions) Context() *Context { + return b.builder.Context() +} + func (b *builderWithOptions) GetFTBalance( options ...common.Option, ) (map[ids.ID]uint64, error) { - return b.Builder.GetFTBalance( + return b.builder.GetFTBalance( common.UnionOptions(b.options, options)..., ) } @@ -45,7 +49,7 @@ func (b *builderWithOptions) GetImportableBalance( chainID ids.ID, options ...common.Option, ) (map[ids.ID]uint64, error) { - return b.Builder.GetImportableBalance( + return b.builder.GetImportableBalance( chainID, common.UnionOptions(b.options, options)..., ) @@ -55,7 +59,7 @@ func (b *builderWithOptions) NewBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.BaseTx, error) { - return b.Builder.NewBaseTx( + return b.builder.NewBaseTx( outputs, common.UnionOptions(b.options, options)..., ) @@ -68,7 +72,7 @@ func (b *builderWithOptions) NewCreateAssetTx( initialState map[uint32][]verify.State, options ...common.Option, ) (*txs.CreateAssetTx, error) { - return b.Builder.NewCreateAssetTx( + return b.builder.NewCreateAssetTx( name, symbol, denomination, @@ -81,7 +85,7 @@ func (b *builderWithOptions) NewOperationTx( operations []*txs.Operation, options ...common.Option, ) (*txs.OperationTx, error) { - return b.Builder.NewOperationTx( + return b.builder.NewOperationTx( operations, common.UnionOptions(b.options, options)..., ) @@ -91,7 +95,7 @@ func (b *builderWithOptions) NewOperationTxMintFT( outputs map[ids.ID]*secp256k1fx.TransferOutput, options ...common.Option, ) (*txs.OperationTx, error) { - return b.Builder.NewOperationTxMintFT( + return b.builder.NewOperationTxMintFT( outputs, common.UnionOptions(b.options, options)..., ) @@ -103,7 +107,7 @@ func (b *builderWithOptions) NewOperationTxMintNFT( owners []*secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.OperationTx, error) { - return b.Builder.NewOperationTxMintNFT( + return b.builder.NewOperationTxMintNFT( assetID, payload, owners, @@ -116,7 +120,7 @@ func (b *builderWithOptions) NewOperationTxMintProperty( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.OperationTx, error) { - return b.Builder.NewOperationTxMintProperty( + return b.builder.NewOperationTxMintProperty( assetID, owner, common.UnionOptions(b.options, options)..., @@ -127,7 +131,7 @@ func (b *builderWithOptions) NewOperationTxBurnProperty( assetID ids.ID, options ...common.Option, ) (*txs.OperationTx, error) { - return b.Builder.NewOperationTxBurnProperty( + return b.builder.NewOperationTxBurnProperty( assetID, common.UnionOptions(b.options, options)..., ) @@ -138,7 +142,7 @@ func (b *builderWithOptions) NewImportTx( to *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.ImportTx, error) { - return b.Builder.NewImportTx( + return b.builder.NewImportTx( chainID, to, common.UnionOptions(b.options, options)..., @@ -150,7 +154,7 @@ func (b *builderWithOptions) NewExportTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.ExportTx, error) { - return b.Builder.NewExportTx( + return b.builder.NewExportTx( chainID, outputs, common.UnionOptions(b.options, options)..., diff --git a/wallet/chain/x/constants.go b/wallet/chain/x/builder/constants.go similarity index 97% rename from wallet/chain/x/constants.go rename to wallet/chain/x/builder/constants.go index 690fa168b5fd..2fc1b1132b93 100644 --- a/wallet/chain/x/constants.go +++ b/wallet/chain/x/builder/constants.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package x +package builder import ( "github.com/ava-labs/avalanchego/vms/avm/block" diff --git a/wallet/chain/x/builder/context.go b/wallet/chain/x/builder/context.go new file mode 100644 index 000000000000..6a072cf6230b --- /dev/null +++ b/wallet/chain/x/builder/context.go @@ -0,0 +1,38 @@ +// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package builder + +import ( + "github.com/ava-labs/avalanchego/ids" + "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils/constants" + "github.com/ava-labs/avalanchego/utils/logging" +) + +const Alias = "X" + +type Context struct { + NetworkID uint32 + BlockchainID ids.ID + AVAXAssetID ids.ID + BaseTxFee uint64 + CreateAssetTxFee uint64 +} + +func NewSnowContext( + networkID uint32, + blockchainID ids.ID, + avaxAssetID ids.ID, +) (*snow.Context, error) { + lookup := ids.NewAliaser() + return &snow.Context{ + NetworkID: networkID, + SubnetID: constants.PrimaryNetworkID, + ChainID: blockchainID, + XChainID: blockchainID, + AVAXAssetID: avaxAssetID, + Log: logging.NoLog{}, + BCLookup: lookup, + }, lookup.Alias(blockchainID, Alias) +} diff --git a/wallet/chain/x/builder_test.go b/wallet/chain/x/builder_test.go index 0e349ad28565..801046c185ca 100644 --- a/wallet/chain/x/builder_test.go +++ b/wallet/chain/x/builder_test.go @@ -18,6 +18,7 @@ import ( "github.com/ava-labs/avalanchego/vms/nftfx" "github.com/ava-labs/avalanchego/vms/propertyfx" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) @@ -31,13 +32,13 @@ var ( nftAssetID = ids.Empty.Prefix(2022) propertyAssetID = ids.Empty.Prefix(2023) - testCtx = NewContext( - constants.UnitTestID, - xChainID, - avaxAssetID, - units.MicroAvax, // BaseTxFee - 99*units.MilliAvax, // CreateAssetTxFee - ) + testContext = &builder.Context{ + NetworkID: constants.UnitTestID, + BlockchainID: xChainID, + AVAXAssetID: avaxAssetID, + BaseTxFee: units.MicroAvax, + CreateAssetTxFee: 99 * units.MilliAvax, + } ) // These tests create and sign a tx, then verify that utxos included @@ -56,11 +57,11 @@ func TestBaseTx(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction outputsToMove = []*avax.TransferableOutput{{ @@ -86,7 +87,7 @@ func TestBaseTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 2) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() - outs[1].Out.Amount() require.Equal(expectedConsumed, consumed) require.Equal(outputsToMove[0], outs[1]) @@ -105,11 +106,11 @@ func TestCreateAssetTx(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction assetName = "Team Rocket" @@ -176,7 +177,7 @@ func TestCreateAssetTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 1) - expectedConsumed := testCtx.CreateAssetTxFee() + expectedConsumed := testContext.CreateAssetTxFee consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -194,11 +195,11 @@ func TestMintNFTOperation(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction payload = []byte{'h', 'e', 'l', 'l', 'o'} @@ -221,7 +222,7 @@ func TestMintNFTOperation(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -239,11 +240,11 @@ func TestMintFTOperation(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction outputs = map[ids.ID]*secp256k1fx.TransferOutput{ @@ -268,7 +269,7 @@ func TestMintFTOperation(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -286,11 +287,11 @@ func TestMintPropertyOperation(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction propertyOwner = &secp256k1fx.OutputOwners{ @@ -311,7 +312,7 @@ func TestMintPropertyOperation(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -329,11 +330,11 @@ func TestBurnPropertyOperation(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) ) utx, err := builder.NewOperationTxBurnProperty( @@ -347,7 +348,7 @@ func TestBurnPropertyOperation(t *testing.T) { require.Len(ins, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := ins[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -369,11 +370,11 @@ func TestImportTx(t *testing.T) { }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction importKey = testKeys[0] @@ -399,7 +400,7 @@ func TestImportTx(t *testing.T) { require.Len(importedIns, 1) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + expectedConsumed := testContext.BaseTxFee consumed := importedIns[0].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) } @@ -417,11 +418,11 @@ func TestExportTx(t *testing.T) { xChainID: utxos, }, ) - backend = NewBackend(testCtx, genericBackend) + backend = NewBackend(testContext, genericBackend) // builder utxoAddr = utxosKey.Address() - builder = NewBuilder(set.Of(utxoAddr), backend) + builder = builder.New(set.Of(utxoAddr), testContext, backend) // data to build the transaction subnetID = ids.GenerateTestID() @@ -449,7 +450,7 @@ func TestExportTx(t *testing.T) { require.Len(ins, 2) require.Len(outs, 1) - expectedConsumed := testCtx.BaseTxFee() + exportedOutputs[0].Out.Amount() + expectedConsumed := testContext.BaseTxFee + exportedOutputs[0].Out.Amount() consumed := ins[0].In.Amount() + ins[1].In.Amount() - outs[0].Out.Amount() require.Equal(expectedConsumed, consumed) require.Equal(utx.ExportedOuts, exportedOutputs) diff --git a/wallet/chain/x/context.go b/wallet/chain/x/context.go index 7218bc8c1436..7bd4e280a2cf 100644 --- a/wallet/chain/x/context.go +++ b/wallet/chain/x/context.go @@ -4,53 +4,30 @@ package x import ( + "context" + "github.com/ava-labs/avalanchego/api/info" - "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/snow" - "github.com/ava-labs/avalanchego/utils/constants" - "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms/avm" - - stdcontext "context" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" ) -const Alias = "X" - -var _ Context = (*context)(nil) - -type Context interface { - NetworkID() uint32 - BlockchainID() ids.ID - AVAXAssetID() ids.ID - BaseTxFee() uint64 - CreateAssetTxFee() uint64 -} - -type context struct { - networkID uint32 - blockchainID ids.ID - avaxAssetID ids.ID - baseTxFee uint64 - createAssetTxFee uint64 -} - -func NewContextFromURI(ctx stdcontext.Context, uri string) (Context, error) { +func NewContextFromURI(ctx context.Context, uri string) (*builder.Context, error) { infoClient := info.NewClient(uri) - xChainClient := avm.NewClient(uri, Alias) + xChainClient := avm.NewClient(uri, builder.Alias) return NewContextFromClients(ctx, infoClient, xChainClient) } func NewContextFromClients( - ctx stdcontext.Context, + ctx context.Context, infoClient info.Client, xChainClient avm.Client, -) (Context, error) { +) (*builder.Context, error) { networkID, err := infoClient.GetNetworkID(ctx) if err != nil { return nil, err } - chainID, err := infoClient.GetBlockchainID(ctx, Alias) + chainID, err := infoClient.GetBlockchainID(ctx, builder.Alias) if err != nil { return nil, err } @@ -65,61 +42,11 @@ func NewContextFromClients( return nil, err } - return NewContext( - networkID, - chainID, - asset.AssetID, - uint64(txFees.TxFee), - uint64(txFees.CreateAssetTxFee), - ), nil -} - -func NewContext( - networkID uint32, - blockchainID ids.ID, - avaxAssetID ids.ID, - baseTxFee uint64, - createAssetTxFee uint64, -) Context { - return &context{ - networkID: networkID, - blockchainID: blockchainID, - avaxAssetID: avaxAssetID, - baseTxFee: baseTxFee, - createAssetTxFee: createAssetTxFee, - } -} - -func (c *context) NetworkID() uint32 { - return c.networkID -} - -func (c *context) BlockchainID() ids.ID { - return c.blockchainID -} - -func (c *context) AVAXAssetID() ids.ID { - return c.avaxAssetID -} - -func (c *context) BaseTxFee() uint64 { - return c.baseTxFee -} - -func (c *context) CreateAssetTxFee() uint64 { - return c.createAssetTxFee -} - -func newSnowContext(c Context) (*snow.Context, error) { - chainID := c.BlockchainID() - lookup := ids.NewAliaser() - return &snow.Context{ - NetworkID: c.NetworkID(), - SubnetID: constants.PrimaryNetworkID, - ChainID: chainID, - XChainID: chainID, - AVAXAssetID: c.AVAXAssetID(), - Log: logging.NoLog{}, - BCLookup: lookup, - }, lookup.Alias(chainID, Alias) + return &builder.Context{ + NetworkID: networkID, + BlockchainID: chainID, + AVAXAssetID: asset.AssetID, + BaseTxFee: uint64(txFees.TxFee), + CreateAssetTxFee: uint64(txFees.CreateAssetTxFee), + }, nil } diff --git a/wallet/chain/x/signer.go b/wallet/chain/x/signer/signer.go similarity index 71% rename from wallet/chain/x/signer.go rename to wallet/chain/x/signer/signer.go index 9bc8734e46cd..1d3b943e6b87 100644 --- a/wallet/chain/x/signer.go +++ b/wallet/chain/x/signer/signer.go @@ -1,15 +1,15 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package x +package signer import ( + "context" + "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/crypto/keychain" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" - - stdcontext "context" ) var _ Signer = (*signer)(nil) @@ -23,27 +23,27 @@ type Signer interface { // // If the signer doesn't have the ability to provide a required signature, // the signature slot will be skipped without reporting an error. - Sign(ctx stdcontext.Context, tx *txs.Tx) error + Sign(ctx context.Context, tx *txs.Tx) error } -type SignerBackend interface { - GetUTXO(ctx stdcontext.Context, chainID, utxoID ids.ID) (*avax.UTXO, error) +type Backend interface { + GetUTXO(ctx context.Context, chainID, utxoID ids.ID) (*avax.UTXO, error) } type signer struct { kc keychain.Keychain - backend SignerBackend + backend Backend } -func NewSigner(kc keychain.Keychain, backend SignerBackend) Signer { +func New(kc keychain.Keychain, backend Backend) Signer { return &signer{ kc: kc, backend: backend, } } -func (s *signer) Sign(ctx stdcontext.Context, tx *txs.Tx) error { - return tx.Unsigned.Visit(&signerVisitor{ +func (s *signer) Sign(ctx context.Context, tx *txs.Tx) error { + return tx.Unsigned.Visit(&visitor{ kc: s.kc, backend: s.backend, ctx: ctx, @@ -52,7 +52,7 @@ func (s *signer) Sign(ctx stdcontext.Context, tx *txs.Tx) error { } func SignUnsigned( - ctx stdcontext.Context, + ctx context.Context, signer Signer, utx txs.UnsignedTx, ) (*txs.Tx, error) { diff --git a/wallet/chain/x/signer_visitor.go b/wallet/chain/x/signer/visitor.go similarity index 82% rename from wallet/chain/x/signer_visitor.go rename to wallet/chain/x/signer/visitor.go index be442f5511f3..23a9940c6147 100644 --- a/wallet/chain/x/signer_visitor.go +++ b/wallet/chain/x/signer/visitor.go @@ -1,9 +1,10 @@ // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package x +package signer import ( + "context" "errors" "fmt" @@ -18,32 +19,31 @@ import ( "github.com/ava-labs/avalanchego/vms/nftfx" "github.com/ava-labs/avalanchego/vms/propertyfx" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - - stdcontext "context" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" ) var ( - _ txs.Visitor = (*signerVisitor)(nil) + _ txs.Visitor = (*visitor)(nil) - errUnknownInputType = errors.New("unknown input type") - errUnknownOpType = errors.New("unknown operation type") - errInvalidNumUTXOsInOp = errors.New("invalid number of UTXOs in operation") - errUnknownCredentialType = errors.New("unknown credential type") - errUnknownOutputType = errors.New("unknown output type") - errInvalidUTXOSigIndex = errors.New("invalid UTXO signature index") + ErrUnknownInputType = errors.New("unknown input type") + ErrUnknownOpType = errors.New("unknown operation type") + ErrInvalidNumUTXOsInOp = errors.New("invalid number of UTXOs in operation") + ErrUnknownCredentialType = errors.New("unknown credential type") + ErrUnknownOutputType = errors.New("unknown output type") + ErrInvalidUTXOSigIndex = errors.New("invalid UTXO signature index") emptySig [secp256k1.SignatureLen]byte ) -// signerVisitor handles signing transactions for the signer -type signerVisitor struct { +// visitor handles signing transactions for the signer +type visitor struct { kc keychain.Keychain - backend SignerBackend - ctx stdcontext.Context + backend Backend + ctx context.Context tx *txs.Tx } -func (s *signerVisitor) BaseTx(tx *txs.BaseTx) error { +func (s *visitor) BaseTx(tx *txs.BaseTx) error { txCreds, txSigners, err := s.getSigners(s.ctx, tx.BlockchainID, tx.Ins) if err != nil { return err @@ -51,7 +51,7 @@ func (s *signerVisitor) BaseTx(tx *txs.BaseTx) error { return sign(s.tx, txCreds, txSigners) } -func (s *signerVisitor) CreateAssetTx(tx *txs.CreateAssetTx) error { +func (s *visitor) CreateAssetTx(tx *txs.CreateAssetTx) error { txCreds, txSigners, err := s.getSigners(s.ctx, tx.BlockchainID, tx.Ins) if err != nil { return err @@ -59,7 +59,7 @@ func (s *signerVisitor) CreateAssetTx(tx *txs.CreateAssetTx) error { return sign(s.tx, txCreds, txSigners) } -func (s *signerVisitor) OperationTx(tx *txs.OperationTx) error { +func (s *visitor) OperationTx(tx *txs.OperationTx) error { txCreds, txSigners, err := s.getSigners(s.ctx, tx.BlockchainID, tx.Ins) if err != nil { return err @@ -73,7 +73,7 @@ func (s *signerVisitor) OperationTx(tx *txs.OperationTx) error { return sign(s.tx, txCreds, txSigners) } -func (s *signerVisitor) ImportTx(tx *txs.ImportTx) error { +func (s *visitor) ImportTx(tx *txs.ImportTx) error { txCreds, txSigners, err := s.getSigners(s.ctx, tx.BlockchainID, tx.Ins) if err != nil { return err @@ -87,7 +87,7 @@ func (s *signerVisitor) ImportTx(tx *txs.ImportTx) error { return sign(s.tx, txCreds, txSigners) } -func (s *signerVisitor) ExportTx(tx *txs.ExportTx) error { +func (s *visitor) ExportTx(tx *txs.ExportTx) error { txCreds, txSigners, err := s.getSigners(s.ctx, tx.BlockchainID, tx.Ins) if err != nil { return err @@ -95,14 +95,14 @@ func (s *signerVisitor) ExportTx(tx *txs.ExportTx) error { return sign(s.tx, txCreds, txSigners) } -func (s *signerVisitor) getSigners(ctx stdcontext.Context, sourceChainID ids.ID, ins []*avax.TransferableInput) ([]verify.Verifiable, [][]keychain.Signer, error) { +func (s *visitor) getSigners(ctx context.Context, sourceChainID ids.ID, ins []*avax.TransferableInput) ([]verify.Verifiable, [][]keychain.Signer, error) { txCreds := make([]verify.Verifiable, len(ins)) txSigners := make([][]keychain.Signer, len(ins)) for credIndex, transferInput := range ins { txCreds[credIndex] = &secp256k1fx.Credential{} input, ok := transferInput.In.(*secp256k1fx.TransferInput) if !ok { - return nil, nil, errUnknownInputType + return nil, nil, ErrUnknownInputType } inputSigners := make([]keychain.Signer, len(input.SigIndices)) @@ -121,12 +121,12 @@ func (s *signerVisitor) getSigners(ctx stdcontext.Context, sourceChainID ids.ID, out, ok := utxo.Out.(*secp256k1fx.TransferOutput) if !ok { - return nil, nil, errUnknownOutputType + return nil, nil, ErrUnknownOutputType } for sigIndex, addrIndex := range input.SigIndices { if addrIndex >= uint32(len(out.Addrs)) { - return nil, nil, errInvalidUTXOSigIndex + return nil, nil, ErrInvalidUTXOSigIndex } addr := out.Addrs[addrIndex] @@ -142,7 +142,7 @@ func (s *signerVisitor) getSigners(ctx stdcontext.Context, sourceChainID ids.ID, return txCreds, txSigners, nil } -func (s *signerVisitor) getOpsSigners(ctx stdcontext.Context, sourceChainID ids.ID, ops []*txs.Operation) ([]verify.Verifiable, [][]keychain.Signer, error) { +func (s *visitor) getOpsSigners(ctx context.Context, sourceChainID ids.ID, ops []*txs.Operation) ([]verify.Verifiable, [][]keychain.Signer, error) { txCreds := make([]verify.Verifiable, len(ops)) txSigners := make([][]keychain.Signer, len(ops)) for credIndex, op := range ops { @@ -164,14 +164,14 @@ func (s *signerVisitor) getOpsSigners(ctx stdcontext.Context, sourceChainID ids. txCreds[credIndex] = &propertyfx.Credential{} input = &op.Input default: - return nil, nil, errUnknownOpType + return nil, nil, ErrUnknownOpType } inputSigners := make([]keychain.Signer, len(input.SigIndices)) txSigners[credIndex] = inputSigners if len(op.UTXOIDs) != 1 { - return nil, nil, errInvalidNumUTXOsInOp + return nil, nil, ErrInvalidNumUTXOsInOp } utxoID := op.UTXOIDs[0].InputID() utxo, err := s.backend.GetUTXO(ctx, sourceChainID, utxoID) @@ -197,12 +197,12 @@ func (s *signerVisitor) getOpsSigners(ctx stdcontext.Context, sourceChainID ids. case *propertyfx.OwnedOutput: addrs = out.Addrs default: - return nil, nil, errUnknownOutputType + return nil, nil, ErrUnknownOutputType } for sigIndex, addrIndex := range input.SigIndices { if addrIndex >= uint32(len(addrs)) { - return nil, nil, errInvalidUTXOSigIndex + return nil, nil, ErrInvalidUTXOSigIndex } addr := addrs[addrIndex] @@ -219,7 +219,7 @@ func (s *signerVisitor) getOpsSigners(ctx stdcontext.Context, sourceChainID ids. } func sign(tx *txs.Tx, creds []verify.Verifiable, txSigners [][]keychain.Signer) error { - codec := Parser.Codec() + codec := builder.Parser.Codec() unsignedBytes, err := codec.Marshal(txs.CodecVersion, &tx.Unsigned) if err != nil { return fmt.Errorf("couldn't marshal unsigned tx: %w", err) @@ -254,7 +254,7 @@ func sign(tx *txs.Tx, creds []verify.Verifiable, txSigners [][]keychain.Signer) fxCred.FxID = propertyfx.ID cred = &credImpl.Credential default: - return errUnknownCredentialType + return ErrUnknownCredentialType } if expectedLen := len(inputSigners); expectedLen != len(cred.Sigs) { diff --git a/wallet/chain/x/wallet.go b/wallet/chain/x/wallet.go index 13491a241349..bb6484b5526a 100644 --- a/wallet/chain/x/wallet.go +++ b/wallet/chain/x/wallet.go @@ -13,23 +13,23 @@ import ( "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" + "github.com/ava-labs/avalanchego/wallet/chain/x/signer" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) var ( - errNotAccepted = errors.New("not accepted") + ErrNotAccepted = errors.New("not accepted") _ Wallet = (*wallet)(nil) ) type Wallet interface { - Context - // Builder returns the builder that will be used to create the transactions. - Builder() Builder + Builder() builder.Builder // Signer returns the signer that will be used to sign the transactions. - Signer() Signer + Signer() signer.Signer // IssueBaseTx creates, signs, and issues a new simple value transfer. // @@ -145,13 +145,13 @@ type Wallet interface { } func NewWallet( - builder Builder, - signer Signer, + builder builder.Builder, + signer signer.Signer, client avm.Client, backend Backend, ) Wallet { return &wallet{ - Backend: backend, + backend: backend, builder: builder, signer: signer, client: client, @@ -159,17 +159,17 @@ func NewWallet( } type wallet struct { - Backend - builder Builder - signer Signer + backend Backend + builder builder.Builder + signer signer.Signer client avm.Client } -func (w *wallet) Builder() Builder { +func (w *wallet) Builder() builder.Builder { return w.builder } -func (w *wallet) Signer() Signer { +func (w *wallet) Signer() signer.Signer { return w.signer } @@ -286,7 +286,7 @@ func (w *wallet) IssueUnsignedTx( ) (*txs.Tx, error) { ops := common.NewOptions(options) ctx := ops.Context() - tx, err := SignUnsigned(ctx, w.signer, utx) + tx, err := signer.SignUnsigned(ctx, w.signer, utx) if err != nil { return nil, err } @@ -310,7 +310,7 @@ func (w *wallet) IssueTx( } if ops.AssumeDecided() { - return w.Backend.AcceptTx(ctx, tx) + return w.backend.AcceptTx(ctx, tx) } txStatus, err := w.client.ConfirmTx(ctx, txID, ops.PollFrequency()) @@ -318,12 +318,12 @@ func (w *wallet) IssueTx( return err } - if err := w.Backend.AcceptTx(ctx, tx); err != nil { + if err := w.backend.AcceptTx(ctx, tx); err != nil { return err } if txStatus != choices.Accepted { - return errNotAccepted + return ErrNotAccepted } return nil } diff --git a/wallet/chain/x/wallet_with_options.go b/wallet/chain/x/wallet_with_options.go index d62d02efdd40..33de453b7d61 100644 --- a/wallet/chain/x/wallet_with_options.go +++ b/wallet/chain/x/wallet_with_options.go @@ -9,6 +9,8 @@ import ( "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/components/verify" "github.com/ava-labs/avalanchego/vms/secp256k1fx" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" + "github.com/ava-labs/avalanchego/wallet/chain/x/signer" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) @@ -19,28 +21,32 @@ func NewWalletWithOptions( options ...common.Option, ) Wallet { return &walletWithOptions{ - Wallet: wallet, + wallet: wallet, options: options, } } type walletWithOptions struct { - Wallet + wallet Wallet options []common.Option } -func (w *walletWithOptions) Builder() Builder { - return NewBuilderWithOptions( - w.Wallet.Builder(), +func (w *walletWithOptions) Builder() builder.Builder { + return builder.NewWithOptions( + w.wallet.Builder(), w.options..., ) } +func (w *walletWithOptions) Signer() signer.Signer { + return w.wallet.Signer() +} + func (w *walletWithOptions) IssueBaseTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueBaseTx( + return w.wallet.IssueBaseTx( outputs, common.UnionOptions(w.options, options)..., ) @@ -53,7 +59,7 @@ func (w *walletWithOptions) IssueCreateAssetTx( initialState map[uint32][]verify.State, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueCreateAssetTx( + return w.wallet.IssueCreateAssetTx( name, symbol, denomination, @@ -66,7 +72,7 @@ func (w *walletWithOptions) IssueOperationTx( operations []*txs.Operation, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueOperationTx( + return w.wallet.IssueOperationTx( operations, common.UnionOptions(w.options, options)..., ) @@ -76,7 +82,7 @@ func (w *walletWithOptions) IssueOperationTxMintFT( outputs map[ids.ID]*secp256k1fx.TransferOutput, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueOperationTxMintFT( + return w.wallet.IssueOperationTxMintFT( outputs, common.UnionOptions(w.options, options)..., ) @@ -88,7 +94,7 @@ func (w *walletWithOptions) IssueOperationTxMintNFT( owners []*secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueOperationTxMintNFT( + return w.wallet.IssueOperationTxMintNFT( assetID, payload, owners, @@ -101,7 +107,7 @@ func (w *walletWithOptions) IssueOperationTxMintProperty( owner *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueOperationTxMintProperty( + return w.wallet.IssueOperationTxMintProperty( assetID, owner, common.UnionOptions(w.options, options)..., @@ -112,7 +118,7 @@ func (w *walletWithOptions) IssueOperationTxBurnProperty( assetID ids.ID, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueOperationTxBurnProperty( + return w.wallet.IssueOperationTxBurnProperty( assetID, common.UnionOptions(w.options, options)..., ) @@ -123,7 +129,7 @@ func (w *walletWithOptions) IssueImportTx( to *secp256k1fx.OutputOwners, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueImportTx( + return w.wallet.IssueImportTx( chainID, to, common.UnionOptions(w.options, options)..., @@ -135,7 +141,7 @@ func (w *walletWithOptions) IssueExportTx( outputs []*avax.TransferableOutput, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueExportTx( + return w.wallet.IssueExportTx( chainID, outputs, common.UnionOptions(w.options, options)..., @@ -146,7 +152,7 @@ func (w *walletWithOptions) IssueUnsignedTx( utx txs.UnsignedTx, options ...common.Option, ) (*txs.Tx, error) { - return w.Wallet.IssueUnsignedTx( + return w.wallet.IssueUnsignedTx( utx, common.UnionOptions(w.options, options)..., ) @@ -156,7 +162,7 @@ func (w *walletWithOptions) IssueTx( tx *txs.Tx, options ...common.Option, ) error { - return w.Wallet.IssueTx( + return w.wallet.IssueTx( tx, common.UnionOptions(w.options, options)..., ) diff --git a/wallet/subnet/primary/api.go b/wallet/subnet/primary/api.go index 3c30b60d81c2..a7c271b385bf 100644 --- a/wallet/subnet/primary/api.go +++ b/wallet/subnet/primary/api.go @@ -21,9 +21,10 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/avalanchego/wallet/chain/c" - "github.com/ava-labs/avalanchego/wallet/chain/p" "github.com/ava-labs/avalanchego/wallet/chain/x" + pbuilder "github.com/ava-labs/avalanchego/wallet/chain/p/builder" + xbuilder "github.com/ava-labs/avalanchego/wallet/chain/x/builder" walletcommon "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ethcommon "github.com/ethereum/go-ethereum/common" ) @@ -57,9 +58,9 @@ type UTXOClient interface { type AVAXState struct { PClient platformvm.Client - PCTX p.Context + PCTX *pbuilder.Context XClient avm.Client - XCTX x.Context + XCTX *xbuilder.Context CClient evm.Client CCTX c.Context UTXOs walletcommon.UTXOs @@ -78,7 +79,7 @@ func FetchState( xClient := avm.NewClient(uri, "X") cClient := evm.NewCChainClient(uri) - pCTX, err := p.NewContextFromClients(ctx, infoClient, xClient) + pCTX, err := pbuilder.NewContextFromClients(ctx, infoClient, xClient) if err != nil { return nil, err } @@ -106,9 +107,9 @@ func FetchState( codec: txs.Codec, }, { - id: xCTX.BlockchainID(), + id: xCTX.BlockchainID, client: xClient, - codec: x.Parser.Codec(), + codec: xbuilder.Parser.Codec(), }, { id: cCTX.BlockchainID(), diff --git a/wallet/subnet/primary/example_test.go b/wallet/subnet/primary/example_test.go index 2b8d8b8eeec8..6c2390e00be4 100644 --- a/wallet/subnet/primary/example_test.go +++ b/wallet/subnet/primary/example_test.go @@ -41,9 +41,11 @@ func ExampleWallet() { // Get the P-chain and the X-chain wallets pWallet := wallet.P() xWallet := wallet.X() + xBuilder := xWallet.Builder() + xContext := xBuilder.Context() // Pull out useful constants to use when issuing transactions. - xChainID := xWallet.BlockchainID() + xChainID := xContext.BlockchainID owner := &secp256k1fx.OutputOwners{ Threshold: 1, Addrs: []ids.ShortID{ diff --git a/wallet/subnet/primary/examples/add-primary-validator/main.go b/wallet/subnet/primary/examples/add-primary-validator/main.go index 987229d1ec22..7c2b6c055855 100644 --- a/wallet/subnet/primary/examples/add-primary-validator/main.go +++ b/wallet/subnet/primary/examples/add-primary-validator/main.go @@ -54,7 +54,9 @@ func main() { // Get the P-chain wallet pWallet := wallet.P() - avaxAssetID := pWallet.AVAXAssetID() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + avaxAssetID := pContext.AVAXAssetID addValidatorStartTime := time.Now() addValidatorTx, err := pWallet.IssueAddPermissionlessValidatorTx( diff --git a/wallet/subnet/primary/examples/create-locked-stakeable/main.go b/wallet/subnet/primary/examples/create-locked-stakeable/main.go index 32cdcf983ba0..a6cf5c78604e 100644 --- a/wallet/subnet/primary/examples/create-locked-stakeable/main.go +++ b/wallet/subnet/primary/examples/create-locked-stakeable/main.go @@ -48,7 +48,9 @@ func main() { // Get the P-chain wallet pWallet := wallet.P() - avaxAssetID := pWallet.AVAXAssetID() + pBuilder := pWallet.Builder() + pContext := pBuilder.Context() + avaxAssetID := pContext.AVAXAssetID issueTxStartTime := time.Now() tx, err := pWallet.IssueBaseTx([]*avax.TransferableOutput{ diff --git a/wallet/subnet/primary/examples/get-p-chain-balance/main.go b/wallet/subnet/primary/examples/get-p-chain-balance/main.go index 08f2cd538c29..e190247515bf 100644 --- a/wallet/subnet/primary/examples/get-p-chain-balance/main.go +++ b/wallet/subnet/primary/examples/get-p-chain-balance/main.go @@ -12,6 +12,7 @@ import ( "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/wallet/chain/p" + "github.com/ava-labs/avalanchego/wallet/chain/p/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) @@ -38,14 +39,14 @@ func main() { pUTXOs := common.NewChainUTXOs(constants.PlatformChainID, state.UTXOs) pBackend := p.NewBackend(state.PCTX, pUTXOs, nil) - pBuilder := p.NewBuilder(addresses, pBackend) + pBuilder := builder.New(addresses, state.PCTX, pBackend) currentBalances, err := pBuilder.GetBalance() if err != nil { log.Fatalf("failed to get the balance: %s\n", err) } - avaxID := state.PCTX.AVAXAssetID() + avaxID := state.PCTX.AVAXAssetID avaxBalance := currentBalances[avaxID] log.Printf("current AVAX balance of %s is %d nAVAX\n", addrStr, avaxBalance) } diff --git a/wallet/subnet/primary/examples/get-x-chain-balance/main.go b/wallet/subnet/primary/examples/get-x-chain-balance/main.go index 9895546879ee..1d45e1de609d 100644 --- a/wallet/subnet/primary/examples/get-x-chain-balance/main.go +++ b/wallet/subnet/primary/examples/get-x-chain-balance/main.go @@ -11,6 +11,7 @@ import ( "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/wallet/chain/x" + "github.com/ava-labs/avalanchego/wallet/chain/x/builder" "github.com/ava-labs/avalanchego/wallet/subnet/primary" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) @@ -35,18 +36,18 @@ func main() { } log.Printf("fetched state of %s in %s\n", addrStr, time.Since(fetchStartTime)) - xChainID := state.XCTX.BlockchainID() + xChainID := state.XCTX.BlockchainID xUTXOs := common.NewChainUTXOs(xChainID, state.UTXOs) xBackend := x.NewBackend(state.XCTX, xUTXOs) - xBuilder := x.NewBuilder(addresses, xBackend) + xBuilder := builder.New(addresses, state.XCTX, xBackend) currentBalances, err := xBuilder.GetFTBalance() if err != nil { log.Fatalf("failed to get the balance: %s\n", err) } - avaxID := state.XCTX.AVAXAssetID() + avaxID := state.XCTX.AVAXAssetID avaxBalance := currentBalances[avaxID] log.Printf("current AVAX balance of %s is %d nAVAX\n", addrStr, avaxBalance) } diff --git a/wallet/subnet/primary/wallet.go b/wallet/subnet/primary/wallet.go index 9aabf651cff7..382a042a6bee 100644 --- a/wallet/subnet/primary/wallet.go +++ b/wallet/subnet/primary/wallet.go @@ -15,6 +15,11 @@ import ( "github.com/ava-labs/avalanchego/wallet/chain/p" "github.com/ava-labs/avalanchego/wallet/chain/x" "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" + + pbuilder "github.com/ava-labs/avalanchego/wallet/chain/p/builder" + psigner "github.com/ava-labs/avalanchego/wallet/chain/p/signer" + xbuilder "github.com/ava-labs/avalanchego/wallet/chain/x/builder" + xsigner "github.com/ava-labs/avalanchego/wallet/chain/x/signer" ) var _ Wallet = (*wallet)(nil) @@ -118,14 +123,14 @@ func MakeWallet(ctx context.Context, config *WalletConfig) (Wallet, error) { pUTXOs := common.NewChainUTXOs(constants.PlatformChainID, avaxState.UTXOs) pBackend := p.NewBackend(avaxState.PCTX, pUTXOs, pChainTxs) - pBuilder := p.NewBuilder(avaxAddrs, pBackend) - pSigner := p.NewSigner(config.AVAXKeychain, pBackend) + pBuilder := pbuilder.New(avaxAddrs, avaxState.PCTX, pBackend) + pSigner := psigner.New(config.AVAXKeychain, pBackend) - xChainID := avaxState.XCTX.BlockchainID() + xChainID := avaxState.XCTX.BlockchainID xUTXOs := common.NewChainUTXOs(xChainID, avaxState.UTXOs) xBackend := x.NewBackend(avaxState.XCTX, xUTXOs) - xBuilder := x.NewBuilder(avaxAddrs, xBackend) - xSigner := x.NewSigner(config.AVAXKeychain, xBackend) + xBuilder := xbuilder.New(avaxAddrs, avaxState.XCTX, xBackend) + xSigner := xsigner.New(config.AVAXKeychain, xBackend) cChainID := avaxState.CCTX.BlockchainID() cUTXOs := common.NewChainUTXOs(cChainID, avaxState.UTXOs) diff --git a/x/merkledb/README.md b/x/merkledb/README.md index 29c9f0a73247..be2fb4e6b2aa 100644 --- a/x/merkledb/README.md +++ b/x/merkledb/README.md @@ -379,7 +379,7 @@ Specifically, we encode these values in the following way: +----------------------------------------------------+ | Value (variable length bytes) (optional) | +----------------------------------------------------+ -| Key length (varint) | +| Key bit length (varint) | +----------------------------------------------------+ | Key (variable length bytes) | +----------------------------------------------------+ @@ -392,7 +392,7 @@ Where: * `Value existence flag` is `1` if this node has a value, otherwise `0`. * `Value length` is the length of the value, if it exists (i.e. if `Value existence flag` is `1`.) Otherwise not serialized. * `Value` is the value, if it exists (i.e. if `Value existence flag` is `1`.) Otherwise not serialized. -* `Key length` is the number of nibbles in this node's key. +* `Key length` is the number of bits in this node's key. * `Key` is the node's key. Note that, as with the node serialization format, the `Child index` values aren't necessarily sequential, but they are unique and strictly increasing.