Merge branch 'develop' into manav/upstream_merge_v1.14.11

This commit is contained in:
Manav Darji 2025-03-20 18:31:15 +05:30
commit 754cce0629
No known key found for this signature in database
GPG key ID: A426F0124435F36E
54 changed files with 518 additions and 403 deletions

View file

@ -20,7 +20,7 @@ Heimdall client version: [e.g. v0.2.10] <!--Can be found by running the command
OS & Version: Windows / Linux / OSX OS & Version: Windows / Linux / OSX
Environment: Polygon Mainnet / Polygon Mumbai / Polygon Amoy / Devnet Environment: Polygon Mainnet / Polygon Amoy / Devnet
Type of node: Validator / Sentry / Archive Type of node: Validator / Sentry / Archive

View file

@ -1,26 +1,38 @@
defaultStake: 10000 devnetType: docker
defaultFee: 2000 defaultFee: 2000
defaultStake: 10000
borChainId: 15001 borChainId: 15001
heimdallChainId: heimdall-15001 heimdallChainId: heimdall-15001
contractsBranch: mardizzone/node-16
borDockerBuildContext: '../../bor'
heimdallDockerBuildContext: 'https://github.com/maticnetwork/heimdall.git#develop'
genesisContractsBranch: master genesisContractsBranch: master
sprintSize: contractsRepo: https://github.com/0xPolygon/pos-contracts.git
- '64' contractsBranch: anvil-pos
blockNumber:
- '0'
blockTime: blockTime:
- '2' - '2'
blockNumber:
- '0'
sprintSize:
- '64'
sprintSizeBlockNumber:
- '0'
numOfBorValidators: 3 numOfBorValidators: 3
numOfBorSentries: 0 numOfBorSentries: 0
numOfBorArchiveNodes: 0 numOfBorArchiveNodes: 0
devnetBorFlags: config,config,config
numOfErigonValidators: 0 numOfErigonValidators: 0
numOfErigonSentries: 0 numOfErigonSentries: 0
numOfErigonArchiveNodes: 0 numOfErigonArchiveNodes: 0
ethURL: http://ganache:9545
ethURL: http://anvil:9545
ethHostUser: ubuntu ethHostUser: ubuntu
devnetType: docker mnemonic: 'clock radar mass judge dismiss just intact mind resemble fringe diary casino'
borDockerBuildContext: "../../bor"
heimdallDockerBuildContext: "https://github.com/maticnetwork/heimdall.git#develop"
sprintSizeBlockNumber:
- '0'
devnetBorFlags: config,config,config

View file

@ -1,7 +1,7 @@
# Number of days of inactivity before an Issue is closed for lack of response # Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 30 daysUntilClose: 30
# Label requiring a response # Label requiring a response
responseRequiredLabel: "need:more-information" responseRequiredLabel: 'need:more-information'
# Comment to post when closing an Issue for lack of response. Set to `false` to disable # Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: > closeComment: >
This issue has been automatically closed because there has been no response This issue has been automatically closed because there has been no response

View file

@ -39,7 +39,7 @@ In case this PR includes changes that must be applied only to a subset of nodes,
- [ ] I have added tests to CI - [ ] I have added tests to CI
- [ ] I have tested this code manually on local environment - [ ] I have tested this code manually on local environment
- [ ] I have tested this code manually on remote devnet using express-cli - [ ] I have tested this code manually on remote devnet using express-cli
- [ ] I have tested this code manually on mumbai/amoy - [ ] I have tested this code manually on amoy
- [ ] I have created new e2e tests into express-cli - [ ] I have created new e2e tests into express-cli
### Manual tests ### Manual tests

2
.github/stale.yml vendored
View file

@ -7,7 +7,7 @@ exemptLabels:
- pinned - pinned
- security - security
# Label to use when marking an issue as stale # Label to use when marking an issue as stale
staleLabel: "status:inactive" staleLabel: 'status:inactive'
# Comment to post when marking an issue as stale. Set to `false` to disable # Comment to post when marking an issue as stale. Set to `false` to disable
markComment: > markComment: >
This issue has been automatically marked as stale because it has not had This issue has been automatically marked as stale because it has not had

View file

@ -29,7 +29,6 @@ jobs:
NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' ) NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' )
echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV
- name: Making directory structure for yaml - name: Making directory structure for yaml
run: mkdir -p packaging/deb/bor/var/lib/bor run: mkdir -p packaging/deb/bor/var/lib/bor
- name: making directory structure for the systemd - name: making directory structure for the systemd
@ -391,14 +390,3 @@ jobs:
packaging/deb/bor-pbss-amoy-**.deb packaging/deb/bor-pbss-amoy-**.deb
packaging/deb/bor-amoy-**.deb.checksum packaging/deb/bor-amoy-**.deb.checksum
packaging/deb/bor-pbss-amoy-**.deb.checksum packaging/deb/bor-pbss-amoy-**.deb.checksum

View file

