Skip to content

Commit

Permalink
Merge tag 'v1.1.0-beta3' into release/polygon-1.x-fh2.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/state_processor.go
#	core/vm/evm.go
#	go.mod
#	params/version.go
  • Loading branch information
maoueh committed Oct 31, 2023
2 parents 4591432 + 5da60c2 commit f2ca794
Show file tree
Hide file tree
Showing 75 changed files with 3,730 additions and 2,939 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://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
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/0xPolygonDevs) 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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: ''

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation.

For general questions please join our [discord](https://discord.com/invite/zdwkdvMNY2) server.
For general questions please join our [discord](https://discord.com/invite/0xPolygonDevs) server.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ jobs:

- name: Test
run: make test

- uses: actions/upload-artifact@v2
with:
name: unitTest-coverage
path: cover.out

#- name: Data race tests
# run: make test-race
Expand Down Expand Up @@ -153,17 +158,25 @@ jobs:
- name: test-integration
run: make test-integration

- uses: actions/upload-artifact@v2
with:
name: integrationTest-coverage
path: cover.out

codecov:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy:
matrix:
os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}
needs: [unit-tests, integration-tests]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./cover.out
uses: codecov/codecov-action@v3

e2e-tests:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]
schedule:
- cron: '0 0 * * *'

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Security CI
name: Govuln
on: [ push, pull_request ]

jobs:
Expand All @@ -8,12 +8,12 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Running govulncheck
uses: Templum/govulncheck-action@v0.10.1
uses: Templum/govulncheck-action@v1.0.0
continue-on-error: true
env:
DEBUG: "true"
with:
go-version: 1.20.5
go-version: 1.21
package: ./...
github-token: ${{ secrets.GITHUB_TOKEN }}
fail-on-vuln: true
Expand Down
41 changes: 0 additions & 41 deletions .snyk

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ test-txpool-race:

test-race:
$(GOTEST) --timeout 15m -race -shuffle=on $(TESTALL)

gocovmerge-deps:
$(GOBUILD) -o $(GOBIN)/gocovmerge github.com/wadey/gocovmerge

test-integration:
$(GOTEST) --timeout 60m -tags integration $(TESTE2E)
$(GOTEST) --timeout 60m -cover -coverprofile=cover.out -covermode=atomic -tags integration $(TESTE2E)

