Skip to content

Commit

Permalink
Merge branch 'develop' into krish/p2p_sync
Browse files Browse the repository at this point in the history
  • Loading branch information
krish-nr authored Oct 18, 2023
2 parents 7f16649 + e7cb32f commit d792c9f
Show file tree
Hide file tree
Showing 20 changed files with 2,095 additions and 142 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/prysm@v1.0.0
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
* ...
41 changes: 18 additions & 23 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: DockerImage build and push

on:
workflow_dispatch:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*
branches:
- develop
- main
tags: '*'

jobs:
# Push image to GitHub Packages.
push-op-geth:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v3
Expand All @@ -22,28 +23,22 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ImageId
id: image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/op-geth
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo "IMAGE_ID=$IMAGE_ID">>$GITHUB_OUTPUT
echo "VERSION=$VERSION">>$GITHUB_OUTPUT
- name: image meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/op-geth
tags: |
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{version}}
type=sha
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.image.outputs.IMAGE_ID }}:${{ steps.image.outputs.VERSION }},${{ steps.image.outputs.IMAGE_ID }}:latest
cache-from: type=registry,ref=${{ steps.image.outputs.IMAGE_ID }}:buildcache
cache-to: type=registry,ref=${{ steps.image.outputs.IMAGE_ID }}:buildcache,mode=max

tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
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
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/cometbft@v0.37.2", "-replace", "github.com/cometbft/cometbft=github.com/bnb-chain/greenfield-cometbft@v1.0.0") // 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
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 d792c9f

Please sign in to comment.