@ -2,12 +2,12 @@ name: CI
on: on:
push: push:
branches: branches:
- "master" - 'master'
- "qa" - 'qa'
- "develop" - 'develop'
pull_request: pull_request:
branches: branches:
- "**" - '**'
types: [opened, synchronize] types: [opened, synchronize]
concurrency: concurrency:
@ -16,267 +16,287 @@ concurrency:
jobs: jobs:
build: build:
name: Build
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: | - run: |
git submodule update --init --recursive --force git submodule update --init --recursive --force
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: 1.23.x go-version: 1.23.x
- name: Install dependencies on Linux - name: Install dependencies on Linux
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential run: sudo apt update && sudo apt install build-essential
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: | path: |
~/.cache/go-build ~/.cache/go-build
~/Library/Caches/go-build ~/Library/Caches/go-build
~/go/pkg/mod ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go- restore-keys: ${{ runner.os }}-go-
- name: Build - name: Build
run: make all run: make all
lint: lint:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: | - run: |
git submodule update --init --recursive --force git submodule update --init --recursive --force
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: 1.23.x go-version: 1.23.x
- name: Install dependencies on Linux - name: Install dependencies on Linux
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential run: sudo apt update && sudo apt install build-essential
- name: Golang-ci install - name: Golang-ci install
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: make lintci-deps run: make lintci-deps
- name: Lint - name: Lint
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: make lint run: make lint
unit-tests: unit-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: | - run: |
git submodule update --init --recursive --force git submodule update --init --recursive --force
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: 1.23.x go-version: 1.23.x
- name: Install dependencies on Linux - name: Install dependencies on Linux
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential run: sudo apt update && sudo apt install build-essential
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
path: | path: |
~/.cache/go-build ~/.cache/go-build
~/Library/Caches/go-build ~/Library/Caches/go-build
~/go/pkg/mod ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go- restore-keys: ${{ runner.os }}-go-
- name: Test - name: Test
run: make test run: make test
- uses: actions/upload-artifact@v4.4.0 - uses: actions/upload-artifact@v4.4.0
with: with:
name: unitTest-coverage name: unitTest-coverage
path: cover.out path: cover.out
#- name: Data race tests # - name: Data race tests
# run: make test-race # run: make test-race
# # TODO: make it work # # TODO: make it work
# - name: Reproducible build test # - name: Reproducible build test
# run: | # run: |
# make geth # make geth
# shasum -a256 ./build/bin/geth > bor1.sha256 # shasum -a256 ./build/bin/geth > bor1.sha256
# make geth # make geth
# shasum -a256 ./build/bin/geth > bor2.sha256 # shasum -a256 ./build/bin/geth > bor2.sha256
# if ! cmp -s bor1.sha256 bor2.sha256; then # if ! cmp -s bor1.sha256 bor2.sha256; then
# echo >&2 "Reproducible build broken"; cat bor1.sha256; cat bor2.sha256; exit 1 # echo >&2 "Reproducible build broken"; cat bor1.sha256; cat bor2.sha256; exit 1
# fi # fi
integration-tests: integration-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: | - run: |
git submodule update --init --recursive --force git submodule update --init --recursive --force
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: 1.23.x go-version: 1.23.x
- name: Install dependencies on Linux - name: Install dependencies on Linux
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential run: sudo apt update && sudo apt install build-essential
- uses: actions/cache@v4 - uses: actions/cache@v4
with: with:
path: | path: |
~/.cache/go-build ~/.cache/go-build
~/Library/Caches/go-build ~/Library/Caches/go-build
~/go/pkg/mod ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go- restore-keys: ${{ runner.os }}-go-
- name: test-integration - name: test-integration
run: make test-integration run: make test-integration
- uses: actions/upload-artifact@v4.4.0 - uses: actions/upload-artifact@v4.4.0
with: with:
name: integrationTest-coverage name: integrationTest-coverage
path: cover.out path: cover.out
codecov: codecov:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: [unit-tests, integration-tests] needs: [unit-tests, integration-tests]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v4.1.8 uses: actions/download-artifact@v4.1.8
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
e2e-tests: e2e-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true) if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy: strategy:
matrix: matrix:
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments os: [ubuntu-22.04] # List of OS: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
path: bor path: bor
- name: Checkout submodules - name: Checkout submodules
run: | run: |
cd bor cd bor
git submodule update --init --recursive --force git submodule update --init --recursive --force
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: 1.23.x go-version: 1.23.x
- name: Checkout matic-cli - name: Checkout matic-cli
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
repository: maticnetwork/matic-cli repository: maticnetwork/matic-cli
ref: master ref: master
path: matic-cli path: matic-cli
- name: Install dependencies on Linux - name: Install dependencies on Linux
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: | run: |
sudo apt update sudo apt update
sudo apt install build-essential sudo apt install build-essential
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
sudo snap install solc sudo apt install jq curl
sudo apt install python2 jq curl
sudo ln -sf /usr/bin/python2 /usr/bin/python
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: '18.19.0' node-version: '18.19.0'
cache: 'npm' cache: 'npm'
cache-dependency-path: | cache-dependency-path: |
matic-cli/package-lock.json matic-cli/package-lock.json
matic-cli/devnet/code/contracts/package-lock.json matic-cli/devnet/code/contracts/package-lock.json
matic-cli/devnet/code/genesis-contracts/package-lock.json matic-cli/devnet/code/genesis-contracts/package-lock.json
matic-cli/devnet/code/genesis-contracts/matic-contracts/package-lock.json matic-cli/devnet/code/genesis-contracts/matic-contracts/package-lock.json
- name: Bootstrap devnet - name: Install solc-select
run: | run: |
cd matic-cli sudo apt update
npm install --prefer-offline --no-audit --progress=false sudo apt install python3 python3-pip -y
mkdir devnet sudo ln -sf /usr/bin/python3 /usr/bin/python
cd devnet pip install solc-select
../bin/matic-cli.js setup devnet -c ../../bor/.github/matic-cli-config.yml
- name: Launch devnet - name: Install Solidity Version
run: | run: |
cd matic-cli/devnet solc-select install 0.5.17
bash ../util-scripts/docker/devnet_setup.sh solc-select install 0.6.12
cd - solc-select use 0.5.17
timeout 2m bash bor/integration-tests/bor_health.sh solc --version
- name: Run smoke tests - name: Install Foundry
run: | uses: foundry-rs/foundry-toolchain@v1
echo "Funding ganache accounts..."
timeout 10m bash bor/integration-tests/fund_ganache_accounts.sh - name: Bootstrap devnet
echo "Deposit 100 matic for each account to bor network" run: |
cd matic-cli/devnet/code/contracts cd matic-cli
npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000 npm install --prefer-offline --no-audit --progress=false
mkdir devnet
cd devnet
../bin/matic-cli.js setup devnet -c ../../bor/.github/matic-cli-config.yml
- name: Launch devnet
run: |
cd matic-cli/devnet
bash ../util-scripts/docker/devnet_setup.sh
cd - cd -
timeout 60m bash bor/integration-tests/smoke_test.sh timeout 2m bash bor/integration-tests/bor_health.sh
- name: Run RPC Tests - name: Run smoke tests
run: | run: |
echo "Starting RPC Tests..." echo "Deposit 100 matic for each account to bor network"
timeout 5m bash bor/integration-tests/rpc_test.sh cd matic-cli/devnet/devnet
SCRIPT_ADDRESS=$(jq -r '.[0].address' signer-dump.json)
SCRIPT_PRIVATE_KEY=$(jq -r '.[0].priv_key' signer-dump.json)
cd ../code/pos-contracts
CONTRACT_ADDRESS=$(jq -r .root.tokens.MaticToken contractAddresses.json)
forge script scripts/matic-cli-scripts/Deposit.s.sol:MaticDeposit --rpc-url http://localhost:9545 --private-key $SCRIPT_PRIVATE_KEY --broadcast --sig "run(address,address,uint256)" $SCRIPT_ADDRESS $CONTRACT_ADDRESS 100000000000000000000
cd ../../../..
timeout 60m bash bor/integration-tests/smoke_test.sh
- name: Upload logs - name: Run RPC Tests
if: always() run: |
uses: actions/upload-artifact@v4.4.0 echo "Starting RPC Tests..."
with: timeout 5m bash bor/integration-tests/rpc_test.sh
name: logs_${{ github.run_id }}
path: |
matic-cli/devnet/logs
- name: Package code and chain data - name: Upload logs
if: always() if: always()
run: | uses: actions/upload-artifact@v4.4.0
cd matic-cli/devnet with:
docker compose down --remove-orphans name: logs_${{ github.run_id }}
cd - path: |
mkdir -p ${{ github.run_id }}/matic-cli matic-cli/devnet/logs
sudo mv bor ${{ github.run_id }}
sudo mv matic-cli/devnet ${{ github.run_id }}/matic-cli
sudo tar czf code.tar.gz ${{ github.run_id }}
- name: Upload code and chain data - name: Package code and chain data
if: always() if: always()
uses: actions/upload-artifact@v4.4.0 run: |
with: cd matic-cli/devnet
name: code_${{ github.run_id }} docker compose down --remove-orphans
path: code.tar.gz cd -
mkdir -p ${{ github.run_id }}/matic-cli
sudo mv bor ${{ github.run_id }}
sudo mv matic-cli/devnet ${{ github.run_id }}/matic-cli
sudo tar czf code.tar.gz ${{ github.run_id }}
- name: Upload code and chain data
if: always()
uses: actions/upload-artifact@v4.4.0
with:
name: code_${{ github.run_id }}
path: code.tar.gz

