Merge remote-tracking branch 'upstream/develop' into block-stm

This commit is contained in:
Jerry 2023-04-11 11:30:48 -07:00
commit 362db7ad10
No known key found for this signature in database
GPG key ID: 5B33FA23CB103211
176 changed files with 8161 additions and 1213 deletions

View file

@ -6,7 +6,7 @@ labels: 'type:bug'
assignees: ''
---
Our support team has aggregated some common issues and their solutions from past which are faced while running or interacting with a bor client. In order to prevent redundant efforts, we would encourage you to have a look at the [FAQ's section](https://docs.polygon.technology/docs/faq/technical-faqs) of our documentation mentioning the same, before filing an issue here. In case of additional support, you can also join our [discord](https://discord.com/invite/zdwkdvMNY2) server
Our support team has aggregated some common issues and their solutions from past which are faced while running or interacting with a bor client. In order to prevent redundant efforts, we would encourage you to have a look at the [FAQ's section](https://wiki.polygon.technology/docs/faq/technical-faqs/) of our documentation mentioning the same, before filing an issue here. In case of additional support, you can also join our [discord](https://discord.com/invite/zdwkdvMNY2) server
<!--
NOTE: Please make sure to check of any addresses / private keys / rpc url's / IP's before sharing the logs or anything from the additional information section (start.sh or heimdall config).

View file

@ -1,11 +1,15 @@
defaultStake: 10000
defaultFee: 2000
borChainId: "15001"
borChainId: 15001
heimdallChainId: heimdall-15001
contractsBranch: jc/v0.3.1-backport
sprintSize: 64
blockNumber: '0'
blockTime: '2'
contractsBranch: 2ed59de3641c407c64def1b40bcd090cb9cc048a
genesisContractsBranch: master
sprintSize:
- '64'
blockNumber:
- '0'
blockTime:
- '2'
numOfValidators: 3
numOfNonValidators: 0
ethURL: http://ganache:9545
@ -13,3 +17,6 @@ ethHostUser: ubuntu
devnetType: docker
borDockerBuildContext: "../../bor"
heimdallDockerBuildContext: "https://github.com/maticnetwork/heimdall.git#develop"
sprintSizeBlockNumber:
- '0'
numOfArchiveNodes: 0

View file

@ -8,11 +8,16 @@ Please provide a detailed description of what was done in this PR
- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)
- [ ] Changes only for a subset of nodes
# Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
# Nodes audience
In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)
# Checklist
- [ ] I have added at least 2 reviewer or the whole pos-v1 team

View file

@ -104,7 +104,7 @@ jobs:
uses: actions/checkout@v3
with:
repository: maticnetwork/matic-cli
ref: arpit/pos-655-2
ref: master
path: matic-cli
- name: Install dependencies on Linux
@ -119,7 +119,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '10.17.0'
node-version: '16.17.1'
cache: 'npm'
cache-dependency-path: |
matic-cli/package-lock.json

738
.github/workflows/packager.yml vendored Normal file
View file

@ -0,0 +1,738 @@
name: packager
on:
push:
branches:
- 'main'
paths:
- '**'
tags:
- 'v*.*.*'
- 'v*.*.*-*'
jobs:
build:
runs-on:
group: ubuntu-runners
labels: 18.04RunnerT2Large
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.19
- name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
- name: Cleaning repo
run: make clean
- name: Building for amd64
run: make bor
- name: Making directory structure
run: mkdir -p packaging/deb/bor/usr/bin
- name: Making directory structure for toml
run: mkdir -p packaging/deb/bor/var/lib/bor
- name: Copying necessary files
run: cp -rp build/bin/bor packaging/deb/bor/usr/bin/
- name: copying control file
run: cp -rp packaging/templates/package_scripts/control packaging/deb/bor/DEBIAN/control
- name: removing systemd file for binary
run: rm -rf lib/systemd/system/bor.service
- name: Creating package for binary for bor ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
- name: Running package build
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
- name: Removing the bor binary
run: rm -rf packaging/deb/bor/usr/bin/bor
- name: making directory structure for systemd
run: mkdir -p packaging/deb/bor/lib/systemd/system
- name: Copying systemd file
run: cp -rp packaging/templates/systemd/bor.service packaging/deb/bor/lib/systemd/system/bor.service
- name: Prepping ${{ env.NETWORK }} ${{ env.NODE }} node for ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Putting toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/sentry/sentry/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying the postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying systemd file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/systemd/bor.service packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/lib/systemd/system/
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Running package build for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: sentry
NETWORK: mumbai
- name: Setting up ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Putting toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying the postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Building ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: sentry
NETWORK: mainnet
- name: Prepping Bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.validator packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying Postinstall script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying Prerm script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying Postrm script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying config.toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/sentry/validator/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: validator
NETWORK: mumbai
- name: Prepping Bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.validator packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying Postinstall script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying config.toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/sentry/validator/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: validator
NETWORK: mainnet
- name: Creating bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying profile preinst file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying the profile postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying profile prerm file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying profile postrm file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Copying the toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/archive/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: archive
NETWORK: mumbai
- name: Creating bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.amd64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying profile preinst file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying the profile postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying profile prerm file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying profile postrm file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Copying the toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/archive/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: amd64
NODE: archive
NETWORK: mainnet
- name: Cleaning build directory for arm64 build
run: make clean
- name: Removing systemd file
run: rm -rf packaging/deb/bor/lib/systemd/system/bor.service
- name: Updating the apt-get
run: sudo apt-get update -y
- name: Adding requirements for cross compile
run: sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
- name: removing systemd file for binary
run: rm -rf lib/systemd/system/bor.service
- name: Building bor for arm64
run: GOARCH=arm64 GOOS=linux CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CGO_ENABLED=1 go build -o build/bin/bor ./cmd/cli/main.go
- name: Copying bor arm64 for use with packaging
run: cp -rp build/bin/bor packaging/deb/bor/usr/bin/
- name: Creating package for binary only bor
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
- name: Copying control file
run: cp -rp packaging/templates/package_scripts/control.arm64 packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
- name: Running package build
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
- name: Removing the bor binary
run: rm -rf packaging/deb/bor/usr/bin/bor
- name: Copying systemd file
run: cp -rp packaging/templates/systemd/bor.service packaging/deb/bor/lib/systemd/system/bor.service
- name: Updating the control file to use with the arm64 profile
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor/DEBIAN/control
- name: Setting up bor for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Putting toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/sentry/sentry/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying the postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: sentry
NETWORK: mumbai
- name: Setting up bor for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Putting toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/sentry/sentry/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying the postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: sentry
NETWORK: mainnet
- name: Prepping Bor for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.validator.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying Postinstall script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying config.toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/sentry/validator/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: validator
NETWORK: mumbai
- name: Prepping Bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.validator.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying the preinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/preinst packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/preinst
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying Postinstall script for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying the prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying the postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying config.toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/sentry/validator/bor/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: validator
NETWORK: mainnet
- name: Updating the control file to use with the arm64 profile
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor/DEBIAN/control
- name: Creating bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Copying over profile postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Copying prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Copying postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Copying the toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/testnet-v4/archive/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: archive
NETWORK: mumbai
- name: Creating bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Copying profile control file for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/control.profile.arm64 packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/control
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Copying over profile postinst for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postinst.profile packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postinst
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Copying prerm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/prerm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/prerm
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Copying postrm for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/package_scripts/postrm packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/DEBIAN/postrm
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Copying the toml for ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }}
run: cp -rp packaging/templates/mainnet-v1/archive/config.toml packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}/var/lib/bor/
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Building bor ${{ env.NODE }} on ${{ env.NETWORK }} on ${{ env.ARCH }} profile
run: dpkg-deb --build --root-owner-group packaging/deb/bor-${{ env.NETWORK }}-${{ env.NODE }}-config_${{ env.GIT_TAG }}-${{ env.ARCH }}
env:
ARCH: arm64
NODE: archive
NETWORK: mainnet
- name: Confirming package built
run: ls -ltr packaging/deb/ | grep bor
- name: Release bor Packages
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.GIT_TAG }}
prerelease: true
files: |
packaging/deb/bor**.deb
binary/bo**

View file

@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.17.x
go-version: 1.19.x
- name: Prepare
id: prepare
@ -29,6 +29,12 @@ jobs:
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB }}
password: ${{ secrets.DOCKERHUB_KEY }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
@ -39,5 +45,3 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}

View file

@ -1,5 +1,5 @@
name: Security CI
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
snyk:
@ -13,10 +13,12 @@ jobs:
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
GOFLAGS: "-buildvcs=false"
with:
args: --org=${{ secrets.SNYK_ORG }} --severity-threshold=medium --sarif-file-output=snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
with:
sarif_file: snyk.sarif
@ -37,6 +39,7 @@ jobs:
command: code test
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
continue-on-error: true
with:
sarif_file: snyk.sarif

View file

@ -0,0 +1,32 @@
name: SonarQube CI
on:
push:
branches:
- develop
jobs:
sonarqube:
name: SonarQube
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting.
fetch-depth: 0
# Triggering SonarQube analysis as results of it are required by Quality Gate check.
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# Check the Quality Gate status.
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
# Force to fail step after specific time.
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

View file

@ -1,7 +1,7 @@
project_name: bor
release:
disable: false
disable: true
draft: true
prerelease: auto

View file

@ -1,17 +1,17 @@
FROM golang:latest
ARG BOR_DIR=/bor
ARG BOR_DIR=/var/lib/bor
ENV BOR_DIR=$BOR_DIR
RUN apt-get update -y && apt-get upgrade -y \
&& apt install build-essential git -y \
&& mkdir -p /bor
&& mkdir -p ${BOR_DIR}
WORKDIR ${BOR_DIR}
COPY . .
RUN make bor
RUN cp build/bin/bor /usr/local/bin/
RUN cp build/bin/bor /usr/bin/
ENV SHELL /bin/bash
EXPOSE 8545 8546 8547 30303 30303/udp

View file

