Skip to content

Commit

Permalink
merged in the current develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
thogard785 committed Apr 5, 2023
2 parents a5b49c3 + b39e64c commit 1e926cf
Show file tree
Hide file tree
Showing 80 changed files with 2,941 additions and 493 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
29 changes: 3 additions & 26 deletions .github/workflows/security-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -62,29 +65,3 @@ jobs:
with:
name: raw-report
path: raw-report.json

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 }}
32 changes: 32 additions & 0 deletions .github/workflows/security-sonarqube-ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down
35 changes: 32 additions & 3 deletions builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

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"
Expand All @@ -13,16 +14,25 @@ syncmode = "full"
# snapshot = true
# "bor.logs" = false
# ethstats = ""

# devfakeauthor = false
# ["eth.requiredblocks"]

# [log]
# vmodule = ""
# json = false
# backtrace = ""
# debug = true

[p2p]
# maxpeers = 1
# nodiscover = true
# maxpendpeers = 50
# 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"]
Expand Down Expand Up @@ -58,13 +68,16 @@ syncmode = "full"
# mine = true
# etherbase = "VALIDATOR ADDRESS"
# extradata = ""
# recommit = "2m5s"


# [jsonrpc]
# ipcdisable = false
# ipcpath = ""
# gascap = 50000000
# evmtimeout = "5s"
# txfeecap = 5.0
# allow-unprotected-txs = false
# [jsonrpc.http]
# enabled = false
# port = 8545
Expand All @@ -87,6 +100,11 @@ syncmode = "full"
# host = ""
# vhosts = ["*"]
# corsdomain = ["*"]
# [jsonrpc.auth]
# jwtsecret = ""
# addr = "localhost"
# port = 8551
# vhosts = ["localhost"]
# [jsonrpc.timeouts]
# read = "30s"
# write = "30s"
Expand All @@ -95,6 +113,8 @@ syncmode = "full"
[gpo]
# blocks = 20
# percentile = 60
# maxheaderhistory = 1024
# maxblockhistory = 1024
# maxprice = "5000000000000"
ignoreprice = "30000000000"

Expand Down Expand Up @@ -128,6 +148,7 @@ syncmode = "full"
# txlookuplimit = 2350000
# triesinmemory = 128
# timeout = "1h0m0s"
# fdlimit = 0

[accounts]
# allow-insecure-unlock = true
Expand All @@ -142,3 +163,11 @@ syncmode = "full"
# [developer]
# dev = false
# period = 0
# gaslimit = 11500000

# [pprof]
# pprof = false
# port = 6060
# addr = "127.0.0.1"
# memprofilerate = 524288
# blockprofilerate = 0
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
utils.HeimdallgRPCAddressFlag,
utils.RunHeimdallFlag,
utils.RunHeimdallArgsFlag,
utils.UseHeimdallAppFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down
8 changes: 4 additions & 4 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,6 @@ func geth(ctx *cli.Context) error {
return fmt.Errorf("invalid command: %q", args[0])
}

prepare(ctx)
stack, backend := makeFullNode(ctx)
defer stack.Close()

if ctx.GlobalBool(utils.RunHeimdallFlag.Name) {
shutdownCtx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
defer stop()
Expand All @@ -360,6 +356,10 @@ func geth(ctx *cli.Context) error {
}()
}

prepare(ctx)
stack, backend := makeFullNode(ctx)
defer stack.Close()

startNode(ctx, stack, backend, false)
stack.Wait()
return nil
Expand Down
8 changes: 8 additions & 0 deletions cmd/utils/bor_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ var (
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,
}
)

Expand All @@ -82,6 +89,7 @@ func SetBorConfig(ctx *cli.Context, cfg *eth.Config) {
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
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
HeimdallgRPCAddress: ctx.GlobalString(HeimdallgRPCAddressFlag.Name),
RunHeimdall: ctx.GlobalBool(RunHeimdallFlag.Name),
RunHeimdallArgs: ctx.GlobalString(RunHeimdallArgsFlag.Name),
UseHeimdallApp: ctx.GlobalBool(UseHeimdallAppFlag.Name),
})
engine = ethereum.Engine()
} else {
Expand Down
18 changes: 17 additions & 1 deletion consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -245,6 +246,7 @@ func New(
spanner Spanner,
heimdallClient IHeimdallClient,
genesisContracts GenesisContract,
devFakeAuthor bool,
) *Bor {
// get bor config
borConfig := chainConfig.Bor
Expand All @@ -267,6 +269,7 @@ func New(
spanner: spanner,
GenesisContractsClient: genesisContracts,
HeimdallClient: heimdallClient,
devFakeAuthor: devFakeAuthor,
}

c.authorizedSigner.Store(&signer{
Expand Down Expand Up @@ -480,6 +483,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)
Expand Down
52 changes: 52 additions & 0 deletions consensus/bor/heimdallapp/checkpoint.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
Loading

0 comments on commit 1e926cf

Please sign in to comment.