View file

@ -1,10 +1,10 @@
name: "CodeQL" name: 'CodeQL'
on: on:
push: push:
branches: [ "master", "develop" ] branches: ['master', 'develop']
pull_request: pull_request:
branches: [ "master", "develop" ] branches: ['master', 'develop']
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
@ -21,7 +21,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: [ 'go' ] language: ['go']
steps: steps:
- name: Checkout repository - name: Checkout repository
@ -43,4 +43,4 @@ jobs:
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v2
with: with:
category: "/language:${{matrix.language}}" category: '/language:${{matrix.language}}'

View file

@ -1,5 +1,5 @@
name: Govuln name: Govuln
on: [ push, pull_request ] on: [push, pull_request]
jobs: jobs:
govulncheck: govulncheck:
@ -8,7 +8,7 @@ jobs:
steps: steps:
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: with:
go-version: "1.23.6" go-version: '1.23.6'
check-latest: true check-latest: true
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6 - uses: technote-space/get-diff-action@v6
@ -20,4 +20,4 @@ jobs:
Makefile Makefile
- name: govulncheck - name: govulncheck
run: make vulncheck run: make vulncheck
if: "env.GIT_DIFF != ''" if: env.GIT_DIFF != ''

View file

@ -29,7 +29,6 @@ jobs:
NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' ) NUMERIC_VERSION=$( echo ${{ env.GIT_TAG }} | sed 's/[^0-9.]//g' )
echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV echo "VERSION=$NUMERIC_VERSION" >> $GITHUB_ENV
- name: Making directory structure for yaml - name: Making directory structure for yaml
run: mkdir -p packaging/deb/bor/var/lib/bor run: mkdir -p packaging/deb/bor/var/lib/bor
- name: making directory structure for the systemd - name: making directory structure for the systemd
@ -387,8 +386,6 @@ jobs:
NODE: archive NODE: archive
NETWORK: mainnet NETWORK: mainnet
############ Check and Upload ########################## ############ Check and Upload ##########################
- name: Confirming package built - name: Confirming package built
run: ls -ltr packaging/deb/ | grep bor run: ls -ltr packaging/deb/ | grep bor

View file

@ -25,7 +25,7 @@ jobs:
uses: actions/setup-go@master uses: actions/setup-go@master
with: with:
go-version: 1.23.6 go-version: 1.23.6
# Variables # Variables
- name: Adding TAG to ENV - name: Adding TAG to ENV
run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV run: echo "GIT_TAG=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
- name: adding version - name: adding version
@ -97,7 +97,6 @@ jobs:
echo "Maintainer: devops@polygon.technology" >> packaging/deb/bor/DEBIAN/control echo "Maintainer: devops@polygon.technology" >> packaging/deb/bor/DEBIAN/control
echo "Description: bor binary package" >> packaging/deb/bor/DEBIAN/control echo "Description: bor binary package" >> packaging/deb/bor/DEBIAN/control
- name: Creating package for binary for bor ${{ env.ARCH }} - name: Creating package for binary for bor ${{ env.ARCH }}
run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }} run: cp -rp packaging/deb/bor packaging/deb/bor-${{ env.GIT_TAG }}-${{ env.ARCH }}
env: env:

View file

@ -26,8 +26,8 @@ jobs:
- name: Prepare - name: Prepare
id: prepare id: prepare
run: | run: |
TAG=${GITHUB_REF#refs/tags/} TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG} echo ::set-output name=tag_name::${TAG}
- name: Login to Docker Hub - name: Login to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@v2
@ -40,7 +40,7 @@ jobs:
- name: Run GoReleaser - name: Run GoReleaser
run: | run: |
make release make release
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }} VERSION: ${{ steps.prepare.outputs.tag_name }}

View file

@ -7,26 +7,25 @@ name: Mark stale issues and pull requests
on: on:
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 0 * * *'
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
issues: write issues: write
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v9 - uses: actions/stale@v9
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.' stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
stale-pr-message: 'This PR is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 14 days.' stale-pr-message: 'This PR is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
close-issue-message: 'This issue was closed because it has been stalled for 28 days with no activity.' close-issue-message: 'This issue was closed because it has been stalled for 28 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 35 days with no activity.' close-pr-message: 'This PR was closed because it has been stalled for 35 days with no activity.'
days-before-issue-stale: 14 days-before-issue-stale: 14
days-before-pr-stale: 21 days-before-pr-stale: 21
days-before-issue-close: 14 days-before-issue-close: 14
days-before-pr-close: 14 days-before-pr-close: 14
exempt-draft-pr: true exempt-draft-pr: true

View file

@ -90,7 +90,6 @@ lintci-deps:
vulncheck: vulncheck:
@go run golang.org/x/vuln/cmd/govulncheck@latest ./... @go run golang.org/x/vuln/cmd/govulncheck@latest ./...
goimports: goimports:
goimports -local "$(PACKAGE)" -w . goimports -local "$(PACKAGE)" -w .

View file