escape:
cd $(path) && go test -gcflags "-m -m" -run none -bench=BenchmarkJumpdest* -benchmem -memprofile mem.out
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
)](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)
![MIT License](https://img.shields.io/github/license/maticnetwork/bor)
[![Discord](https://img.shields.io/discord/714888181740339261?color=1C1CE1&label=Polygon%20%7C%20Discord%20%F0%9F%91%8B%20&style=flat-square)](https://discord.gg/zdwkdvMNY2)
[![Discord](https://img.shields.io/discord/714888181740339261?color=1C1CE1&label=Polygon%20%7C%20Discord%20%F0%9F%91%8B%20&style=flat-square)](https://discord.com/invite/0xPolygonDevs)
[![Twitter Follow](https://img.shields.io/twitter/follow/0xPolygon.svg?style=social)](https://twitter.com/0xPolygon)

### Installing bor using packaging
Expand Down Expand Up @@ -81,4 +81,4 @@ included in our repository in the `COPYING` file.
## Join our Discord server
Join Polygon community – share your ideas or just say hi over [on Discord](https://discord.gg/zdwkdvMNY2).
Join Polygon community – share your ideas or just say hi over [on Discord](https://discord.com/invite/0xPolygonDevs).
9 changes: 8 additions & 1 deletion accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,14 @@ func (w *trezorDriver) trezorExchange(req proto.Message, results ...proto.Messag
return 0, err
}

payload := make([]byte, 8+len(data))
var payload []byte

if len(data) < 64*1024*1024 {
payload = make([]byte, 8+len(data))
} else {
return 0, errors.New("data too large")
}

copy(payload, []byte{0x23, 0x23})
binary.BigEndian.PutUint16(payload[2:], trezor.Type(req))
binary.BigEndian.PutUint32(payload[4:], uint32(len(data)))
Expand Down
10 changes: 9 additions & 1 deletion builder/files/genesis-testnet-v4.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions cmd/evm/internal/t8ntool/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func Transaction(ctx *cli.Context) error {
}
// Check intrinsic gas
if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil,
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(0)); err != nil {
chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int))); err != nil {
r.Error = err
results = append(results, r)

Expand Down Expand Up @@ -190,9 +190,8 @@ func Transaction(ctx *cli.Context) error {
case new(big.Int).Mul(tx.GasFeeCap(), new(big.Int).SetUint64(tx.Gas())).BitLen() > 256:
r.Error = errors.New("gas * maxFeePerGas exceeds 256 bits")
}
// TODO marcello double check
// Check whether the init code size has been exceeded.
if chainConfig.IsShanghai(0) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
if chainConfig.IsShanghai(new(big.Int)) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
r.Error = errors.New("max initcode size exceeded")
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/evm/internal/t8ntool/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ func Transition(ctx *cli.Context) error {
return NewError(ErrorConfig, errors.New("EIP-1559 config but missing 'currentBaseFee' in env section"))
}
}
// TODO marcello double check
if chainConfig.IsShanghai(prestate.Env.Number) && prestate.Env.Withdrawals == nil {

if chainConfig.IsShanghai(big.NewInt(int64(prestate.Env.Number))) && prestate.Env.Withdrawals == nil {
return NewError(ErrorConfig, errors.New("Shanghai config but missing 'withdrawals' in env section"))
}

Expand Down
1 change: 0 additions & 1 deletion cmd/evm/t8n_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ func TestT8n(t *testing.T) {
output: t8nOutput{result: true},
expOut: "exp.json",
},
// TODO marcello double check
{ // Test post-merge transition
base: "./testdata/24",
input: t8nInput{
Expand Down
6 changes: 3 additions & 3 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"fmt"
"math/big"
"os"
"time"

Expand Down Expand Up @@ -147,10 +148,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// makeFullNode loads geth configuration and creates the Ethereum backend.
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx)
// TODO marcello double check
if ctx.IsSet(utils.OverrideShanghai.Name) {
v := ctx.Uint64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = &v
v := ctx.Int64(utils.OverrideShanghai.Name)
cfg.Eth.OverrideShanghai = new(big.Int).SetInt64(v)
}

backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
Expand Down
1 change: 0 additions & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ var (
utils.NoUSBFlag,
utils.USBFlag,
utils.SmartCardDaemonPathFlag,
// TODO marcello double check
utils.OverrideShanghai,
utils.EnablePersonal,
utils.EthashCacheDirFlag,
Expand Down
9 changes: 4 additions & 5 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return err
}
// Verify existence / non-existence of withdrawalsHash.
// TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time)
shanghai := chain.Config().IsShanghai(header.Number)
if shanghai && header.WithdrawalsHash == nil {
return errors.New("missing withdrawalsHash")
}
Expand All @@ -294,7 +293,7 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
}
// Verify the existence / non-existence of excessDataGas
cancun := chain.Config().IsCancun(header.Time)
cancun := chain.Config().IsCancun(header.Number)
if cancun && header.ExcessDataGas == nil {
return errors.New("missing excessDataGas")
}
Expand Down Expand Up @@ -392,8 +391,8 @@ func (beacon *Beacon) FinalizeAndAssemble(ctx context.Context, chain consensus.C
if !beacon.IsPoSHeader(header) {
return beacon.ethone.FinalizeAndAssemble(ctx, chain, header, state, txs, uncles, receipts, nil, firehoseContext)
}
// TODO marcello double check
shanghai := chain.Config().IsShanghai(header.Time)

shanghai := chain.Config().IsShanghai(header.Number)
if shanghai {
// All blocks after Shanghai must include a withdrawals root.
if withdrawals == nil {
Expand Down
17 changes: 14 additions & 3 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,14 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head

// Verify that the gas limit is <= 2^63-1
gasCap := uint64(0x7fffffffffffffff)

if header.GasLimit > gasCap {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap)
}

if header.WithdrawalsHash != nil {
return consensus.ErrUnexpectedWithdrawals
}

// All basic checks passed, verify cascading fields
return c.verifyCascadingFields(chain, header, parents)
}
Expand Down Expand Up @@ -817,6 +820,10 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,

headerNumber := header.Number.Uint64()

if withdrawals != nil || header.WithdrawalsHash != nil {
return
}

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
ctx := context.Background()
cx := statefull.ChainContext{Chain: chain, Bor: c}
Expand Down Expand Up @@ -889,10 +896,14 @@ func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHead
finalizeCtx, finalizeSpan := tracing.StartSpan(ctx, "bor.FinalizeAndAssemble")
defer tracing.EndSpan(finalizeSpan)

stateSyncData := []*types.StateSyncData{}

headerNumber := header.Number.Uint64()

if withdrawals != nil || header.WithdrawalsHash != nil {
return nil, consensus.ErrUnexpectedWithdrawals
}

stateSyncData := []*types.StateSyncData{}

var err error

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
Expand Down
7 changes: 6 additions & 1 deletion consensus/bor/statefull/processor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statefull

import (
"bytes"
"context"
"math"
"math/big"
Expand Down Expand Up @@ -130,7 +131,11 @@ func ApplyMessage(

success := big.NewInt(5).SetBytes(ret)

if success.Cmp(big.NewInt(0)) == 0 {
validatorContract := common.HexToAddress(chainConfig.Bor.ValidatorContract)

// if success == 0 and msg.To() != validatorContractAddress, log Error
// if msg.To() == validatorContractAddress, its committing a span and we don't get any return value
if success.Cmp(big.NewInt(0)) == 0 && !bytes.Equal(msg.To().Bytes(), validatorContract.Bytes()) {
log.Error("message execution failed on contract", "msgData", msg.Data)
}

Expand Down
6 changes: 3 additions & 3 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
if header.GasLimit > params.MaxGasLimit {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit)
}
// TODO marcello double check
if chain.Config().IsShanghai(header.Time) {

if chain.Config().IsShanghai(header.Number) {
return fmt.Errorf("clique does not support shanghai fork")
}

if chain.Config().IsCancun(header.Time) {
if chain.Config().IsCancun(header.Number) {
return fmt.Errorf("clique does not support cancun fork")
}
// All basic checks passed, verify cascading fields
Expand Down
3 changes: 3 additions & 0 deletions consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ var (
// ErrInvalidTerminalBlock is returned if a block is invalid wrt. the terminal
// total difficulty.
ErrInvalidTerminalBlock = errors.New("invalid terminal block")

// ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals.
ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals")
)
Loading

0 comments on commit f2ca794

Please sign in to comment.