Skip to content

Commit

Permalink
chg: solve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Sep 10, 2024
2 parents 4ef3f6e + 44d0938 commit 8c14f12
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 26 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/0xPolygonDevs) 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/0xPolygonCommunity) 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/0xPolygonDevs) server.
For general questions please join our [discord](https://discord.com/invite/0xPolygonCommunity) server.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
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](
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
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)
![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/0xpolygon)
[![Discord](https://img.shields.io/badge/discord-join%20chat-blue.svg)](https://discord.com/invite/0xpolygonrnd)
[![Twitter Follow](https://img.shields.io/twitter/follow/0xPolygon.svg?style=social)](https://twitter.com/0xPolygon)

### Installing bor using packaging
Expand Down Expand Up @@ -79,4 +79,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.com/invite/0xPolygonDevs).
Join Polygon community – share your ideas or just say hi over on [Polygon Community Discord](https://discord.com/invite/0xPolygonCommunity) or on [Polygon R&D Discord](https://discord.com/invite/0xpolygonrnd).
2 changes: 0 additions & 2 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ func geth(ctx *cli.Context) error {
// it unlocks any requested accounts, and starts the RPC/IPC interfaces and the
// miner.
func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isConsole bool) {
debug.Memsize.Add("node", stack)

// Start up the node itself
utils.StartNode(ctx, stack, isConsole)

Expand Down
8 changes: 8 additions & 0 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head
}

if isSprintEnd && signersBytes%validatorHeaderBytesLength != 0 {
log.Warn("Invalid validator set", "number", number, "signersBytes", signersBytes)
return errInvalidSpanValidators
}

Expand Down Expand Up @@ -481,11 +482,13 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
}

if len(newValidators) != len(headerVals) {
log.Warn("Invalid validator set", "block number", number, "newValidators", newValidators, "headerVals", headerVals)
return errInvalidSpanValidators
}

for i, val := range newValidators {
if !bytes.Equal(val.HeaderBytes(), headerVals[i].HeaderBytes()) {
log.Warn("Invalid validator set", "block number", number, "index", i, "local validator", val, "header validator", headerVals[i])
return errInvalidSpanValidators
}
}
Expand Down Expand Up @@ -1420,6 +1423,11 @@ func getUpdatedValidatorSet(oldValidatorSet *valset.ValidatorSet, newVals []*val
}

if err := v.UpdateWithChangeSet(changes); err != nil {
changesStr := ""
for _, change := range changes {
changesStr += fmt.Sprintf("Address: %s, VotingPower: %d\n", change.Address, change.VotingPower)
}
log.Warn("Changes in validator set", "changes", changesStr)
log.Error("Error while updating change set", "error", err)
}

Expand Down
2 changes: 0 additions & 2 deletions core/blockchain_repair_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package core

// TEST CI

import (
"math/big"
"path/filepath"
Expand Down
56 changes: 56 additions & 0 deletions core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,62 @@ func TestApplyMVWriteSet(t *testing.T) {
assert.Equal(t, sSingleProcess.IntermediateRoot(true), sClean.IntermediateRoot(true))
}

func TestMVHashMapRevertConcurrent(t *testing.T) {
t.Parallel()

db := NewDatabase(rawdb.NewMemoryDatabase())
mvhm := blockstm.MakeMVHashMap()
s, _ := NewWithMVHashmap(common.Hash{}, db, nil, mvhm)

states := []*StateDB{s}

// Create copies of the original state for each transition
for i := 1; i <= 2; i++ {
sCopy := s.Copy()
sCopy.txIndex = i
states = append(states, sCopy)
}

addr := common.HexToAddress("0x01")
balance := new(big.Int).SetUint64(uint64(100))

Check failure on line 1216 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

undefined: big

Check failure on line 1216 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / unit-tests (ubuntu-20.04)

undefined: big

// Tx0 touches the account. Amount doesn't matter.
// This is to make sure that Tx1 and Tx2 will use the same state object from Tx0.
states[0].AddBalance(addr, common.Big0)

Check failure on line 1220 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

not enough arguments in call to states[0].AddBalance

Check failure on line 1220 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / unit-tests (ubuntu-20.04)

not enough arguments in call to states[0].AddBalance
states[0].Finalise(false)
states[0].FlushMVWriteSet()

// Tx1 creates the account and add balance
snapshot1 := states[1].Snapshot()
states[1].CreateAccount(addr)
states[1].AddBalance(addr, balance)

Check failure on line 1227 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

not enough arguments in call to states[1].AddBalance

Check failure on line 1227 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / unit-tests (ubuntu-20.04)

not enough arguments in call to states[1].AddBalance

// Tx2 creates the account, reverts.
snapshot2 := states[2].Snapshot()
states[2].CreateAccount(addr)
states[2].RevertToSnapshot(snapshot2)
states[2].Finalise(false)

// Tx2 adds balance
states[2].AddBalance(addr, balance)

Check failure on line 1236 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-20.04)

not enough arguments in call to states[2].AddBalance

Check failure on line 1236 in core/state/statedb_test.go

View workflow job for this annotation

GitHub Actions / unit-tests (ubuntu-20.04)

not enough arguments in call to states[2].AddBalance

// Tx1 now reverts
states[1].RevertToSnapshot(snapshot1)
states[1].Finalise(false)

// Balance after executing Tx0 should be 0 because it shouldn't be affected by Tx1 or Tx2
b := states[0].GetBalance(addr)
assert.Equal(t, common.Big0, b)

// Balance after executing Tx1 should be 0 because Tx1 got reverted
b = states[1].GetBalance(addr)
assert.Equal(t, common.Big0, b)

// Balance after executing Tx2 should be 100 because its snapshot is taken before Tx1 got reverted
b = states[2].GetBalance(addr)
assert.Equal(t, balance, b)
}

// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
func TestCopyOfCopy(t *testing.T) {
Expand Down
10 changes: 8 additions & 2 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,14 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
}

// Check whether the max code size has been exceeded, assign err if the case.
if err == nil && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSize {
err = ErrMaxCodeSizeExceeded
if err == nil && evm.chainRules.IsEIP158 {
if evm.chainConfig.Bor != nil && evm.chainConfig.Bor.IsAhmedabad(evm.Context.BlockNumber) {
if len(ret) > params.MaxCodeSizePostAhmedabad {
err = ErrMaxCodeSizeExceeded
}
} else if len(ret) > params.MaxCodeSize {
err = ErrMaxCodeSizeExceeded
}
}

// Reject code starting with 0xEF if EIP-3541 is enabled.
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require (
github.com/fatih/color v1.17.0
github.com/ferranbt/fastssz v0.1.2
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e
github.com/fjl/memsize v0.0.2
github.com/fsnotify/fsnotify v1.7.0
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
github.com/gofrs/flock v0.8.1
Expand Down Expand Up @@ -101,7 +100,7 @@ require (
golang.org/x/text v0.16.0
golang.org/x/time v0.5.0
golang.org/x/tools v0.22.0
google.golang.org/grpc v1.64.0
google.golang.org/grpc v1.64.1
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,6 @@ github.com/ferranbt/fastssz v0.1.2 h1:Dky6dXlngF6Qjc+EfDipAkE83N5I5DE68bY6O0VLNP
github.com/ferranbt/fastssz v0.1.2/go.mod h1:X5UPrE2u1UJjxHA8X54u04SBwdAQjG2sFtWs39YxyWs=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e h1:bBLctRc7kr01YGvaDfgLbTwjFNW5jdp5y5rj8XXBHfY=
github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA=
github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
github.com/flosch/pongo2/v4 v4.0.2/go.mod h1:B5ObFANs/36VwxxlgKpdchIJHMvHB562PW+BWPhwZD8=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
Expand Down Expand Up @@ -3219,8 +3218,8 @@ google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGO
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
Expand Down
12 changes: 4 additions & 8 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/exp"
"github.com/fjl/memsize/memsizeui"
colorable "github.com/mattn/go-colorable"
isatty "github.com/mattn/go-isatty"
cli "github.com/urfave/cli/v2"
lumberjack "gopkg.in/natefinch/lumberjack.v2"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/urfave/cli/v2"
"gopkg.in/natefinch/lumberjack.v2"
)

var Memsize memsizeui.Handler

var (
verbosityFlag = &cli.IntFlag{
Name: "verbosity",
Expand Down Expand Up @@ -313,7 +310,6 @@ func StartPProf(address string, withMetrics bool) {
if withMetrics {
exp.Exp(metrics.DefaultRegistry)
}
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
go func() {
if err := http.ListenAndServe(address, nil); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ type BorConfig struct {
DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi)
IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore)
StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to`
AhmedabadBlock *big.Int `json:"ahmedabadBlock"` // Ahmedabad switch block (nil = no fork, 0 = already on ahmedabad)
}

// String implements the stringer interface, returning the consensus engine details.
Expand Down Expand Up @@ -714,6 +715,10 @@ func (c *BorConfig) CalculateStateSyncDelay(number uint64) uint64 {
return borKeyValueConfigHelper(c.StateSyncConfirmationDelay, number)
}

func (c *BorConfig) IsAhmedabad(number *big.Int) bool {
return isBlockForked(c.AhmedabadBlock, number)
}

// // TODO: modify this function once the block number is finalized
// func (c *BorConfig) IsNapoli(number *big.Int) bool {
// if c.NapoliBlock != nil {
Expand Down
5 changes: 3 additions & 2 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ const (
DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks.
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.

MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
MaxCodeSizePostAhmedabad = 32768 // Maximum bytecode to permit for a contract post Ahmedabad hard fork (bor / polygon pos) (32KB)
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions

// Precompiled contract gas prices

Expand Down

0 comments on commit 8c14f12

Please sign in to comment.