@ -1,9 +1,7 @@
# Bor Overview # Bor Overview
Bor is the Official Golang implementation of the Polygon PoS blockchain. It is a fork of [geth](https://github.com/ethereum/go-ethereum) and is EVM compatible (upto London fork). Bor is the official Golang implementation of the Polygon PoS blockchain. It is a fork of [geth](https://github.com/ethereum/go-ethereum) and is EVM compatible (upto London fork).
[![API Reference]( [![API Reference](https://pkg.go.dev/badge/github.com/maticnetwork/bor)](https://pkg.go.dev/github.com/maticnetwork/bor)
https://pkg.go.dev/badge/github.com/maticnetwork/bor
)](https://pkg.go.dev/github.com/maticnetwork/bor)
[![Go Report Card](https://goreportcard.com/badge/github.com/maticnetwork/bor)](https://goreportcard.com/report/github.com/maticnetwork/bor) [![Go Report Card](https://goreportcard.com/badge/github.com/maticnetwork/bor)](https://goreportcard.com/report/github.com/maticnetwork/bor)
![MIT License](https://img.shields.io/github/license/maticnetwork/bor) ![MIT License](https://img.shields.io/github/license/maticnetwork/bor)
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.com/invite/0xpolygonrnd) [![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.com/invite/0xpolygonrnd)
@ -13,15 +11,15 @@ https://pkg.go.dev/badge/github.com/maticnetwork/bor
The easiest way to get started with bor is to install the packages using the command below. Please take a look at the [releases](https://github.com/maticnetwork/bor/releases) section to find the latest stable version of bor. The easiest way to get started with bor is to install the packages using the command below. Please take a look at the [releases](https://github.com/maticnetwork/bor/releases) section to find the latest stable version of bor.
curl -L https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s -- v0.4.0 <network> <node_type> curl -L https://raw.githubusercontent.com/maticnetwork/install/main/bor.sh | bash -s -- v2.0.0 <network> <node_type>
The network accepts `mainnet`,`amoy` or `mumbai` and the node type accepts `validator` or `sentry` or `archive`. The installation script does the following things: The network accepts `mainnet`, or `amoy` and the node type accepts `validator` or `sentry` or `archive`. The installation script does the following things:
- Create a new user named `bor`. - Create a new user named `bor`.
- Install the bor binary at `/usr/bin/bor`. - Install the bor binary at `/usr/bin/bor`.
- Dump the suitable config file (based on the network and node type provided) at `/var/lib/bor` and use it as the home dir. - Dump the suitable config file (based on the network and node type provided) at `/var/lib/bor` and use it as the home dir.
- Create a systemd service named `bor` at `/lib/systemd/system/bor.service` which starts bor using the config file as `bor` user. - Create a systemd service named `bor` at `/lib/systemd/system/bor.service` which starts bor using the config file as `bor` user.
The releases supports both the networks i.e. Polygon Mainnet, Amoy and Mumbai (Testnet) unless explicitly specified. Before the stable release for mainnet, pre-releases will be available marked with `beta` tag for deploying on Mumbai/Amoy (testnet). On sufficient testing, stable release for mainnet will be announced with a forum post. The releases supports both the networks i.e. Polygon Mainnet, and Amoy (Testnet) unless explicitly specified. Before the stable release for mainnet, pre-releases will be available marked with `beta` tag for deploying on Amoy (testnet). On sufficient testing, stable release for mainnet will be announced with a forum post.
### Building from source ### Building from source

View file

@ -61,14 +61,7 @@ func TestMain(m *testing.M) {
func runClef(t *testing.T, args ...string) *testproc { func runClef(t *testing.T, args ...string) *testproc {
t.Helper() t.Helper()
ddir, err := os.MkdirTemp("", "cleftest-*") ddir := t.TempDir()
if err != nil {
return nil
}
t.Cleanup(func() {
os.RemoveAll(ddir)
})
return runWithKeystore(t, ddir, args...) return runWithKeystore(t, ddir, args...)
} }

View file

@ -4,8 +4,10 @@ import (
"os" "os"
"github.com/ethereum/go-ethereum/internal/cli" "github.com/ethereum/go-ethereum/internal/cli"
"github.com/ethereum/go-ethereum/params"
) )
func main() { func main() {
params.UpdateBorInfo()
os.Exit(cli.Run(os.Args[1:])) os.Exit(cli.Run(os.Args[1:]))
} }

View file

@ -87,11 +87,7 @@ func TestHistoryImportAndExport(t *testing.T) {
} }
// Make temp directory for era files. // Make temp directory for era files.
dir, err := os.MkdirTemp("", "history-export-test") dir := t.TempDir()
if err != nil {
t.Fatalf("error creating temp test directory: %v", err)
}
defer os.RemoveAll(dir)
// Export history to temp directory. // Export history to temp directory.
if err := ExportHistory(chain, dir, 0, count, step); err != nil { if err := ExportHistory(chain, dir, 0, count, step); err != nil {

View file

@ -19,6 +19,7 @@ package state
import ( import (
"errors" "errors"
"maps" "maps"
"sync"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/state/snapshot"
@ -139,12 +140,14 @@ func (r *stateReader) Copy() Reader {
// trieReader implements the Reader interface, providing functions to access // trieReader implements the Reader interface, providing functions to access
// state from the referenced trie. // state from the referenced trie.
type trieReader struct { type trieReader struct {
root common.Hash // State root which uniquely represent a state root common.Hash // State root which uniquely represent a state
db *triedb.Database // Database for loading trie db *triedb.Database // Database for loading trie
buff crypto.KeccakState // Buffer for keccak256 hashing buff crypto.KeccakState // Buffer for keccak256 hashing
mainTrie Trie // Main trie, resolved in constructor mainTrie Trie // Main trie, resolved in constructor
subRoots map[common.Address]common.Hash // Set of storage roots, cached when the account is resolved subRoots map[common.Address]common.Hash // Set of storage roots, cached when the account is resolved
subTries map[common.Address]Trie // Group of storage tries, cached when it's resolved subTries map[common.Address]Trie // Group of storage tries, cached when it's resolved
muSubRoot sync.Mutex
muSubTries sync.Mutex
} }
// trieReader constructs a trie reader of the specific state. An error will be // trieReader constructs a trie reader of the specific state. An error will be
@ -181,11 +184,14 @@ func (r *trieReader) Account(addr common.Address) (*types.StateAccount, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
r.muSubRoot.Lock()
if account == nil { if account == nil {
r.subRoots[addr] = types.EmptyRootHash r.subRoots[addr] = types.EmptyRootHash
} else { } else {
r.subRoots[addr] = account.Root r.subRoots[addr] = account.Root
} }
r.muSubRoot.Unlock()
return account, nil return account, nil
} }
@ -221,7 +227,9 @@ func (r *trieReader) Storage(addr common.Address, key common.Hash) (common.Hash,
if err != nil { if err != nil {
return common.Hash{}, err return common.Hash{}, err
} }
r.muSubTries.Lock()
r.subTries[addr] = tr r.subTries[addr] = tr
r.muSubTries.Unlock()
} }
} }
ret, err := tr.GetStorage(addr, key.Bytes()) ret, err := tr.GetStorage(addr, key.Bytes())

View file

@ -332,8 +332,7 @@ func TestOpenDrops(t *testing.T) {
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true))) log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
// Create a temporary folder for the persistent backend // Create a temporary folder for the persistent backend
storage, _ := os.MkdirTemp("", "blobpool-") storage := t.TempDir()
defer os.RemoveAll(storage)
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700) os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil) store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil)
@ -655,8 +654,7 @@ func TestOpenIndex(t *testing.T) {
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true))) log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
// Create a temporary folder for the persistent backend // Create a temporary folder for the persistent backend
storage, _ := os.MkdirTemp("", "blobpool-") storage := t.TempDir()
defer os.RemoveAll(storage)
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700) os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil) store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil)
@ -744,8 +742,7 @@ func TestOpenHeap(t *testing.T) {
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true))) log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
// Create a temporary folder for the persistent backend // Create a temporary folder for the persistent backend
storage, _ := os.MkdirTemp("", "blobpool-") storage := t.TempDir()
defer os.RemoveAll(storage)
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700) os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil) store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil)
@ -831,8 +828,8 @@ func TestOpenCap(t *testing.T) {
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true))) log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
// Create a temporary folder for the persistent backend // Create a temporary folder for the persistent backend
storage, _ := os.MkdirTemp("", "blobpool-")
defer os.RemoveAll(storage) storage := t.TempDir()
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700) os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil) store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil)
@ -1286,8 +1283,7 @@ func TestAdd(t *testing.T) {
} }
for i, tt := range tests { for i, tt := range tests {
// Create a temporary folder for the persistent backend // Create a temporary folder for the persistent backend
storage, _ := os.MkdirTemp("", "blobpool-") storage := t.TempDir()
defer os.RemoveAll(storage) // late defer, still ok
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700) os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil) store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(), nil)

