Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/audit_bnb21
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-reorg authored Nov 9, 2023
2 parents 03d021c + 8b9d5f9 commit 960d838
Show file tree
Hide file tree
Showing 24 changed files with 2,167 additions and 123 deletions.
10 changes: 6 additions & 4 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
---
name: Report a bug
about: Something with go-ethereum is not working as expected
about: Something with opBNB is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

Geth version: `geth version`
CL client & version: e.g. lighthouse/nimbus/[email protected]
Network: `mainnet`/`testnet`/`local`

if you are running a local node, please provide the following information:
op-node version: `op-node version`
op-geth version: `op-geth -v`
OS & Version: Windows/Linux/OSX
Commit hash : (if `develop`)

#### Expected behaviour

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 @@ -6,4 +6,4 @@ labels: 'type:docs'
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 use [discord](https://discord.gg/nthXNEv) or the Ethereum stack exchange at https://ethereum.stackexchange.com.
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 use [discord](https://discord.gg/bnbchain).
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Description

add a description of your changes here...

### Rationale

tell us why we need these changes...

### Example

add an example CLI or API response...

### Changes

Notable changes:
* add each change in a bullet point here
* ...
14 changes: 14 additions & 0 deletions .github/workflows/review-assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Review Assign

on:
pull_request_target:
types: [opened, ready_for_review]

jobs:
assign:
runs-on: ubuntu-latest
steps:
- uses: hkusu/review-assign-action@v1
with:
reviewers: ${{ vars.REVIEWERS }}
max-num-of-reviewers: 2
18 changes: 18 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Unit Test

on:
pull_request:
types: [ opened, synchronize, reopened ]
push:
branches: [main, develop]

jobs:
unit_test:
name: unit_test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.21.3'
- run: make test
72 changes: 72 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Changelog

## v0.2.1

This is the Fermat Hardfork release for opBNB Mainnet.
It will be activated at block height 9397477, expected to occur on November 28, 2023, at 6 AM UTC.

All mainnet nodes must upgrade to this release before the hardfork.
Upgrading for other networks is optional.

### User Facing Changes

NA

### Partial Changelog

- #30: feat: add opbnb mainnet Fermat fork height

### Docker Images

- ghcr.io/bnb-chain/op-geth:v0.2.1

### Full Changelog

https://github.com/bnb-chain/op-geth/compare/v0.2.0...v0.2.1

## v0.2.0

This is a hardfork release for the opBNB Testnet called Fermat.
It will be activated at block height 12113000, expected to occur on November 3, 2023, at 6 AM UTC.

### User Facing Changes

- Two new precompiled contracts have been introduced: blsSignatureVerify and cometBFTLightBlockValidate. The purpose of blsSignatureVerify is to verify BLS signatures in smart contracts, while cometBFTLightBlockValidate is designed to validate cometBFT light blocks. Although these contracts were primarily introduced to facilitate cross-chain communication between opBNB and Greenfield, they can also be utilized for other purposes. For instance, blsSignatureVerify can be employed to verify BLS signatures in smart contracts, and cometBFTLightBlockValidate can facilitate cross-chain communication with other blockchains based on the cosmos framework.(#7)
- Enable the layer 2 sync mechanism for opBNB by using the flag `--syncmode=snap` or `--syncmode=full` to choose the sync mode. Make sure to enable the `l2.engine-sync=true` flag on the op-node. (#8)

### Partial Changelog

- #7: feat: add precompiled contracts for Greenfield link
- #8: feat: support snap sync for OP chains
- #11: fix: pass a SnapshotOption func when init a new pruner
- #24: snap: fix snap-tests to handle legacy code lookups
- #25: sec: update version of cometbft

### Docker Images

- ghcr.io/bnb-chain/op-geth:v0.2.0

### Full Changelog

https://github.com/bnb-chain/op-geth/compare/v0.1.3...v0.2.0

## v0.1.3

This release adds the preDeployedContract hardfork, which changes the name and symbol of the preDeployed contract WBNB(0x4200000000000000000000000000000000000006). It also removes the preDeployed contract GovernanceToken(0x4200000000000000000000000000000000000042).

### Changelog

- ci: add docker release workflow to build and release docker image #3
- feat: add preDeployedContract hardfork #5

## v0.1.2

This is the initial release for opBNB Testnet.

The repo base is [optimism op-geth](https://github.com/ethereum-optimism/op-geth).

### Changelog

1. [perf: concurrency and memory improvements for execution layer](https://github.com/bnb-chain/op-geth/commit/f80e72bcd2b00f738326e37c96ae150dbc9fa4d4)
2. [perf: op-node related api improvement](https://github.com/bnb-chain/op-geth/commit/0d9dc40a39242130e71621e081640935afc23a0a)
3. [feat: reannounce local pending transactions](https://github.com/bnb-chain/op-geth/pull/2)
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ARG BUILDNUM=""
# Build Geth in a stock Go builder container
FROM golang:1.20-alpine as builder

RUN apk add --no-cache build-base libc-dev
RUN apk add --no-cache gcc musl-dev linux-headers git

# Get dependencies - will also be cached if we won't change go.mod/go.sum
Expand Down
7 changes: 7 additions & 0 deletions accounts/abi/bind/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,13 @@ func TestGolangBindings(t *testing.T) {
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace binding test dependency to current source tree: %v\n%s", err, out)
}

replacer = exec.Command(gocmd, "mod", "edit", "-x", "-require", "github.com/cometbft/[email protected]", "-replace", "github.com/cometbft/cometbft=github.com/bnb-chain/[email protected]") // Repo root
replacer.Dir = pkg
if out, err := replacer.CombinedOutput(); err != nil {
t.Fatalf("failed to replace cometbft dependency to bnb-chain source: %v\n%s", err, out)
}

tidier := exec.Command(gocmd, "mod", "tidy")
tidier.Dir = pkg
if out, err := tidier.CombinedOutput(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/devp2p/internal/ethtest/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ func (s *Suite) TestSnapGetByteCodes(t *utesting.T) {
// A few stateroots
{
nBytes: 10000, hashes: []common.Hash{s.chain.RootAt(0), s.chain.RootAt(999)},
expHashes: 0,
expHashes: 1, // 32-byte keys are detected as code, even if not code (like genesis hash), in legacy lookups.
},
{
nBytes: 10000, hashes: []common.Hash{s.chain.RootAt(0), s.chain.RootAt(0)},
expHashes: 0,
expHashes: 2, // 32-byte keys are detected as code, even if not code (like genesis hash), in legacy lookups.
},
// Empties
{
Expand Down
13 changes: 10 additions & 3 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"os"
"time"

cli "github.com/urfave/cli/v2"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
Expand All @@ -35,7 +37,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
cli "github.com/urfave/cli/v2"
)

var (
Expand Down Expand Up @@ -173,8 +174,14 @@ func pruneState(ctx *cli.Context) error {
Cachedir: stack.ResolvePath(config.Eth.TrieCleanCacheJournal),
BloomSize: ctx.Uint64(utils.BloomFilterSizeFlag.Name),
}
pruner, err := pruner.NewPruner(chaindb, prunerconfig,
pruner.WithTriesInMemory(ctx.Uint64(utils.TriesInMemoryFlag.Name)))
pruner, err := pruner.NewPruner(chaindb, prunerconfig, pruner.CombinedOptions{
PrunerOptions: []pruner.PrunerOption{
pruner.WithTriesInMemory(ctx.Uint64(utils.TriesInMemoryFlag.Name)),
},
SnapshotOptions: []snapshot.SnapshotOption{
snapshot.SetCapLimit(int(ctx.Uint64(utils.TriesInMemoryFlag.Name))),
},
})
if err != nil {
log.Error("Failed to open snapshot tree", "err", err)
return err
Expand Down
9 changes: 8 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
// chain config as that would be AllProtocolChanges (applying any new fork
// on top of an existing private network genesis block). In that case, only
// apply the overrides.
if genesis == nil && stored != params.MainnetGenesisHash {
if genesis == nil && stored != params.MainnetGenesisHash && stored != params.OPBNBMainNetGenesisHash &&
stored != params.OPBNBTestNetGenesisHash && stored != params.OPBNBDevNetGenesisHash {
newcfg = storedcfg
applyOverrides(newcfg)
}
Expand Down Expand Up @@ -453,6 +454,12 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.RinkebyChainConfig
case ghash == params.GoerliGenesisHash:
return params.GoerliChainConfig
case ghash == params.OPBNBMainNetGenesisHash:
return params.OPBNBMainNetConfig
case ghash == params.OPBNBTestNetGenesisHash:
return params.OPBNBTestNetConfig
case ghash == params.OPBNBDevNetGenesisHash:
return params.OPBNBDevNetConfig
default:
return params.AllEthashProtocolChanges
}
Expand Down
18 changes: 14 additions & 4 deletions core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ type Pruner struct {
triesInMemory uint64
}

type CombinedOptions struct {
PrunerOptions []PrunerOption
SnapshotOptions []snapshot.SnapshotOption
}

// NewPruner creates the pruner instance.
func NewPruner(db ethdb.Database, config Config, opts ...PrunerOption) (*Pruner, error) {
func NewPruner(db ethdb.Database, config Config, opts CombinedOptions) (*Pruner, error) {
headBlock := rawdb.ReadHeadBlock(db)
if headBlock == nil {
return nil, errors.New("failed to load head block")
Expand All @@ -105,6 +110,11 @@ func NewPruner(db ethdb.Database, config Config, opts ...PrunerOption) (*Pruner,
AsyncBuild: false,
}
snaptree, err := snapshot.New(snapconfig, db, trie.NewDatabase(db), headBlock.Root())
for _, snapshotOption := range opts.SnapshotOptions {
if snapshotOption != nil {
snapshotOption(snaptree)
}
}
if err != nil {
return nil, err // The relevant snapshot(s) might not exist
}
Expand All @@ -125,9 +135,9 @@ func NewPruner(db ethdb.Database, config Config, opts ...PrunerOption) (*Pruner,
snaptree: snaptree,
triesInMemory: core.TriesInMemory,
}
for _, opt := range opts {
if opt != nil {
opt(pruner)
for _, prunerOption := range opts.PrunerOptions {
if prunerOption != nil {
prunerOption(pruner)
}
}
return pruner, nil
Expand Down
Loading

0 comments on commit 960d838

Please sign in to comment.