@ -13,6 +13,6 @@ RUN set -x \
&& apk add --update --no-cache \
ca-certificates \
&& rm -rf /var/cache/apk/*
COPY --from=builder /bor/build/bin/* /usr/local/bin/
COPY --from=builder /bor/build/bin/* /usr/bin/
EXPOSE 8545 8546 30303 30303/udp

View file

@ -1,10 +1,15 @@
FROM alpine:3.14
ARG BOR_DIR=/var/lib/bor
ENV BOR_DIR=$BOR_DIR
RUN apk add --no-cache ca-certificates && \
mkdir -p /etc/bor
COPY bor /usr/local/bin/
COPY builder/files/genesis-mainnet-v1.json /etc/bor/
COPY builder/files/genesis-testnet-v4.json /etc/bor/
mkdir -p ${BOR_DIR}
WORKDIR ${BOR_DIR}
COPY bor /usr/bin/
COPY builder/files/genesis-mainnet-v1.json ${BOR_DIR}
COPY builder/files/genesis-testnet-v4.json ${BOR_DIR}
EXPOSE 8545 8546 8547 30303 30303/udp
ENTRYPOINT ["bor"]

View file

@ -14,20 +14,18 @@ GORUN = env GO111MODULE=on go run
GOPATH = $(shell go env GOPATH)
GIT_COMMIT ?= $(shell git rev-list -1 HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
GIT_TAG ?= $(shell git describe --tags `git rev-list --tags="v*" --max-count=1`)
PACKAGE = github.com/ethereum/go-ethereum
GO_FLAGS += -buildvcs=false
GO_FLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} -X ${PACKAGE}/params.GitBranch=${GIT_BRANCH} -X ${PACKAGE}/params.GitTag=${GIT_TAG}"
GO_LDFLAGS += -ldflags "-X ${PACKAGE}/params.GitCommit=${GIT_COMMIT} "
TESTALL = $$(go list ./... | grep -v go-ethereum/cmd/)
TESTE2E = ./tests/...
GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) -p 1
GOTEST = GODEBUG=cgocheck=0 go test $(GO_FLAGS) $(GO_LDFLAGS) -p 1
bor:
mkdir -p $(GOPATH)/bin/
go build -o $(GOBIN)/bor ./cmd/cli/main.go
go build -o $(GOBIN)/bor $(GO_LDFLAGS) ./cmd/cli/main.go
cp $(GOBIN)/bor $(GOPATH)/bin/
@echo "Done building."
@ -199,7 +197,7 @@ geth-windows-amd64:
@ls -ld $(GOBIN)/geth-windows-* | grep amd64
PACKAGE_NAME := github.com/maticnetwork/bor
GOLANG_CROSS_VERSION ?= v1.18.1
GOLANG_CROSS_VERSION ?= v1.19.1
.PHONY: release-dry-run
release-dry-run:
@ -227,6 +225,7 @@ release:
-e DOCKER_PASSWORD \
-e SLACK_WEBHOOK \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(HOME)/.docker/config.json:/root/.docker/config.json \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \

View file

@ -56,7 +56,7 @@ We believe one of the things that makes Polygon special is its coherent design a
### Building the source
- Building `bor` requires both a Go (version 1.14 or later) and a C compiler. You can install
- Building `bor` requires both a Go (version 1.19 or later) and a C compiler. You can install
them using your favourite package manager. Once the dependencies are installed, run
```shell
@ -74,7 +74,7 @@ them using your favourite package manager. Once the dependencies are installed,
2. Commit and prepare for pull request (PR). In your PR commit message, reference the issue it resolves (see [how to link a commit message to an issue using a keyword](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword).
Checkout our [Git-Rules](https://docs.polygon.technology/docs/contribute/orientation#git-rules)
Checkout our [Git-Rules](https://wiki.polygon.technology/docs/contribute/orientation/#git-rules)
```
$ git commit -m "brief description of changes [Fixes #1234]"

View file

@ -1959,6 +1959,7 @@ var bindTests = []struct {
// Tests that packages generated by the binder can be successfully compiled and
// the requested tester run against it.
func TestGolangBindings(t *testing.T) {
t.Skip("skipping test until we can fix it")
// Skip the test if no Go command can be found
gocmd := runtime.GOROOT() + "/bin/go"
if !common.FileExist(gocmd) {

View file

@ -6,7 +6,7 @@
[Service]
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/bor server -config="/var/lib/bor/config.toml"
ExecStart=/usr/local/bin/bor server -config "/var/lib/bor/config.toml"
Type=simple
User=bor
KillSignal=SIGINT

View file

@ -3,18 +3,28 @@
chain = "mainnet"
# chain = "mumbai"
# identity = "Pratiks-MacBook-Pro.local"
# log-level = "INFO"
# identity = "Annon-Identity"
# verbosity = 3
# vmdebug = false
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "/var/lib/bor/keystore"
# "rpc.batchlimit" = 100
# "rpc.returndatalimit" = 100000
syncmode = "full"
# gcmode = "full"
# snapshot = true
# "bor.logs" = false
# ethstats = ""
# devfakeauthor = false
# ["eth.requiredblocks"]
# [log]
# vmodule = ""
# json = false
# backtrace = ""
# debug = true
[p2p]
# maxpeers = 1
# nodiscover = true
@ -22,6 +32,9 @@ syncmode = "full"
# bind = "0.0.0.0"
# port = 30303
# nat = "any"
# netrestrict = ""
# nodekey = ""
# nodekeyhex = ""
[p2p.discovery]
# v5disc = false
bootnodes = ["enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303", "enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303"]
@ -52,46 +65,64 @@ syncmode = "full"
# pricebump = 10
[miner]
gaslimit = 20000000
gaslimit = 30000000
gasprice = "30000000000"
# mine = true
# etherbase = "VALIDATOR ADDRESS"
# extradata = ""
# recommit = "2m5s"
# [jsonrpc]
# ipcdisable = false
# ipcpath = ""
# gascap = 50000000
# txfeecap = 5.0
# [jsonrpc.http]
# enabled = false
# port = 8545
# prefix = ""
# host = "localhost"
# api = ["eth", "net", "web3", "txpool", "bor"]
# vhosts = ["*"]
# corsdomain = ["*"]
# [jsonrpc.ws]
# enabled = false
# port = 8546
# prefix = ""
# host = "localhost"
# api = ["web3", "net"]
# origins = ["*"]
# [jsonrpc.graphql]
# enabled = false
# port = 0
# prefix = ""
# host = ""
# vhosts = ["*"]
# corsdomain = ["*"]
# ipcdisable = false
# ipcpath = ""
# gascap = 50000000
# evmtimeout = "5s"
# txfeecap = 5.0
# allow-unprotected-txs = false
# [jsonrpc.http]
# enabled = false
# port = 8545
# prefix = ""
# host = "localhost"
# api = ["eth", "net", "web3", "txpool", "bor"]
# vhosts = ["*"]
# corsdomain = ["*"]
# ep-size = 40
# ep-requesttimeout = "0s"
# [jsonrpc.ws]
# enabled = false
# port = 8546
# prefix = ""
# host = "localhost"
# api = ["web3", "net"]
# origins = ["*"]
# ep-size = 40
# ep-requesttimeout = "0s"
# [jsonrpc.graphql]
# enabled = false
# port = 0
# prefix = ""
# host = ""
# vhosts = ["*"]
# corsdomain = ["*"]
# [jsonrpc.auth]
# jwtsecret = ""
# addr = "localhost"
# port = 8551
# vhosts = ["localhost"]
# [jsonrpc.timeouts]
# read = "10s"
# write = "30s"
# idle = "2m0s"
# [gpo]
[gpo]
# blocks = 20
# percentile = 60
# maxheaderhistory = 1024
# maxblockhistory = 1024
# maxprice = "5000000000000"
# ignoreprice = "2"
ignoreprice = "30000000000"
[telemetry]
metrics = true
@ -122,6 +153,8 @@ syncmode = "full"
# preimages = false
# txlookuplimit = 2350000
# triesinmemory = 128
# timeout = "1h0m0s"
# fdlimit = 0
[accounts]
# allow-insecure-unlock = true
@ -136,7 +169,15 @@ syncmode = "full"
# [developer]
# dev = false
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = false
# procs = 8
# [pprof]
# pprof = false
# port = 6060
# addr = "127.0.0.1"
# memprofilerate = 524288
# blockprofilerate = 0

View file

@ -15,14 +15,17 @@
"londonBlock": 23850000,
"bor": {
"jaipurBlock": 23850000,
"delhiBlock": 38189056,
"period": {
"0": 2
},
"producerDelay": {
"0": 6
"0": 6,
"38189056": 4
},
"sprint": {
"0": 64
"0": 64,
"38189056": 16
},
"backupMultiplier": {
"0": 2

View file

@ -656,7 +656,7 @@ func signer(c *cli.Context) error {
vhosts := utils.SplitAndTrim(c.GlobalString(utils.HTTPVirtualHostsFlag.Name))
cors := utils.SplitAndTrim(c.GlobalString(utils.HTTPCORSDomainFlag.Name))
srv := rpc.NewServer()
srv := rpc.NewServer(0, 0)
err := node.RegisterApis(rpcAPI, []string{"account"}, srv, false)
if err != nil {
utils.Fatalf("Could not register API: %w", err)

View file

@ -109,6 +109,9 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
utils.HeimdallURLFlag,
utils.WithoutHeimdallFlag,
utils.HeimdallgRPCAddressFlag,
utils.RunHeimdallFlag,
utils.RunHeimdallArgsFlag,
utils.UseHeimdallAppFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `

View file

@ -18,11 +18,14 @@
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sort"
"strconv"
"strings"
"syscall"
"time"
"github.com/ethereum/go-ethereum/accounts"
@ -44,6 +47,7 @@ import (
_ "github.com/ethereum/go-ethereum/eth/tracers/js"
_ "github.com/ethereum/go-ethereum/eth/tracers/native"
"github.com/maticnetwork/heimdall/cmd/heimdalld/service"
"gopkg.in/urfave/cli.v1"
)
@ -343,6 +347,15 @@ func geth(ctx *cli.Context) error {
return fmt.Errorf("invalid command: %q", args[0])
}
if ctx.GlobalBool(utils.RunHeimdallFlag.Name) {
shutdownCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer stop()
go func() {
service.NewHeimdallService(shutdownCtx, getHeimdallArgs(ctx))
}()
}
prepare(ctx)
stack, backend := makeFullNode(ctx)
defer stack.Close()
@ -477,3 +490,8 @@ func unlockAccounts(ctx *cli.Context, stack *node.Node) {
unlockAccount(ks, account, i, passwords)
}
}
func getHeimdallArgs(ctx *cli.Context) []string {
heimdallArgs := strings.Split(ctx.GlobalString(utils.RunHeimdallArgsFlag.Name), ",")
return append([]string{"start"}, heimdallArgs...)
}

View file

@ -38,11 +38,32 @@ var (
Value: "",
}
// RunHeimdallFlag flag for running heimdall internally from bor
RunHeimdallFlag = cli.BoolFlag{
Name: "bor.runheimdall",
Usage: "Run Heimdall service as a child process",
}
RunHeimdallArgsFlag = cli.StringFlag{
Name: "bor.runheimdallargs",
Usage: "Arguments to pass to Heimdall service",
Value: "",
}
// UseHeimdallApp flag for using internall heimdall app to fetch data
UseHeimdallAppFlag = cli.BoolFlag{
Name: "bor.useheimdallapp",
Usage: "Use child heimdall process to fetch data, Only works when bor.runheimdall is true",
}
// BorFlags all bor related flags
BorFlags = []cli.Flag{
HeimdallURLFlag,
WithoutHeimdallFlag,
HeimdallgRPCAddressFlag,
RunHeimdallFlag,
RunHeimdallArgsFlag,
UseHeimdallAppFlag,
}
)
@ -66,6 +87,9 @@ func SetBorConfig(ctx *cli.Context, cfg *eth.Config) {
cfg.HeimdallURL = ctx.GlobalString(HeimdallURLFlag.Name)
cfg.WithoutHeimdall = ctx.GlobalBool(WithoutHeimdallFlag.Name)
cfg.HeimdallgRPCAddress = ctx.GlobalString(HeimdallgRPCAddressFlag.Name)
cfg.RunHeimdall = ctx.GlobalBool(RunHeimdallFlag.Name)
cfg.RunHeimdallArgs = ctx.GlobalString(RunHeimdallArgsFlag.Name)
cfg.UseHeimdallApp = ctx.GlobalBool(UseHeimdallAppFlag.Name)
}
// CreateBorEthereum Creates bor ethereum object from eth.Config

View file

@ -2035,6 +2035,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
HeimdallURL: ctx.GlobalString(HeimdallURLFlag.Name),
WithoutHeimdall: ctx.GlobalBool(WithoutHeimdallFlag.Name),
HeimdallgRPCAddress: ctx.GlobalString(HeimdallgRPCAddressFlag.Name),
RunHeimdall: ctx.GlobalBool(RunHeimdallFlag.Name),
RunHeimdallArgs: ctx.GlobalString(RunHeimdallArgsFlag.Name),
UseHeimdallApp: ctx.GlobalBool(UseHeimdallAppFlag.Name),
})
engine = ethereum.Engine()
} else {

View file

@ -227,7 +227,8 @@ type Bor struct {
HeimdallClient IHeimdallClient
// The fields below are for testing only
fakeDiff bool // Skip difficulty verifications
fakeDiff bool // Skip difficulty verifications
devFakeAuthor bool
closeOnce sync.Once
}
@ -245,6 +246,7 @@ func New(
spanner Spanner,
heimdallClient IHeimdallClient,
genesisContracts GenesisContract,
devFakeAuthor bool,
) *Bor {
// get bor config
borConfig := chainConfig.Bor
@ -267,6 +269,7 @@ func New(
spanner: spanner,
GenesisContractsClient: genesisContracts,
HeimdallClient: heimdallClient,
devFakeAuthor: devFakeAuthor,
}
c.authorizedSigner.Store(&signer{
@ -298,6 +301,14 @@ func (c *Bor) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Head
return c.verifyHeader(chain, header, nil)
}
func (c *Bor) GetSpanner() Spanner {
return c.spanner
}
func (c *Bor) SetSpanner(spanner Spanner) {
c.spanner = spanner
}
// VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The
// method returns a quit channel to abort the operations and a results channel to
// retrieve the async verifications (the order is that of the input slice).
@ -454,6 +465,33 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
return err
}
// Verify the validator list match the local contract
if IsSprintStart(number+1, c.config.CalculateSprint(number)) {
newValidators, err := c.spanner.GetCurrentValidatorsByBlockNrOrHash(context.Background(), rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber), number+1)
if err != nil {
return err
}
sort.Sort(valset.ValidatorsByAddress(newValidators))
headerVals, err := valset.ParseValidators(header.Extra[extraVanity : len(header.Extra)-extraSeal])
if err != nil {
return err
}
if len(newValidators) != len(headerVals) {
return errInvalidSpanValidators
}
for i, val := range newValidators {
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
return errInvalidSpanValidators
}
}
}
// verify the validator list in the last sprint block
if IsSprintStart(number, c.config.CalculateSprint(number)) {
parentValidatorBytes := parent.Extra[extraVanity : len(parent.Extra)-extraSeal]
@ -480,6 +518,19 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
// nolint: gocognit
func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash common.Hash, parents []*types.Header) (*Snapshot, error) {
// Search for a snapshot in memory or on disk for checkpoints
signer := common.BytesToAddress(c.authorizedSigner.Load().signer.Bytes())
if c.devFakeAuthor && signer.String() != "0x0000000000000000000000000000000000000000" {
log.Info("👨💻Using DevFakeAuthor", "signer", signer)
val := valset.NewValidator(signer, 1000)
validatorset := valset.NewValidatorSet([]*valset.Validator{val})
snapshot := newSnapshot(c.config, c.signatures, number, hash, validatorset.Validators)
return snapshot, nil
}
var snap *Snapshot
headers := make([]*types.Header, 0, 16)
@ -518,7 +569,7 @@ func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash co
hash := checkpoint.Hash()
// get validators and current span
validators, err := c.spanner.GetCurrentValidators(context.Background(), hash, number+1)
validators, err := c.spanner.GetCurrentValidatorsByHash(context.Background(), hash, number+1)
if err != nil {
return nil, err
}
@ -688,7 +739,7 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e
// get validator set if number
if IsSprintStart(number+1, c.config.CalculateSprint(number)) {
newValidators, err := c.spanner.GetCurrentValidators(context.Background(), header.ParentHash, number+1)
newValidators, err := c.spanner.GetCurrentValidatorsByHash(context.Background(), header.ParentHash, number+1)
if err != nil {
return errUnknownValidators
}
@ -1161,7 +1212,7 @@ func (c *Bor) CommitStates(
processStart := time.Now()
totalGas := 0 /// limit on gas for state sync per block
chainID := c.chainConfig.ChainID.String()
stateSyncs := make([]*types.StateSyncData, len(eventRecords))
stateSyncs := make([]*types.StateSyncData, 0, len(eventRecords))
var gasUsed uint64
@ -1218,7 +1269,7 @@ func (c *Bor) SetHeimdallClient(h IHeimdallClient) {
}
func (c *Bor) GetCurrentValidators(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) {
return c.spanner.GetCurrentValidators(ctx, headerHash, blockNumber)
return c.spanner.GetCurrentValidatorsByHash(ctx, headerHash, blockNumber)
}
//

View file

@ -89,7 +89,7 @@ func (c *ChainSpanner) GetCurrentSpan(ctx context.Context, headerHash common.Has
}
// GetCurrentValidators get current validators
func (c *ChainSpanner) GetCurrentValidators(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) {
func (c *ChainSpanner) GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@ -107,16 +107,13 @@ func (c *ChainSpanner) GetCurrentValidators(ctx context.Context, headerHash comm
toAddress := c.validatorContractAddress
gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2))
// block
blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false)
result, err := c.ethAPI.Call(ctx, ethapi.TransactionArgs{
Gas: &gas,
To: &toAddress,
Data: &msgData,
}, blockNr, nil)
}, blockNrOrHash, nil)
if err != nil {
panic(err)
return nil, err
}
var (
@ -144,6 +141,12 @@ func (c *ChainSpanner) GetCurrentValidators(ctx context.Context, headerHash comm
return valz, nil
}
func (c *ChainSpanner) GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) {
blockNr := rpc.BlockNumberOrHashWithHash(headerHash, false)
return c.GetCurrentValidatorsByBlockNrOrHash(ctx, blockNr, blockNumber)
}
const method = "commitSpan"
func (c *ChainSpanner) CommitSpan(ctx context.Context, heimdallSpan HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error {

View file

@ -0,0 +1,52 @@
package heimdallapp
import (
"context"
"math/big"
"github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/consensus/bor/heimdall/checkpoint"
"github.com/ethereum/go-ethereum/log"
hmTypes "github.com/maticnetwork/heimdall/types"
abci "github.com/tendermint/tendermint/abci/types"
)
func (h *HeimdallAppClient) FetchCheckpointCount(_ context.Context) (int64, error) {
log.Info("Fetching checkpoint count")
res := h.hApp.CheckpointKeeper.GetACKCount(h.NewContext())
log.Info("Fetched checkpoint count")
return int64(res), nil
}
func (h *HeimdallAppClient) FetchCheckpoint(_ context.Context, number int64) (*checkpoint.Checkpoint, error) {
log.Info("Fetching checkpoint", "number", number)
res, err := h.hApp.CheckpointKeeper.GetCheckpointByNumber(h.NewContext(), uint64(number))
if err != nil {
return nil, err
}
log.Info("Fetched checkpoint", "number", number)
return toBorCheckpoint(res), nil
}
func (h *HeimdallAppClient) NewContext() types.Context {
return h.hApp.NewContext(true, abci.Header{Height: h.hApp.LastBlockHeight()})
}
func toBorCheckpoint(hdCheckpoint hmTypes.Checkpoint) *checkpoint.Checkpoint {
return &checkpoint.Checkpoint{
Proposer: hdCheckpoint.Proposer.EthAddress(),
StartBlock: big.NewInt(int64(hdCheckpoint.StartBlock)),
EndBlock: big.NewInt(int64(hdCheckpoint.EndBlock)),
RootHash: hdCheckpoint.RootHash.EthHash(),
BorChainID: hdCheckpoint.BorChainID,
Timestamp: hdCheckpoint.TimeStamp,
}
}

View file

@ -0,0 +1,27 @@
package heimdallapp
import (
"github.com/ethereum/go-ethereum/log"
"github.com/maticnetwork/heimdall/app"
"github.com/maticnetwork/heimdall/cmd/heimdalld/service"
)
const (
stateFetchLimit = 50
)
type HeimdallAppClient struct {
hApp *app.HeimdallApp
}
func NewHeimdallAppClient() *HeimdallAppClient {
return &HeimdallAppClient{
hApp: service.GetHeimdallApp(),
}
}
func (h *HeimdallAppClient) Close() {
// Nothing to close as of now
log.Warn("Shutdown detected, Closing Heimdall App conn")
}

View file

@ -0,0 +1,86 @@
package heimdallapp
import (
"context"
hmTypes "github.com/maticnetwork/heimdall/types"
"github.com/ethereum/go-ethereum/consensus/bor/heimdall/span"
"github.com/ethereum/go-ethereum/consensus/bor/valset"
"github.com/ethereum/go-ethereum/log"
)
func (h *HeimdallAppClient) Span(ctx context.Context, spanID uint64) (*span.HeimdallSpan, error) {
log.Info("Fetching span", "spanID", spanID)
res, err := h.hApp.BorKeeper.GetSpan(h.NewContext(), spanID)
if err != nil {
return nil, err
}
log.Info("Fetched span", "spanID", spanID)
return toSpan(res), nil
}
func toSpan(hdSpan *hmTypes.Span) *span.HeimdallSpan {
return &span.HeimdallSpan{
Span: span.Span{
ID: hdSpan.ID,
StartBlock: hdSpan.StartBlock,
EndBlock: hdSpan.EndBlock,
},
ValidatorSet: toValidatorSet(hdSpan.ValidatorSet),
SelectedProducers: toValidators(hdSpan.SelectedProducers),
ChainID: hdSpan.ChainID,
}
}
func toValidatorSet(vs hmTypes.ValidatorSet) valset.ValidatorSet {
return valset.ValidatorSet{
Validators: toValidatorsRef(vs.Validators),
Proposer: toValidatorRef(vs.Proposer),
}
}
func toValidators(vs []hmTypes.Validator) []valset.Validator {
newVS := make([]valset.Validator, len(vs))
for i, v := range vs {
newVS[i] = toValidator(v)
}
return newVS
}
func toValidatorsRef(vs []*hmTypes.Validator) []*valset.Validator {
newVS := make([]*valset.Validator, len(vs))
for i, v := range vs {
if v == nil {
continue
}
newVS[i] = toValidatorRef(v)
}
return newVS
}
func toValidatorRef(v *hmTypes.Validator) *valset.Validator {
return &valset.Validator{
ID: v.ID.Uint64(),
Address: v.Signer.EthAddress(),
VotingPower: v.VotingPower,
ProposerPriority: v.ProposerPriority,
}
}
func toValidator(v hmTypes.Validator) valset.Validator {
return valset.Validator{
ID: v.ID.Uint64(),
Address: v.Signer.EthAddress(),
VotingPower: v.VotingPower,
ProposerPriority: v.ProposerPriority,
}
}

View file

@ -0,0 +1,64 @@
package heimdallapp
import (
"context"
"time"
"github.com/maticnetwork/heimdall/clerk/types"
"github.com/ethereum/go-ethereum/consensus/bor/clerk"
abci "github.com/tendermint/tendermint/abci/types"
)
func (h *HeimdallAppClient) StateSyncEvents(ctx context.Context, fromID uint64, to int64) ([]*clerk.EventRecordWithTime, error) {
totalRecords := make([]*clerk.EventRecordWithTime, 0)
hCtx := h.hApp.NewContext(true, abci.Header{Height: h.hApp.LastBlockHeight()})
for {
fromRecord, err := h.hApp.ClerkKeeper.GetEventRecord(hCtx, fromID)
if err != nil {
return nil, err
}
events, err := h.hApp.ClerkKeeper.GetEventRecordListWithTime(hCtx, fromRecord.RecordTime, time.Unix(to, 0), 1, stateFetchLimit)
if err != nil {
return nil, err
}
totalRecords = append(totalRecords, toEvents(events)...)
if len(events) < stateFetchLimit {
break
}
fromID += uint64(stateFetchLimit)
}
return totalRecords, nil
}
func toEvents(hdEvents []types.EventRecord) []*clerk.EventRecordWithTime {
events := make([]*clerk.EventRecordWithTime, len(hdEvents))
for i, ev := range hdEvents {
events[i] = toEvent(ev)
}
return events
}
func toEvent(hdEvent types.EventRecord) *clerk.EventRecordWithTime {
return &clerk.EventRecordWithTime{
EventRecord: clerk.EventRecord{
ID: hdEvent.ID,
Contract: hdEvent.Contract.EthAddress(),
Data: hdEvent.Data.Bytes(),
TxHash: hdEvent.TxHash.EthHash(),
LogIndex: hdEvent.LogIndex,
ChainID: hdEvent.ChainID,
},
Time: hdEvent.RecordTime,
}
}

View file

@ -9,11 +9,13 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
)
//go:generate mockgen -destination=./span_mock.go -package=bor . Spanner
type Spanner interface {
GetCurrentSpan(ctx context.Context, headerHash common.Hash) (*span.Span, error)
GetCurrentValidators(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error)
GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error)
GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error)
CommitSpan(ctx context.Context, heimdallSpan span.HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error
}

View file

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/ethereum/go-ethereum/consensus/bor (interfaces: Spanner)
// Source: consensus/bor/span.go
// Package bor is a generated GoMock package.
package bor
@ -14,6 +14,7 @@ import (
core "github.com/ethereum/go-ethereum/core"
state "github.com/ethereum/go-ethereum/core/state"
types "github.com/ethereum/go-ethereum/core/types"
rpc "github.com/ethereum/go-ethereum/rpc"
gomock "github.com/golang/mock/gomock"
)
@ -41,45 +42,60 @@ func (m *MockSpanner) EXPECT() *MockSpannerMockRecorder {
}
// CommitSpan mocks base method.
func (m *MockSpanner) CommitSpan(arg0 context.Context, arg1 span.HeimdallSpan, arg2 *state.StateDB, arg3 *types.Header, arg4 core.ChainContext) error {
func (m *MockSpanner) CommitSpan(ctx context.Context, heimdallSpan span.HeimdallSpan, state *state.StateDB, header *types.Header, chainContext core.ChainContext) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CommitSpan", arg0, arg1, arg2, arg3, arg4)
ret := m.ctrl.Call(m, "CommitSpan", ctx, heimdallSpan, state, header, chainContext)
ret0, _ := ret[0].(error)
return ret0
}
// CommitSpan indicates an expected call of CommitSpan.
func (mr *MockSpannerMockRecorder) CommitSpan(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
func (mr *MockSpannerMockRecorder) CommitSpan(ctx, heimdallSpan, state, header, chainContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitSpan", reflect.TypeOf((*MockSpanner)(nil).CommitSpan), arg0, arg1, arg2, arg3, arg4)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitSpan", reflect.TypeOf((*MockSpanner)(nil).CommitSpan), ctx, heimdallSpan, state, header, chainContext)
}
// GetCurrentSpan mocks base method.
func (m *MockSpanner) GetCurrentSpan(arg0 context.Context, arg1 common.Hash) (*span.Span, error) {
func (m *MockSpanner) GetCurrentSpan(ctx context.Context, headerHash common.Hash) (*span.Span, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCurrentSpan", arg0, arg1)
ret := m.ctrl.Call(m, "GetCurrentSpan", ctx, headerHash)
ret0, _ := ret[0].(*span.Span)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetCurrentSpan indicates an expected call of GetCurrentSpan.
func (mr *MockSpannerMockRecorder) GetCurrentSpan(arg0, arg1 interface{}) *gomock.Call {
func (mr *MockSpannerMockRecorder) GetCurrentSpan(ctx, headerHash interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentSpan", reflect.TypeOf((*MockSpanner)(nil).GetCurrentSpan), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentSpan", reflect.TypeOf((*MockSpanner)(nil).GetCurrentSpan), ctx, headerHash)
}
// GetCurrentValidators mocks base method.
func (m *MockSpanner) GetCurrentValidators(arg0 context.Context, arg1 common.Hash, arg2 uint64) ([]*valset.Validator, error) {
// GetCurrentValidatorsByBlockNrOrHash mocks base method.
func (m *MockSpanner) GetCurrentValidatorsByBlockNrOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNumber uint64) ([]*valset.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCurrentValidators", arg0, arg1, arg2)
ret := m.ctrl.Call(m, "GetCurrentValidatorsByBlockNrOrHash", ctx, blockNrOrHash, blockNumber)
ret0, _ := ret[0].([]*valset.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetCurrentValidators indicates an expected call of GetCurrentValidators.
func (mr *MockSpannerMockRecorder) GetCurrentValidators(arg0, arg1, arg2 interface{}) *gomock.Call {
// GetCurrentValidatorsByBlockNrOrHash indicates an expected call of GetCurrentValidatorsByBlockNrOrHash.
func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByBlockNrOrHash(ctx, blockNrOrHash, blockNumber interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidators", reflect.TypeOf((*MockSpanner)(nil).GetCurrentValidators), arg0, arg1, arg2)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorsByBlockNrOrHash", reflect.TypeOf((*MockSpanner)(nil).GetCurrentValidatorsByBlockNrOrHash), ctx, blockNrOrHash, blockNumber)
}
// GetCurrentValidatorsByHash mocks base method.
func (m *MockSpanner) GetCurrentValidatorsByHash(ctx context.Context, headerHash common.Hash, blockNumber uint64) ([]*valset.Validator, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetCurrentValidatorsByHash", ctx, headerHash, blockNumber)
ret0, _ := ret[0].([]*valset.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetCurrentValidatorsByHash indicates an expected call of GetCurrentValidatorsByHash.
func (mr *MockSpannerMockRecorder) GetCurrentValidatorsByHash(ctx, headerHash, blockNumber interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCurrentValidatorsByHash", reflect.TypeOf((*MockSpanner)(nil).GetCurrentValidatorsByHash), ctx, headerHash, blockNumber)
}

View file

@ -305,7 +305,7 @@ func (vals *ValidatorSet) UpdateTotalVotingPower() error {
// It recomputes the total voting power if required.
func (vals *ValidatorSet) TotalVotingPower() int64 {
if vals.totalVotingPower == 0 {
log.Info("invoking updateTotalVotingPower before returning it")
log.Debug("invoking updateTotalVotingPower before returning it")
if err := vals.UpdateTotalVotingPower(); err != nil {
// Can/should we do better?
@ -641,14 +641,15 @@ func (vals *ValidatorSet) UpdateValidatorMap() {
// UpdateWithChangeSet attempts to update the validator set with 'changes'.
// It performs the following steps:
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
//
// If an error is detected during verification steps, it is returned and the validator set
// is not changed.
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error {
@ -705,6 +706,14 @@ func (vals *ValidatorSet) StringIndented(indent string) string {
indent)
}
func (vals *ValidatorSet) SetTotalVotingPower(totalVotingPower int64) {
vals.totalVotingPower = totalVotingPower
}
func (vals *ValidatorSet) SetMap(validatorsMap map[common.Address]int) {
vals.validatorsMap = validatorsMap
}
//-------------------------------------
// Implements sort for sorting validators by address.

View file

@ -18,21 +18,29 @@
package core
import (
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"math/big"
"os"
"path/filepath"
"sort"
"strings"
"sync"
"sync/atomic"
"time"
lru "github.com/hashicorp/golang-lru"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/mclock"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/common/tracing"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
@ -68,6 +76,7 @@ var (
snapshotStorageReadTimer = metrics.NewRegisteredTimer("chain/snapshot/storage/reads", nil)
snapshotCommitTimer = metrics.NewRegisteredTimer("chain/snapshot/commits", nil)
blockImportTimer = metrics.NewRegisteredMeter("chain/imports", nil)
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil)
blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil)
@ -1361,43 +1370,89 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
}
// WriteBlockWithState writes the block and all associated state to the database.
func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
func (bc *BlockChain) WriteBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
if !bc.chainmu.TryLock() {
return NonStatTy, errChainStopped
}
defer bc.chainmu.Unlock()
return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent)
return bc.writeBlockAndSetHead(ctx, block, receipts, logs, state, emitHeadEvent)
}
// writeBlockAndSetHead writes the block and all associated state to the database,
// and also it applies the given block as the new chain head. This function expects
// the chain mutex to be held.
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
func (bc *BlockChain) writeBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
writeBlockAndSetHeadCtx, span := tracing.StartSpan(ctx, "blockchain.writeBlockAndSetHead")
defer tracing.EndSpan(span)
var stateSyncLogs []*types.Log
if stateSyncLogs, err = bc.writeBlockWithState(block, receipts, logs, state); err != nil {
return NonStatTy, err
}
currentBlock := bc.CurrentBlock()
reorg, err := bc.forker.ReorgNeeded(currentBlock.Header(), block.Header())
tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.writeBlockWithState", func(_ context.Context, span trace.Span) {
stateSyncLogs, err = bc.writeBlockWithState(block, receipts, logs, state)
tracing.SetAttributes(
span,
attribute.Int("number", int(block.Number().Uint64())),
attribute.Bool("error", err != nil),
)
})
if err != nil {
return NonStatTy, err
}
if reorg {
// Reorganise the chain if the parent is not the head block
if block.ParentHash() != currentBlock.Hash() {
if err := bc.reorg(currentBlock, block); err != nil {
return NonStatTy, err
}
}
status = CanonStatTy
} else {
status = SideStatTy
currentBlock := bc.CurrentBlock()
var reorg bool
tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.ReorgNeeded", func(_ context.Context, span trace.Span) {
reorg, err = bc.forker.ReorgNeeded(currentBlock.Header(), block.Header())
tracing.SetAttributes(
span,
attribute.Int("number", int(block.Number().Uint64())),
attribute.Int("current block", int(currentBlock.Number().Uint64())),
attribute.Bool("reorg needed", reorg),
attribute.Bool("error", err != nil),
)
})
if err != nil {
return NonStatTy, err
}
tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.reorg", func(_ context.Context, span trace.Span) {
if reorg {
// Reorganise the chain if the parent is not the head block
if block.ParentHash() != currentBlock.Hash() {
if err = bc.reorg(currentBlock, block); err != nil {
status = NonStatTy
}
}
status = CanonStatTy
} else {
status = SideStatTy
}
tracing.SetAttributes(
span,
attribute.Int("number", int(block.Number().Uint64())),
attribute.Int("current block", int(currentBlock.Number().Uint64())),
attribute.Bool("reorg needed", reorg),
attribute.Bool("error", err != nil),
attribute.String("status", string(status)),
)
})
if status == NonStatTy {
return
}
// Set new head.
if status == CanonStatTy {
bc.writeHeadBlock(block)
tracing.Exec(writeBlockAndSetHeadCtx, "", "blockchain.writeHeadBlock", func(_ context.Context, _ trace.Span) {
bc.writeHeadBlock(block)
})
}
bc.futureBlocks.Remove(block.Hash())
if status == CanonStatTy {
@ -1531,6 +1586,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
it := newInsertIterator(chain, results, bc.validator)
block, err := it.next()
// Update the block import meter; it will just record chains we've received
// from other peers. (Note that the actual chain which gets imported would be
// quite low).
blockImportTimer.Mark(int64(len(headers)))
// Check the validity of incoming chain
isValid, err1 := bc.forker.ValidateReorg(bc.CurrentBlock().Header(), headers)
if err1 != nil {
@ -1789,7 +1849,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
// Don't set the head, only insert the block
_, err = bc.writeBlockWithState(block, receipts, logs, statedb)
} else {
status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false)
status, err = bc.writeBlockAndSetHead(context.Background(), block, receipts, logs, statedb, false)
}
atomic.StoreUint32(&followupInterrupt, 1)
if err != nil {
@ -2066,7 +2126,7 @@ func (bc *BlockChain) collectLogs(hash common.Hash, removed bool) []*types.Log {
receipts := rawdb.ReadReceipts(bc.db, hash, *number, bc.chainConfig)
// Append bor receipt
borReceipt := rawdb.ReadBorReceipt(bc.db, hash, *number)
borReceipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig)
if borReceipt != nil {
receipts = append(receipts, borReceipt)
}
@ -2198,6 +2258,35 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
} else {
// len(newChain) == 0 && len(oldChain) > 0
// rewind the canonical chain to a lower point.
home, err := os.UserHomeDir()
if err != nil {
fmt.Println("Impossible reorg : Unable to get user home dir", "Error", err)
}
outPath := filepath.Join(home, "impossible-reorgs", fmt.Sprintf("%v-impossibleReorg", time.Now().Format(time.RFC3339)))
if _, err := os.Stat(outPath); errors.Is(err, os.ErrNotExist) {
err := os.MkdirAll(outPath, os.ModePerm)
if err != nil {
log.Error("Impossible reorg : Unable to create Dir", "Error", err)
}
} else {
err = ExportBlocks(oldChain, filepath.Join(outPath, "oldChain.gz"))
if err != nil {
log.Error("Impossible reorg : Unable to export oldChain", "Error", err)
}
err = ExportBlocks([]*types.Block{oldBlock}, filepath.Join(outPath, "oldBlock.gz"))
if err != nil {
log.Error("Impossible reorg : Unable to export oldBlock", "Error", err)
}
err = ExportBlocks([]*types.Block{newBlock}, filepath.Join(outPath, "newBlock.gz"))
if err != nil {
log.Error("Impossible reorg : Unable to export newBlock", "Error", err)
}
}
log.Error("Impossible reorg, please file an issue", "oldnum", oldBlock.Number(), "oldhash", oldBlock.Hash(), "oldblocks", len(oldChain), "newnum", newBlock.Number(), "newhash", newBlock.Hash(), "newblocks", len(newChain))
}
// Insert the new chain(except the head block(reverse order)),
@ -2250,6 +2339,44 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
return nil
}
// ExportBlocks exports blocks into the specified file, truncating any data
// already present in the file.
func ExportBlocks(blocks []*types.Block, fn string) error {
log.Info("Exporting blockchain", "file", fn)
// Open the file handle and potentially wrap with a gzip stream
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {
return err
}
defer fh.Close()
var writer io.Writer = fh
if strings.HasSuffix(fn, ".gz") {
writer = gzip.NewWriter(writer)
defer writer.(*gzip.Writer).Close()
}
// Iterate over the blocks and export them
if err := ExportN(writer, blocks); err != nil {
return err
}
log.Info("Exported blocks", "file", fn)
return nil
}
// ExportBlock writes a block to the given writer.
func ExportN(w io.Writer, blocks []*types.Block) error {
for _, block := range blocks {
if err := block.EncodeRLP(w); err != nil {
return err
}
}
return nil
}
// InsertBlockWithoutSetHead executes the block, runs the necessary verification
// upon it and then persist the block and the associate state into the database.
// The key difference between the InsertChain is it won't do the canonical chain

View file

@ -422,6 +422,10 @@ func (bc *BlockChain) SetStateSync(stateData []*types.StateSyncData) {
bc.stateSyncData = stateData
}
func (bc *BlockChain) GetStateSync() []*types.StateSyncData {
return bc.stateSyncData
}
// SubscribeStateSyncEvent registers a subscription of StateSyncEvent.
func (bc *BlockChain) SubscribeStateSyncEvent(ch chan<- StateSyncEvent) event.Subscription {
return bc.scope.Track(bc.stateSyncFeed.Subscribe(ch))

View file

@ -19,7 +19,7 @@ func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt {
}
// read bor reciept by hash and number
receipt := rawdb.ReadBorReceipt(bc.db, hash, *number)
receipt := rawdb.ReadBorReceipt(bc.db, hash, *number, bc.chainConfig)
if receipt == nil {
return nil
}

View file

@ -63,6 +63,10 @@ var (
// have enough funds for transfer(topmost call only).
ErrInsufficientFundsForTransfer = errors.New("insufficient funds for transfer")
// ErrMaxInitCodeSizeExceeded is returned if creation transaction provides the init code bigger
// than init code size limit.
ErrMaxInitCodeSizeExceeded = errors.New("max initcode size exceeded")
// ErrInsufficientFunds is returned if the total cost of executing a transaction
// is higher than the balance of the user's account.
ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value")

View file

@ -114,9 +114,7 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, header *types.Header) (b
func (f *ForkChoice) ValidateReorg(current *types.Header, chain []*types.Header) (bool, error) {
// Call the bor chain validator service
if f.validator != nil {
if isValid := f.validator.IsValidChain(current, chain); !isValid {
return false, nil
}
return f.validator.IsValidChain(current, chain)
}
return true, nil

View file

@ -13,7 +13,7 @@ import (
// chainValidatorFake is a mock for the chain validator service
type chainValidatorFake struct {
validate func(currentHeader *types.Header, chain []*types.Header) bool
validate func(currentHeader *types.Header, chain []*types.Header) (bool, error)
}
// chainReaderFake is a mock for the chain reader service
@ -21,7 +21,7 @@ type chainReaderFake struct {
getTd func(hash common.Hash, number uint64) *big.Int
}
func newChainValidatorFake(validate func(currentHeader *types.Header, chain []*types.Header) bool) *chainValidatorFake {
func newChainValidatorFake(validate func(currentHeader *types.Header, chain []*types.Header) (bool, error)) *chainValidatorFake {
return &chainValidatorFake{validate: validate}
}
@ -46,18 +46,18 @@ func TestPastChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If canonical chain is of len 64 and we're importing a past chain from 54-64, then accept it
if currentHeader.Number.Uint64() == uint64(64) && chain[0].Number.Uint64() == 55 && len(chain) == 10 {
return true
return true, nil
}
return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
@ -116,18 +116,18 @@ func TestFutureChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If length of future chains > some value, they should not be accepted
if currentHeader.Number.Uint64() == uint64(64) && len(chain) <= 10 {
return true
return true, nil
}
return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
@ -174,18 +174,18 @@ func TestOverlappingChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If length of chain is > some fixed value then don't accept it
if currentHeader.Number.Uint64() == uint64(64) && len(chain) <= 20 {
return true
return true, nil
}
return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
@ -227,7 +227,7 @@ func (c *chainReaderFake) GetTd(hash common.Hash, number uint64) *big.Int {
func (w *chainValidatorFake) IsValidPeer(remoteHeader *types.Header, fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) {
return true, nil
}
func (w *chainValidatorFake) IsValidChain(current *types.Header, headers []*types.Header) bool {
func (w *chainValidatorFake) IsValidChain(current *types.Header, headers []*types.Header) (bool, error) {
return w.validate(current, headers)
}
func (w *chainValidatorFake) ProcessCheckpoint(endBlockNum uint64, endBlockHash common.Hash) {}

View file

@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
)
@ -33,49 +34,28 @@ func borTxLookupKey(hash common.Hash) []byte {
return append(borTxLookupPrefix, hash.Bytes()...)
}
// HasBorReceipt verifies the existence of all block receipt belonging
// to a block.
func HasBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) bool {
if has, err := db.Ancient(freezerHashTable, number); err == nil && common.BytesToHash(has) == hash {
return true
}
if has, err := db.Has(borReceiptKey(number, hash)); !has || err != nil {
return false
}
return true
}
// ReadBorReceiptRLP retrieves the block receipt belonging to a block in RLP encoding.
func ReadBorReceiptRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
// First try to look up the data in ancient database. Extra hash
// comparison is necessary since ancient database only maintains
// the canonical data.
data, _ := db.Ancient(freezerBorReceiptTable, number)
if len(data) > 0 {
h, _ := db.Ancient(freezerHashTable, number)
if common.BytesToHash(h) == hash {
return data
var data []byte
err := db.ReadAncients(func(reader ethdb.AncientReader) error {
// Check if the data is in ancients
if isCanon(reader, number, hash) {
data, _ = reader.Ancient(freezerBorReceiptTable, number)
return nil
}
// If not, try reading from leveldb
data, _ = db.Get(borReceiptKey(number, hash))
return nil
})
if err != nil {
log.Warn("during ReadBorReceiptRLP", "number", number, "hash", hash, "err", err)
}
// Then try to look up the data in leveldb.
data, _ = db.Get(borReceiptKey(number, hash))
if len(data) > 0 {
return data
}
// In the background freezer is moving data from leveldb to flatten files.
// So during the first check for ancient db, the data is not yet in there,
// but when we reach into leveldb, the data was already moved. That would
// result in a not found error.
data, _ = db.Ancient(freezerBorReceiptTable, number)
if len(data) > 0 {
h, _ := db.Ancient(freezerHashTable, number)
if common.BytesToHash(h) == hash {
return data
}
}
return nil // Can't find the data anywhere.
return data
}
// ReadRawBorReceipt retrieves the block receipt belonging to a block.
@ -101,7 +81,11 @@ func ReadRawBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types.
// ReadBorReceipt retrieves all the bor block receipts belonging to a block, including
// its correspoinding metadata fields. If it is unable to populate these metadata
// fields then nil is returned.
func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64) *types.Receipt {
func ReadBorReceipt(db ethdb.Reader, hash common.Hash, number uint64, config *params.ChainConfig) *types.Receipt {
if config != nil && config.Bor != nil && config.Bor.Sprint != nil && !config.Bor.IsSprintStart(number) {
return nil
}
// We're deriving many fields from the block body, retrieve beside the receipt
borReceipt := ReadRawBorReceipt(db, hash, number)
if borReceipt == nil {

View file

@ -1796,7 +1796,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
ethAPIMock.EXPECT().Call(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
spanner := bor.NewMockSpanner(ctrl)
spanner.EXPECT().GetCurrentValidators(gomock.Any(), gomock.Any(), gomock.Any()).Return([]*valset.Validator{
spanner.EXPECT().GetCurrentValidatorsByHash(gomock.Any(), gomock.Any(), gomock.Any()).Return([]*valset.Validator{
{
ID: 0,
Address: miner.TestBankAddress,
@ -1815,7 +1815,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
chainConfig.LondonBlock = big.NewInt(0)
_, back, closeFn := miner.NewTestWorker(t, chainConfig, engine, db, 0)
_, back, closeFn := miner.NewTestWorker(t, chainConfig, engine, db, 0, 0, 0)
defer closeFn()
genesis := back.BlockChain().Genesis()

View file

@ -19,6 +19,7 @@ package core
import (
"container/heap"
"math"
"math/big"
"sort"
"sync"
"sync/atomic"
@ -29,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/common"
cmath "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
)
// nonceHeap is a heap.Interface implementation over 64bit unsigned integers for
@ -149,19 +151,38 @@ func (m *txSortedMap) Filter(filter func(*types.Transaction) bool) types.Transac
removed := m.filter(filter)
// If transactions were removed, the heap and cache are ruined
if len(removed) > 0 {
m.reheap()
m.reheap(false)
}
return removed
}
func (m *txSortedMap) reheap() {
*m.index = make([]uint64, 0, len(m.items))
func (m *txSortedMap) reheap(withRlock bool) {
index := make(nonceHeap, 0, len(m.items))
for nonce := range m.items {
*m.index = append(*m.index, nonce)
if withRlock {
m.m.RLock()
log.Info("[DEBUG] Acquired lock over txpool map while performing reheap")
}
heap.Init(m.index)
for nonce := range m.items {
index = append(index, nonce)
}
if withRlock {
m.m.RUnlock()
}
heap.Init(&index)
if withRlock {
m.m.Lock()
}
m.index = &index
if withRlock {
m.m.Unlock()
}
m.cacheMu.Lock()
m.cache = nil
@ -351,9 +372,8 @@ func (m *txSortedMap) lastElement() *types.Transaction {
m.cacheMu.Unlock()
cache = make(types.Transactions, 0, len(m.items))
m.m.RLock()
cache = make(types.Transactions, 0, len(m.items))
for _, tx := range m.items {
cache = append(cache, tx)
@ -373,6 +393,11 @@ func (m *txSortedMap) lastElement() *types.Transaction {
hitCacheCounter.Inc(1)
}
ln := len(cache)
if ln == 0 {
return nil
}
return cache[len(cache)-1]
}
@ -398,16 +423,18 @@ type txList struct {
strict bool // Whether nonces are strictly continuous or not
txs *txSortedMap // Heap indexed sorted hash map of the transactions
costcap *uint256.Int // Price of the highest costing transaction (reset only if exceeds balance)
gascap uint64 // Gas limit of the highest spending transaction (reset only if exceeds block limit)
costcap *uint256.Int // Price of the highest costing transaction (reset only if exceeds balance)
gascap uint64 // Gas limit of the highest spending transaction (reset only if exceeds block limit)
totalcost *big.Int // Total cost of all transactions in the list
}
// newTxList create a new transaction list for maintaining nonce-indexable fast,
// gapped, sortable transaction lists.
func newTxList(strict bool) *txList {
return &txList{
strict: strict,
txs: newTxSortedMap(),
strict: strict,
txs: newTxSortedMap(),
totalcost: new(big.Int),
}
}
@ -446,8 +473,13 @@ func (l *txList) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Tran
if tx.GasFeeCapUIntLt(thresholdFeeCap) || tx.GasTipCapUIntLt(thresholdTip) {
return false, nil
}
// Old is being replaced, subtract old cost
l.subTotalCost([]*types.Transaction{old})
}
// Add new tx cost to totalcost
l.totalcost.Add(l.totalcost, tx.Cost())
// Otherwise overwrite the old transaction with the current one
l.txs.Put(tx)
@ -466,7 +498,10 @@ func (l *txList) Add(tx *types.Transaction, priceBump uint64) (bool, *types.Tran
// provided threshold. Every removed transaction is returned for any post-removal
// maintenance.
func (l *txList) Forward(threshold uint64) types.Transactions {
return l.txs.Forward(threshold)
txs := l.txs.Forward(threshold)
l.subTotalCost(txs)
return txs
}
// Filter removes all transactions from the list with a cost or gas limit higher
@ -506,16 +541,27 @@ func (l *txList) Filter(costLimit *uint256.Int, gasLimit uint64) (types.Transact
lowest = nonce
}
}
l.txs.m.Lock()
invalids = l.txs.filter(func(tx *types.Transaction) bool { return tx.Nonce() > lowest })
l.txs.m.Unlock()
}
l.txs.reheap()
// Reset total cost
l.subTotalCost(removed)
l.subTotalCost(invalids)
l.txs.reheap(true)
return removed, invalids
}
// Cap places a hard limit on the number of items, returning all transactions
// exceeding that limit.
func (l *txList) Cap(threshold int) types.Transactions {
return l.txs.Cap(threshold)
txs := l.txs.Cap(threshold)
l.subTotalCost(txs)
return txs
}
// Remove deletes a transaction from the maintained list, returning whether the
@ -527,9 +573,14 @@ func (l *txList) Remove(tx *types.Transaction) (bool, types.Transactions) {
if removed := l.txs.Remove(nonce); !removed {
return false, nil
}
l.subTotalCost([]*types.Transaction{tx})
// In strict mode, filter out non-executable transactions
if l.strict {
return true, l.txs.Filter(func(tx *types.Transaction) bool { return tx.Nonce() > nonce })
txs := l.txs.Filter(func(tx *types.Transaction) bool { return tx.Nonce() > nonce })
l.subTotalCost(txs)
return true, txs
}
return true, nil
}
@ -542,7 +593,10 @@ func (l *txList) Remove(tx *types.Transaction) (bool, types.Transactions) {
// prevent getting into and invalid state. This is not something that should ever
// happen but better to be self correcting than failing!
func (l *txList) Ready(start uint64) types.Transactions {
return l.txs.Ready(start)
txs := l.txs.Ready(start)
l.subTotalCost(txs)
return txs
}
// Len returns the length of the transaction list.
@ -572,6 +626,14 @@ func (l *txList) Has(nonce uint64) bool {
return l != nil && l.txs.items[nonce] != nil
}
// subTotalCost subtracts the cost of the given transactions from the
// total cost of all transactions.
func (l *txList) subTotalCost(txs []*types.Transaction) {
for _, tx := range txs {
l.totalcost.Sub(l.totalcost, tx.Cost())
}
}
// priceHeap is a heap.Interface implementation over transactions for retrieving
// price-sorted transactions to discard when the pool fills up. If baseFee is set
// then the heap is sorted based on the effective tip based on the given base fee.

View file

@ -17,8 +17,10 @@
package core
import (
"container/heap"
"context"
"errors"
"fmt"
"math"
"math/big"
"sort"
@ -90,6 +92,14 @@ var (
// than some meaningful limit a user might use. This is not a consensus error
// making the transaction invalid, rather a DOS protection.
ErrOversizedData = errors.New("oversized data")
// ErrFutureReplacePending is returned if a future transaction replaces a pending
// transaction. Future transactions should only be able to replace other future transactions.
ErrFutureReplacePending = errors.New("future transaction tries to replace pending")
// ErrOverdraft is returned if a transaction would cause the senders balance to go negative
// thus invalidating a potential large number of transactions.
ErrOverdraft = errors.New("transaction would cause overdraft")
)
var (
@ -174,7 +184,8 @@ type TxPoolConfig struct {
AccountQueue uint64 // Maximum number of non-executable transaction slots permitted per account
GlobalQueue uint64 // Maximum number of non-executable transaction slots for all accounts
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
Lifetime time.Duration // Maximum amount of time non-executable transaction are queued
AllowUnprotectedTxs bool // Allow non-EIP-155 transactions
}
// DefaultTxPoolConfig contains the default configurations for the transaction
@ -191,7 +202,8 @@ var DefaultTxPoolConfig = TxPoolConfig{
AccountQueue: 64,
GlobalQueue: 1024,
Lifetime: 3 * time.Hour,
Lifetime: 3 * time.Hour,
AllowUnprotectedTxs: false,
}
// sanitize checks the provided user configurations and changes anything that's
@ -727,7 +739,11 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
if uint64(tx.Size()) > txMaxSize {
return ErrOversizedData
}
// Check whether the init code size has been exceeded.
// (TODO): Add a hardfork check here while pulling upstream changes.
if tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
return fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize)
}
// Transactions can't be negative. This may never happen using RLP decoded
// transactions but may occur if you create a transaction using the RPC.
if tx.Value().Sign() < 0 {
@ -759,7 +775,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Make sure the transaction is signed properly.
from, err := types.Sender(pool.signer, tx)
if err != nil {
if err != nil && !pool.config.AllowUnprotectedTxs {
return ErrInvalidSender
}
@ -781,10 +797,24 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Transactor should have enough funds to cover the costs
// cost == V + GP * GL
if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 {
balance := pool.currentState.GetBalance(from)
if balance.Cmp(tx.Cost()) < 0 {
return ErrInsufficientFunds
}
// Verify that replacing transactions will not result in overdraft
list := pool.pending[from]
if list != nil { // Sender already has pending txs
sum := new(big.Int).Add(tx.Cost(), list.totalcost)
if repl := list.txs.Get(tx.Nonce()); repl != nil {
// Deduct the cost of a transaction replaced by this
sum.Sub(sum, repl.Cost())
}
if balance.Cmp(sum) < 0 {
log.Trace("Replacing transactions would overdraft", "sender", from, "balance", pool.currentState.GetBalance(from), "required", sum)
return ErrOverdraft
}
}
// Ensure the transaction has more gas than the basic tx fee.
intrGas, err := IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul)
if err != nil {
@ -823,6 +853,10 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
invalidTxMeter.Mark(1)
return false, err
}
// already validated by this point
from, _ := types.Sender(pool.signer, tx)
// If the transaction pool is full, discard underpriced transactions
if uint64(pool.all.Slots()+numSlots(tx)) > pool.config.GlobalSlots+pool.config.GlobalQueue {
// If the new transaction is underpriced, don't accept it
@ -831,6 +865,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
underpricedTxMeter.Mark(1)
return false, ErrUnderpriced
}
// We're about to replace a transaction. The reorg does a more thorough
// analysis of what to remove and how, but it runs async. We don't want to
// do too many replacements between reorg-runs, so we cap the number of
@ -851,18 +886,39 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
overflowedTxMeter.Mark(1)
return false, ErrTxPoolOverflow
}
// Bump the counter of rejections-since-reorg
pool.changesSinceReorg += len(drop)
// If the new transaction is a future transaction it should never churn pending transactions
if pool.isFuture(from, tx) {
var replacesPending bool
for _, dropTx := range drop {
dropSender, _ := types.Sender(pool.signer, dropTx)
if list := pool.pending[dropSender]; list != nil && list.Overlaps(dropTx) {
replacesPending = true
break
}
}
// Add all transactions back to the priced queue
if replacesPending {
for _, dropTx := range drop {
heap.Push(&pool.priced.urgent, dropTx)
}
log.Trace("Discarding future transaction replacing pending tx", "hash", hash)
return false, ErrFutureReplacePending
}
}
// Kick out the underpriced remote transactions.
for _, tx := range drop {
log.Trace("Discarding freshly underpriced transaction", "hash", tx.Hash(), "gasTipCap", tx.GasTipCapUint(), "gasFeeCap", tx.GasFeeCapUint())
underpricedTxMeter.Mark(1)
pool.removeTx(tx.Hash(), false)
dropped := pool.removeTx(tx.Hash(), false)
pool.changesSinceReorg += dropped
}
}
// Try to replace an existing transaction in the pending pool
from, _ := types.Sender(pool.signer, tx) // already validated
// Try to replace an existing transaction in the pending pool
pool.pendingMu.RLock()
list := pool.pending[from]
@ -920,6 +976,20 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
return replaced, nil
}
// isFuture reports whether the given transaction is immediately executable.
func (pool *TxPool) isFuture(from common.Address, tx *types.Transaction) bool {
list := pool.pending[from]
if list == nil {
return pool.pendingNonces.get(from) != tx.Nonce()
}
// Sender has pending transactions.
if old := list.txs.Get(tx.Nonce()); old != nil {
return false // It replaces a pending transaction.
}
// Not replacing, check if parent nonce exists in pending.
return list.txs.Get(tx.Nonce()-1) == nil
}
// enqueueTx inserts a new transaction into the non-executable transaction queue.
//
// Note, this method assumes the pool lock is held!
@ -1093,6 +1163,10 @@ func (pool *TxPool) addTxs(txs []*types.Transaction, local, sync bool) []error {
continue
}
if pool.config.AllowUnprotectedTxs {
pool.signer = types.NewFakeSigner(tx.ChainId())
}
// Exclude transactions with invalid signatures as soon as
// possible and cache senders in transactions before
// obtaining lock
@ -1149,6 +1223,10 @@ func (pool *TxPool) addTx(tx *types.Transaction, local, sync bool) error {
// Exclude transactions with invalid signatures as soon as
// possible and cache senders in transactions before
// obtaining lock
if pool.config.AllowUnprotectedTxs {
pool.signer = types.NewFakeSigner(tx.ChainId())
}
_, err = types.Sender(pool.signer, tx)
if err != nil {
invalidTxMeter.Mark(1)
@ -1282,11 +1360,12 @@ func (pool *TxPool) Has(hash common.Hash) bool {
// removeTx removes a single transaction from the queue, moving all subsequent
// transactions back to the future queue.
func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) {
// Returns the number of transactions removed from the pending queue.
func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) int {
// Fetch the transaction we wish to delete
tx := pool.all.Get(hash)
if tx == nil {
return
return 0
}
addr, _ := types.Sender(pool.signer, tx) // already validated during insertion
@ -1327,7 +1406,7 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) {
// Reduce the pending counter
pendingGauge.Dec(int64(1 + len(invalids)))
return
return 1 + len(invalids)
}
pool.pendingMu.TryLock()
@ -1347,6 +1426,8 @@ func (pool *TxPool) removeTx(hash common.Hash, outofbound bool) {
delete(pool.beats, addr)
}
}
return 0
}
// requestReset requests a pool reset to the new head block.
@ -1539,6 +1620,7 @@ func (pool *TxPool) runReorg(ctx context.Context, done chan struct{}, reset *txp
// remove any transaction that has been included in the block or was invalidated
// because of another transaction (e.g. higher gas price).
//nolint:nestif
if reset != nil {
tracing.ElapsedTime(ctx, span, "new block", func(_ context.Context, innerSpan trace.Span) {
@ -1573,7 +1655,9 @@ func (pool *TxPool) runReorg(ctx context.Context, done chan struct{}, reset *txp
tracing.ElapsedTime(ctx, innerSpan, "09 fill nonces", func(_ context.Context, innerSpan trace.Span) {
for addr, list := range pool.pending {
highestPending = list.LastElement()
nonces[addr] = highestPending.Nonce() + 1
if highestPending != nil {
nonces[addr] = highestPending.Nonce() + 1
}
}
})

View file

@ -49,6 +49,8 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
"github.com/JekaMas/crand"
)
var (
@ -181,6 +183,10 @@ func validateTxPoolInternals(pool *TxPool) error {
if nonce := pool.pendingNonces.get(addr); nonce != last+1 {
return fmt.Errorf("pending nonce mismatch: have %v, want %v", nonce, last+1)
}
if txs.totalcost.Cmp(common.Big0) < 0 {
return fmt.Errorf("totalcost went negative: %v", txs.totalcost)
}
}
return nil
@ -890,6 +896,7 @@ func TestTransactionGapFilling(t *testing.T) {
if queued != 1 {
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 1)
}
if err := validateEvents(events, 1); err != nil {
t.Fatalf("original event firing failed: %v", err)
}
@ -954,6 +961,53 @@ func TestTransactionQueueAccountLimiting(t *testing.T) {
}
}
// Test that txpool rejects unprotected txs by default
// FIXME: The below test causes some tests to fail randomly (probably due to parallel execution)
//
//nolint:paralleltest
func TestRejectUnprotectedTransaction(t *testing.T) {
//nolint:paralleltest
t.Skip()
pool, key := setupTxPool()
defer pool.Stop()
tx := dynamicFeeTx(0, 22000, big.NewInt(5), big.NewInt(2), key)
from := crypto.PubkeyToAddress(key.PublicKey)
pool.chainconfig.ChainID = big.NewInt(5)
pool.signer = types.LatestSignerForChainID(pool.chainconfig.ChainID)
testAddBalance(pool, from, big.NewInt(0xffffffffffffff))
if err := pool.AddRemote(tx); !errors.Is(err, types.ErrInvalidChainId) {
t.Error("expected", types.ErrInvalidChainId, "got", err)
}
}
// Test that txpool allows unprotected txs when AllowUnprotectedTxs flag is set
// FIXME: The below test causes some tests to fail randomly (probably due to parallel execution)
//
//nolint:paralleltest
func TestAllowUnprotectedTransactionWhenSet(t *testing.T) {
t.Skip()
pool, key := setupTxPool()
defer pool.Stop()
tx := dynamicFeeTx(0, 22000, big.NewInt(5), big.NewInt(2), key)
from := crypto.PubkeyToAddress(key.PublicKey)
// Allow unprotected txs
pool.config.AllowUnprotectedTxs = true
pool.chainconfig.ChainID = big.NewInt(5)
pool.signer = types.LatestSignerForChainID(pool.chainconfig.ChainID)
testAddBalance(pool, from, big.NewInt(0xffffffffffffff))
if err := pool.AddRemote(tx); err != nil {
t.Error("expected", nil, "got", err)
}
}
// Tests that if the transaction count belonging to multiple accounts go above
// some threshold, the higher transactions are dropped to prevent DOS attacks.
//
@ -1212,7 +1266,7 @@ func TestTransactionPendingLimiting(t *testing.T) {
defer pool.Stop()
account := crypto.PubkeyToAddress(key.PublicKey)
testAddBalance(pool, account, big.NewInt(1000000))
testAddBalance(pool, account, big.NewInt(1000000000000))
// Keep track of transaction events to ensure all executables get announced
events := make(chan NewTxsEvent, testTxPoolConfig.AccountQueue+5)
@ -1752,7 +1806,7 @@ func TestTransactionPoolRepricingKeepsLocals(t *testing.T) {
keys := make([]*ecdsa.PrivateKey, 3)
for i := 0; i < len(keys); i++ {
keys[i], _ = crypto.GenerateKey()
testAddBalance(pool, crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1000*1000000))
testAddBalance(pool, crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(100000*1000000))
}
// Create transaction (both pending and queued) with a linearly growing gasprice
for i := uint64(0); i < 500; i++ {
@ -1831,7 +1885,7 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
defer sub.Unsubscribe()
// Create a number of test accounts and fund them
keys := make([]*ecdsa.PrivateKey, 4)
keys := make([]*ecdsa.PrivateKey, 5)
for i := 0; i < len(keys); i++ {
keys[i], _ = crypto.GenerateKey()
testAddBalance(pool, crypto.PubkeyToAddress(keys[i].PublicKey), big.NewInt(1000000))
@ -1867,6 +1921,10 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
if err := pool.AddRemote(pricedTransaction(0, 100000, big.NewInt(1), keys[1])); !errors.Is(err, ErrUnderpriced) {
t.Fatalf("adding underpriced pending transaction error mismatch: have %v, want %v", err, ErrUnderpriced)
}
// Replace a future transaction with a future transaction
if err := pool.AddRemote(pricedTransaction(1, 100000, big.NewInt(2), keys[1])); err != nil { // +K1:1 => -K1:1 => Pend K0:0, K0:1, K2:0; Que K1:1
t.Fatalf("failed to add well priced transaction: %v", err)
}
// Ensure that adding high priced transactions drops cheap ones, but not own
if err := pool.AddRemote(pricedTransaction(0, 100000, big.NewInt(3), keys[1])); err != nil { // +K1:0 => -K1:1 => Pend K0:0, K0:1, K1:0, K2:0; Que -
t.Fatalf("failed to add well priced transaction: %v", err)
@ -1877,6 +1935,10 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
if err := pool.AddRemote(pricedTransaction(3, 100000, big.NewInt(5), keys[1])); err != nil { // +K1:3 => -K0:1 => Pend K1:0, K2:0; Que K1:2 K1:3
t.Fatalf("failed to add well priced transaction: %v", err)
}
// Ensure that replacing a pending transaction with a future transaction fails
if err := pool.AddRemote(pricedTransaction(5, 100000, big.NewInt(6), keys[1])); err != ErrFutureReplacePending {
t.Fatalf("adding future replace transaction error mismatch: have %v, want %v", err, ErrFutureReplacePending)
}
pending, queued = pool.Stats()
if pending != 2 {
t.Fatalf("pending transactions mismatched: have %d, want %d", pending, 2)
@ -1884,9 +1946,11 @@ func TestTransactionPoolUnderpricing(t *testing.T) {
if queued != 2 {
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 2)
}
if err := validateEvents(events, 1); err != nil {
if err := validateEvents(events, 2); err != nil {
t.Fatalf("additional event firing failed: %v", err)
}
if err := validateTxPoolInternals(pool); err != nil {
t.Fatalf("pool internal state corrupted: %v", err)
}
@ -2046,11 +2110,12 @@ func TestTransactionPoolUnderpricingDynamicFee(t *testing.T) {
t.Fatalf("failed to add well priced transaction: %v", err)
}
tx = pricedTransaction(2, 100000, big.NewInt(3), keys[1])
tx = pricedTransaction(1, 100000, big.NewInt(3), keys[1])
if err := pool.AddRemote(tx); err != nil { // +K1:2, -K0:1 => Pend K0:0 K1:0, K2:0; Que K1:2
t.Fatalf("failed to add well priced transaction: %v", err)
}
tx = dynamicFeeTx(3, 100000, big.NewInt(4), big.NewInt(1), keys[1])
tx = dynamicFeeTx(2, 100000, big.NewInt(4), big.NewInt(1), keys[1])
if err := pool.AddRemote(tx); err != nil { // +K1:3, -K1:0 => Pend K0:0 K2:0; Que K1:2 K1:3
t.Fatalf("failed to add well priced transaction: %v", err)
}
@ -2061,9 +2126,11 @@ func TestTransactionPoolUnderpricingDynamicFee(t *testing.T) {
if queued != 2 {
t.Fatalf("queued transactions mismatched: have %d, want %d", queued, 2)
}
if err := validateEvents(events, 1); err != nil {
if err := validateEvents(events, 2); err != nil {
t.Fatalf("additional event firing failed: %v", err)
}
if err := validateTxPoolInternals(pool); err != nil {
t.Fatalf("pool internal state corrupted: %v", err)
}
@ -2675,7 +2742,7 @@ func BenchmarkPoolBatchInsert(b *testing.B) {
defer pool.Stop()
account := crypto.PubkeyToAddress(key.PublicKey)
testAddBalance(pool, account, big.NewInt(1000000))
testAddBalance(pool, account, big.NewInt(1000000000000000000))
const format = "size %d, is local %t"
@ -3692,6 +3759,45 @@ func MakeWithPromoteTxCh(ch chan struct{}) func(*TxPool) {
}
}
func BenchmarkBigs(b *testing.B) {
// max 256-bit
max := new(big.Int)
max.Exp(big.NewInt(2), big.NewInt(256), nil).Sub(max, big.NewInt(1))
ints := make([]*big.Int, 1000000)
intUs := make([]*uint256.Int, 1000000)
var over bool
for i := 0; i < len(ints); i++ {
ints[i] = crand.BigInt(max)
intUs[i], over = uint256.FromBig(ints[i])
if over {
b.Fatal(ints[i], over)
}
}
b.Run("*big.Int", func(b *testing.B) {
var r int
for i := 0; i < b.N; i++ {
r = ints[i%len(ints)%b.N].Cmp(ints[(i+1)%len(ints)%b.N])
}
fmt.Fprintln(io.Discard, r)
})
b.Run("*uint256.Int", func(b *testing.B) {
var r int
for i := 0; i < b.N; i++ {
r = intUs[i%len(intUs)%b.N].Cmp(intUs[(i+1)%len(intUs)%b.N])
}
fmt.Fprintln(io.Discard, r)
})
}
//nolint:thelper
func mining(tb testing.TB, pool *TxPool, signer types.Signer, baseFee *uint256.Int, blockGasLimit uint64, totalBlocks int) (int, time.Duration, time.Duration) {
var (

229
core/txpool2_test.go Normal file
View file

@ -0,0 +1,229 @@
// Copyright 2023 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package core
import (
"crypto/ecdsa"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
)
func pricedValuedTransaction(nonce uint64, value int64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
tx, _ := types.SignTx(types.NewTransaction(nonce, common.Address{}, big.NewInt(value), gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
return tx
}
func count(t *testing.T, pool *TxPool) (pending int, queued int) {
t.Helper()
pending, queued = pool.stats()
if err := validateTxPoolInternals(pool); err != nil {
t.Fatalf("pool internal state corrupted: %v", err)
}
return pending, queued
}
func fillPool(t *testing.T, pool *TxPool) {
t.Helper()
// Create a number of test accounts, fund them and make transactions
executableTxs := types.Transactions{}
nonExecutableTxs := types.Transactions{}
for i := 0; i < 384; i++ {
key, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(key.PublicKey), big.NewInt(10000000000))
// Add executable ones
for j := 0; j < int(pool.config.AccountSlots); j++ {
executableTxs = append(executableTxs, pricedTransaction(uint64(j), 100000, big.NewInt(300), key))
}
}
// Import the batch and verify that limits have been enforced
pool.AddRemotesSync(executableTxs)
pool.AddRemotesSync(nonExecutableTxs)
pending, queued := pool.Stats()
slots := pool.all.Slots()
// sanity-check that the test prerequisites are ok (pending full)
if have, want := pending, slots; have != want {
t.Fatalf("have %d, want %d", have, want)
}
if have, want := queued, 0; have != want {
t.Fatalf("have %d, want %d", have, want)
}
t.Logf("pool.config: GlobalSlots=%d, GlobalQueue=%d\n", pool.config.GlobalSlots, pool.config.GlobalQueue)
t.Logf("pending: %d queued: %d, all: %d\n", pending, queued, slots)
}
// Tests that if a batch high-priced of non-executables arrive, they do not kick out
// executable transactions
func TestTransactionFutureAttack(t *testing.T) {
t.Parallel()
// Create the pool to test the limit enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{1000000, statedb, new(event.Feed)}
config := testTxPoolConfig
config.GlobalQueue = 100
config.GlobalSlots = 100
pool := NewTxPool(config, eip1559Config, blockchain)
defer pool.Stop()
fillPool(t, pool)
pending, _ := pool.Stats()
// Now, future transaction attack starts, let's add a bunch of expensive non-executables, and see if the pending-count drops
{
key, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(key.PublicKey), big.NewInt(100000000000))
futureTxs := types.Transactions{}
for j := 0; j < int(pool.config.GlobalSlots+pool.config.GlobalQueue); j++ {
futureTxs = append(futureTxs, pricedTransaction(1000+uint64(j), 100000, big.NewInt(500), key))
}
for i := 0; i < 5; i++ {
pool.AddRemotesSync(futureTxs)
newPending, newQueued := count(t, pool)
t.Logf("pending: %d queued: %d, all: %d\n", newPending, newQueued, pool.all.Slots())
}
}
newPending, _ := pool.Stats()
// Pending should not have been touched
if have, want := newPending, pending; have < want {
t.Errorf("wrong pending-count, have %d, want %d (GlobalSlots: %d)",
have, want, pool.config.GlobalSlots)
}
}
// Tests that if a batch high-priced of non-executables arrive, they do not kick out
// executable transactions
func TestTransactionFuture1559(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{1000000, statedb, new(event.Feed)}
pool := NewTxPool(testTxPoolConfig, eip1559Config, blockchain)
defer pool.Stop()
// Create a number of test accounts, fund them and make transactions
fillPool(t, pool)
pending, _ := pool.Stats()
// Now, future transaction attack starts, let's add a bunch of expensive non-executables, and see if the pending-count drops
{
key, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(key.PublicKey), big.NewInt(100000000000))
futureTxs := types.Transactions{}
for j := 0; j < int(pool.config.GlobalSlots+pool.config.GlobalQueue); j++ {
futureTxs = append(futureTxs, dynamicFeeTx(1000+uint64(j), 100000, big.NewInt(200), big.NewInt(101), key))
}
pool.AddRemotesSync(futureTxs)
}
newPending, _ := pool.Stats()
// Pending should not have been touched
if have, want := newPending, pending; have != want {
t.Errorf("Wrong pending-count, have %d, want %d (GlobalSlots: %d)",
have, want, pool.config.GlobalSlots)
}
}
// Tests that if a batch of balance-overdraft txs arrive, they do not kick out
// executable transactions
func TestTransactionZAttack(t *testing.T) {
t.Parallel()
// Create the pool to test the pricing enforcement with
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
blockchain := &testBlockChain{1000000, statedb, new(event.Feed)}
pool := NewTxPool(testTxPoolConfig, eip1559Config, blockchain)
defer pool.Stop()
// Create a number of test accounts, fund them and make transactions
fillPool(t, pool)
countInvalidPending := func() int {
t.Helper()
var ivpendingNum int
pendingtxs, _ := pool.Content()
for account, txs := range pendingtxs {
cur_balance := new(big.Int).Set(pool.currentState.GetBalance(account))
for _, tx := range txs {
if cur_balance.Cmp(tx.Value()) <= 0 {
ivpendingNum++
} else {
cur_balance.Sub(cur_balance, tx.Value())
}
}
}
if err := validateTxPoolInternals(pool); err != nil {
t.Fatalf("pool internal state corrupted: %v", err)
}
return ivpendingNum
}
ivPending := countInvalidPending()
t.Logf("invalid pending: %d\n", ivPending)
// Now, DETER-Z attack starts, let's add a bunch of expensive non-executables (from N accounts) along with balance-overdraft txs (from one account), and see if the pending-count drops
for j := 0; j < int(pool.config.GlobalQueue); j++ {
futureTxs := types.Transactions{}
key, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(key.PublicKey), big.NewInt(100000000000))
futureTxs = append(futureTxs, pricedTransaction(1000+uint64(j), 21000, big.NewInt(500), key))
pool.AddRemotesSync(futureTxs)
}
overDraftTxs := types.Transactions{}
{
key, _ := crypto.GenerateKey()
pool.currentState.AddBalance(crypto.PubkeyToAddress(key.PublicKey), big.NewInt(100000000000))
for j := 0; j < int(pool.config.GlobalSlots); j++ {
overDraftTxs = append(overDraftTxs, pricedValuedTransaction(uint64(j), 60000000000, 21000, big.NewInt(500), key))
}
}
pool.AddRemotesSync(overDraftTxs)
pool.AddRemotesSync(overDraftTxs)
pool.AddRemotesSync(overDraftTxs)
pool.AddRemotesSync(overDraftTxs)
pool.AddRemotesSync(overDraftTxs)
newPending, newQueued := count(t, pool)
newIvPending := countInvalidPending()
t.Logf("pool.all.Slots(): %d\n", pool.all.Slots())
t.Logf("pending: %d queued: %d, all: %d\n", newPending, newQueued, pool.all.Slots())
t.Logf("invalid pending: %d\n", newIvPending)
// Pending should not have been touched
if newIvPending != ivPending {
t.Errorf("Wrong invalid pending-count, have %d, want %d (GlobalSlots: %d, queued: %d)",
newIvPending, ivPending, pool.config.GlobalSlots, newQueued)
}
}

View file

@ -470,6 +470,42 @@ func (fs FrontierSigner) Hash(tx *Transaction) common.Hash {
})
}
// FakeSigner implements the Signer interface and accepts unprotected transactions
type FakeSigner struct{ londonSigner }
var _ Signer = FakeSigner{}
func NewFakeSigner(chainId *big.Int) Signer {
signer := NewLondonSigner(chainId)
ls, _ := signer.(londonSigner)
return FakeSigner{londonSigner: ls}
}
func (f FakeSigner) Sender(tx *Transaction) (common.Address, error) {
return f.londonSigner.Sender(tx)
}
func (f FakeSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) {
return f.londonSigner.SignatureValues(tx, sig)
}
func (f FakeSigner) ChainID() *big.Int {
return f.londonSigner.ChainID()
}
// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
// private key. This hash does not uniquely identify the transaction.
func (f FakeSigner) Hash(tx *Transaction) common.Hash {
return f.londonSigner.Hash(tx)
}
// Equal returns true if the given signer is the same as the receiver.
func (f FakeSigner) Equal(Signer) bool {
// Always return true
return true
}
func decodeSignature(sig []byte) (r, s, v *big.Int) {
if len(sig) != crypto.SignatureLength {
panic(fmt.Sprintf("wrong size for signature: got %d, want %d", len(sig), crypto.SignatureLength))

View file

@ -30,7 +30,7 @@ import (
"github.com/ethereum/go-ethereum/crypto/bn256"
"github.com/ethereum/go-ethereum/params"
//lint:ignore SA1019 Needed for precompile
big2 "github.com/holiman/big"
"golang.org/x/crypto/ripemd160"
)
@ -263,12 +263,14 @@ var (
big199680 = big.NewInt(199680)
)
// nolint: gofmt
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
//
// def mult_complexity(x):
// if x <= 64: return x ** 2
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// else: return x ** 2 // 16 + 480 * x - 199680
//
// if x <= 64: return x ** 2
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// else: return x ** 2 // 16 + 480 * x - 199680
//
// where is x is max(length_of_MODULUS, length_of_BASE)
func modexpMultComplexity(x *big.Int) *big.Int {
@ -379,15 +381,24 @@ func (c *bigModExp) Run(input []byte) ([]byte, error) {
}
// Retrieve the operands and execute the exponentiation
var (
base = new(big.Int).SetBytes(getData(input, 0, baseLen))
exp = new(big.Int).SetBytes(getData(input, baseLen, expLen))
mod = new(big.Int).SetBytes(getData(input, baseLen+expLen, modLen))
base = new(big2.Int).SetBytes(getData(input, 0, baseLen))
exp = new(big2.Int).SetBytes(getData(input, baseLen, expLen))
mod = new(big2.Int).SetBytes(getData(input, baseLen+expLen, modLen))
v []byte
)
if mod.BitLen() == 0 {
switch {
case mod.BitLen() == 0:
// Modulo 0 is undefined, return zero
return common.LeftPadBytes([]byte{}, int(modLen)), nil
case base.BitLen() == 1: // a bit length of 1 means it's 1 (or -1).
//If base == 1, then we can just return base % mod (if mod >= 1, which it is)
v = base.Mod(base, mod).Bytes()
default:
v = base.Exp(base, exp, mod).Bytes()
}
return common.LeftPadBytes(base.Exp(base, exp, mod).Bytes(), int(modLen)), nil
return common.LeftPadBytes(v, int(modLen)), nil
}
// newCurvePoint unmarshals a binary blob into a bn256 elliptic curve point,

View file

@ -1,9 +1,7 @@
# Documentation
- [Command-line-interface](./cli)
- [Configuration file](./config.md)
[The new command line interface (CLI)](./cli) in this version of Bor aims to give users more control over the codebase when interacting with and starting a node. We have made every effort to keep most of the flags similar to the old CLI, except for a few notable changes. One major change is the use of the --config flag, which previously represented fields without available flags. It now represents all flags available to the user, and will overwrite any other flags if provided. As a node operator, you still have the flexibility to modify flags as needed. Please note that this change does not affect the internal functionality of the node, and it remains compatible with Geth and the Ethereum Virtual Machine (EVM).
## Additional notes
@ -13,8 +11,16 @@
$ bor server <flags>
```
- Toml files used earlier just to configure static/trusted nodes are being deprecated. Instead, a toml file now can be used instead of flags and can contain all configuration for the node to run. The link to a sample config file is given above. To simply run bor with a configuration file, the following command can be used.
See [here](./cli/server.md) for more flag details.
- The `bor dumpconfig` sub-command prints the default configurations, in the TOML format, on the terminal. One can `pipe (>)` this to a file (say `config.toml`) and use it to start bor.
- A toml file now can be used instead of flags and can contain all configuration for the node to run. To simply run bor with a configuration file, the following command can be used.
```
$ bor server --config <path_to_config.toml>
```
- You can find an example config file [here](./cli/example_config.toml) to know more about what each flag is used for, what are the defaults and recommended values for different networks.
- Toml files used earlier (with `--config` flag) to configure additional fields (like static and trusted nodes) are being deprecated and have been converted to flags.

View file

@ -44,6 +44,10 @@
- [```server```](./server.md)
- [```snapshot```](./snapshot.md)
- [```snapshot prune-state```](./snapshot_prune-state.md)
- [```status```](./status.md)
- [```version```](./version.md)

View file

@ -6,4 +6,4 @@ The ```account import``` command imports an account in Json format to the Bor da
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys

View file

@ -6,4 +6,4 @@ The `account list` command lists all the accounts in the Bor data directory.
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys

View file

@ -6,4 +6,4 @@ The `account new` command creates a new local account file on the Bor data direc
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys

View file

@ -2,16 +2,18 @@
## Options
- ```listen-addr```: listening address of bootnode (<ip>:<port>)
- ```listen-addr```: listening address of bootnode (<ip>:<port>) (default: 0.0.0.0:30303)
- ```v5```: Enable UDP v5
- ```v5```: Enable UDP v5 (default: false)
- ```log-level```: Log level (trace|debug|info|warn|error|crit)
- ```verbosity```: Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (default: 3)
- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
- ```log-level```: log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead (default: info)
- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: none)
- ```node-key```: file or hex node key
- ```save-key```: path to save the ecdsa private key
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode (default: false)

View file

@ -8,6 +8,6 @@ The ```chain sethead <number>``` command sets the current chain to a certain blo
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```yes```: Force set head
- ```yes```: Force set head (default: false)

View file

@ -4,6 +4,6 @@ The ```bor debug block <number>``` command will create an archive containing tra
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```output```: Output directory

View file

@ -4,8 +4,10 @@ The ```debug pprof <enode>``` command will create an archive containing bor ppro
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```seconds```: seconds to trace
- ```seconds```: seconds to profile (default: 2)
- ```output```: Output directory
- ```skiptrace```: Skip running the trace (default: false)

View file

@ -0,0 +1,183 @@
# This configuration file is for reference and learning purpose only.
# The default value of the flags is provided below (except a few flags which has custom defaults which are explicitly mentioned).
# Recommended values for mainnet and/or mumbai are also provided.
chain = "mainnet" # Name of the chain to sync ("mumbai", "mainnet") or path to a genesis file
identity = "Annon-Identity" # Name/Identity of the node (default = OS hostname)
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
vmdebug = false # Record information useful for VM and contract debugging
datadir = "var/lib/bor" # Path of the data directory to store information
ancient = "" # Data directory for ancient chain segments (default = inside chaindata)
keystore = "" # Path of the directory where keystores are located
"rpc.batchlimit" = 100 # Maximum number of messages in a batch (default=100, use 0 for no limits)
"rpc.returndatalimit" = 100000 # Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits)
syncmode = "full" # Blockchain sync mode (only "full" sync supported)
gcmode = "full" # Blockchain garbage collection mode ("full", "archive")
snapshot = true # Enables the snapshot-database mode
"bor.logs" = false # Enables bor log retrieval
ethstats = "" # Reporting URL of a ethstats service (nodename:secret@host:port)
devfakeauthor = false # Run miner without validator set authorization [dev mode] : Use with '--bor.withoutheimdall' (default: false)
["eth.requiredblocks"] # Comma separated block number-to-hash mappings to require for peering (<number>=<hash>) (default = empty map)
"31000000" = "0x2087b9e2b353209c2c21e370c82daa12278efd0fe5f0febe6c29035352cf050e"
"32000000" = "0x875500011e5eecc0c554f95d07b31cf59df4ca2505f4dbbfffa7d4e4da917c68"
[log]
vmodule = "" # Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
json = false # Format logs with JSON
backtrace = "" # Request a stack trace at a specific logging statement (e.g. "block.go:271")
debug = true # Prepends log messages with call-site location (file and line number) - {requires some effort}
[p2p]
maxpeers = 50 # Maximum number of network peers (network disabled if set to 0)
maxpendpeers = 50 # Maximum number of pending connection attempts
bind = "0.0.0.0" # Network binding address
port = 30303 # Network listening port
nodiscover = false # Disables the peer discovery mechanism (manual peer addition)
nat = "any" # NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
netrestrict = "" # Restricts network communication to the given IP networks (CIDR masks)
nodekey = "" # P2P node key file
nodekeyhex = "" # P2P node key as hex
[p2p.discovery]
v5disc = false # Enables the experimental RLPx V5 (Topic Discovery) mechanism
bootnodes = [] # Comma separated enode URLs for P2P discovery bootstrap
bootnodesv4 = [] # List of initial v4 bootnodes
bootnodesv5 = [] # List of initial v5 bootnodes
static-nodes = [] # List of static nodes
trusted-nodes = [] # List of trusted nodes
dns = [] # List of enrtree:// URLs which will be queried for nodes to connect to
[heimdall]
url = "http://localhost:1317" # URL of Heimdall service
"bor.without" = false # Run without Heimdall service (for testing purpose)
grpc-address = "" # Address of Heimdall gRPC service
[txpool]
locals = [] # Comma separated accounts to treat as locals (no flush, priority inclusion)
nolocals = false # Disables price exemptions for locally submitted transactions
journal = "transactions.rlp" # Disk journal for local transaction to survive node restarts
rejournal = "1h0m0s" # Time interval to regenerate the local transaction journal
pricelimit = 1 # Minimum gas price limit to enforce for acceptance into the pool (mainnet = 30000000000)
pricebump = 10 # Price bump percentage to replace an already existing transaction
accountslots = 16 # Minimum number of executable transaction slots guaranteed per account
globalslots = 32768 # Maximum number of executable transaction slots for all accounts
accountqueue = 16 # Maximum number of non-executable transaction slots permitted per account
globalqueue = 32768 # Maximum number of non-executable transaction slots for all accounts
lifetime = "3h0m0s" # Maximum amount of time non-executable transaction are queued
[miner]
mine = false # Enable mining
etherbase = "" # Public address for block mining rewards
extradata = "" # Block extra data set by the miner (default = client version)
gaslimit = 30000000 # Target gas ceiling for mined blocks
gasprice = "1000000000" # Minimum gas price for mining a transaction (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)
recommit = "2m5s" # The time interval for miner to re-create mining work
[jsonrpc]
ipcdisable = false # Disable the IPC-RPC server
ipcpath = "" # Filename for IPC socket/pipe within the datadir (explicit paths escape it)
gascap = 50000000 # Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)
evmtimeout = "5s" # Sets a timeout used for eth_call (0=infinite)
txfeecap = 5.0 # Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)
allow-unprotected-txs = false # Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC (default: false)
[jsonrpc.http]
enabled = false # Enable the HTTP-RPC server
port = 8545 # http.port
prefix = "" # http.rpcprefix
host = "localhost" # HTTP-RPC server listening interface
api = ["eth", "net", "web3", "txpool", "bor"] # API's offered over the HTTP-RPC interface
vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
corsdomain = ["localhost"] # Comma separated list of domains from which to accept cross origin requests (browser enforced)
ep-size = 40 # Maximum size of workers to run in rpc execution pool for HTTP requests (default: 40)
ep-requesttimeout = "0s" # Request Timeout for rpc execution pool for HTTP requests (default: 0s, 0s = disabled)
[jsonrpc.ws]
enabled = false # Enable the WS-RPC server
port = 8546 # WS-RPC server listening port
prefix = "" # HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
host = "localhost" # ws.addr
api = ["net", "web3"] # API's offered over the WS-RPC interface
origins = ["localhost"] # Origins from which to accept websockets requests
ep-size = 40 # Maximum size of workers to run in rpc execution pool for WS requests (default: 40)
ep-requesttimeout = "0s" # Request Timeout for rpc execution pool for WS requests (default: 0s, 0s = disabled)
[jsonrpc.graphql]
enabled = false # Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
port = 0 #
prefix = "" #
host = "" #
vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
corsdomain = ["localhost"] # Comma separated list of domains from which to accept cross origin requests (browser enforced)
[jsonrpc.auth]
jwtsecret = "" # Path to a JWT secret to use for authenticated RPC endpoints
addr = "localhost" # Listening address for authenticated APIs
port = 8551 # Listening port for authenticated APIs
vhosts = ["localhost"] # Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
[jsonrpc.timeouts]
read = "10s"
write = "30s"
idle = "2m0s"
[gpo]
blocks = 20 # Number of recent blocks to check for gas prices
percentile = 60 # Suggested gas price is the given percentile of a set of recent transaction gas prices
maxheaderhistory = 1024 # Maximum header history of gasprice oracle
maxblockhistory = 1024 # Maximum block history of gasprice oracle
maxprice = "5000000000000" # Maximum gas price will be recommended by gpo
ignoreprice = "2" # Gas price below which gpo will ignore transactions (recommended for mainnet = 30000000000, default suitable for mumbai/devnet)
[telemetry]
metrics = false # Enable metrics collection and reporting
expensive = false # Enable expensive metrics collection and reporting
prometheus-addr = "127.0.0.1:7071" # Address for Prometheus Server
opencollector-endpoint = "127.0.0.1:4317" # OpenCollector Endpoint (host:port)
[telemetry.influx]
influxdb = false # Enable metrics export/push to an external InfluxDB database (v1)
endpoint = "" # InfluxDB API endpoint to report metrics to
database = "" # InfluxDB database name to push reported metrics to
username = "" # Username to authorize access to the database
password = "" # Password to authorize access to the database
influxdbv2 = false # Enable metrics export/push to an external InfluxDB v2 database
token = "" # Token to authorize access to the database (v2 only)
bucket = "" # InfluxDB bucket name to push reported metrics to (v2 only)
organization = "" # InfluxDB organization name (v2 only)
[telemetry.influx.tags] # Comma-separated InfluxDB tags (key/values) attached to all measurements
cloud = "aws"
host = "annon-host"
ip = "99.911.221.66"
region = "us-north-1"
[cache]
cache = 1024 # Megabytes of memory allocated to internal caching (recommended for mainnet = 4096, default suitable for mumbai/devnet)
gc = 25 # Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
snapshot = 10 # Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)
database = 50 # Percentage of cache memory allowance to use for database io
trie = 15 # Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)
journal = "triecache" # Disk journal directory for trie cache to survive node restarts
rejournal = "1h0m0s" # Time interval to regenerate the trie cache journal
noprefetch = false # Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)
preimages = false # Enable recording the SHA3/keccak preimages of trie keys
txlookuplimit = 2350000 # Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)
triesinmemory = 128 # Number of block states (tries) to keep in memory
timeout = "1h0m0s" # Time after which the Merkle Patricia Trie is stored to disc from memory
fdlimit = 0 # Raise the open file descriptor resource limit (default = system fd limit)
[accounts]
unlock = [] # Comma separated list of accounts to unlock
password = "" # Password file to use for non-interactive password input
allow-insecure-unlock = false # Allow insecure account unlocking when account-related RPCs are exposed by http
lightkdf = false # Reduce key-derivation RAM & CPU usage at some expense of KDF strength
disable-bor-wallet = true # Disable the personal wallet endpoints
[grpc]
addr = ":3131" # Address and port to bind the GRPC server
[developer]
dev = false # Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled
period = 0 # Block period to use in developer mode (0 = mine only if transaction pending)
gaslimit = 11500000 # Initial block gas limit
[pprof]
pprof = false # Enable the pprof HTTP server
port = 6060 # pprof HTTP server listening port
addr = "127.0.0.1" # pprof HTTP server listening interface
memprofilerate = 524288 # Turn on memory profiling with the given rate
blockprofilerate = 0 # Turn on block profiling with the given rate

View file

@ -4,6 +4,6 @@ The ```peers add <enode>``` command joins the local client to another remote pee
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```trusted```: Add the peer as a trusted
- ```trusted```: Add the peer as a trusted (default: false)

View file

@ -4,4 +4,4 @@ The ```peers list``` command lists the connected peers.
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

View file

@ -4,6 +4,6 @@ The ```peers remove <enode>``` command disconnects the local client from a conne
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```trusted```: Add the peer as a trusted
- ```trusted```: Add the peer as a trusted (default: false)

View file

@ -4,4 +4,4 @@ The ```peers status <peer id>``` command displays the status of a peer by its id
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

View file

@ -4,6 +4,6 @@ The ```bor removedb``` command will remove the blockchain and state databases at
## Options
- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
- ```datadir```: Path of the data directory to store information

View file

@ -4,51 +4,85 @@ The ```bor server``` command runs the Bor client.
## Options
- ```chain```: Name of the chain to sync
- ```chain```: Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file (default: mainnet)
- ```identity```: Name/Identity of the node
- ```log-level```: Set log level for the server
- ```verbosity```: Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3 (default: 3)
- ```log-level```: Log level for the server (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the directory to store keystores
- ```vmdebug```: Record information useful for VM and contract debugging (default: false)
- ```config```: File for the config file
- ```datadir.ancient```: Data directory for ancient chain segments (default = inside chaindata)
- ```syncmode```: Blockchain sync mode (only "full" sync supported)
- ```keystore```: Path of the directory where keystores are located
- ```gcmode```: Blockchain garbage collection mode ("full", "archive")
- ```rpc.batchlimit```: Maximum number of messages in a batch (default=100, use 0 for no limits) (default: 100)
- ```rpc.returndatalimit```: Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits) (default: 100000)
- ```config```: Path to the TOML configuration file
- ```syncmode```: Blockchain sync mode (only "full" sync supported) (default: full)
- ```gcmode```: Blockchain garbage collection mode ("full", "archive") (default: full)
- ```eth.requiredblocks```: Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)
- ```snapshot```: Enables the snapshot-database mode (default = true)
- ```snapshot```: Enables the snapshot-database mode (default: true)
- ```bor.logs```: Enables bor log retrieval (default = false)
- ```bor.logs```: Enables bor log retrieval (default: false)
- ```bor.heimdall```: URL of Heimdall service
- ```bor.heimdall```: URL of Heimdall service (default: http://localhost:1317)
- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose)
- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) (default: false)
- ```bor.devfakeauthor```: Run miner without validator set authorization [dev mode] : Use with '--bor.withoutheimdall' (default: false)
- ```bor.heimdallgRPC```: Address of Heimdall gRPC service
- ```bor.runheimdall```: Run Heimdall service as a child process (default: false)
- ```bor.runheimdallargs```: Arguments to pass to Heimdall service
- ```bor.useheimdallapp```: Use child heimdall process to fetch data, Only works when bor.runheimdall is true (default: false)
- ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port)
- ```gpo.blocks```: Number of recent blocks to check for gas prices
- ```gpo.blocks```: Number of recent blocks to check for gas prices (default: 20)
- ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices
- ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)
- ```gpo.maxprice```: Maximum gas price will be recommended by gpo
- ```gpo.maxheaderhistory```: Maximum header history of gasprice oracle (default: 1024)
- ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions
- ```gpo.maxblockhistory```: Maximum block history of gasprice oracle (default: 1024)
- ```disable-bor-wallet```: Disable the personal wallet endpoints
- ```gpo.maxprice```: Maximum gas price will be recommended by gpo (default: 5000000000000)
- ```grpc.addr```: Address and port to bind the GRPC server
- ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions (default: 2)
- ```dev```: Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled
- ```disable-bor-wallet```: Disable the personal wallet endpoints (default: true)
- ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending)
- ```grpc.addr```: Address and port to bind the GRPC server (default: :3131)
- ```dev```: Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled (default: false)
- ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)
- ```dev.gaslimit```: Initial block gas limit (default: 11500000)
- ```pprof```: Enable the pprof HTTP server (default: false)
- ```pprof.port```: pprof HTTP server listening port (default: 6060)
- ```pprof.addr```: pprof HTTP server listening interface (default: 127.0.0.1)
- ```pprof.memprofilerate```: Turn on memory profiling with the given rate (default: 524288)
- ```pprof.blockprofilerate```: Turn on block profiling with the given rate (default: 0)
### Account Management Options
@ -56,113 +90,153 @@ The ```bor server``` command runs the Bor client.
- ```password```: Password file to use for non-interactive password input
- ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http
- ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http (default: false)
- ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength
- ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength (default: false)
### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)
- ```cache```: Megabytes of memory allocated to internal caching (default: 1024)
- ```cache.database```: Percentage of cache memory allowance to use for database io
- ```cache.database```: Percentage of cache memory allowance to use for database io (default: 50)
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default: 15)
- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts
- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts (default: triecache)
- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal
- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal (default: 1h0m0s)
- ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
- ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default: 25)
- ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)
- ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default: 10)
- ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)
- ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data) (default: false)
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys (default: false)
- ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default = 128)
- ```cache.triesinmemory```: Number of block states (tries) to keep in memory (default = 128) (default: 128)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default: 2350000)
- ```fdlimit```: Raise the open file descriptor resource limit (default = system fd limit) (default: 0)
### JsonRPC Options
- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)
- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite) (default: 50000000)
- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)
- ```rpc.evmtimeout```: Sets a timeout used for eth_call (0=infinite) (default: 5s)
- ```ipcdisable```: Disable the IPC-RPC server
- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap) (default: 5)
- ```rpc.allow-unprotected-txs```: Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC (default: false)
- ```ipcdisable```: Disable the IPC-RPC server (default: false)
- ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it)
- ```http.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced)
- ```authrpc.jwtsecret```: Path to a JWT secret to use for authenticated RPC endpoints
- ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```authrpc.addr```: Listening address for authenticated APIs (default: localhost)
- ```ws.origins```: Origins from which to accept websockets requests
- ```authrpc.port```: Listening port for authenticated APIs (default: 8551)
- ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced)
- ```authrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
- ```graphql.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```http.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) (default: localhost)
- ```http```: Enable the HTTP-RPC server
- ```http.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
- ```http.addr```: HTTP-RPC server listening interface
- ```ws.origins```: Origins from which to accept websockets requests (default: localhost)
- ```http.port```: HTTP-RPC server listening port
- ```graphql.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced) (default: localhost)
- ```graphql.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: localhost)
- ```http```: Enable the HTTP-RPC server (default: false)
- ```http.addr```: HTTP-RPC server listening interface (default: localhost)
- ```http.port```: HTTP-RPC server listening port (default: 8545)
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.api```: API's offered over the HTTP-RPC interface
- ```http.api```: API's offered over the HTTP-RPC interface (default: eth,net,web3,txpool,bor)
- ```ws```: Enable the WS-RPC server
- ```http.ep-size```: Maximum size of workers to run in rpc execution pool for HTTP requests (default: 40)
- ```ws.addr```: WS-RPC server listening interface
- ```http.ep-requesttimeout```: Request Timeout for rpc execution pool for HTTP requests (default: 0s)
- ```ws.port```: WS-RPC server listening port
- ```ws```: Enable the WS-RPC server (default: false)
- ```ws.addr```: WS-RPC server listening interface (default: localhost)
- ```ws.port```: WS-RPC server listening port (default: 8546)
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.api```: API's offered over the WS-RPC interface
- ```ws.api```: API's offered over the WS-RPC interface (default: net,web3)
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
- ```ws.ep-size```: Maximum size of workers to run in rpc execution pool for WS requests (default: 40)
- ```ws.ep-requesttimeout```: Request Timeout for rpc execution pool for WS requests (default: 0s)
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. (default: false)
### Logging Options
- ```vmodule```: Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
- ```log.json```: Format logs with JSON (default: false)
- ```log.backtrace```: Request a stack trace at a specific logging statement (e.g. 'block.go:271')
- ```log.debug```: Prepends log messages with call-site location (file and line number) (default: false)
### P2P Options
- ```bind```: Network binding address
- ```bind```: Network binding address (default: 0.0.0.0)
- ```port```: Network listening port
- ```port```: Network listening port (default: 30303)
- ```bootnodes```: Comma separated enode URLs for P2P discovery bootstrap
- ```maxpeers```: Maximum number of network peers (network disabled if set to 0)
- ```maxpeers```: Maximum number of network peers (network disabled if set to 0) (default: 50)
- ```maxpendpeers```: Maximum number of pending connection attempts (defaults used if set to 0)
- ```maxpendpeers```: Maximum number of pending connection attempts (default: 50)
- ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
- ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: any)
- ```nodiscover```: Disables the peer discovery mechanism (manual peer addition)
- ```netrestrict```: Restricts network communication to the given IP networks (CIDR masks)
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism
- ```nodekey```: P2P node key file
- ```nodekeyhex```: P2P node key as hex
- ```nodiscover```: Disables the peer discovery mechanism (manual peer addition) (default: false)
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false)
### Sealer Options
- ```mine```: Enable mining
- ```mine```: Enable mining (default: false)
- ```miner.etherbase```: Public address for block mining rewards (default = first account)
- ```miner.etherbase```: Public address for block mining rewards
- ```miner.extradata```: Block extra data set by the miner (default = client version)
- ```miner.gaslimit```: Target gas ceiling for mined blocks
- ```miner.gaslimit```: Target gas ceiling (gas limit) for mined blocks (default: 30000000)
- ```miner.gasprice```: Minimum gas price for mining a transaction
- ```miner.gasprice```: Minimum gas price for mining a transaction (default: 1000000000)
- ```miner.recommit```: The time interval for miner to re-create mining work (default: 2m5s)
### Telemetry Options
- ```metrics```: Enable metrics collection and reporting
- ```metrics```: Enable metrics collection and reporting (default: false)
- ```metrics.expensive```: Enable expensive metrics collection and reporting
- ```metrics.expensive```: Enable expensive metrics collection and reporting (default: false)
- ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1)
- ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1) (default: false)
- ```metrics.influxdb.endpoint```: InfluxDB API endpoint to report metrics to
@ -174,11 +248,11 @@ The ```bor server``` command runs the Bor client.
- ```metrics.influxdb.tags```: Comma-separated InfluxDB tags (key/values) attached to all measurements
- ```metrics.prometheus-addr```: Address for Prometheus Server
- ```metrics.prometheus-addr```: Address for Prometheus Server (default: 127.0.0.1:7071)
- ```metrics.opencollector-endpoint```: OpenCollector Endpoint (host:port)
- ```metrics.opencollector-endpoint```: OpenCollector Endpoint (host:port) (default: 127.0.0.1:4317)
- ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database
- ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database (default: false)
- ```metrics.influxdb.token```: Token to authorize access to the database (v2 only)
@ -190,22 +264,22 @@ The ```bor server``` command runs the Bor client.
- ```txpool.locals```: Comma separated accounts to treat as locals (no flush, priority inclusion)
- ```txpool.nolocals```: Disables price exemptions for locally submitted transactions
- ```txpool.nolocals```: Disables price exemptions for locally submitted transactions (default: false)
- ```txpool.journal```: Disk journal for local transaction to survive node restarts
- ```txpool.journal```: Disk journal for local transaction to survive node restarts (default: transactions.rlp)
- ```txpool.rejournal```: Time interval to regenerate the local transaction journal
- ```txpool.rejournal```: Time interval to regenerate the local transaction journal (default: 1h0m0s)
- ```txpool.pricelimit```: Minimum gas price limit to enforce for acceptance into the pool
- ```txpool.pricelimit```: Minimum gas price limit to enforce for acceptance into the pool (default: 1)
- ```txpool.pricebump```: Price bump percentage to replace an already existing transaction
- ```txpool.pricebump```: Price bump percentage to replace an already existing transaction (default: 10)
- ```txpool.accountslots```: Minimum number of executable transaction slots guaranteed per account
- ```txpool.accountslots```: Minimum number of executable transaction slots guaranteed per account (default: 16)
- ```txpool.globalslots```: Maximum number of executable transaction slots for all accounts
- ```txpool.globalslots```: Maximum number of executable transaction slots for all accounts (default: 32768)
- ```txpool.accountqueue```: Maximum number of non-executable transaction slots permitted per account
- ```txpool.accountqueue```: Maximum number of non-executable transaction slots permitted per account (default: 16)
- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts
- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts (default: 32768)
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued (default: 3h0m0s)

5
docs/cli/snapshot.md Normal file
View file

@ -0,0 +1,5 @@
# snapshot
The ```snapshot``` command groups snapshot related actions:
- [```snapshot prune-state```](./snapshot_prune-state.md): Prune state databases at the given datadir location.

View file

@ -0,0 +1,21 @@
# Prune state
The ```bor snapshot prune-state``` command will prune historical state data with the help of the state snapshot. All trie nodes and contract codes that do not belong to the specified version state will be deleted from the database. After pruning, only two version states are available: genesis and the specific one.
## Options
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys
- ```datadir.ancient```: Path of the ancient data directory to store information
- ```bloomfilter.size```: Size of the bloom filter (default: 2048)
### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default: 1024)
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default: 25)
- ```cache.trie.journal```: Path of the trie journal directory to store information (default: triecache)

View file

@ -324,6 +324,10 @@ func (b *EthAPIBackend) RPCGasCap() uint64 {
return b.eth.config.RPCGasCap
}
func (b *EthAPIBackend) RPCRpcReturnDataLimit() uint64 {
return b.eth.config.RPCReturnDataLimit
}
func (b *EthAPIBackend) RPCEVMTimeout() time.Duration {
return b.eth.config.RPCEVMTimeout
}

View file

@ -175,7 +175,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// START: Bor changes
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
if eth.APIBackend.allowUnprotectedTxs {
log.Info("Unprotected transactions allowed")
log.Debug(" ###########", "Unprotected transactions allowed")
config.TxPool.AllowUnprotectedTxs = true
}
gpoParams := config.GPO
if gpoParams.Default == nil {

View file

@ -357,10 +357,6 @@ func (d *Downloader) LegacySync(id string, head common.Hash, td, ttd *big.Int, m
return err // This is an expected fault, don't keep printing it in a spin-loop
}
if errors.Is(err, whitelist.ErrNoRemoteCheckoint) {
log.Warn("Doesn't have remote checkpoint yet", "peer", id, "err", err)
}
log.Warn("Synchronisation failed, retrying", "peer", id, "err", err)
return err
@ -1581,6 +1577,13 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error {
// of the blocks delivered from the downloader, and the indexing will be off.
log.Debug("Downloaded item processing failed on sidechain import", "index", index, "err", err)
}
// If we've received too long future chain error (from whitelisting service),
// return that as the root error and `errInvalidChain` as context.
if errors.Is(err, whitelist.ErrLongFutureChain) {
return fmt.Errorf("%v: %w", errInvalidChain, err)
}
return fmt.Errorf("%w: %v", errInvalidChain, err)
}
return nil

View file

@ -1426,8 +1426,8 @@ func (w *whitelistFake) IsValidPeer(_ *types.Header, _ func(number uint64, amoun
return w.validate(w.count)
}
func (w *whitelistFake) IsValidChain(current *types.Header, headers []*types.Header) bool {
return true
func (w *whitelistFake) IsValidChain(current *types.Header, headers []*types.Header) (bool, error) {
return true, nil
}
func (w *whitelistFake) ProcessCheckpoint(_ uint64, _ common.Hash) {}

View file

@ -30,6 +30,7 @@ func NewService(maxCapacity uint) *Service {
var (
ErrCheckpointMismatch = errors.New("checkpoint mismatch")
ErrLongFutureChain = errors.New("received future chain of unacceptable length")
ErrNoRemoteCheckoint = errors.New("remote peer doesn't have a checkoint")
)
@ -74,16 +75,16 @@ func (w *Service) IsValidPeer(remoteHeader *types.Header, fetchHeadersByNumber f
// IsValidChain checks the validity of chain by comparing it
// against the local checkpoint entries
func (w *Service) IsValidChain(currentHeader *types.Header, chain []*types.Header) bool {
func (w *Service) IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Check if we have checkpoints to validate incoming chain in memory
if len(w.checkpointWhitelist) == 0 {
// We don't have any entries, no additional validation will be possible
return true
return true, nil
}
// Return if we've received empty chain
if len(chain) == 0 {
return false
return false, nil
}
var (
@ -95,32 +96,34 @@ func (w *Service) IsValidChain(currentHeader *types.Header, chain []*types.Heade
if chain[len(chain)-1].Number.Uint64() < oldestCheckpointNumber {
// We have future whitelisted entries, so no additional validation will be possible
// This case will occur when bor is in middle of sync, but heimdall is ahead/fully synced.
return true
return true, nil
}
// Split the chain into past and future chain
pastChain, futureChain := splitChain(current, chain)
pastChain, _ := splitChain(current, chain)
// Note: Do not act on future chain and allow importing all kinds of future chains.
// Add an offset to future chain if it's not in continuity
offset := 0
if len(futureChain) != 0 {
offset += int(futureChain[0].Number.Uint64()-currentHeader.Number.Uint64()) - 1
}
// offset := 0
// if len(futureChain) != 0 {
// offset += int(futureChain[0].Number.Uint64()-currentHeader.Number.Uint64()) - 1
// }
// Don't accept future chain of unacceptable length (from current block)
if len(futureChain)+offset > int(w.checkpointInterval) {
return false
}
// if len(futureChain)+offset > int(w.checkpointInterval) {
// return false, ErrLongFutureChain
// }
// Iterate over the chain and validate against the last checkpoint
// It will handle all cases where the incoming chain has atleast one checkpoint
for i := len(pastChain) - 1; i >= 0; i-- {
if _, ok := w.checkpointWhitelist[pastChain[i].Number.Uint64()]; ok {
return pastChain[i].Hash() == w.checkpointWhitelist[pastChain[i].Number.Uint64()]
return pastChain[i].Hash() == w.checkpointWhitelist[pastChain[i].Number.Uint64()], nil
}
}
return true
return true, nil
}
func splitChain(current uint64, chain []*types.Header) ([]*types.Header, []*types.Header) {

View file

@ -119,8 +119,9 @@ func TestIsValidChain(t *testing.T) {
s := NewMockService(10, 10)
chainA := createMockChain(1, 20) // A1->A2...A19->A20
// case1: no checkpoint whitelist, should consider the chain as valid
res := s.IsValidChain(nil, chainA)
res, err := s.IsValidChain(nil, chainA)
require.Equal(t, res, true, "expected chain to be valid")
require.Equal(t, err, nil, "expected error to be nil")
tempChain := createMockChain(21, 22) // A21->A22
@ -132,8 +133,9 @@ func TestIsValidChain(t *testing.T) {
// case2: We're behind the oldest whitelisted block entry, should consider
// the chain as valid as we're still far behind the latest blocks
res = s.IsValidChain(chainA[len(chainA)-1], chainA)
res, err = s.IsValidChain(chainA[len(chainA)-1], chainA)
require.Equal(t, res, true, "expected chain to be valid")
require.Equal(t, err, nil, "expected error to be nil")
// Clear checkpoint whitelist and add blocks A5 and A15 in whitelist
s.PurgeCheckpointWhitelist()
@ -144,8 +146,9 @@ func TestIsValidChain(t *testing.T) {
// case3: Try importing a past chain having valid checkpoint, should
// consider the chain as valid
res = s.IsValidChain(chainA[len(chainA)-1], chainA)
res, err = s.IsValidChain(chainA[len(chainA)-1], chainA)
require.Equal(t, res, true, "expected chain to be valid")
require.Equal(t, err, nil, "expected error to be nil")
// Clear checkpoint whitelist and mock blocks in whitelist
tempChain = createMockChain(20, 20) // A20
@ -156,22 +159,28 @@ func TestIsValidChain(t *testing.T) {
require.Equal(t, s.length(), 1, "expected 1 items in whitelist")
// case4: Try importing a past chain having invalid checkpoint
res = s.IsValidChain(chainA[len(chainA)-1], chainA)
res, _ = s.IsValidChain(chainA[len(chainA)-1], chainA)
require.Equal(t, res, false, "expected chain to be invalid")
// Not checking error here because we return nil in case of checkpoint mismatch
// create a future chain to be imported of length <= `checkpointInterval`
chainB := createMockChain(21, 30) // B21->B22...B29->B30
// case5: Try importing a future chain of acceptable length
res = s.IsValidChain(chainA[len(chainA)-1], chainB)
// case5: Try importing a future chain (1)
res, err = s.IsValidChain(chainA[len(chainA)-1], chainB)
require.Equal(t, res, true, "expected chain to be valid")
require.Equal(t, err, nil, "expected error to be nil")
// create a future chain to be imported of length > `checkpointInterval`
chainB = createMockChain(21, 40) // C21->C22...C39->C40
// case5: Try importing a future chain of unacceptable length
res = s.IsValidChain(chainA[len(chainA)-1], chainB)
require.Equal(t, res, false, "expected chain to be invalid")
// Note: Earlier, it used to reject future chains longer than some threshold.
// That check is removed for now.
// case6: Try importing a future chain (2)
res, err = s.IsValidChain(chainA[len(chainA)-1], chainB)
require.Equal(t, res, true, "expected chain to be valid")
require.Equal(t, err, nil, "expected error to be nil")
}
func TestSplitChain(t *testing.T) {

View file

@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/bor/contract"
"github.com/ethereum/go-ethereum/consensus/bor/heimdall" //nolint:typecheck
"github.com/ethereum/go-ethereum/consensus/bor/heimdall/span"
"github.com/ethereum/go-ethereum/consensus/bor/heimdallapp"
"github.com/ethereum/go-ethereum/consensus/bor/heimdallgrpc"
"github.com/ethereum/go-ethereum/consensus/clique"
"github.com/ethereum/go-ethereum/consensus/ethash"
@ -94,11 +95,12 @@ var Defaults = Config{
GasPrice: big.NewInt(params.GWei),
Recommit: 125 * time.Second,
},
TxPool: core.DefaultTxPoolConfig,
RPCGasCap: 50000000,
RPCEVMTimeout: 5 * time.Second,
GPO: FullNodeGPO,
RPCTxFeeCap: 5, // 5 matic
TxPool: core.DefaultTxPoolConfig,
RPCGasCap: 50000000,
RPCReturnDataLimit: 100000,
RPCEVMTimeout: 5 * time.Second,
GPO: FullNodeGPO,
RPCTxFeeCap: 5, // 5 matic
}
func init() {
@ -199,6 +201,9 @@ type Config struct {
// RPCGasCap is the global gas cap for eth-call variants.
RPCGasCap uint64
// Maximum size (in bytes) a result of an rpc request could have
RPCReturnDataLimit uint64
// RPCEVMTimeout is the global timeout for eth-call.
RPCEVMTimeout time.Duration
@ -221,6 +226,15 @@ type Config struct {
// Address to connect to Heimdall gRPC server
HeimdallgRPCAddress string
// Run heimdall service as a child process
RunHeimdall bool
// Arguments to pass to heimdall service
RunHeimdallArgs string
// Use child heimdall process to fetch data, Only works when RunHeimdall is true
UseHeimdallApp bool
// Bor logs flag
BorLogs bool
@ -232,6 +246,9 @@ type Config struct {
// OverrideTerminalTotalDifficulty (TODO: remove after the fork)
OverrideTerminalTotalDifficulty *big.Int `toml:",omitempty"`
// Develop Fake Author mode to produce blocks without authorisation
DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
}
// CreateConsensusEngine creates a consensus engine for the given chain configuration.
@ -252,16 +269,21 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
spanner := span.NewChainSpanner(blockchainAPI, contract.ValidatorSet(), chainConfig, common.HexToAddress(chainConfig.Bor.ValidatorContract))
if ethConfig.WithoutHeimdall {
return bor.New(chainConfig, db, blockchainAPI, spanner, nil, genesisContractsClient)
return bor.New(chainConfig, db, blockchainAPI, spanner, nil, genesisContractsClient, ethConfig.DevFakeAuthor)
} else {
if ethConfig.DevFakeAuthor {
log.Warn("Sanitizing DevFakeAuthor", "Use DevFakeAuthor with", "--bor.withoutheimdall")
}
var heimdallClient bor.IHeimdallClient
if ethConfig.HeimdallgRPCAddress != "" {
if ethConfig.RunHeimdall && ethConfig.UseHeimdallApp {
heimdallClient = heimdallapp.NewHeimdallAppClient()
} else if ethConfig.HeimdallgRPCAddress != "" {
heimdallClient = heimdallgrpc.NewHeimdallGRPCClient(ethConfig.HeimdallgRPCAddress)
} else {
heimdallClient = heimdall.NewHeimdallClient(ethConfig.HeimdallURL)
}
return bor.New(chainConfig, db, blockchainAPI, spanner, heimdallClient, genesisContractsClient)
return bor.New(chainConfig, db, blockchainAPI, spanner, heimdallClient, genesisContractsClient, false)
}
} else {
switch config.PowMode {

View file

@ -55,11 +55,11 @@ const (
// txArriveTimeout is the time allowance before an announced transaction is
// explicitly requested.
txArriveTimeout = 100 * time.Millisecond
txArriveTimeout = 500 * time.Millisecond
// txGatherSlack is the interval used to collate almost-expired announces
// with network fetches.
txGatherSlack = 20 * time.Millisecond
txGatherSlack = 100 * time.Millisecond
)
var (

View file

@ -1,7 +1,6 @@
package filters
import (
"bytes"
"context"
"errors"
@ -19,7 +18,7 @@ func (api *PublicFilterAPI) SetChainConfig(chainConfig *params.ChainConfig) {
func (api *PublicFilterAPI) GetBorBlockLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {
if api.chainConfig == nil {
return nil, errors.New("No chain config found. Proper PublicFilterAPI initialization required")
return nil, errors.New("no chain config found. Proper PublicFilterAPI initialization required")
}
// get sprint from bor config
@ -64,11 +63,12 @@ func (api *PublicFilterAPI) NewDeposits(ctx context.Context, crit ethereum.State
stateSyncData := make(chan *types.StateSyncData, 10)
stateSyncSub := api.events.SubscribeNewDeposits(stateSyncData)
// nolint: gosimple
for {
select {
case h := <-stateSyncData:
if crit.ID == h.ID || bytes.Compare(crit.Contract.Bytes(), h.Contract.Bytes()) == 0 ||
(crit.ID == 0 && crit.Contract == common.Address{}) {
if h != nil && (crit.ID == h.ID || crit.Contract == h.Contract ||
(crit.ID == 0 && crit.Contract == common.Address{})) {
notifier.Notify(rpcSub.ID, h)
}
case <-rpcSub.Err():

View file

@ -38,7 +38,7 @@ func (b *TestBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash)
return &types.Receipt{}, nil
}
receipt := rawdb.ReadBorReceipt(b.DB, hash, *number)
receipt := rawdb.ReadBorReceipt(b.DB, hash, *number, nil)
if receipt == nil {
return &types.Receipt{}, nil
}

View file

@ -184,7 +184,7 @@ func (api *API) getAllBlockTransactions(ctx context.Context, block *types.Block)
stateSyncPresent := false
borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64())
borReceipt := rawdb.ReadBorReceipt(api.backend.ChainDb(), block.Hash(), block.NumberU64(), api.backend.ChainConfig())
if borReceipt != nil {
txHash := types.GetDerivedBorTxHash(types.BorReceiptKey(block.Number().Uint64(), block.Hash()))
if txHash != (common.Hash{}) {

View file

@ -126,6 +126,10 @@ func (b *testBackend) RPCGasCap() uint64 {
return 25000000
}
func (b *testBackend) RPCRpcReturnDataLimit() uint64 {
return 100000
}
func (b *testBackend) ChainConfig() *params.ChainConfig {
return b.chainConfig
}

View file

@ -33,9 +33,6 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
)
@ -211,31 +208,31 @@ var testTx2 = types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), &
To: &common.Address{2},
})
func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
// Generate test chain.
blocks := generateTestChain()
// func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
// // Generate test chain.
// blocks := generateTestChain()
// Create node
n, err := node.New(&node.Config{})
if err != nil {
t.Fatalf("can't create new node: %v", err)
}
// Create Ethereum Service
config := &ethconfig.Config{Genesis: genesis}
config.Ethash.PowMode = ethash.ModeFake
ethservice, err := eth.New(n, config)
if err != nil {
t.Fatalf("can't create new ethereum service: %v", err)
}
// Import the test chain.
if err := n.Start(); err != nil {
t.Fatalf("can't start test node: %v", err)
}
if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil {
t.Fatalf("can't import test blocks: %v", err)
}
return n, blocks
}
// // Create node
// n, err := node.New(&node.Config{})
// if err != nil {
// t.Fatalf("can't create new node: %v", err)
// }
// // Create Ethereum Service
// config := &ethconfig.Config{Genesis: genesis}
// config.Ethash.PowMode = ethash.ModeFake
// ethservice, err := eth.New(n, config)
// if err != nil {
// t.Fatalf("can't create new ethereum service: %v", err)
// }
// // Import the test chain.
// if err := n.Start(); err != nil {
// t.Fatalf("can't start test node: %v", err)
// }
// if _, err := ethservice.BlockChain().InsertChain(blocks[1:]); err != nil {
// t.Fatalf("can't import test blocks: %v", err)
// }
// return n, blocks
// }
func generateTestChain() []*types.Block {
db := rawdb.NewMemoryDatabase()
@ -258,50 +255,50 @@ func generateTestChain() []*types.Block {
func TestEthClient(t *testing.T) {
t.Skip("bor due to burn contract")
backend, chain := newTestBackend(t)
client, _ := backend.Attach()
defer backend.Close()
defer client.Close()
// backend, chain := newTestBackend(t)
// client, _ := backend.Attach()
// defer backend.Close()
// defer client.Close()
tests := map[string]struct {
test func(t *testing.T)
}{
"Header": {
func(t *testing.T) { testHeader(t, chain, client) },
},
"BalanceAt": {
func(t *testing.T) { testBalanceAt(t, client) },
},
"TxInBlockInterrupted": {
func(t *testing.T) { testTransactionInBlockInterrupted(t, client) },
},
"ChainID": {
func(t *testing.T) { testChainID(t, client) },
},
"GetBlock": {
func(t *testing.T) { testGetBlock(t, client) },
},
"StatusFunctions": {
func(t *testing.T) { testStatusFunctions(t, client) },
},
"CallContract": {
func(t *testing.T) { testCallContract(t, client) },
},
"CallContractAtHash": {
func(t *testing.T) { testCallContractAtHash(t, client) },
},
"AtFunctions": {
func(t *testing.T) { testAtFunctions(t, client) },
},
"TransactionSender": {
func(t *testing.T) { testTransactionSender(t, client) },
},
}
// tests := map[string]struct {
// test func(t *testing.T)
// }{
// "Header": {
// func(t *testing.T) { testHeader(t, chain, client) },
// },
// "BalanceAt": {
// func(t *testing.T) { testBalanceAt(t, client) },
// },
// "TxInBlockInterrupted": {
// func(t *testing.T) { testTransactionInBlockInterrupted(t, client) },
// },
// "ChainID": {
// func(t *testing.T) { testChainID(t, client) },
// },
// "GetBlock": {
// func(t *testing.T) { testGetBlock(t, client) },
// },
// "StatusFunctions": {
// func(t *testing.T) { testStatusFunctions(t, client) },
// },
// "CallContract": {
// func(t *testing.T) { testCallContract(t, client) },
// },
// "CallContractAtHash": {
// func(t *testing.T) { testCallContractAtHash(t, client) },
// },
// "AtFunctions": {
// func(t *testing.T) { testAtFunctions(t, client) },
// },
// "TransactionSender": {
// func(t *testing.T) { testTransactionSender(t, client) },
// },
// }
t.Parallel()
for name, tt := range tests {
t.Run(name, tt.test)
}
// t.Parallel()
// for name, tt := range tests {
// t.Run(name, tt.test)
// }
}
func testHeader(t *testing.T, chain []*types.Block, client *rpc.Client) {

139
go.mod
View file

@ -5,30 +5,32 @@ go 1.19
require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0
github.com/BurntSushi/toml v1.1.0
github.com/JekaMas/crand v1.0.1
github.com/JekaMas/go-grpc-net-conn v0.0.0-20220708155319-6aff21f2d13d
github.com/JekaMas/workerpool v1.1.5
github.com/VictoriaMetrics/fastcache v1.6.0
github.com/aws/aws-sdk-go-v2 v1.2.0
github.com/aws/aws-sdk-go-v2/config v1.1.1
github.com/aws/aws-sdk-go-v2/credentials v1.1.1
github.com/aws/aws-sdk-go-v2/service/route53 v1.1.1
github.com/btcsuite/btcd/btcec/v2 v2.1.2
github.com/cespare/cp v0.1.0
github.com/btcsuite/btcd/btcec/v2 v2.1.3
github.com/cespare/cp v1.1.1
github.com/cloudflare/cloudflare-go v0.14.0
github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf
github.com/docker/docker v1.6.1
github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48
github.com/edsrzf/mmap-go v1.0.0
github.com/fatih/color v1.7.0
github.com/fatih/color v1.9.0
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff
github.com/go-stack/stack v1.8.0
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
github.com/go-stack/stack v1.8.1
github.com/golang-jwt/jwt/v4 v4.3.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.4
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa
github.com/google/gofuzz v1.2.0
github.com/google/uuid v1.2.0
github.com/gorilla/websocket v1.4.2
github.com/graph-gophers/graphql-go v1.3.0
@ -37,9 +39,10 @@ require (
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hashicorp/hcl/v2 v2.10.1
github.com/heimdalr/dag v1.2.1
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e
github.com/holiman/bloomfilter/v2 v2.0.3
github.com/holiman/uint256 v1.2.0
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204
github.com/huin/goupnp v1.0.3
github.com/imdario/mergo v0.3.11
github.com/influxdata/influxdb v1.8.3
github.com/influxdata/influxdb-client-go/v2 v2.4.0
@ -48,36 +51,37 @@ require (
github.com/julienschmidt/httprouter v1.3.0
github.com/karalabe/usb v0.0.2
github.com/maticnetwork/crand v1.0.2
github.com/maticnetwork/heimdall v0.3.1-0.20230105132832-d0063f71e3f0
github.com/maticnetwork/polyproto v0.0.2
github.com/mattn/go-colorable v0.1.8
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/cli v1.1.2
github.com/mitchellh/go-homedir v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
github.com/prometheus/tsdb v0.7.1
github.com/rjeczalik/notify v0.9.1
github.com/peterh/liner v1.2.0
github.com/prometheus/tsdb v0.10.0
github.com/rjeczalik/notify v0.9.2
github.com/rs/cors v1.7.0
github.com/ryanuber/columnize v2.1.2+incompatible
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d
github.com/stretchr/testify v1.8.0
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
github.com/tyler-smith/go-bip39 v1.1.0
github.com/xsleonard/go-merkle v1.1.0
go.opentelemetry.io/otel v1.2.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.2.0
go.opentelemetry.io/otel/sdk v1.2.0
go.uber.org/goleak v1.1.12
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10
golang.org/x/text v0.4.0
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/tools v0.1.12
golang.org/x/crypto v0.1.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.6.0
golang.org/x/text v0.8.0
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
golang.org/x/tools v0.6.0
gonum.org/v1/gonum v0.11.0
google.golang.org/grpc v1.51.0
google.golang.org/protobuf v1.28.0
google.golang.org/protobuf v1.28.1
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6
gopkg.in/urfave/cli.v1 v1.20.0
@ -85,66 +89,139 @@ require (
pgregory.net/rapid v0.4.8
)
require github.com/orcaman/concurrent-map/v2 v2.0.0 // indirect
require (
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/gammazero/deque v0.2.1 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
)
require (
cloud.google.com/go v0.65.0 // indirect
cloud.google.com/go/pubsub v1.3.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 // indirect
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/RichardKnop/logging v0.0.0-20190827224416-1a693bdd4fae // indirect
github.com/RichardKnop/machinery v1.7.4 // indirect
github.com/RichardKnop/redsync v1.2.0 // indirect
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect
github.com/aws/aws-sdk-go v1.29.15 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.0.2 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.0.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.1.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.1.1 // indirect
github.com/aws/smithy-go v1.1.0 // indirect
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect
github.com/cbergoon/merkletree v0.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cosmos/cosmos-sdk v0.37.4
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8 // indirect
github.com/cosmos/ledger-cosmos-go v0.10.3 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/deepmap/oapi-codegen v1.8.2 // indirect
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
github.com/emirpasic/gods v1.18.1
github.com/go-kit/kit v0.9.0 // indirect
github.com/etcd-io/bbolt v1.3.3 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-redis/redis v6.15.7+incompatible // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/gomodule/redigo v2.0.0+incompatible // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.1.1 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v0.0.5 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.4.0 // indirect
github.com/streadway/amqp v0.0.0-20200108173154-1c71cc93ed71 // indirect
github.com/stumble/gorocksdb v0.0.3 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.15.0 // indirect
github.com/tendermint/iavl v0.12.4 // indirect
github.com/tendermint/tendermint v0.32.7
github.com/tendermint/tm-db v0.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/xdg/scram v1.0.3 // indirect
github.com/xdg/stringprep v1.0.3 // indirect
github.com/zclconf/go-cty v1.8.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.mongodb.org/mongo-driver v1.3.0 // indirect
go.opencensus.io v0.22.6 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.2.0 // indirect
go.opentelemetry.io/otel/trace v1.2.0
go.opentelemetry.io/proto/otlp v0.10.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220728030405-41545e8bf201 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/api v0.34.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace github.com/cosmos/cosmos-sdk => github.com/maticnetwork/cosmos-sdk v0.37.5-0.20220311095845-81690c6a53e7
replace github.com/tendermint/tendermint => github.com/maticnetwork/tendermint v0.26.0-dev0.0.20220923185258-3e7c7f86ce9f
replace github.com/ethereum/go-ethereum => github.com/maticnetwork/bor v0.2.18-0.20220922050621-c91d4ca1fa4f
replace github.com/Masterminds/goutils => github.com/Masterminds/goutils v1.1.1

729
go.sum

File diff suppressed because it is too large Load diff

View file

@ -242,7 +242,7 @@ type StateSyncFilter struct {
// interface for whitelist service
type ChainValidator interface {
IsValidPeer(remoteHeader *types.Header, fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error)
IsValidChain(currentHeader *types.Header, chain []*types.Header) bool
IsValidChain(currentHeader *types.Header, chain []*types.Header) (bool, error)
ProcessCheckpoint(endBlockNum uint64, endBlockHash common.Hash)
GetCheckpointWhitelist() map[uint64]common.Hash
PurgeCheckpointWhitelist()

View file

@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
@ -27,6 +28,7 @@ type BootnodeCommand struct {
listenAddr string
v5 bool
verbosity int
logLevel string
nat string
nodeKey string
@ -64,10 +66,16 @@ func (b *BootnodeCommand) Flags() *flagset.Flagset {
Usage: "Enable UDP v5",
Value: &b.v5,
})
flags.IntFlag(&flagset.IntFlag{
Name: "verbosity",
Default: 3,
Usage: "Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit)",
Value: &b.verbosity,
})
flags.StringFlag(&flagset.StringFlag{
Name: "log-level",
Default: "info",
Usage: "Log level (trace|debug|info|warn|error|crit)",
Usage: "log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead",
Value: &b.logLevel,
})
flags.StringFlag(&flagset.StringFlag{
@ -114,7 +122,18 @@ func (b *BootnodeCommand) Run(args []string) int {
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
lvl, err := log.LvlFromString(strings.ToLower(b.logLevel))
var logInfo string
if b.verbosity != 0 && b.logLevel != "" {
b.UI.Warn(fmt.Sprintf("Both verbosity and log-level provided, using verbosity: %v", b.verbosity))
logInfo = server.VerbosityIntToString(b.verbosity)
} else if b.verbosity != 0 {
logInfo = server.VerbosityIntToString(b.verbosity)
} else {
logInfo = b.logLevel
}
lvl, err := log.LvlFromString(strings.ToLower(logInfo))
if err == nil {
glogger.Verbosity(lvl)
} else {

View file

@ -189,6 +189,16 @@ func Commands() map[string]MarkDownCommandFactory {
Meta2: meta2,
}, nil
},
"snapshot": func() (MarkDownCommand, error) {
return &SnapshotCommand{
UI: ui,
}, nil
},
"snapshot prune-state": func() (MarkDownCommand, error) {
return &PruneStateCommand{
Meta: meta,
}, nil
},
}
}
@ -248,7 +258,7 @@ func (m *Meta) NewFlagSet(n string) *flagset.Flagset {
f.StringFlag(&flagset.StringFlag{
Name: "keystore",
Value: &m.keyStoreDir,
Usage: "Path of the data directory to store information",
Usage: "Path of the data directory to store keys",
})
return f

View file

@ -7,7 +7,7 @@ import (
"fmt"
"strings"
empty "google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/grpc"
"github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
@ -16,8 +16,9 @@ import (
type DebugPprofCommand struct {
*Meta2
seconds uint64
output string
seconds uint64
output string
skiptrace bool
}
func (p *DebugPprofCommand) MarkDown() string {
@ -44,7 +45,7 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
flags.Uint64Flag(&flagset.Uint64Flag{
Name: "seconds",
Usage: "seconds to trace",
Usage: "seconds to profile",
Value: &d.seconds,
Default: 2,
})
@ -54,6 +55,15 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
Usage: "Output directory",
})
// Trace profiles can be expensive and take too much size (for grpc).
// This flag will help in making it optional.
flags.BoolFlag(&flagset.BoolFlag{
Name: "skiptrace",
Value: &d.skiptrace,
Usage: "Skip running the trace",
Default: false,
})
return flags
}
@ -103,7 +113,7 @@ func (d *DebugPprofCommand) Run(args []string) int {
req.Profile = profile
}
stream, err := clt.DebugPprof(ctx, req)
stream, err := clt.DebugPprof(ctx, req, grpc.MaxCallRecvMsgSize(1024*1024*1024))
if err != nil {
return err
@ -119,11 +129,17 @@ func (d *DebugPprofCommand) Run(args []string) int {
ctx, cancelFn := context.WithCancel(context.Background())
trapSignal(cancelFn)
// Only take cpu and heap profiles by default
profiles := map[string]string{
"heap": "heap",
"cpu": "cpu",
"trace": "trace",
"mutex": "mutex",
}
if !d.skiptrace {
profiles["trace"] = "trace"
}
for profile, filename := range profiles {
if err := pprofProfile(ctx, profile, filename); err != nil {
d.UI.Error(fmt.Sprintf("Error creating profile '%s': %v", profile, err))
@ -133,7 +149,7 @@ func (d *DebugPprofCommand) Run(args []string) int {
// append the status
{
statusResp, err := clt.Status(ctx, &empty.Empty{})
statusResp, err := clt.Status(ctx, &proto.StatusRequest{})
if err != nil {
d.UI.Output(fmt.Sprintf("Failed to get status: %v", err))
return 1

View file

@ -23,7 +23,8 @@ func TestCommand_DebugBlock(t *testing.T) {
// enable developer mode
config.Developer.Enabled = true
config.Developer.Period = 2 // block time
config.Developer.Period = 2 // block time
config.Developer.GasLimit = 11500000 // initial block gaslimit
// enable archive mode for getting traces of ancient blocks
config.GcMode = "archive"

View file

@ -52,12 +52,20 @@ func (c *DumpconfigCommand) Run(args []string) int {
userConfig := command.GetConfig()
// convert the big.Int and time.Duration fields to their corresponding Raw fields
userConfig.JsonRPC.RPCEVMTimeoutRaw = userConfig.JsonRPC.RPCEVMTimeout.String()
userConfig.JsonRPC.HttpTimeout.ReadTimeoutRaw = userConfig.JsonRPC.HttpTimeout.ReadTimeout.String()
userConfig.JsonRPC.HttpTimeout.WriteTimeoutRaw = userConfig.JsonRPC.HttpTimeout.WriteTimeout.String()
userConfig.JsonRPC.HttpTimeout.IdleTimeoutRaw = userConfig.JsonRPC.HttpTimeout.IdleTimeout.String()
userConfig.JsonRPC.Http.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Http.ExecutionPoolRequestTimeout.String()
userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeoutRaw = userConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout.String()
userConfig.TxPool.RejournalRaw = userConfig.TxPool.Rejournal.String()
userConfig.TxPool.LifeTimeRaw = userConfig.TxPool.LifeTime.String()
userConfig.Sealer.GasPriceRaw = userConfig.Sealer.GasPrice.String()
userConfig.Sealer.RecommitRaw = userConfig.Sealer.Recommit.String()
userConfig.Gpo.MaxPriceRaw = userConfig.Gpo.MaxPrice.String()
userConfig.Gpo.IgnorePriceRaw = userConfig.Gpo.IgnorePrice.String()
userConfig.Cache.RejournalRaw = userConfig.Cache.Rejournal.String()
userConfig.Cache.TrieTimeoutRaw = userConfig.Cache.TrieTimeout.String()
if err := toml.NewEncoder(os.Stdout).Encode(userConfig); err != nil {
c.UI.Error(err.Error())

View file

@ -24,9 +24,10 @@ func NewFlagSet(name string) *Flagset {
}
type FlagVar struct {
Name string
Usage string
Group string
Name string
Usage string
Group string
Default any
}
func (f *Flagset) addFlag(fl *FlagVar) {
@ -38,7 +39,11 @@ func (f *Flagset) Help() string {
items := []string{}
for _, item := range f.flags {
items = append(items, fmt.Sprintf(" -%s\n %s", item.Name, item.Usage))
if item.Default != nil {
items = append(items, fmt.Sprintf(" -%s\n %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
items = append(items, fmt.Sprintf(" -%s\n %s", item.Name, item.Usage))
}
}
return str + strings.Join(items, "\n\n")
@ -85,7 +90,11 @@ func (f *Flagset) MarkDown() string {
}
for _, item := range groups[k] {
items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage))
if item.Default != nil {
items = append(items, fmt.Sprintf("- ```%s```: %s (default: %v)", item.Name, item.Usage, item.Default))
} else {
items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage))
}
}
}
@ -110,27 +119,39 @@ type BoolFlag struct {
func (f *Flagset) BoolFlag(b *BoolFlag) {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Default: b.Default,
})
f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage)
}
type StringFlag struct {
Name string
Usage string
Default string
Value *string
Group string
Name string
Usage string
Default string
Value *string
Group string
HideDefaultFromDoc bool
}
func (f *Flagset) StringFlag(b *StringFlag) {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
})
if b.Default == "" || b.HideDefaultFromDoc {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Default: nil,
})
} else {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Default: b.Default,
})
}
f.set.StringVar(b.Value, b.Name, b.Default, b.Usage)
}
@ -144,9 +165,10 @@ type IntFlag struct {
func (f *Flagset) IntFlag(i *IntFlag) {
f.addFlag(&FlagVar{
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Default: i.Default,
})
f.set.IntVar(i.Value, i.Name, i.Default, i.Usage)
}
@ -161,18 +183,20 @@ type Uint64Flag struct {
func (f *Flagset) Uint64Flag(i *Uint64Flag) {
f.addFlag(&FlagVar{
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Default: fmt.Sprintf("%d", i.Default),
})
f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage)
}
type BigIntFlag struct {
Name string
Usage string
Value *big.Int
Group string
Name string
Usage string
Value *big.Int
Group string
Default *big.Int
}
func (b *BigIntFlag) String() string {
@ -204,9 +228,10 @@ func (b *BigIntFlag) Set(value string) error {
func (f *Flagset) BigIntFlag(b *BigIntFlag) {
f.addFlag(&FlagVar{
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Name: b.Name,
Usage: b.Usage,
Group: b.Group,
Default: b.Default,
})
f.set.Var(b, b.Name, b.Usage)
}
@ -247,11 +272,21 @@ func (i *SliceStringFlag) Set(value string) error {
}
func (f *Flagset) SliceStringFlag(s *SliceStringFlag) {
f.addFlag(&FlagVar{
Name: s.Name,
Usage: s.Usage,
Group: s.Group,
})
if s.Default == nil || len(s.Default) == 0 {
f.addFlag(&FlagVar{
Name: s.Name,
Usage: s.Usage,
Group: s.Group,
Default: nil,
})
} else {
f.addFlag(&FlagVar{
Name: s.Name,
Usage: s.Usage,
Group: s.Group,
Default: strings.Join(s.Default, ","),
})
}
f.set.Var(s, s.Name, s.Usage)
}
@ -265,33 +300,39 @@ type DurationFlag struct {
func (f *Flagset) DurationFlag(d *DurationFlag) {
f.addFlag(&FlagVar{
Name: d.Name,
Usage: d.Usage,
Group: d.Group,
Name: d.Name,
Usage: d.Usage,
Group: d.Group,
Default: d.Default,
})
f.set.DurationVar(d.Value, d.Name, d.Default, "")
}
type MapStringFlag struct {
Name string
Usage string
Value *map[string]string
Group string
Name string
Usage string
Value *map[string]string
Group string
Default map[string]string
}
func (m *MapStringFlag) String() string {
if m.Value == nil {
func formatMapString(m map[string]string) string {
if len(m) == 0 {
return ""
}
ls := []string{}
for k, v := range *m.Value {
for k, v := range m {
ls = append(ls, k+"="+v)
}
return strings.Join(ls, ",")
}
func (m *MapStringFlag) String() string {
return formatMapString(*m.Value)
}
func (m *MapStringFlag) Set(value string) error {
if m.Value == nil {
m.Value = &map[string]string{}
@ -311,11 +352,21 @@ func (m *MapStringFlag) Set(value string) error {
}
func (f *Flagset) MapStringFlag(m *MapStringFlag) {
f.addFlag(&FlagVar{
Name: m.Name,
Usage: m.Usage,
Group: m.Group,
})
if m.Default == nil || len(m.Default) == 0 {
f.addFlag(&FlagVar{
Name: m.Name,
Usage: m.Usage,
Group: m.Group,
Default: nil,
})
} else {
f.addFlag(&FlagVar{
Name: m.Name,
Usage: m.Usage,
Group: m.Group,
Default: formatMapString(m.Default),
})
}
f.set.Var(m, m.Name, m.Usage)
}
@ -329,9 +380,10 @@ type Float64Flag struct {
func (f *Flagset) Float64Flag(i *Float64Flag) {
f.addFlag(&FlagVar{
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Name: i.Name,
Usage: i.Usage,
Group: i.Group,
Default: i.Default,
})
f.set.Float64Var(i.Value, i.Name, i.Default, "")
}

View file

@ -24,9 +24,10 @@ type RemoveDBCommand struct {
}
const (
chaindataPath string = "chaindata"
ancientPath string = "ancient"
lightchaindataPath string = "lightchaindata"
chaindataPath string = "chaindata"
ancientPath string = "ancient"
trieCacheJournalPath string = "triecache"
lightchaindataPath string = "lightchaindata"
)
// MarkDown implements cli.MarkDown interface

View file

@ -10,7 +10,7 @@ import (
)
// GetDeveloperChain returns the developer mode configs.
func GetDeveloperChain(period uint64, faucet common.Address) *Chain {
func GetDeveloperChain(period uint64, gasLimitt uint64, faucet common.Address) *Chain {
// Override the default period to the user requested one
config := *params.AllCliqueProtocolChanges
config.Clique = &params.CliqueConfig{
@ -26,7 +26,7 @@ func GetDeveloperChain(period uint64, faucet common.Address) *Chain {
Genesis: &core.Genesis{
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 11500000,
GasLimit: gasLimitt,
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(1),
Alloc: map[common.Address]core.GenesisAccount{

View file

@ -30,14 +30,17 @@ var mainnetBor = &Chain{
LondonBlock: big.NewInt(23850000),
Bor: &params.BorConfig{
JaipurBlock: big.NewInt(23850000),
DelhiBlock: big.NewInt(38189056),
Period: map[string]uint64{
"0": 2,
},
ProducerDelay: map[string]uint64{
"0": 6,
"0": 6,
"38189056": 4,
},
Sprint: map[string]uint64{
"0": 64,
"0": 64,
"38189056": 16,
},
BackupMultiplier: map[string]uint64{
"0": 2,

View file

@ -1,13 +1,16 @@
package server
import (
"context"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"github.com/maticnetwork/heimdall/cmd/heimdalld/service"
"github.com/mitchellh/cli"
"github.com/pelletier/go-toml"
"github.com/ethereum/go-ethereum/log"
)
@ -88,6 +91,32 @@ func (c *Command) extractFlags(args []string) error {
}
}
// nolint: nestif
// check for log-level and verbosity here
if c.configFile != "" {
data, _ := toml.LoadFile(c.configFile)
if data.Has("verbosity") && data.Has("log-level") {
log.Warn("Config contains both, verbosity and log-level, log-level will be deprecated soon. Use verbosity only.", "using", data.Get("verbosity"))
} else if !data.Has("verbosity") && data.Has("log-level") {
log.Warn("Config contains log-level only, note that log-level will be deprecated soon. Use verbosity instead.", "using", data.Get("log-level"))
config.Verbosity = VerbosityStringToInt(strings.ToLower(data.Get("log-level").(string)))
}
} else {
tempFlag := 0
for _, val := range args {
if (strings.HasPrefix(val, "-verbosity") || strings.HasPrefix(val, "--verbosity")) && config.LogLevel != "" {
tempFlag = 1
break
}
}
if tempFlag == 1 {
log.Warn("Both, verbosity and log-level flags are provided, log-level will be deprecated soon. Use verbosity only.", "using", config.Verbosity)
} else if tempFlag == 0 && config.LogLevel != "" {
log.Warn("Only log-level flag is provided, note that log-level will be deprecated soon. Use verbosity instead.", "using", config.LogLevel)
config.Verbosity = VerbosityStringToInt(strings.ToLower(config.LogLevel))
}
}
c.config = &config
return nil
@ -101,6 +130,15 @@ func (c *Command) Run(args []string) int {
return 1
}
if c.config.Heimdall.RunHeimdall {
shutdownCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer stop()
go func() {
service.NewHeimdallService(shutdownCtx, c.getHeimdallArgs())
}()
}
srv, err := NewServer(c.config, WithGRPCAddress())
if err != nil {
c.UI.Error(err.Error())
@ -141,3 +179,8 @@ func (c *Command) handleSignals() int {
func (c *Command) GetConfig() *Config {
return c.cliConfig
}
func (c *Command) getHeimdallArgs() []string {
heimdallArgs := strings.Split(c.config.Heimdall.RunHeimdallArgs, ",")
return append([]string{"start"}, heimdallArgs...)
}

View file

@ -1,6 +1,7 @@
package server
import (
"crypto/ecdsa"
"fmt"
"io/ioutil"
"math"
@ -24,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/eth/gasprice"
@ -33,7 +35,9 @@ import (
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/p2p/netutil"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
)
type Config struct {
@ -48,15 +52,30 @@ type Config struct {
// RequiredBlocks is a list of required (block number, hash) pairs to accept
RequiredBlocks map[string]string `hcl:"eth.requiredblocks,optional" toml:"eth.requiredblocks,optional"`
// Verbosity is the level of the logs to put out
Verbosity int `hcl:"verbosity,optional" toml:"verbosity,optional"`
// LogLevel is the level of the logs to put out
LogLevel string `hcl:"log-level,optional" toml:"log-level,optional"`
// Record information useful for VM and contract debugging
EnablePreimageRecording bool `hcl:"vmdebug,optional" toml:"vmdebug,optional"`
// DataDir is the directory to store the state in
DataDir string `hcl:"datadir,optional" toml:"datadir,optional"`
// Ancient is the directory to store the state in
Ancient string `hcl:"ancient,optional" toml:"ancient,optional"`
// KeyStoreDir is the directory to store keystores
KeyStoreDir string `hcl:"keystore,optional" toml:"keystore,optional"`
// Maximum number of messages in a batch (default=100, use 0 for no limits)
RPCBatchLimit uint64 `hcl:"rpc.batchlimit,optional" toml:"rpc.batchlimit,optional"`
// Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits)
RPCReturnDataLimit uint64 `hcl:"rpc.returndatalimit,optional" toml:"rpc.returndatalimit,optional"`
// SyncMode selects the sync protocol
SyncMode string `hcl:"syncmode,optional" toml:"syncmode,optional"`
@ -72,6 +91,9 @@ type Config struct {
// Ethstats is the address of the ethstats server to send telemetry
Ethstats string `hcl:"ethstats,optional" toml:"ethstats,optional"`
// Logging has the logging related settings
Logging *LoggingConfig `hcl:"log,block" toml:"log,block"`
// P2P has the p2p network related settings
P2P *P2PConfig `hcl:"p2p,block" toml:"p2p,block"`
@ -107,6 +129,49 @@ type Config struct {
// ParallelEVM has the parallel evm related settings
ParallelEVM *ParallelEVMConfig `hcl:"parallelevm,block" toml:"parallelevm,block"`
// Develop Fake Author mode to produce blocks without authorisation
DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
// Pprof has the pprof related settings
Pprof *PprofConfig `hcl:"pprof,block" toml:"pprof,block"`
}
type LoggingConfig struct {
// Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
Vmodule string `hcl:"vmodule,optional" toml:"vmodule,optional"`
// Format logs with JSON
Json bool `hcl:"json,optional" toml:"json,optional"`
// Request a stack trace at a specific logging statement (e.g. "block.go:271")
Backtrace string `hcl:"backtrace,optional" toml:"backtrace,optional"`
// Prepends log messages with call-site location (file and line number)
Debug bool `hcl:"debug,optional" toml:"debug,optional"`
// TODO - implement this
// // Write execution trace to the given file
// Trace string `hcl:"trace,optional" toml:"trace,optional"`
}
type PprofConfig struct {
// Enableed enable the pprof HTTP server
Enabled bool `hcl:"pprof,optional" toml:"pprof,optional"`
// pprof HTTP server listening port
Port int `hcl:"port,optional" toml:"port,optional"`
// pprof HTTP server listening interface
Addr string `hcl:"addr,optional" toml:"addr,optional"`
// Turn on memory profiling with the given rate
MemProfileRate int `hcl:"memprofilerate,optional" toml:"memprofilerate,optional"`
// Turn on block profiling with the given rate
BlockProfileRate int `hcl:"blockprofilerate,optional" toml:"blockprofilerate,optional"`
// // Write CPU profile to the given file
// CPUProfile string `hcl:"cpuprofile,optional" toml:"cpuprofile,optional"`
}
type P2PConfig struct {
@ -128,6 +193,17 @@ type P2PConfig struct {
// NAT it used to set NAT options
NAT string `hcl:"nat,optional" toml:"nat,optional"`
// Connectivity can be restricted to certain IP networks.
// If this option is set to a non-nil value, only hosts which match one of the
// IP networks contained in the list are considered.
NetRestrict string `hcl:"netrestrict,optional" toml:"netrestrict,optional"`
// P2P node key file
NodeKey string `hcl:"nodekey,optional" toml:"nodekey,optional"`
// P2P node key as hex
NodeKeyHex string `hcl:"nodekeyhex,optional" toml:"nodekeyhex,optional"`
// Discovery has the p2p discovery related settings
Discovery *P2PDiscovery `hcl:"discovery,block" toml:"discovery,block"`
}
@ -164,6 +240,15 @@ type HeimdallConfig struct {
// GRPCAddress is the address of the heimdall grpc server
GRPCAddress string `hcl:"grpc-address,optional" toml:"grpc-address,optional"`
// RunHeimdall is used to run heimdall as a child process
RunHeimdall bool `hcl:"bor.runheimdall,optional" toml:"bor.runheimdall,optional"`
// RunHeimdal args are the arguments to run heimdall with
RunHeimdallArgs string `hcl:"bor.runheimdallargs,optional" toml:"bor.runheimdallargs,optional"`
// UseHeimdallApp is used to fetch data from heimdall app when running heimdall as a child process
UseHeimdallApp bool `hcl:"bor.useheimdallapp,optional" toml:"bor.useheimdallapp,optional"`
}
type TxPoolConfig struct {
@ -219,6 +304,10 @@ type SealerConfig struct {
// GasPrice is the minimum gas price for mining a transaction
GasPrice *big.Int `hcl:"-,optional" toml:"-"`
GasPriceRaw string `hcl:"gasprice,optional" toml:"gasprice,optional"`
// The time interval for miner to re-create mining work.
Recommit time.Duration `hcl:"-,optional" toml:"-"`
RecommitRaw string `hcl:"recommit,optional" toml:"recommit,optional"`
}
type JsonRPCConfig struct {
@ -231,6 +320,10 @@ type JsonRPCConfig struct {
// GasCap is the global gas cap for eth-call variants.
GasCap uint64 `hcl:"gascap,optional" toml:"gascap,optional"`
// Sets a timeout used for eth_call (0=infinite)
RPCEVMTimeout time.Duration `hcl:"-,optional" toml:"-"`
RPCEVMTimeoutRaw string `hcl:"evmtimeout,optional" toml:"evmtimeout,optional"`
// TxFeeCap is the global transaction fee cap for send-transaction variants
TxFeeCap float64 `hcl:"txfeecap,optional" toml:"txfeecap,optional"`
@ -242,6 +335,28 @@ type JsonRPCConfig struct {
// Graphql has the json-rpc graphql related settings
Graphql *APIConfig `hcl:"graphql,block" toml:"graphql,block"`
// AUTH RPC related settings
Auth *AUTHConfig `hcl:"auth,block" toml:"auth,block"`
HttpTimeout *HttpTimeouts `hcl:"timeouts,block" toml:"timeouts,block"`
AllowUnprotectedTxs bool `hcl:"allow-unprotected-txs,optional" toml:"allow-unprotected-txs,optional"`
}
type AUTHConfig struct {
// JWTSecret is the hex-encoded jwt secret.
JWTSecret string `hcl:"jwtsecret,optional" toml:"jwtsecret,optional"`
// Addr is the listening address on which authenticated APIs are provided.
Addr string `hcl:"addr,optional" toml:"addr,optional"`
// Port is the port number on which authenticated APIs are provided.
Port uint64 `hcl:"port,optional" toml:"port,optional"`
// VHosts is the list of virtual hostnames which are allowed on incoming requests
// for the authenticated api. This is by default {'localhost'}.
VHosts []string `hcl:"vhosts,optional" toml:"vhosts,optional"`
}
type GRPCConfig struct {
@ -273,6 +388,40 @@ type APIConfig struct {
// Origins is the list of endpoints to accept requests from (only consumed for websockets)
Origins []string `hcl:"origins,optional" toml:"origins,optional"`
// ExecutionPoolSize is max size of workers to be used for rpc execution
ExecutionPoolSize uint64 `hcl:"ep-size,optional" toml:"ep-size,optional"`
// ExecutionPoolRequestTimeout is timeout used by execution pool for rpc execution
ExecutionPoolRequestTimeout time.Duration `hcl:"-,optional" toml:"-"`
ExecutionPoolRequestTimeoutRaw string `hcl:"ep-requesttimeout,optional" toml:"ep-requesttimeout,optional"`
}
// Used from rpc.HTTPTimeouts
type HttpTimeouts struct {
// ReadTimeout is the maximum duration for reading the entire
// request, including the body.
//
// Because ReadTimeout does not let Handlers make per-request
// decisions on each request body's acceptable deadline or
// upload rate, most users will prefer to use
// ReadHeaderTimeout. It is valid to use them both.
ReadTimeout time.Duration `hcl:"-,optional" toml:"-"`
ReadTimeoutRaw string `hcl:"read,optional" toml:"read,optional"`
// WriteTimeout is the maximum duration before timing out
// writes of the response. It is reset whenever a new
// request's header is read. Like ReadTimeout, it does not
// let Handlers make decisions on a per-request basis.
WriteTimeout time.Duration `hcl:"-,optional" toml:"-"`
WriteTimeoutRaw string `hcl:"write,optional" toml:"write,optional"`
// IdleTimeout is the maximum amount of time to wait for the
// next request when keep-alives are enabled. If IdleTimeout
// is zero, the value of ReadTimeout is used. If both are
// zero, ReadHeaderTimeout is used.
IdleTimeout time.Duration `hcl:"-,optional" toml:"-"`
IdleTimeoutRaw string `hcl:"idle,optional" toml:"idle,optional"`
}
type GpoConfig struct {
@ -282,6 +431,12 @@ type GpoConfig struct {
// Percentile sets the weights to new blocks
Percentile uint64 `hcl:"percentile,optional" toml:"percentile,optional"`
// Maximum header history of gasprice oracle
MaxHeaderHistory int `hcl:"maxheaderhistory,optional" toml:"maxheaderhistory,optional"`
// Maximum block history of gasprice oracle
MaxBlockHistory int `hcl:"maxblockhistory,optional" toml:"maxblockhistory,optional"`
// MaxPrice is an upper bound gas price
MaxPrice *big.Int `hcl:"-,optional" toml:"-"`
MaxPriceRaw string `hcl:"maxprice,optional" toml:"maxprice,optional"`
@ -374,6 +529,12 @@ type CacheConfig struct {
// Number of block states to keep in memory (default = 128)
TriesInMemory uint64 `hcl:"triesinmemory,optional" toml:"triesinmemory,optional"`
// Time after which the Merkle Patricia Trie is stored to disc from memory
TrieTimeout time.Duration `hcl:"-,optional" toml:"-"`
TrieTimeoutRaw string `hcl:"timeout,optional" toml:"timeout,optional"`
// Raise the open file descriptor resource limit (default = system fd limit)
FDLimit int `hcl:"fdlimit,optional" toml:"fdlimit,optional"`
}
type AccountsConfig struct {
@ -399,6 +560,9 @@ type DeveloperConfig struct {
// Period is the block period to use in developer mode
Period uint64 `hcl:"period,optional" toml:"period,optional"`
// Initial block gas limit
GasLimit uint64 `hcl:"gaslimit,optional" toml:"gaslimit,optional"`
}
type ParallelEVMConfig struct {
@ -409,11 +573,22 @@ type ParallelEVMConfig struct {
func DefaultConfig() *Config {
return &Config{
Chain: "mainnet",
Identity: Hostname(),
RequiredBlocks: map[string]string{},
LogLevel: "INFO",
DataDir: DefaultDataDir(),
Chain: "mainnet",
Identity: Hostname(),
RequiredBlocks: map[string]string{},
Verbosity: 3,
LogLevel: "",
EnablePreimageRecording: false,
DataDir: DefaultDataDir(),
Ancient: "",
Logging: &LoggingConfig{
Vmodule: "",
Json: false,
Backtrace: "",
Debug: false,
},
RPCBatchLimit: 100,
RPCReturnDataLimit: 100000,
P2P: &P2PConfig{
MaxPeers: 50,
MaxPendPeers: 50,
@ -421,6 +596,7 @@ func DefaultConfig() *Config {
Port: 30303,
NoDiscover: false,
NAT: "any",
NetRestrict: "",
Discovery: &P2PDiscovery{
V5Enabled: false,
Bootnodes: []string{},
@ -445,7 +621,7 @@ func DefaultConfig() *Config {
NoLocals: false,
Journal: "transactions.rlp",
Rejournal: 1 * time.Hour,
PriceLimit: 1,
PriceLimit: 1, // geth's default
PriceBump: 10,
AccountSlots: 16,
GlobalSlots: 32768,
@ -456,43 +632,63 @@ func DefaultConfig() *Config {
Sealer: &SealerConfig{
Enabled: false,
Etherbase: "",
GasCeil: 30_000_000,
GasPrice: big.NewInt(1 * params.GWei),
GasCeil: 30_000_000, // geth's default
GasPrice: big.NewInt(1 * params.GWei), // geth's default
ExtraData: "",
Recommit: 125 * time.Second,
},
Gpo: &GpoConfig{
Blocks: 20,
Percentile: 60,
MaxPrice: gasprice.DefaultMaxPrice,
IgnorePrice: gasprice.DefaultIgnorePrice,
Blocks: 20,
Percentile: 60,
MaxHeaderHistory: 1024,
MaxBlockHistory: 1024,
MaxPrice: gasprice.DefaultMaxPrice,
IgnorePrice: gasprice.DefaultIgnorePrice,
},
JsonRPC: &JsonRPCConfig{
IPCDisable: false,
IPCPath: "",
GasCap: ethconfig.Defaults.RPCGasCap,
TxFeeCap: ethconfig.Defaults.RPCTxFeeCap,
IPCDisable: false,
IPCPath: "",
GasCap: ethconfig.Defaults.RPCGasCap,
TxFeeCap: ethconfig.Defaults.RPCTxFeeCap,
RPCEVMTimeout: ethconfig.Defaults.RPCEVMTimeout,
AllowUnprotectedTxs: false,
Http: &APIConfig{
Enabled: false,
Port: 8545,
Prefix: "",
Host: "localhost",
API: []string{"eth", "net", "web3", "txpool", "bor"},
Cors: []string{"localhost"},
VHost: []string{"localhost"},
Enabled: false,
Port: 8545,
Prefix: "",
Host: "localhost",
API: []string{"eth", "net", "web3", "txpool", "bor"},
Cors: []string{"localhost"},
VHost: []string{"localhost"},
ExecutionPoolSize: 40,
ExecutionPoolRequestTimeout: 0,
},
Ws: &APIConfig{
Enabled: false,
Port: 8546,
Prefix: "",
Host: "localhost",
API: []string{"net", "web3"},
Origins: []string{"localhost"},
Enabled: false,
Port: 8546,
Prefix: "",
Host: "localhost",
API: []string{"net", "web3"},
Origins: []string{"localhost"},
ExecutionPoolSize: 40,
ExecutionPoolRequestTimeout: 0,
},
Graphql: &APIConfig{
Enabled: false,
Cors: []string{"localhost"},
VHost: []string{"localhost"},
},
HttpTimeout: &HttpTimeouts{
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 120 * time.Second,
},
Auth: &AUTHConfig{
JWTSecret: "",
Port: node.DefaultAuthPort,
Addr: node.DefaultAuthHost,
VHosts: node.DefaultAuthVhosts,
},
},
Ethstats: "",
Telemetry: &TelemetryConfig{
@ -514,7 +710,7 @@ func DefaultConfig() *Config {
},
},
Cache: &CacheConfig{
Cache: 1024,
Cache: 1024, // geth's default (suitable for mumbai)
PercDatabase: 50,
PercTrie: 15,
PercGc: 25,
@ -525,6 +721,8 @@ func DefaultConfig() *Config {
Preimages: false,
TxLookupLimit: 2350000,
TriesInMemory: 128,
TrieTimeout: 60 * time.Minute,
FDLimit: 0,
},
Accounts: &AccountsConfig{
Unlock: []string{},
@ -537,8 +735,18 @@ func DefaultConfig() *Config {
Addr: ":3131",
},
Developer: &DeveloperConfig{
Enabled: false,
Period: 0,
Enabled: false,
Period: 0,
GasLimit: 11500000,
},
DevFakeAuthor: false,
Pprof: &PprofConfig{
Enabled: false,
Port: 6060,
Addr: "127.0.0.1",
MemProfileRate: 512 * 1024,
BlockProfileRate: 0,
// CPUProfile: "",
},
ParallelEVM: &ParallelEVMConfig{
Enable: false,
@ -588,9 +796,17 @@ func (c *Config) fillTimeDurations() error {
td *time.Duration
str *string
}{
{"jsonrpc.evmtimeout", &c.JsonRPC.RPCEVMTimeout, &c.JsonRPC.RPCEVMTimeoutRaw},
{"miner.recommit", &c.Sealer.Recommit, &c.Sealer.RecommitRaw},
{"jsonrpc.timeouts.read", &c.JsonRPC.HttpTimeout.ReadTimeout, &c.JsonRPC.HttpTimeout.ReadTimeoutRaw},
{"jsonrpc.timeouts.write", &c.JsonRPC.HttpTimeout.WriteTimeout, &c.JsonRPC.HttpTimeout.WriteTimeoutRaw},
{"jsonrpc.timeouts.idle", &c.JsonRPC.HttpTimeout.IdleTimeout, &c.JsonRPC.HttpTimeout.IdleTimeoutRaw},
{"jsonrpc.ws.ep-requesttimeout", &c.JsonRPC.Ws.ExecutionPoolRequestTimeout, &c.JsonRPC.Ws.ExecutionPoolRequestTimeoutRaw},
{"jsonrpc.http.ep-requesttimeout", &c.JsonRPC.Http.ExecutionPoolRequestTimeout, &c.JsonRPC.Http.ExecutionPoolRequestTimeoutRaw},
{"txpool.lifetime", &c.TxPool.LifeTime, &c.TxPool.LifeTimeRaw},
{"txpool.rejournal", &c.TxPool.Rejournal, &c.TxPool.RejournalRaw},
{"cache.rejournal", &c.Cache.Rejournal, &c.Cache.RejournalRaw},
{"cache.timeout", &c.Cache.TrieTimeout, &c.Cache.TrieTimeoutRaw},
}
for _, x := range tds {
@ -648,19 +864,12 @@ func (c *Config) loadChain() error {
c.P2P.Discovery.DNS = c.chain.DNS
}
// depending on the chain we have different cache values
if c.Chain == "mainnet" {
c.Cache.Cache = 4096
} else {
c.Cache.Cache = 1024
}
return nil
}
//nolint:gocognit
func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*ethconfig.Config, error) {
dbHandles, err := makeDatabaseHandles()
dbHandles, err := MakeDatabaseHandles(c.Cache.FDLimit)
if err != nil {
return nil, err
}
@ -677,15 +886,28 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.HeimdallURL = c.Heimdall.URL
n.WithoutHeimdall = c.Heimdall.Without
n.HeimdallgRPCAddress = c.Heimdall.GRPCAddress
n.RunHeimdall = c.Heimdall.RunHeimdall
n.RunHeimdallArgs = c.Heimdall.RunHeimdallArgs
n.UseHeimdallApp = c.Heimdall.UseHeimdallApp
// Developer Fake Author for producing blocks without authorisation on bor consensus
n.DevFakeAuthor = c.DevFakeAuthor
// Developer Fake Author for producing blocks without authorisation on bor consensus
n.DevFakeAuthor = c.DevFakeAuthor
// gas price oracle
{
n.GPO.Blocks = int(c.Gpo.Blocks)
n.GPO.Percentile = int(c.Gpo.Percentile)
n.GPO.MaxHeaderHistory = c.Gpo.MaxHeaderHistory
n.GPO.MaxBlockHistory = c.Gpo.MaxBlockHistory
n.GPO.MaxPrice = c.Gpo.MaxPrice
n.GPO.IgnorePrice = c.Gpo.IgnorePrice
}
n.EnablePreimageRecording = c.EnablePreimageRecording
// txpool options
{
n.TxPool.NoLocals = c.TxPool.NoLocals
@ -702,6 +924,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
// miner options
{
n.Miner.Recommit = c.Sealer.Recommit
n.Miner.GasPrice = c.Sealer.GasPrice
n.Miner.GasCeil = c.Sealer.GasCeil
n.Miner.ExtraData = []byte(c.Sealer.ExtraData)
@ -775,7 +998,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.Miner.Etherbase = developer.Address
// get developer mode chain config
c.chain = chains.GetDeveloperChain(c.Developer.Period, developer.Address)
c.chain = chains.GetDeveloperChain(c.Developer.Period, c.Developer.GasLimit, developer.Address)
// update the parameters
n.NetworkId = c.chain.NetworkId
@ -853,6 +1076,8 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.NoPrefetch = c.Cache.NoPrefetch
n.Preimages = c.Cache.Preimages
n.TxLookupLimit = c.Cache.TxLookupLimit
n.TrieTimeout = c.Cache.TrieTimeout
n.TriesInMemory = c.Cache.TriesInMemory
}
n.RPCGasCap = c.JsonRPC.GasCap
@ -862,6 +1087,8 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
log.Info("Global gas cap disabled")
}
n.RPCEVMTimeout = c.JsonRPC.RPCEVMTimeout
n.RPCTxFeeCap = c.JsonRPC.TxFeeCap
// sync mode. It can either be "fast", "full" or "snap". We disable
@ -908,6 +1135,11 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.ParallelEVM.Enable = c.ParallelEVM.Enable
n.ParallelEVM.SpeculativeProcesses = c.ParallelEVM.SpeculativeProcesses
n.RPCReturnDataLimit = c.RPCReturnDataLimit
if c.Ancient != "" {
n.DatabaseFreezer = c.Ancient
}
return &n, nil
}
@ -987,6 +1219,35 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
return *match
}
// setNodeKey creates a node key from set command line flags, either loading it
// from a file or as a specified hex value. If neither flags were provided, this
// method returns nil and an emphemeral key is to be generated.
func getNodeKey(hex string, file string) *ecdsa.PrivateKey {
var (
key *ecdsa.PrivateKey
err error
)
switch {
case file != "" && hex != "":
utils.Fatalf("Options %q and %q are mutually exclusive", file, hex)
case file != "":
if key, err = crypto.LoadECDSA(file); err != nil {
utils.Fatalf("Option %q: %v", file, err)
}
return key
case hex != "":
if key, err = crypto.HexToECDSA(hex); err != nil {
utils.Fatalf("Option %q: %v", hex, err)
}
return key
}
return nil
}
func (c *Config) buildNode() (*node.Config, error) {
ipcPath := ""
if !c.JsonRPC.IPCDisable {
@ -1004,6 +1265,7 @@ func (c *Config) buildNode() (*node.Config, error) {
InsecureUnlockAllowed: c.Accounts.AllowInsecureUnlock,
Version: params.VersionWithCommit(gitCommit, gitDate),
IPCPath: ipcPath,
AllowUnprotectedTxs: c.JsonRPC.AllowUnprotectedTxs,
P2P: p2p.Config{
MaxPeers: int(c.P2P.MaxPeers),
MaxPendingPeers: int(c.P2P.MaxPendPeers),
@ -1019,6 +1281,34 @@ func (c *Config) buildNode() (*node.Config, error) {
WSPathPrefix: c.JsonRPC.Ws.Prefix,
GraphQLCors: c.JsonRPC.Graphql.Cors,
GraphQLVirtualHosts: c.JsonRPC.Graphql.VHost,
HTTPTimeouts: rpc.HTTPTimeouts{
ReadTimeout: c.JsonRPC.HttpTimeout.ReadTimeout,
WriteTimeout: c.JsonRPC.HttpTimeout.WriteTimeout,
IdleTimeout: c.JsonRPC.HttpTimeout.IdleTimeout,
},
JWTSecret: c.JsonRPC.Auth.JWTSecret,
AuthPort: int(c.JsonRPC.Auth.Port),
AuthAddr: c.JsonRPC.Auth.Addr,
AuthVirtualHosts: c.JsonRPC.Auth.VHosts,
RPCBatchLimit: c.RPCBatchLimit,
WSJsonRPCExecutionPoolSize: c.JsonRPC.Ws.ExecutionPoolSize,
WSJsonRPCExecutionPoolRequestTimeout: c.JsonRPC.Ws.ExecutionPoolRequestTimeout,
HTTPJsonRPCExecutionPoolSize: c.JsonRPC.Http.ExecutionPoolSize,
HTTPJsonRPCExecutionPoolRequestTimeout: c.JsonRPC.Http.ExecutionPoolRequestTimeout,
}
if c.P2P.NetRestrict != "" {
list, err := netutil.ParseNetlist(c.P2P.NetRestrict)
if err != nil {
utils.Fatalf("Option %q: %v", c.P2P.NetRestrict, err)
}
cfg.P2P.NetRestrict = list
}
key := getNodeKey(c.P2P.NodeKeyHex, c.P2P.NodeKey)
if key != nil {
cfg.P2P.PrivateKey = key
}
// dev mode
@ -1108,18 +1398,32 @@ func (c *Config) Merge(cc ...*Config) error {
return nil
}
func makeDatabaseHandles() (int, error) {
func MakeDatabaseHandles(max int) (int, error) {
limit, err := fdlimit.Maximum()
if err != nil {
return -1, err
}
switch {
case max == 0:
// User didn't specify a meaningful value, use system limits
case max < 128:
// User specified something unhealthy, just use system defaults
log.Error("File descriptor limit invalid (<128)", "had", max, "updated", limit)
case max > limit:
// User requested more than the OS allows, notify that we can't allocate it
log.Warn("Requested file descriptors denied by OS", "req", max, "limit", limit)
default:
// User limit is meaningful and within allowed range, use that
limit = max
}
raised, err := fdlimit.Raise(uint64(limit))
if err != nil {
return -1, err
}
return int(raised / 2), nil
return int(raised / 2), nil // Leave half for networking and other stuff
}
func parseBootnodes(urls []string) ([]*enode.Node, error) {

View file

@ -1,7 +1,6 @@
package server
import (
"math/big"
"testing"
"time"
@ -101,44 +100,6 @@ func TestDefaultDatatypeOverride(t *testing.T) {
assert.Equal(t, c0, expected)
}
func TestConfigLoadFile(t *testing.T) {
t.Parallel()
readFile := func(path string) {
config, err := readConfigFile(path)
assert.NoError(t, err)
assert.Equal(t, config, &Config{
DataDir: "./data",
P2P: &P2PConfig{
MaxPeers: 30,
},
TxPool: &TxPoolConfig{
LifeTime: 1 * time.Second,
},
Gpo: &GpoConfig{
MaxPrice: big.NewInt(100),
},
Sealer: &SealerConfig{},
Cache: &CacheConfig{},
})
}
// read file in hcl format
t.Run("hcl", func(t *testing.T) {
t.Parallel()
readFile("./testdata/test.hcl")
})
// read file in json format
t.Run("json", func(t *testing.T) {
t.Parallel()
readFile("./testdata/test.json")
})
}
var dummyEnodeAddr = "enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303"
func TestConfigBootnodesDefault(t *testing.T) {

View file

@ -11,36 +11,68 @@ func (c *Command) Flags() *flagset.Flagset {
f.StringFlag(&flagset.StringFlag{
Name: "chain",
Usage: "Name of the chain to sync",
Usage: "Name of the chain to sync ('mumbai', 'mainnet') or path to a genesis file",
Value: &c.cliConfig.Chain,
Default: c.cliConfig.Chain,
})
f.StringFlag(&flagset.StringFlag{
Name: "identity",
Usage: "Name/Identity of the node",
Value: &c.cliConfig.Identity,
Default: c.cliConfig.Identity,
Name: "identity",
Usage: "Name/Identity of the node",
Value: &c.cliConfig.Identity,
Default: c.cliConfig.Identity,
HideDefaultFromDoc: true,
})
f.IntFlag(&flagset.IntFlag{
Name: "verbosity",
Usage: "Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3",
Value: &c.cliConfig.Verbosity,
Default: c.cliConfig.Verbosity,
})
f.StringFlag(&flagset.StringFlag{
Name: "log-level",
Usage: "Set log level for the server",
Usage: "Log level for the server (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead",
Value: &c.cliConfig.LogLevel,
Default: c.cliConfig.LogLevel,
})
f.StringFlag(&flagset.StringFlag{
Name: "datadir",
Usage: "Path of the data directory to store information",
Value: &c.cliConfig.DataDir,
Default: c.cliConfig.DataDir,
Name: "datadir",
Usage: "Path of the data directory to store information",
Value: &c.cliConfig.DataDir,
Default: c.cliConfig.DataDir,
HideDefaultFromDoc: true,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "vmdebug",
Usage: "Record information useful for VM and contract debugging",
Value: &c.cliConfig.EnablePreimageRecording,
Default: c.cliConfig.EnablePreimageRecording,
})
f.StringFlag(&flagset.StringFlag{
Name: "datadir.ancient",
Usage: "Data directory for ancient chain segments (default = inside chaindata)",
Value: &c.cliConfig.Ancient,
Default: c.cliConfig.Ancient,
})
f.StringFlag(&flagset.StringFlag{
Name: "keystore",
Usage: "Path of the directory to store keystores",
Usage: "Path of the directory where keystores are located",
Value: &c.cliConfig.KeyStoreDir,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "rpc.batchlimit",
Usage: "Maximum number of messages in a batch (default=100, use 0 for no limits)",
Value: &c.cliConfig.RPCBatchLimit,
Default: c.cliConfig.RPCBatchLimit,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "rpc.returndatalimit",
Usage: "Maximum size (in bytes) a result of an rpc request could have (default=100000, use 0 for no limits)",
Value: &c.cliConfig.RPCReturnDataLimit,
Default: c.cliConfig.RPCReturnDataLimit,
})
f.StringFlag(&flagset.StringFlag{
Name: "config",
Usage: "File for the config file",
Usage: "Path to the TOML configuration file",
Value: &c.configFile,
})
f.StringFlag(&flagset.StringFlag{
@ -56,23 +88,54 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.GcMode,
})
f.MapStringFlag(&flagset.MapStringFlag{
Name: "eth.requiredblocks",
Usage: "Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)",
Value: &c.cliConfig.RequiredBlocks,
Name: "eth.requiredblocks",
Usage: "Comma separated block number-to-hash mappings to require for peering (<number>=<hash>)",
Value: &c.cliConfig.RequiredBlocks,
Default: c.cliConfig.RequiredBlocks,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "snapshot",
Usage: `Enables the snapshot-database mode (default = true)`,
Usage: `Enables the snapshot-database mode`,
Value: &c.cliConfig.Snapshot,
Default: c.cliConfig.Snapshot,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.logs",
Usage: `Enables bor log retrieval (default = false)`,
Usage: `Enables bor log retrieval`,
Value: &c.cliConfig.BorLogs,
Default: c.cliConfig.BorLogs,
})
// logging related flags (log-level and verbosity is present above, it will be removed soon)
f.StringFlag(&flagset.StringFlag{
Name: "vmodule",
Usage: "Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)",
Value: &c.cliConfig.Logging.Vmodule,
Default: c.cliConfig.Logging.Vmodule,
Group: "Logging",
})
f.BoolFlag(&flagset.BoolFlag{
Name: "log.json",
Usage: "Format logs with JSON",
Value: &c.cliConfig.Logging.Json,
Default: c.cliConfig.Logging.Json,
Group: "Logging",
})
f.StringFlag(&flagset.StringFlag{
Name: "log.backtrace",
Usage: "Request a stack trace at a specific logging statement (e.g. 'block.go:271')",
Value: &c.cliConfig.Logging.Backtrace,
Default: c.cliConfig.Logging.Backtrace,
Group: "Logging",
})
f.BoolFlag(&flagset.BoolFlag{
Name: "log.debug",
Usage: "Prepends log messages with call-site location (file and line number)",
Value: &c.cliConfig.Logging.Debug,
Default: c.cliConfig.Logging.Debug,
Group: "Logging",
})
// heimdall
f.StringFlag(&flagset.StringFlag{
Name: "bor.heimdall",
@ -86,12 +149,36 @@ func (c *Command) Flags() *flagset.Flagset {
Value: &c.cliConfig.Heimdall.Without,
Default: c.cliConfig.Heimdall.Without,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.devfakeauthor",
Usage: "Run miner without validator set authorization [dev mode] : Use with '--bor.withoutheimdall'",
Value: &c.cliConfig.DevFakeAuthor,
Default: c.cliConfig.DevFakeAuthor,
})
f.StringFlag(&flagset.StringFlag{
Name: "bor.heimdallgRPC",
Usage: "Address of Heimdall gRPC service",
Value: &c.cliConfig.Heimdall.GRPCAddress,
Default: c.cliConfig.Heimdall.GRPCAddress,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.runheimdall",
Usage: "Run Heimdall service as a child process",
Value: &c.cliConfig.Heimdall.RunHeimdall,
Default: c.cliConfig.Heimdall.RunHeimdall,
})
f.StringFlag(&flagset.StringFlag{
Name: "bor.runheimdallargs",
Usage: "Arguments to pass to Heimdall service",
Value: &c.cliConfig.Heimdall.RunHeimdallArgs,
Default: c.cliConfig.Heimdall.RunHeimdallArgs,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "bor.useheimdallapp",
Usage: "Use child heimdall process to fetch data, Only works when bor.runheimdall is true",
Value: &c.cliConfig.Heimdall.UseHeimdallApp,
Default: c.cliConfig.Heimdall.UseHeimdallApp,
})
// txpool options
f.SliceStringFlag(&flagset.SliceStringFlag{
@ -182,7 +269,7 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.StringFlag(&flagset.StringFlag{
Name: "miner.etherbase",
Usage: "Public address for block mining rewards (default = first account)",
Usage: "Public address for block mining rewards",
Value: &c.cliConfig.Sealer.Etherbase,
Default: c.cliConfig.Sealer.Etherbase,
Group: "Sealer",
@ -196,16 +283,24 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "miner.gaslimit",
Usage: "Target gas ceiling for mined blocks",
Usage: "Target gas ceiling (gas limit) for mined blocks",
Value: &c.cliConfig.Sealer.GasCeil,
Default: c.cliConfig.Sealer.GasCeil,
Group: "Sealer",
})
f.BigIntFlag(&flagset.BigIntFlag{
Name: "miner.gasprice",
Usage: "Minimum gas price for mining a transaction",
Value: c.cliConfig.Sealer.GasPrice,
Group: "Sealer",
Name: "miner.gasprice",
Usage: "Minimum gas price for mining a transaction",
Value: c.cliConfig.Sealer.GasPrice,
Group: "Sealer",
Default: c.cliConfig.Sealer.GasPrice,
})
f.DurationFlag(&flagset.DurationFlag{
Name: "miner.recommit",
Usage: "The time interval for miner to re-create mining work",
Value: &c.cliConfig.Sealer.Recommit,
Default: c.cliConfig.Sealer.Recommit,
Group: "Sealer",
})
// ethstats
@ -229,21 +324,35 @@ func (c *Command) Flags() *flagset.Flagset {
Value: &c.cliConfig.Gpo.Percentile,
Default: c.cliConfig.Gpo.Percentile,
})
f.BigIntFlag(&flagset.BigIntFlag{
Name: "gpo.maxprice",
Usage: "Maximum gas price will be recommended by gpo",
Value: c.cliConfig.Gpo.MaxPrice,
f.IntFlag(&flagset.IntFlag{
Name: "gpo.maxheaderhistory",
Usage: "Maximum header history of gasprice oracle",
Value: &c.cliConfig.Gpo.MaxHeaderHistory,
Default: c.cliConfig.Gpo.MaxHeaderHistory,
})
f.IntFlag(&flagset.IntFlag{
Name: "gpo.maxblockhistory",
Usage: "Maximum block history of gasprice oracle",
Value: &c.cliConfig.Gpo.MaxBlockHistory,
Default: c.cliConfig.Gpo.MaxBlockHistory,
})
f.BigIntFlag(&flagset.BigIntFlag{
Name: "gpo.ignoreprice",
Usage: "Gas price below which gpo will ignore transactions",
Value: c.cliConfig.Gpo.IgnorePrice,
Name: "gpo.maxprice",
Usage: "Maximum gas price will be recommended by gpo",
Value: c.cliConfig.Gpo.MaxPrice,
Default: c.cliConfig.Gpo.MaxPrice,
})
f.BigIntFlag(&flagset.BigIntFlag{
Name: "gpo.ignoreprice",
Usage: "Gas price below which gpo will ignore transactions",
Value: c.cliConfig.Gpo.IgnorePrice,
Default: c.cliConfig.Gpo.IgnorePrice,
})
// cache options
f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache",
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)",
Usage: "Megabytes of memory allocated to internal caching",
Value: &c.cliConfig.Cache.Cache,
Default: c.cliConfig.Cache.Cache,
Group: "Cache",
@ -257,7 +366,7 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.trie",
Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)",
Usage: "Percentage of cache memory allowance to use for trie caching",
Value: &c.cliConfig.Cache.PercTrie,
Default: c.cliConfig.Cache.PercTrie,
Group: "Cache",
@ -278,14 +387,14 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.gc",
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
Usage: "Percentage of cache memory allowance to use for trie pruning",
Value: &c.cliConfig.Cache.PercGc,
Default: c.cliConfig.Cache.PercGc,
Group: "Cache",
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.snapshot",
Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)",
Usage: "Percentage of cache memory allowance to use for snapshot caching",
Value: &c.cliConfig.Cache.PercSnapshot,
Default: c.cliConfig.Cache.PercSnapshot,
Group: "Cache",
@ -313,11 +422,18 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "txlookuplimit",
Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)",
Usage: "Number of recent blocks to maintain transactions index for",
Value: &c.cliConfig.Cache.TxLookupLimit,
Default: c.cliConfig.Cache.TxLookupLimit,
Group: "Cache",
})
f.IntFlag(&flagset.IntFlag{
Name: "fdlimit",
Usage: "Raise the open file descriptor resource limit (default = system fd limit)",
Value: &c.cliConfig.Cache.FDLimit,
Default: c.cliConfig.Cache.FDLimit,
Group: "Cache",
})
// rpc options
f.Uint64Flag(&flagset.Uint64Flag{
@ -327,6 +443,13 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.JsonRPC.GasCap,
Group: "JsonRPC",
})
f.DurationFlag(&flagset.DurationFlag{
Name: "rpc.evmtimeout",
Usage: "Sets a timeout used for eth_call (0=infinite)",
Value: &c.cliConfig.JsonRPC.RPCEVMTimeout,
Default: c.cliConfig.JsonRPC.RPCEVMTimeout,
Group: "JsonRPC",
})
f.Float64Flag(&flagset.Float64Flag{
Name: "rpc.txfeecap",
Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)",
@ -334,6 +457,13 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.JsonRPC.TxFeeCap,
Group: "JsonRPC",
})
f.BoolFlag(&flagset.BoolFlag{
Name: "rpc.allow-unprotected-txs",
Usage: "Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC",
Value: &c.cliConfig.JsonRPC.AllowUnprotectedTxs,
Default: c.cliConfig.JsonRPC.AllowUnprotectedTxs,
Group: "JsonRPC",
})
f.BoolFlag(&flagset.BoolFlag{
Name: "ipcdisable",
Usage: "Disable the IPC-RPC server",
@ -348,6 +478,34 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.JsonRPC.IPCPath,
Group: "JsonRPC",
})
f.StringFlag(&flagset.StringFlag{
Name: "authrpc.jwtsecret",
Usage: "Path to a JWT secret to use for authenticated RPC endpoints",
Value: &c.cliConfig.JsonRPC.Auth.JWTSecret,
Default: c.cliConfig.JsonRPC.Auth.JWTSecret,
Group: "JsonRPC",
})
f.StringFlag(&flagset.StringFlag{
Name: "authrpc.addr",
Usage: "Listening address for authenticated APIs",
Value: &c.cliConfig.JsonRPC.Auth.Addr,
Default: c.cliConfig.JsonRPC.Auth.Addr,
Group: "JsonRPC",
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "authrpc.port",
Usage: "Listening port for authenticated APIs",
Value: &c.cliConfig.JsonRPC.Auth.Port,
Default: c.cliConfig.JsonRPC.Auth.Port,
Group: "JsonRPC",
})
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "authrpc.vhosts",
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: &c.cliConfig.JsonRPC.Auth.VHosts,
Default: c.cliConfig.JsonRPC.Auth.VHosts,
Group: "JsonRPC",
})
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "http.corsdomain",
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
@ -420,6 +578,20 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.JsonRPC.Http.API,
Group: "JsonRPC",
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "http.ep-size",
Usage: "Maximum size of workers to run in rpc execution pool for HTTP requests",
Value: &c.cliConfig.JsonRPC.Http.ExecutionPoolSize,
Default: c.cliConfig.JsonRPC.Http.ExecutionPoolSize,
Group: "JsonRPC",
})
f.DurationFlag(&flagset.DurationFlag{
Name: "http.ep-requesttimeout",
Usage: "Request Timeout for rpc execution pool for HTTP requests",
Value: &c.cliConfig.JsonRPC.Http.ExecutionPoolRequestTimeout,
Default: c.cliConfig.JsonRPC.Http.ExecutionPoolRequestTimeout,
Group: "JsonRPC",
})
// ws options
f.BoolFlag(&flagset.BoolFlag{
@ -457,6 +629,20 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.JsonRPC.Ws.API,
Group: "JsonRPC",
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "ws.ep-size",
Usage: "Maximum size of workers to run in rpc execution pool for WS requests",
Value: &c.cliConfig.JsonRPC.Ws.ExecutionPoolSize,
Default: c.cliConfig.JsonRPC.Ws.ExecutionPoolSize,
Group: "JsonRPC",
})
f.DurationFlag(&flagset.DurationFlag{
Name: "ws.ep-requesttimeout",
Usage: "Request Timeout for rpc execution pool for WS requests",
Value: &c.cliConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout,
Default: c.cliConfig.JsonRPC.Ws.ExecutionPoolRequestTimeout,
Group: "JsonRPC",
})
// graphql options
f.BoolFlag(&flagset.BoolFlag{
@ -498,7 +684,7 @@ func (c *Command) Flags() *flagset.Flagset {
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "maxpendpeers",
Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
Usage: "Maximum number of pending connection attempts",
Value: &c.cliConfig.P2P.MaxPendPeers,
Default: c.cliConfig.P2P.MaxPendPeers,
Group: "P2P",
@ -510,6 +696,27 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.P2P.NAT,
Group: "P2P",
})
f.StringFlag(&flagset.StringFlag{
Name: "netrestrict",
Usage: "Restricts network communication to the given IP networks (CIDR masks)",
Value: &c.cliConfig.P2P.NetRestrict,
Default: c.cliConfig.P2P.NetRestrict,
Group: "P2P",
})
f.StringFlag(&flagset.StringFlag{
Name: "nodekey",
Usage: " P2P node key file",
Value: &c.cliConfig.P2P.NodeKey,
Default: c.cliConfig.P2P.NodeKey,
Group: "P2P",
})
f.StringFlag(&flagset.StringFlag{
Name: "nodekeyhex",
Usage: "P2P node key as hex",
Value: &c.cliConfig.P2P.NodeKeyHex,
Default: c.cliConfig.P2P.NodeKeyHex,
Group: "P2P",
})
f.BoolFlag(&flagset.BoolFlag{
Name: "nodiscover",
Usage: "Disables the peer discovery mechanism (manual peer addition)",
@ -576,10 +783,11 @@ func (c *Command) Flags() *flagset.Flagset {
Group: "Telemetry",
})
f.MapStringFlag(&flagset.MapStringFlag{
Name: "metrics.influxdb.tags",
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
Value: &c.cliConfig.Telemetry.InfluxDB.Tags,
Group: "Telemetry",
Name: "metrics.influxdb.tags",
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
Value: &c.cliConfig.Telemetry.InfluxDB.Tags,
Group: "Telemetry",
Default: c.cliConfig.Telemetry.InfluxDB.Tags,
})
f.StringFlag(&flagset.StringFlag{
Name: "metrics.prometheus-addr",
@ -696,5 +904,50 @@ func (c *Command) Flags() *flagset.Flagset {
Value: &c.cliConfig.ParallelEVM.SpeculativeProcesses,
Default: c.cliConfig.ParallelEVM.SpeculativeProcesses,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "dev.gaslimit",
Usage: "Initial block gas limit",
Value: &c.cliConfig.Developer.GasLimit,
Default: c.cliConfig.Developer.GasLimit,
})
// pprof
f.BoolFlag(&flagset.BoolFlag{
Name: "pprof",
Usage: "Enable the pprof HTTP server",
Value: &c.cliConfig.Pprof.Enabled,
Default: c.cliConfig.Pprof.Enabled,
})
f.IntFlag(&flagset.IntFlag{
Name: "pprof.port",
Usage: "pprof HTTP server listening port",
Value: &c.cliConfig.Pprof.Port,
Default: c.cliConfig.Pprof.Port,
})
f.StringFlag(&flagset.StringFlag{
Name: "pprof.addr",
Usage: "pprof HTTP server listening interface",
Value: &c.cliConfig.Pprof.Addr,
Default: c.cliConfig.Pprof.Addr,
})
f.IntFlag(&flagset.IntFlag{
Name: "pprof.memprofilerate",
Usage: "Turn on memory profiling with the given rate",
Value: &c.cliConfig.Pprof.MemProfileRate,
Default: c.cliConfig.Pprof.MemProfileRate,
})
f.IntFlag(&flagset.IntFlag{
Name: "pprof.blockprofilerate",
Usage: "Turn on block profiling with the given rate",
Value: &c.cliConfig.Pprof.BlockProfileRate,
Default: c.cliConfig.Pprof.BlockProfileRate,
})
// f.StringFlag(&flagset.StringFlag{
// Name: "pprof.cpuprofile",
// Usage: "Write CPU profile to the given file",
// Value: &c.cliConfig.Pprof.CPUProfile,
// Default: c.cliConfig.Pprof.CPUProfile,
// })
return f
}

View file

@ -4,10 +4,13 @@ import (
"bytes"
"context"
"fmt"
"net/http"
"runtime"
"runtime/pprof"
"runtime/trace"
"time"
"github.com/ethereum/go-ethereum/log"
)
// Profile generates a pprof.Profile report for the given profile name.
@ -113,3 +116,22 @@ func sleep(ctx context.Context, d time.Duration) {
case <-ctx.Done():
}
}
func SetMemProfileRate(rate int) {
runtime.MemProfileRate = rate
}
func SetSetBlockProfileRate(rate int) {
runtime.SetBlockProfileRate(rate)
}
func StartPProf(address string) {
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
go func() {
// nolint: gosec
if err := http.ListenAndServe(address, nil); err != nil {
log.Error("Failure in running pprof server", "err", err)
}
}()
}

View file

@ -1,18 +1,17 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc v3.19.3
// protoc-gen-go v1.28.1
// protoc v3.21.12
// source: internal/cli/server/proto/server.proto
package proto
import (
reflect "reflect"
sync "sync"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
reflect "reflect"
sync "sync"
)
const (
@ -68,7 +67,7 @@ func (x DebugPprofRequest_Type) Number() protoreflect.EnumNumber {
// Deprecated: Use DebugPprofRequest_Type.Descriptor instead.
func (DebugPprofRequest_Type) EnumDescriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{18, 0}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{19, 0}
}
type TraceRequest struct {
@ -857,6 +856,53 @@ func (*ChainSetHeadResponse) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{15}
}
type StatusRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Wait bool `protobuf:"varint,1,opt,name=Wait,proto3" json:"Wait,omitempty"`
}
func (x *StatusRequest) Reset() {
*x = StatusRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *StatusRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*StatusRequest) ProtoMessage() {}
func (x *StatusRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[16]
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 StatusRequest.ProtoReflect.Descriptor instead.
func (*StatusRequest) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{16}
}
func (x *StatusRequest) GetWait() bool {
if x != nil {
return x.Wait
}
return false
}
type StatusResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -873,7 +919,7 @@ type StatusResponse struct {
func (x *StatusResponse) Reset() {
*x = StatusResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[16]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -886,7 +932,7 @@ func (x *StatusResponse) String() string {
func (*StatusResponse) ProtoMessage() {}
func (x *StatusResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[16]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[17]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -899,7 +945,7 @@ func (x *StatusResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead.
func (*StatusResponse) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{16}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17}
}
func (x *StatusResponse) GetCurrentBlock() *Header {
@ -956,7 +1002,7 @@ type Header struct {
func (x *Header) Reset() {
*x = Header{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[17]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -969,7 +1015,7 @@ func (x *Header) String() string {
func (*Header) ProtoMessage() {}
func (x *Header) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[17]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[18]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -982,7 +1028,7 @@ func (x *Header) ProtoReflect() protoreflect.Message {
// Deprecated: Use Header.ProtoReflect.Descriptor instead.
func (*Header) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{18}
}
func (x *Header) GetHash() string {
@ -1012,7 +1058,7 @@ type DebugPprofRequest struct {
func (x *DebugPprofRequest) Reset() {
*x = DebugPprofRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[18]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1025,7 +1071,7 @@ func (x *DebugPprofRequest) String() string {
func (*DebugPprofRequest) ProtoMessage() {}
func (x *DebugPprofRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[18]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[19]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1038,7 +1084,7 @@ func (x *DebugPprofRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DebugPprofRequest.ProtoReflect.Descriptor instead.
func (*DebugPprofRequest) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{18}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{19}
}
func (x *DebugPprofRequest) GetType() DebugPprofRequest_Type {
@ -1073,7 +1119,7 @@ type DebugBlockRequest struct {
func (x *DebugBlockRequest) Reset() {
*x = DebugBlockRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[19]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1086,7 +1132,7 @@ func (x *DebugBlockRequest) String() string {
func (*DebugBlockRequest) ProtoMessage() {}
func (x *DebugBlockRequest) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[19]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[20]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1099,7 +1145,7 @@ func (x *DebugBlockRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DebugBlockRequest.ProtoReflect.Descriptor instead.
func (*DebugBlockRequest) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{19}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{20}
}
func (x *DebugBlockRequest) GetNumber() int64 {
@ -1115,6 +1161,7 @@ type DebugFileResponse struct {
unknownFields protoimpl.UnknownFields
// Types that are assignable to Event:
//
// *DebugFileResponse_Open_
// *DebugFileResponse_Input_
// *DebugFileResponse_Eof
@ -1124,7 +1171,7 @@ type DebugFileResponse struct {
func (x *DebugFileResponse) Reset() {
*x = DebugFileResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[20]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1137,7 +1184,7 @@ func (x *DebugFileResponse) String() string {
func (*DebugFileResponse) ProtoMessage() {}
func (x *DebugFileResponse) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[20]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[21]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1150,7 +1197,7 @@ func (x *DebugFileResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use DebugFileResponse.ProtoReflect.Descriptor instead.
func (*DebugFileResponse) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{20}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21}
}
func (m *DebugFileResponse) GetEvent() isDebugFileResponse_Event {
@ -1216,7 +1263,7 @@ type StatusResponse_Fork struct {
func (x *StatusResponse_Fork) Reset() {
*x = StatusResponse_Fork{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[21]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1229,7 +1276,7 @@ func (x *StatusResponse_Fork) String() string {
func (*StatusResponse_Fork) ProtoMessage() {}
func (x *StatusResponse_Fork) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[21]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[22]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1242,7 +1289,7 @@ func (x *StatusResponse_Fork) ProtoReflect() protoreflect.Message {
// Deprecated: Use StatusResponse_Fork.ProtoReflect.Descriptor instead.
func (*StatusResponse_Fork) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{16, 0}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17, 0}
}
func (x *StatusResponse_Fork) GetName() string {
@ -1279,7 +1326,7 @@ type StatusResponse_Syncing struct {
func (x *StatusResponse_Syncing) Reset() {
*x = StatusResponse_Syncing{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[22]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1292,7 +1339,7 @@ func (x *StatusResponse_Syncing) String() string {
func (*StatusResponse_Syncing) ProtoMessage() {}
func (x *StatusResponse_Syncing) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[22]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[23]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1305,7 +1352,7 @@ func (x *StatusResponse_Syncing) ProtoReflect() protoreflect.Message {
// Deprecated: Use StatusResponse_Syncing.ProtoReflect.Descriptor instead.
func (*StatusResponse_Syncing) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{16, 1}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{17, 1}
}
func (x *StatusResponse_Syncing) GetStartingBlock() int64 {
@ -1340,7 +1387,7 @@ type DebugFileResponse_Open struct {
func (x *DebugFileResponse_Open) Reset() {
*x = DebugFileResponse_Open{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[23]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1353,7 +1400,7 @@ func (x *DebugFileResponse_Open) String() string {
func (*DebugFileResponse_Open) ProtoMessage() {}
func (x *DebugFileResponse_Open) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[23]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[24]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1366,7 +1413,7 @@ func (x *DebugFileResponse_Open) ProtoReflect() protoreflect.Message {
// Deprecated: Use DebugFileResponse_Open.ProtoReflect.Descriptor instead.
func (*DebugFileResponse_Open) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{20, 0}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21, 0}
}
func (x *DebugFileResponse_Open) GetHeaders() map[string]string {
@ -1387,7 +1434,7 @@ type DebugFileResponse_Input struct {
func (x *DebugFileResponse_Input) Reset() {
*x = DebugFileResponse_Input{}
if protoimpl.UnsafeEnabled {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[24]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1400,7 +1447,7 @@ func (x *DebugFileResponse_Input) String() string {
func (*DebugFileResponse_Input) ProtoMessage() {}
func (x *DebugFileResponse_Input) ProtoReflect() protoreflect.Message {
mi := &file_internal_cli_server_proto_server_proto_msgTypes[24]
mi := &file_internal_cli_server_proto_server_proto_msgTypes[25]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1413,7 +1460,7 @@ func (x *DebugFileResponse_Input) ProtoReflect() protoreflect.Message {
// Deprecated: Use DebugFileResponse_Input.ProtoReflect.Descriptor instead.
func (*DebugFileResponse_Input) Descriptor() ([]byte, []int) {
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{20, 1}
return file_internal_cli_server_proto_server_proto_rawDescGZIP(), []int{21, 1}
}
func (x *DebugFileResponse_Input) GetData() []byte {
@ -1484,116 +1531,118 @@ var file_internal_cli_server_proto_server_proto_rawDesc = []byte{
0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04,
0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x16, 0x0a, 0x14, 0x43, 0x68, 0x61, 0x69,
0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0xe2, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c,
0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x33, 0x0a, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0d, 0x63, 0x75,
0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x6e,
0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6e,
0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x79, 0x6e, 0x63, 0x4d,
0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x79, 0x6e, 0x63, 0x4d,
0x6f, 0x64, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x53, 0x79, 0x6e, 0x63,
0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x30, 0x0a, 0x05,
0x66, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x05, 0x66, 0x6f, 0x72, 0x6b, 0x73, 0x1a, 0x4c,
0x0a, 0x04, 0x46, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01,
0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x1a, 0x77, 0x0a, 0x07,
0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74,
0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d,
0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x22, 0x0a,
0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63,
0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x34, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12,
0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68,
0x61, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20,
0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xa2, 0x01, 0x0a, 0x11,
0x44, 0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72,
0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04,
0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52,
0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x26, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65,
0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x4f, 0x4f, 0x4b, 0x55, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03,
0x43, 0x50, 0x55, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x02,
0x22, 0x2b, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18,
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xdd, 0x02,
0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x04, 0x6f, 0x70, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46,
0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4f, 0x70, 0x65, 0x6e,
0x48, 0x00, 0x52, 0x04, 0x6f, 0x70, 0x65, 0x6e, 0x12, 0x36, 0x0a, 0x05, 0x69, 0x6e, 0x70, 0x75,
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x70, 0x75, 0x74,
0x12, 0x2a, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x03, 0x65, 0x6f, 0x66, 0x1a, 0x88, 0x01, 0x0a,
0x04, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x44, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44,
0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x1b, 0x0a, 0x05, 0x49, 0x6e, 0x70, 0x75, 0x74,
0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
0x64, 0x61, 0x74, 0x61, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x32, 0xdd, 0x04,
0x0a, 0x03, 0x42, 0x6f, 0x72, 0x12, 0x3b, 0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64,
0x64, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41,
0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76,
0x65, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52,
0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x50, 0x65, 0x65, 0x72,
0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65,
0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72,
0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47,
0x0a, 0x0c, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x12, 0x1a,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48,
0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75,
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, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x22, 0x23, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x12, 0x0a, 0x04, 0x57, 0x61, 0x69, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x04, 0x57, 0x61, 0x69, 0x74, 0x22, 0xe2, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72,
0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x63,
0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x33, 0x0a, 0x0d, 0x63,
0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x52, 0x0d, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01,
0x28, 0x03, 0x52, 0x08, 0x6e, 0x75, 0x6d, 0x50, 0x65, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08,
0x73, 0x79, 0x6e, 0x63, 0x4d, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x73, 0x79, 0x6e, 0x63, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63,
0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x43, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x12, 0x18,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63,
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a, 0x44, 0x65, 0x62, 0x75, 0x67, 0x50, 0x70,
0x72, 0x6f, 0x66, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75,
0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a, 0x44, 0x65, 0x62,
0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46,
0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x1c, 0x5a,
0x1a, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x73,
0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
0x2e, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e,
0x67, 0x12, 0x30, 0x0a, 0x05, 0x66, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x46, 0x6f, 0x72, 0x6b, 0x52, 0x05, 0x66, 0x6f,
0x72, 0x6b, 0x73, 0x1a, 0x4c, 0x0a, 0x04, 0x46, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65,
0x64, 0x1a, 0x77, 0x0a, 0x07, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x24, 0x0a, 0x0d,
0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x12, 0x22, 0x0a, 0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f,
0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x68, 0x69, 0x67, 0x68, 0x65, 0x73,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x63, 0x75,
0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x34, 0x0a, 0x06, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72,
0x22, 0xa2, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62,
0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x54,
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f,
0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x66,
0x69, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x18, 0x03,
0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x22, 0x26, 0x0a,
0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x4f, 0x4f, 0x4b, 0x55, 0x50, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x43, 0x50, 0x55, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52,
0x41, 0x43, 0x45, 0x10, 0x02, 0x22, 0x2b, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c,
0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75,
0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x22, 0xdd, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x04, 0x6f, 0x70, 0x65, 0x6e,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44,
0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x48, 0x00, 0x52, 0x04, 0x6f, 0x70, 0x65, 0x6e, 0x12, 0x36, 0x0a,
0x05, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x48, 0x00, 0x52, 0x05,
0x69, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x2a, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x03, 0x65, 0x6f,
0x66, 0x1a, 0x88, 0x01, 0x0a, 0x04, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x44, 0x0a, 0x07, 0x68, 0x65,
0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73,
0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x1b, 0x0a, 0x05,
0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, 0x65,
0x6e, 0x74, 0x32, 0xdb, 0x04, 0x0a, 0x03, 0x42, 0x6f, 0x72, 0x12, 0x3b, 0x0a, 0x08, 0x50, 0x65,
0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x41, 0x64, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x50, 0x65, 0x65, 0x72, 0x73,
0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x65, 0x65, 0x72, 0x73, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x52,
0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a,
0x09, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72,
0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a,
0x0b, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x19, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x65, 0x65, 0x72, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x48,
0x65, 0x61, 0x64, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69,
0x6e, 0x53, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74,
0x48, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63,
0x68, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57,
0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a, 0x44, 0x65, 0x62, 0x75,
0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44,
0x65, 0x62, 0x75, 0x67, 0x50, 0x70, 0x72, 0x6f, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x46, 0x69,
0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0a,
0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x62,
0x75, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01,
0x42, 0x1c, 0x5a, 0x1a, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6c,
0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1609,7 +1658,7 @@ func file_internal_cli_server_proto_server_proto_rawDescGZIP() []byte {
}
var file_internal_cli_server_proto_server_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_internal_cli_server_proto_server_proto_msgTypes = make([]protoimpl.MessageInfo, 26)
var file_internal_cli_server_proto_server_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
var file_internal_cli_server_proto_server_proto_goTypes = []interface{}{
(DebugPprofRequest_Type)(0), // 0: proto.DebugPprofRequest.Type
(*TraceRequest)(nil), // 1: proto.TraceRequest
@ -1628,50 +1677,51 @@ var file_internal_cli_server_proto_server_proto_goTypes = []interface{}{
(*Peer)(nil), // 14: proto.Peer
(*ChainSetHeadRequest)(nil), // 15: proto.ChainSetHeadRequest
(*ChainSetHeadResponse)(nil), // 16: proto.ChainSetHeadResponse
(*StatusResponse)(nil), // 17: proto.StatusResponse
(*Header)(nil), // 18: proto.Header
(*DebugPprofRequest)(nil), // 19: proto.DebugPprofRequest
(*DebugBlockRequest)(nil), // 20: proto.DebugBlockRequest
(*DebugFileResponse)(nil), // 21: proto.DebugFileResponse
(*StatusResponse_Fork)(nil), // 22: proto.StatusResponse.Fork
(*StatusResponse_Syncing)(nil), // 23: proto.StatusResponse.Syncing
(*DebugFileResponse_Open)(nil), // 24: proto.DebugFileResponse.Open
(*DebugFileResponse_Input)(nil), // 25: proto.DebugFileResponse.Input
nil, // 26: proto.DebugFileResponse.Open.HeadersEntry
(*emptypb.Empty)(nil), // 27: google.protobuf.Empty
(*StatusRequest)(nil), // 17: proto.StatusRequest
(*StatusResponse)(nil), // 18: proto.StatusResponse
(*Header)(nil), // 19: proto.Header
(*DebugPprofRequest)(nil), // 20: proto.DebugPprofRequest
(*DebugBlockRequest)(nil), // 21: proto.DebugBlockRequest
(*DebugFileResponse)(nil), // 22: proto.DebugFileResponse
(*StatusResponse_Fork)(nil), // 23: proto.StatusResponse.Fork
(*StatusResponse_Syncing)(nil), // 24: proto.StatusResponse.Syncing
(*DebugFileResponse_Open)(nil), // 25: proto.DebugFileResponse.Open
(*DebugFileResponse_Input)(nil), // 26: proto.DebugFileResponse.Input
nil, // 27: proto.DebugFileResponse.Open.HeadersEntry
(*emptypb.Empty)(nil), // 28: google.protobuf.Empty
}
var file_internal_cli_server_proto_server_proto_depIdxs = []int32{
5, // 0: proto.ChainWatchResponse.oldchain:type_name -> proto.BlockStub
5, // 1: proto.ChainWatchResponse.newchain:type_name -> proto.BlockStub
14, // 2: proto.PeersListResponse.peers:type_name -> proto.Peer
14, // 3: proto.PeersStatusResponse.peer:type_name -> proto.Peer
18, // 4: proto.StatusResponse.currentBlock:type_name -> proto.Header
18, // 5: proto.StatusResponse.currentHeader:type_name -> proto.Header
23, // 6: proto.StatusResponse.syncing:type_name -> proto.StatusResponse.Syncing
22, // 7: proto.StatusResponse.forks:type_name -> proto.StatusResponse.Fork
19, // 4: proto.StatusResponse.currentBlock:type_name -> proto.Header
19, // 5: proto.StatusResponse.currentHeader:type_name -> proto.Header
24, // 6: proto.StatusResponse.syncing:type_name -> proto.StatusResponse.Syncing
23, // 7: proto.StatusResponse.forks:type_name -> proto.StatusResponse.Fork
0, // 8: proto.DebugPprofRequest.type:type_name -> proto.DebugPprofRequest.Type
24, // 9: proto.DebugFileResponse.open:type_name -> proto.DebugFileResponse.Open
25, // 10: proto.DebugFileResponse.input:type_name -> proto.DebugFileResponse.Input
27, // 11: proto.DebugFileResponse.eof:type_name -> google.protobuf.Empty
26, // 12: proto.DebugFileResponse.Open.headers:type_name -> proto.DebugFileResponse.Open.HeadersEntry
25, // 9: proto.DebugFileResponse.open:type_name -> proto.DebugFileResponse.Open
26, // 10: proto.DebugFileResponse.input:type_name -> proto.DebugFileResponse.Input
28, // 11: proto.DebugFileResponse.eof:type_name -> google.protobuf.Empty
27, // 12: proto.DebugFileResponse.Open.headers:type_name -> proto.DebugFileResponse.Open.HeadersEntry
6, // 13: proto.Bor.PeersAdd:input_type -> proto.PeersAddRequest
8, // 14: proto.Bor.PeersRemove:input_type -> proto.PeersRemoveRequest
10, // 15: proto.Bor.PeersList:input_type -> proto.PeersListRequest
12, // 16: proto.Bor.PeersStatus:input_type -> proto.PeersStatusRequest
15, // 17: proto.Bor.ChainSetHead:input_type -> proto.ChainSetHeadRequest
27, // 18: proto.Bor.Status:input_type -> google.protobuf.Empty
17, // 18: proto.Bor.Status:input_type -> proto.StatusRequest
3, // 19: proto.Bor.ChainWatch:input_type -> proto.ChainWatchRequest
19, // 20: proto.Bor.DebugPprof:input_type -> proto.DebugPprofRequest
20, // 21: proto.Bor.DebugBlock:input_type -> proto.DebugBlockRequest
20, // 20: proto.Bor.DebugPprof:input_type -> proto.DebugPprofRequest
21, // 21: proto.Bor.DebugBlock:input_type -> proto.DebugBlockRequest
7, // 22: proto.Bor.PeersAdd:output_type -> proto.PeersAddResponse
9, // 23: proto.Bor.PeersRemove:output_type -> proto.PeersRemoveResponse
11, // 24: proto.Bor.PeersList:output_type -> proto.PeersListResponse
13, // 25: proto.Bor.PeersStatus:output_type -> proto.PeersStatusResponse
16, // 26: proto.Bor.ChainSetHead:output_type -> proto.ChainSetHeadResponse
17, // 27: proto.Bor.Status:output_type -> proto.StatusResponse
18, // 27: proto.Bor.Status:output_type -> proto.StatusResponse
4, // 28: proto.Bor.ChainWatch:output_type -> proto.ChainWatchResponse
21, // 29: proto.Bor.DebugPprof:output_type -> proto.DebugFileResponse
21, // 30: proto.Bor.DebugBlock:output_type -> proto.DebugFileResponse
22, // 29: proto.Bor.DebugPprof:output_type -> proto.DebugFileResponse
22, // 30: proto.Bor.DebugBlock:output_type -> proto.DebugFileResponse
22, // [22:31] is the sub-list for method output_type
13, // [13:22] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name
@ -1878,7 +1928,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StatusResponse); i {
switch v := v.(*StatusRequest); i {
case 0:
return &v.state
case 1:
@ -1890,7 +1940,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Header); i {
switch v := v.(*StatusResponse); i {
case 0:
return &v.state
case 1:
@ -1902,7 +1952,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugPprofRequest); i {
switch v := v.(*Header); i {
case 0:
return &v.state
case 1:
@ -1914,7 +1964,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugBlockRequest); i {
switch v := v.(*DebugPprofRequest); i {
case 0:
return &v.state
case 1:
@ -1926,7 +1976,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugFileResponse); i {
switch v := v.(*DebugBlockRequest); i {
case 0:
return &v.state
case 1:
@ -1938,7 +1988,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StatusResponse_Fork); i {
switch v := v.(*DebugFileResponse); i {
case 0:
return &v.state
case 1:
@ -1950,7 +2000,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*StatusResponse_Syncing); i {
switch v := v.(*StatusResponse_Fork); i {
case 0:
return &v.state
case 1:
@ -1962,7 +2012,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugFileResponse_Open); i {
switch v := v.(*StatusResponse_Syncing); i {
case 0:
return &v.state
case 1:
@ -1974,6 +2024,18 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
file_internal_cli_server_proto_server_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugFileResponse_Open); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_internal_cli_server_proto_server_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DebugFileResponse_Input); i {
case 0:
return &v.state
@ -1986,7 +2048,7 @@ func file_internal_cli_server_proto_server_proto_init() {
}
}
}
file_internal_cli_server_proto_server_proto_msgTypes[20].OneofWrappers = []interface{}{
file_internal_cli_server_proto_server_proto_msgTypes[21].OneofWrappers = []interface{}{
(*DebugFileResponse_Open_)(nil),
(*DebugFileResponse_Input_)(nil),
(*DebugFileResponse_Eof)(nil),
@ -1997,7 +2059,7 @@ func file_internal_cli_server_proto_server_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_internal_cli_server_proto_server_proto_rawDesc,
NumEnums: 1,
NumMessages: 26,
NumMessages: 27,
NumExtensions: 0,
NumServices: 1,
},

View file

@ -17,7 +17,7 @@ service Bor {
rpc ChainSetHead(ChainSetHeadRequest) returns (ChainSetHeadResponse);
rpc Status(google.protobuf.Empty) returns (StatusResponse);
rpc Status(StatusRequest) returns (StatusResponse);
rpc ChainWatch(ChainWatchRequest) returns (stream ChainWatchResponse);
@ -97,6 +97,10 @@ message ChainSetHeadRequest {
message ChainSetHeadResponse {
}
message StatusRequest {
bool Wait = 1;
}
message StatusResponse {
Header currentBlock = 1;
Header currentHeader = 2;

View file

@ -1,18 +1,16 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.3
// - protoc v3.21.12
// source: internal/cli/server/proto/server.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
// This is a compile-time assertion to ensure that this generated file
@ -29,7 +27,7 @@ type BorClient interface {
PeersList(ctx context.Context, in *PeersListRequest, opts ...grpc.CallOption) (*PeersListResponse, error)
PeersStatus(ctx context.Context, in *PeersStatusRequest, opts ...grpc.CallOption) (*PeersStatusResponse, error)
ChainSetHead(ctx context.Context, in *ChainSetHeadRequest, opts ...grpc.CallOption) (*ChainSetHeadResponse, error)
Status(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*StatusResponse, error)
Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
ChainWatch(ctx context.Context, in *ChainWatchRequest, opts ...grpc.CallOption) (Bor_ChainWatchClient, error)
DebugPprof(ctx context.Context, in *DebugPprofRequest, opts ...grpc.CallOption) (Bor_DebugPprofClient, error)
DebugBlock(ctx context.Context, in *DebugBlockRequest, opts ...grpc.CallOption) (Bor_DebugBlockClient, error)
@ -88,7 +86,7 @@ func (c *borClient) ChainSetHead(ctx context.Context, in *ChainSetHeadRequest, o
return out, nil
}
func (c *borClient) Status(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*StatusResponse, error) {
func (c *borClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) {
out := new(StatusResponse)
err := c.cc.Invoke(ctx, "/proto.Bor/Status", in, out, opts...)
if err != nil {
@ -202,7 +200,7 @@ type BorServer interface {
PeersList(context.Context, *PeersListRequest) (*PeersListResponse, error)
PeersStatus(context.Context, *PeersStatusRequest) (*PeersStatusResponse, error)
ChainSetHead(context.Context, *ChainSetHeadRequest) (*ChainSetHeadResponse, error)
Status(context.Context, *emptypb.Empty) (*StatusResponse, error)
Status(context.Context, *StatusRequest) (*StatusResponse, error)
ChainWatch(*ChainWatchRequest, Bor_ChainWatchServer) error
DebugPprof(*DebugPprofRequest, Bor_DebugPprofServer) error
DebugBlock(*DebugBlockRequest, Bor_DebugBlockServer) error
@ -228,7 +226,7 @@ func (UnimplementedBorServer) PeersStatus(context.Context, *PeersStatusRequest)
func (UnimplementedBorServer) ChainSetHead(context.Context, *ChainSetHeadRequest) (*ChainSetHeadResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ChainSetHead not implemented")
}
func (UnimplementedBorServer) Status(context.Context, *emptypb.Empty) (*StatusResponse, error) {
func (UnimplementedBorServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Status not implemented")
}
func (UnimplementedBorServer) ChainWatch(*ChainWatchRequest, Bor_ChainWatchServer) error {
@ -344,7 +342,7 @@ func _Bor_ChainSetHead_Handler(srv interface{}, ctx context.Context, dec func(in
}
func _Bor_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
in := new(StatusRequest)
if err := dec(in); err != nil {
return nil, err
}
@ -356,7 +354,7 @@ func _Bor_Status_Handler(srv interface{}, ctx context.Context, dec func(interfac
FullMethod: "/proto.Bor/Status",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BorServer).Status(ctx, req.(*emptypb.Empty))
return srv.(BorServer).Status(ctx, req.(*StatusRequest))
}
return interceptor(ctx, in, info, handler)
}

View file

@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"runtime"
"strings"
"time"
@ -30,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/graphql"
"github.com/ethereum/go-ethereum/internal/cli/server/pprof"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
@ -56,6 +58,14 @@ type Server struct {
type serverOption func(srv *Server, config *Config) error
var glogger *log.GlogHandler
func init() {
glogger = log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.LvlInfo)
log.Root().SetHandler(glogger)
}
func WithGRPCAddress() serverOption {
return func(srv *Server, config *Config) error {
return srv.gRPCServerByAddress(config.GRPC.Addr)
@ -68,14 +78,49 @@ func WithGRPCListener(lis net.Listener) serverOption {
}
}
func VerbosityIntToString(verbosity int) string {
mapIntToString := map[int]string{
5: "trace",
4: "debug",
3: "info",
2: "warn",
1: "error",
0: "crit",
}
return mapIntToString[verbosity]
}
func VerbosityStringToInt(loglevel string) int {
mapStringToInt := map[string]int{
"trace": 5,
"debug": 4,
"info": 3,
"warn": 2,
"error": 1,
"crit": 0,
}
return mapStringToInt[loglevel]
}
//nolint:gocognit
func NewServer(config *Config, opts ...serverOption) (*Server, error) {
// start pprof
if config.Pprof.Enabled {
pprof.SetMemProfileRate(config.Pprof.MemProfileRate)
pprof.SetSetBlockProfileRate(config.Pprof.BlockProfileRate)
pprof.StartPProf(fmt.Sprintf("%s:%d", config.Pprof.Addr, config.Pprof.Port))
}
runtime.SetMutexProfileFraction(5)
srv := &Server{
config: config,
}
// start the logger
setupLogger(config.LogLevel)
setupLogger(VerbosityIntToString(config.Verbosity), *config.Logging)
var err error
@ -259,7 +304,13 @@ func (s *Server) Stop() {
func (s *Server) setupMetrics(config *TelemetryConfig, serviceName string) error {
// Check the global metrics if they're matching with the provided config
if metrics.Enabled != config.Enabled || metrics.EnabledExpensive != config.Expensive {
log.Warn("Metric misconfiguration, some of them might not be visible")
log.Warn(
"Metric misconfiguration, some of them might not be visible",
"metrics", metrics.Enabled,
"config.metrics", config.Enabled,
"expensive", metrics.EnabledExpensive,
"config.expensive", config.Expensive,
)
}
// Update the values anyways (for services which don't need immediate attention)
@ -406,16 +457,22 @@ func (s *Server) loggingServerInterceptor(ctx context.Context, req interface{},
return h, err
}
func setupLogger(logLevel string) {
func setupLogger(logLevel string, loggingInfo LoggingConfig) {
var ostream log.Handler
output := io.Writer(os.Stderr)
usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
if usecolor {
output = colorable.NewColorableStderr()
if loggingInfo.Json {
ostream = log.StreamHandler(output, log.JSONFormat())
} else {
usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
if usecolor {
output = colorable.NewColorableStderr()
}
ostream = log.StreamHandler(output, log.TerminalFormat(usecolor))
}
ostream := log.StreamHandler(output, log.TerminalFormat(usecolor))
glogger := log.NewGlogHandler(ostream)
glogger.SetHandler(ostream)
// logging
lvl, err := log.LvlFromString(strings.ToLower(logLevel))
@ -425,6 +482,20 @@ func setupLogger(logLevel string) {
glogger.Verbosity(log.LvlInfo)
}
if loggingInfo.Vmodule != "" {
if err := glogger.Vmodule(loggingInfo.Vmodule); err != nil {
log.Error("failed to set Vmodule", "err", err)
}
}
log.PrintOrigins(loggingInfo.Debug)
if loggingInfo.Backtrace != "" {
if err := glogger.BacktraceAt(loggingInfo.Backtrace); err != nil {
log.Error("failed to set BacktraceAt", "err", err)
}
}
log.Root().SetHandler(glogger)
}

View file

@ -3,13 +3,14 @@ package server
import (
"context"
"encoding/json"
"errors"
"fmt"
"math/big"
"reflect"
"strings"
"time"
grpc_net_conn "github.com/JekaMas/go-grpc-net-conn"
empty "google.golang.org/protobuf/types/known/emptypb"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
@ -23,6 +24,9 @@ import (
const chunkSize = 1024 * 1024 * 1024
var ErrUnavailable = errors.New("bor service is currently unavailable, try again later")
var ErrUnavailable2 = errors.New("bor service unavailable even after waiting for 10 seconds, make sure bor is running")
func sendStreamDebugFile(stream proto.Bor_DebugPprofServer, headers map[string]string, data []byte) error {
// open the stream and send the headers
err := stream.Send(&proto.DebugFileResponse{
@ -164,7 +168,30 @@ func (s *Server) ChainSetHead(ctx context.Context, req *proto.ChainSetHeadReques
return &proto.ChainSetHeadResponse{}, nil
}
func (s *Server) Status(ctx context.Context, _ *empty.Empty) (*proto.StatusResponse, error) {
func (s *Server) Status(ctx context.Context, in *proto.StatusRequest) (*proto.StatusResponse, error) {
if s.backend == nil && !in.Wait {
return nil, ErrUnavailable
}
// check for s.backend at an interval of 2 seconds
// wait for a maximum of 10 seconds (5 iterations)
if s.backend == nil && in.Wait {
i := 1
for {
time.Sleep(2 * time.Second)
if s.backend == nil {
if i == 5 {
return nil, ErrUnavailable2
}
} else {
break
}
i++
}
}
apiBackend := s.backend.APIBackend
syncProgress := apiBackend.SyncProgress()

View file

@ -1,13 +0,0 @@
datadir = "./data"
p2p {
maxpeers = 30
}
txpool {
lifetime = "1s"
}
gpo {
maxprice = "100"
}

Some files were not shown because too many files have changed in this diff Show more