View file

@ -116,9 +116,8 @@ func (e *gfP12) Mul(a, b *gfP12) *gfP12 {
} }
func (e *gfP12) MulScalar(a *gfP12, b *gfP6) *gfP12 { func (e *gfP12) MulScalar(a *gfP12, b *gfP6) *gfP12 {
e.x.Mul(&e.x, b) e.x.Mul(&a.x, b)
e.y.Mul(&e.y, b) e.y.Mul(&a.y, b)
return e return e
} }

View file

@ -135,9 +135,8 @@ func (e *gfP12) Mul(a, b *gfP12, pool *bnPool) *gfP12 {
} }
func (e *gfP12) MulScalar(a *gfP12, b *gfP6, pool *bnPool) *gfP12 { func (e *gfP12) MulScalar(a *gfP12, b *gfP6, pool *bnPool) *gfP12 {
e.x.Mul(e.x, b, pool) e.x.Mul(a.x, b, pool)
e.y.Mul(e.y, b, pool) e.y.Mul(a.y, b, pool)
return e return e
} }

View file

@ -32,16 +32,17 @@ devfakeauthor = false # Run miner without validator set authorization
enable-block-tracking = false # Enables additional logging of information collected while tracking block lifecycle enable-block-tracking = false # Enables additional logging of information collected while tracking block lifecycle
[p2p] [p2p]
maxpeers = 50 # Maximum number of network peers (network disabled if set to 0) maxpeers = 50 # Maximum number of network peers (network disabled if set to 0)
maxpendpeers = 50 # Maximum number of pending connection attempts maxpendpeers = 50 # Maximum number of pending connection attempts
bind = "0.0.0.0" # Network binding address bind = "0.0.0.0" # Network binding address
port = 30303 # Network listening port port = 30303 # Network listening port
nodiscover = false # Disables the peer discovery mechanism (manual peer addition) nodiscover = false # Disables the peer discovery mechanism (manual peer addition)
nat = "any" # NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) nat = "any" # NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
netrestrict = "" # Restricts network communication to the given IP networks (CIDR masks) netrestrict = "" # Restricts network communication to the given IP networks (CIDR masks)
nodekey = "" # P2P node key file nodekey = "" # P2P node key file
nodekeyhex = "" # P2P node key as hex nodekeyhex = "" # P2P node key as hex
txarrivalwait = "500ms" # Maximum duration to wait before requesting an announced transaction txarrivalwait = "500ms" # Maximum duration to wait before requesting an announced transaction
txannouncementonly = false # Whether to only announce transactions to peers
[p2p.discovery] [p2p.discovery]
v4disc = true # Enables the V4 discovery mechanism v4disc = true # Enables the V4 discovery mechanism
v5disc = false # Enables the experimental RLPx V5 (Topic Discovery) mechanism v5disc = false # Enables the experimental RLPx V5 (Topic Discovery) mechanism

View file

@ -22,7 +22,7 @@ The ```bor server``` command runs the Bor client.
- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) (default: false) - ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose) (default: false)
- ```chain```: Name of the chain to sync ('amoy', 'mumbai', 'mainnet') or path to a genesis file (default: mainnet) - ```chain```: Name of the chain to sync ('amoy', 'mainnet') or path to a genesis file (default: mainnet)
- ```config```: Path to the TOML configuration file - ```config```: Path to the TOML configuration file
@ -242,6 +242,8 @@ The ```bor server``` command runs the Bor client.
- ```txarrivalwait```: Maximum duration to wait for a transaction before explicitly requesting it (default: 500ms) - ```txarrivalwait```: Maximum duration to wait for a transaction before explicitly requesting it (default: 500ms)
- ```txannouncementonly```: Whether to only announce transactions to peers (default: false)
- ```v4disc```: Enables the V4 discovery mechanism (default: true) - ```v4disc```: Enables the V4 discovery mechanism (default: true)
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false) - ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism (default: false)

View file

@ -73,13 +73,15 @@ type Config = ethconfig.Config
// Ethereum implements the Ethereum full node service. // Ethereum implements the Ethereum full node service.
type Ethereum struct { type Ethereum struct {
// core protocol objects config *ethconfig.Config
config *ethconfig.Config
txPool *txpool.TxPool
blockchain *core.BlockChain
handler *handler // Handlers
discmix *enode.FairMix txPool *txpool.TxPool
blockchain *core.BlockChain
handler *handler
ethDialCandidates enode.Iterator
snapDialCandidates enode.Iterator
// DB interfaces // DB interfaces
chainDb ethdb.Database // Block chain database chainDb ethdb.Database // Block chain database
@ -166,7 +168,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
bloomRequests: make(chan chan *bloombits.Retrieval), bloomRequests: make(chan chan *bloombits.Retrieval),
bloomIndexer: core.NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms), bloomIndexer: core.NewBloomIndexer(chainDb, params.BloomBitsBlocks, params.BloomConfirms),
p2pServer: stack.Server(), p2pServer: stack.Server(),
discmix: enode.NewFairMix(0),
shutdownTracker: shutdowncheck.NewShutdownTracker(chainDb), shutdownTracker: shutdowncheck.NewShutdownTracker(chainDb),
closeCh: make(chan struct{}), closeCh: make(chan struct{}),
} }
@ -306,6 +307,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EthAPI: blockChainAPI, EthAPI: blockChainAPI,
checker: checker, checker: checker,
enableBlockTracking: eth.config.EnableBlockTracking, enableBlockTracking: eth.config.EnableBlockTracking,
txAnnouncementOnly: eth.p2pServer.TxAnnouncementOnly,
}); err != nil { }); err != nil {
return nil, err return nil, err
} }
@ -320,6 +322,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// 1.14.8: NewOracle function definition was changed to accept (startPrice *big.Int) param. // 1.14.8: NewOracle function definition was changed to accept (startPrice *big.Int) param.
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, config.GPO, config.Miner.GasPrice) eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, config.GPO, config.Miner.GasPrice)
// Setup DNS discovery iterators.
dnsclient := dnsdisc.NewClient(dnsdisc.Config{})
eth.ethDialCandidates, err = dnsclient.NewIterator(eth.config.EthDiscoveryURLs...)
if err != nil {
return nil, err
}
eth.snapDialCandidates, err = dnsclient.NewIterator(eth.config.SnapDiscoveryURLs...)
if err != nil {
return nil, err
}
// Start the RPC service // Start the RPC service
eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, config.NetworkId) eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, config.NetworkId)
@ -587,9 +600,9 @@ func (s *Ethereum) SetAuthorized(authorized bool) {
// Protocols returns all the currently configured // Protocols returns all the currently configured
// network protocols to start. // network protocols to start.
func (s *Ethereum) Protocols() []p2p.Protocol { func (s *Ethereum) Protocols() []p2p.Protocol {
protos := eth.MakeProtocols((*ethHandler)(s.handler), s.networkID, s.discmix) protos := eth.MakeProtocols((*ethHandler)(s.handler), s.networkID, s.ethDialCandidates)
if s.config.SnapshotCache > 0 { if s.config.SnapshotCache > 0 {
protos = append(protos, snap.MakeProtocols((*snapHandler)(s.handler))...) protos = append(protos, snap.MakeProtocols((*snapHandler)(s.handler), s.snapDialCandidates)...)
} }
return protos return protos
@ -598,7 +611,7 @@ func (s *Ethereum) Protocols() []p2p.Protocol {
// Start implements node.Lifecycle, starting all internal goroutines needed by the // Start implements node.Lifecycle, starting all internal goroutines needed by the
// Ethereum protocol implementation. // Ethereum protocol implementation.
func (s *Ethereum) Start() error { func (s *Ethereum) Start() error {
s.setupDiscovery() eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
// Start the bloom bits servicing goroutines // Start the bloom bits servicing goroutines
s.startBloomHandlers(params.BloomBitsBlocks) s.startBloomHandlers(params.BloomBitsBlocks)
@ -785,38 +798,6 @@ func (s *Ethereum) handleNoAckMilestoneByID(ctx context.Context, ethHandler *eth
return nil return nil
} }
func (s *Ethereum) setupDiscovery() error {
eth.StartENRUpdater(s.blockchain, s.p2pServer.LocalNode())
// Add eth nodes from DNS.
dnsclient := dnsdisc.NewClient(dnsdisc.Config{})
if len(s.config.EthDiscoveryURLs) > 0 {
iter, err := dnsclient.NewIterator(s.config.EthDiscoveryURLs...)
if err != nil {
return err
}
s.discmix.AddSource(iter)
}
// Add snap nodes from DNS.
if len(s.config.SnapDiscoveryURLs) > 0 {
iter, err := dnsclient.NewIterator(s.config.SnapDiscoveryURLs...)
if err != nil {
return err
}
s.discmix.AddSource(iter)
}
// Add DHT nodes from discv5.
if s.p2pServer.DiscoveryV5() != nil {
filter := eth.NewNodeFilter(s.blockchain)
iter := enode.Filter(s.p2pServer.DiscoveryV5().RandomNodes(), filter)
s.discmix.AddSource(iter)
}
return nil
}
func (s *Ethereum) getHandler() (*ethHandler, *bor.Bor, error) { func (s *Ethereum) getHandler() (*ethHandler, *bor.Bor, error) {
ethHandler := (*ethHandler)(s.handler) ethHandler := (*ethHandler)(s.handler)
@ -835,14 +816,13 @@ func (s *Ethereum) getHandler() (*ethHandler, *bor.Bor, error) {
// Stop implements node.Lifecycle, terminating all internal goroutines used by the // Stop implements node.Lifecycle, terminating all internal goroutines used by the
// Ethereum protocol. // Ethereum protocol.
func (s *Ethereum) Stop() error { func (s *Ethereum) Stop() error {
// Stop all the peer-related stuff first.
s.discmix.Close()
// Close the engine before handler else it may cause a deadlock where // Close the engine before handler else it may cause a deadlock where
// the heimdall is unresponsive and the syncing loop keeps waiting // the heimdall is unresponsive and the syncing loop keeps waiting
// for a response and is unable to proceed to exit `Finalize` during // for a response and is unable to proceed to exit `Finalize` during
// block processing. // block processing.
s.engine.Close() s.engine.Close()
s.ethDialCandidates.Close()
s.snapDialCandidates.Close()
s.handler.Stop() s.handler.Stop()
// Then stop everything else. // Then stop everything else.

View file

@ -99,6 +99,7 @@ type handlerConfig struct {
RequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges RequiredBlocks map[uint64]common.Hash // Hard coded map of required block hashes for sync challenges
EthAPI *ethapi.BlockChainAPI // EthAPI to interact EthAPI *ethapi.BlockChainAPI // EthAPI to interact
enableBlockTracking bool // Whether to log information collected while tracking block lifecycle enableBlockTracking bool // Whether to log information collected while tracking block lifecycle
txAnnouncementOnly bool // Whether to only announce txs to peers
} }
type handler struct { type handler struct {
@ -129,6 +130,7 @@ type handler struct {
requiredBlocks map[uint64]common.Hash requiredBlocks map[uint64]common.Hash
enableBlockTracking bool enableBlockTracking bool
txAnnouncementOnly bool
// channels for fetcher, syncer, txsyncLoop // channels for fetcher, syncer, txsyncLoop
quitSync chan struct{} quitSync chan struct{}
@ -159,6 +161,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
ethAPI: config.EthAPI, ethAPI: config.EthAPI,
requiredBlocks: config.RequiredBlocks, requiredBlocks: config.RequiredBlocks,
enableBlockTracking: config.enableBlockTracking, enableBlockTracking: config.enableBlockTracking,
txAnnouncementOnly: config.txAnnouncementOnly,
quitSync: make(chan struct{}), quitSync: make(chan struct{}),
handlerDoneCh: make(chan struct{}), handlerDoneCh: make(chan struct{}),
handlerStartCh: make(chan struct{}), handlerStartCh: make(chan struct{}),
@ -633,7 +636,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
case tx.Size() > txMaxBroadcastSize: case tx.Size() > txMaxBroadcastSize:
largeTxs++ largeTxs++
default: default:
maybeDirect = true maybeDirect = !h.txAnnouncementOnly
} }
// Send the transaction (if it's small enough) directly to a subset of // Send the transaction (if it's small enough) directly to a subset of
// the peers that have not received it yet, ensuring that the flow of // the peers that have not received it yet, ensuring that the flow of

View file

@ -454,6 +454,102 @@ func testTransactionPropagation(t *testing.T, protocol uint) {
} }
} }
// This test checks that transactions are only announced when txannouncementonly is enabled
func TestSendTransactionAnnouncementsOnly67(t *testing.T) {
testSendTransactionAnnouncementsOnly(t, eth.ETH67)
}
func TestSendTransactionAnnouncementsOnly68(t *testing.T) {
testSendTransactionAnnouncementsOnly(t, eth.ETH68)
}
func testSendTransactionAnnouncementsOnly(t *testing.T, protocol uint) {
t.Parallel()
// Create a source handler that has txannouncementonly enabled
source := newTestHandler()
source.handler.txAnnouncementOnly = true
defer source.close()
sink := newTestHandler()
defer sink.close()
sourcePipe, sinkPipe := p2p.MsgPipe()
defer sourcePipe.Close()
defer sinkPipe.Close()
sourcePeer := eth.NewPeer(protocol, p2p.NewPeerPipe(enode.ID{1}, "", nil, sourcePipe), sourcePipe, source.txpool)
sinkPeer := eth.NewPeer(protocol, p2p.NewPeerPipe(enode.ID{2}, "", nil, sinkPipe), sinkPipe, sink.txpool)
defer sourcePeer.Close()
defer sinkPeer.Close()
go source.handler.runEthPeer(sourcePeer, func(peer *eth.Peer) error {
return eth.Handle((*ethHandler)(source.handler), peer)
})
// Run the handshake locally
var (
genesis = source.chain.Genesis()
head = source.chain.CurrentBlock()
td = source.chain.GetTd(head.Hash(), head.Number.Uint64())
)
if err := sinkPeer.Handshake(1, td, head.Hash(), genesis.Hash(), forkid.NewIDWithChain(source.chain), forkid.NewFilter(source.chain)); err != nil {
t.Fatalf("failed to run protocol handshake: %v", err)
}
// Subscribe to all inbound network events on the sink peer
backend := new(testEthHandler)
anns := make(chan []common.Hash)
annSub := backend.txAnnounces.Subscribe(anns)
defer annSub.Unsubscribe()
bcasts := make(chan []*types.Transaction)
bcastSub := backend.txBroadcasts.Subscribe(bcasts)
defer bcastSub.Unsubscribe()
go eth.Handle(backend, sinkPeer)
// Fill the source pool with transactions and wait for them at the sink
txs := make([]*types.Transaction, 1024)
for nonce := range txs {
tx := types.NewTransaction(uint64(nonce), common.Address{}, big.NewInt(0), 100000, big.NewInt(0), nil)
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
txs[nonce] = tx
}
source.txpool.Add(txs, false, false)
// Make sure we get all the transactions as announcements
seen := make(map[common.Hash]struct{})
timeout := false
for len(seen) < len(txs) && !timeout {
switch protocol {
case 67, 68:
select {
case hashes := <-anns:
for _, hash := range hashes {
if _, ok := seen[hash]; ok {
t.Errorf("duplicate transaction announced: %x", hash)
}
seen[hash] = struct{}{}
}
case <-bcasts:
t.Errorf("received tx broadcast when txannouncementonly is true")
case <-time.After(5 * time.Second):
t.Errorf("transaction propagation timed out")
timeout = true
}
default:
panic("unsupported protocol, please extend test")
}
}
for _, tx := range txs {
if _, ok := seen[tx.Hash()]; !ok {
t.Errorf("missing transaction: %x", tx.Hash())
}
}
}
// Tests that blocks are broadcast to a sqrt number of peers only. // Tests that blocks are broadcast to a sqrt number of peers only.
func TestBroadcastBlock1Peer(t *testing.T) { testBroadcastBlock(t, 1, 1) } func TestBroadcastBlock1Peer(t *testing.T) { testBroadcastBlock(t, 1, 1) }
func TestBroadcastBlock2Peers(t *testing.T) { testBroadcastBlock(t, 2, 1) } func TestBroadcastBlock2Peers(t *testing.T) { testBroadcastBlock(t, 2, 1) }

View file

@ -66,17 +66,3 @@ func currentENREntry(chain *core.BlockChain) *enrEntry {
ForkID: forkid.NewID(chain.Config(), chain.Genesis(), head.Number.Uint64(), head.Time), ForkID: forkid.NewID(chain.Config(), chain.Genesis(), head.Number.Uint64(), head.Time),
} }
} }
// NewNodeFilter returns a filtering function that returns whether the provided
// enode advertises a forkid compatible with the current chain.
func NewNodeFilter(chain *core.BlockChain) func(*enode.Node) bool {
filter := forkid.NewFilter(chain)
return func(n *enode.Node) bool {
var entry enrEntry
if err := n.Load(entry); err != nil {
return false
}
err := filter(entry.ForkID)
return err == nil
}
}

View file

@ -117,7 +117,8 @@ func MakeProtocols(backend Backend, network uint64, dnsdisc enode.Iterator) []p2
PeerInfo: func(id enode.ID) interface{} { PeerInfo: func(id enode.ID) interface{} {
return backend.PeerInfo(id) return backend.PeerInfo(id)
}, },
Attributes: []enr.Entry{currentENREntry(backend.Chain())}, Attributes: []enr.Entry{currentENREntry(backend.Chain())},
DialCandidates: dnsdisc,
}) })
} }
return protocols return protocols

View file

@ -82,7 +82,13 @@ type Backend interface {
} }
// MakeProtocols constructs the P2P protocol definitions for `snap`. // MakeProtocols constructs the P2P protocol definitions for `snap`.
func MakeProtocols(backend Backend) []p2p.Protocol { func MakeProtocols(backend Backend, dnsdisc enode.Iterator) []p2p.Protocol {
// Filter the discovery iterator for nodes advertising snap support.
dnsdisc = enode.Filter(dnsdisc, func(n *enode.Node) bool {
var snap enrEntry
return n.Load(&snap) == nil
})
protocols := make([]p2p.Protocol, len(ProtocolVersions)) protocols := make([]p2p.Protocol, len(ProtocolVersions))
for i, version := range ProtocolVersions { for i, version := range ProtocolVersions {
@ -103,7 +109,8 @@ func MakeProtocols(backend Backend) []p2p.Protocol {
PeerInfo: func(id enode.ID) interface{} { PeerInfo: func(id enode.ID) interface{} {
return backend.PeerInfo(id) return backend.PeerInfo(id)
}, },
Attributes: []enr.Entry{&enrEntry{}}, Attributes: []enr.Entry{&enrEntry{}},
DialCandidates: dnsdisc,
} }
} }

View file

@ -89,8 +89,5 @@ var amoyTestnet = &Chain{
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/amoy.json"), Alloc: readPrealloc("allocs/amoy.json"),
}, },
Bootnodes: []string{ Bootnodes: params.AmoyBootnodes,
"enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303",
"enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303",
},
} }

View file

@ -110,8 +110,5 @@ var mainnetBor = &Chain{
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/mainnet.json"), Alloc: readPrealloc("allocs/mainnet.json"),
}, },
Bootnodes: []string{ Bootnodes: params.BorMainnetBootnodes,
"enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303",
"enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303",
},
} }

View file

@ -85,8 +85,5 @@ var mumbaiTestnet = &Chain{
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"), Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
Alloc: readPrealloc("allocs/mumbai.json"), Alloc: readPrealloc("allocs/mumbai.json"),
}, },
Bootnodes: []string{ Bootnodes: params.MumbaiBootnodes,
"enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303",
"enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303",
},
} }

View file

@ -222,6 +222,9 @@ type P2PConfig struct {
// an announced transaction to arrive before explicitly requesting it // an announced transaction to arrive before explicitly requesting it
TxArrivalWait time.Duration `hcl:"-,optional" toml:"-"` TxArrivalWait time.Duration `hcl:"-,optional" toml:"-"`
TxArrivalWaitRaw string `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"` TxArrivalWaitRaw string `hcl:"txarrivalwait,optional" toml:"txarrivalwait,optional"`
// TxAnnouncementOnly is used to only announce transactions to peers
TxAnnouncementOnly bool `hcl:"txannouncementonly,optional" toml:"txannouncementonly,optional"`
} }
type P2PDiscovery struct { type P2PDiscovery struct {
@ -625,14 +628,15 @@ func DefaultConfig() *Config {
RPCBatchLimit: 100, RPCBatchLimit: 100,
RPCReturnDataLimit: 100000, RPCReturnDataLimit: 100000,
P2P: &P2PConfig{ P2P: &P2PConfig{
MaxPeers: 50, MaxPeers: 50,
MaxPendPeers: 50, MaxPendPeers: 50,
Bind: "0.0.0.0", Bind: "0.0.0.0",
Port: 30303, Port: 30303,
NoDiscover: false, NoDiscover: false,
NAT: "any", NAT: "any",
NetRestrict: "", NetRestrict: "",
TxArrivalWait: 500 * time.Millisecond, TxArrivalWait: 500 * time.Millisecond,
TxAnnouncementOnly: false,
Discovery: &P2PDiscovery{ Discovery: &P2PDiscovery{
DiscoveryV4: true, DiscoveryV4: true,
V5Enabled: false, V5Enabled: false,
@ -1343,12 +1347,13 @@ func (c *Config) buildNode() (*node.Config, error) {
AllowUnprotectedTxs: c.JsonRPC.AllowUnprotectedTxs, AllowUnprotectedTxs: c.JsonRPC.AllowUnprotectedTxs,
EnablePersonal: c.JsonRPC.EnablePersonal, EnablePersonal: c.JsonRPC.EnablePersonal,
P2P: p2p.Config{ P2P: p2p.Config{
MaxPeers: int(c.P2P.MaxPeers), MaxPeers: int(c.P2P.MaxPeers),
MaxPendingPeers: int(c.P2P.MaxPendPeers), MaxPendingPeers: int(c.P2P.MaxPendPeers),
ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)), ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)),
DiscoveryV4: c.P2P.Discovery.DiscoveryV4, DiscoveryV4: c.P2P.Discovery.DiscoveryV4,
DiscoveryV5: c.P2P.Discovery.V5Enabled, DiscoveryV5: c.P2P.Discovery.V5Enabled,
TxArrivalWait: c.P2P.TxArrivalWait, TxArrivalWait: c.P2P.TxArrivalWait,
TxAnnouncementOnly: c.P2P.TxAnnouncementOnly,
}, },
HTTPModules: c.JsonRPC.Http.API, HTTPModules: c.JsonRPC.Http.API,
HTTPCors: c.JsonRPC.Http.Cors, HTTPCors: c.JsonRPC.Http.Cors,

View file

@ -812,6 +812,13 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
Default: c.cliConfig.P2P.TxArrivalWait, Default: c.cliConfig.P2P.TxArrivalWait,
Group: "P2P", Group: "P2P",
}) })
f.BoolFlag(&flagset.BoolFlag{
Name: "txannouncementonly",
Usage: "Whether to only announce transactions to peers",
Value: &c.cliConfig.P2P.TxAnnouncementOnly,
Default: c.cliConfig.P2P.TxAnnouncementOnly,
Group: "P2P",
})
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "discovery.dns", Name: "discovery.dns",
Usage: "Comma separated list of enrtree:// URLs which will be queried for nodes to connect to", Usage: "Comma separated list of enrtree:// URLs which will be queried for nodes to connect to",

View file

@ -36,6 +36,7 @@ devfakeauthor = false
nodekey = "" nodekey = ""
nodekeyhex = "" nodekeyhex = ""
txarrivalwait = "500ms" txarrivalwait = "500ms"
txannouncementonly = false
[p2p.discovery] [p2p.discovery]
v4disc = true v4disc = true
v5disc = false v5disc = false

View file

@ -59,10 +59,7 @@ func TestOfflineBlockPrune(t *testing.T) {
func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64) { func testOfflineBlockPruneWithAmountReserved(t *testing.T, amountReserved uint64) {
t.Helper() t.Helper()
datadir, err := os.MkdirTemp("", "") datadir := t.TempDir()
require.NoError(t, err, "failed to create temporary datadir")
os.RemoveAll(datadir)
chaindbPath := filepath.Join(datadir, "chaindata") chaindbPath := filepath.Join(datadir, "chaindata")
oldAncientPath := filepath.Join(chaindbPath, "ancient") oldAncientPath := filepath.Join(chaindbPath, "ancient")

View file

@ -172,6 +172,9 @@ type Config struct {
// TxArrivalWait is the duration (ms) that the node will wait after seeing // TxArrivalWait is the duration (ms) that the node will wait after seeing
// an announced transaction before explicitly requesting it // an announced transaction before explicitly requesting it
TxArrivalWait time.Duration TxArrivalWait time.Duration
// TxAnnouncementOnly is used to only announce transactions to peers
TxAnnouncementOnly bool
} }
// Server manages all peer connections. // Server manages all peer connections.

View file

@ -35,6 +35,7 @@ gcmode = "archive"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
# [p2p.discovery] # [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -34,6 +34,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -36,6 +36,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -36,6 +36,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -38,6 +38,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -36,6 +36,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -37,6 +37,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v4disc = true # v4disc = true
# v5disc = false # v5disc = false

View file

@ -34,6 +34,7 @@ gcmode = "archive"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -33,6 +33,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -34,6 +34,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -35,6 +35,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -36,6 +36,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -35,6 +35,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv4 = [] # bootnodesv4 = []

View file

@ -36,6 +36,7 @@ syncmode = "full"
# nodekey = "" # nodekey = ""
# nodekeyhex = "" # nodekeyhex = ""
# txarrivalwait = "500ms" # txarrivalwait = "500ms"
# txannouncementonly = false
[p2p.discovery] [p2p.discovery]
# v5disc = false # v5disc = false
# bootnodesv5 = [] # bootnodesv5 = []

View file

@ -18,6 +18,8 @@ package params
import ( import (
"fmt" "fmt"
"github.com/ethereum/go-ethereum/metrics"
) )
const ( const (
@ -27,7 +29,20 @@ const (
VersionMeta = "" // Version metadata to append to the version string VersionMeta = "" // Version metadata to append to the version string
) )
var GitCommit string var (
// borInfoGauge stores Bor git commit and version details.
borInfoGauge = metrics.NewRegisteredGaugeInfo("bor/info", nil)
GitCommit string
)
// UpdateBorInfo updates the bor_info metric with the current git commit and version details.
func UpdateBorInfo() {
borInfoGauge.Update(metrics.GaugeInfoValue{
"commit": GitCommit,
"version": VersionWithMeta,
})
}
// Version holds the textual version string. // Version holds the textual version string.
var Version = func() string { var Version = func() string {

View file

@ -172,6 +172,7 @@ var nameTagMap = map[string]string{
"maxpeers": "maxpeers", "maxpeers": "maxpeers",
"maxpendpeers": "maxpendpeers", "maxpendpeers": "maxpendpeers",
"txarrivalwait": "txarrivalwait", "txarrivalwait": "txarrivalwait",
"txannouncementonly": "txannouncementonly",
"nat": "nat", "nat": "nat",
"nodiscover": "nodiscover", "nodiscover": "nodiscover",
"v5disc": "v5disc", "v5disc": "v5disc",