Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/bsc' into bsc-validator-support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry123 committed Dec 17, 2021
2 parents 798076d + 6ebcb28 commit 7b07e99
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
1 change: 1 addition & 0 deletions consensus/misc/eip1559_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func config() *params.ChainConfig {

// TestBlockGasLimits tests the gasLimit checks for blocks both across
// the EIP-1559 boundary and post-1559 blocks
// TODO: "this test won't work for BSC because it has another GasLimitBoundDivisor"
func TestBlockGasLimits(t *testing.T) {
initial := new(big.Int).SetUint64(params.InitialBaseFee)

Expand Down
9 changes: 4 additions & 5 deletions core/systemcontracts/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const (
)

var (
GenesisHash common.Hash
//upgrade config
ramanujanUpgrade = make(map[string]*Upgrade)

Expand Down Expand Up @@ -317,13 +316,13 @@ func UpgradeBuildInSystemContract(config *params.ChainConfig, blockNumber *big.I
return
}
var network string
switch GenesisHash {
switch config.ChainName {
/* Add mainnet genesis hash */
case params.BSCGenesisHash:
case params.BSCChainName:
network = mainNet
case params.ChapelGenesisHash:
case params.ChapelChainName:
network = chapelNet
case params.RialtoGenesisHash:
case params.RialtoChainName:
network = rialtoNet
default:
network = defaultNet
Expand Down
9 changes: 7 additions & 2 deletions core/vm/eips.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ import (
)

var activators = map[int]func(*JumpTable){
//3529: enable3529,
//3198: enable3198,
3529: enable3529,
3198: enable3198,
2929: enable2929,
2200: enable2200,
1884: enable1884,
1344: enable1344,
}

func ApplyBinanceSmartChainEIPs() {
delete(activators, 3529)
delete(activators, 3198)
}

// EnableEIP enables the given EIP on the config.
// This operation writes in-place, and callers need to ensure that the globally
// defined jump tables are not polluted.
Expand Down
17 changes: 11 additions & 6 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"context"
"errors"
"fmt"
"github.com/ledgerwatch/erigon/consensus/parlia"
"github.com/ledgerwatch/erigon/core/systemcontracts"
"math/big"
"os"
"path"
Expand All @@ -46,6 +44,12 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/remotedbserver"
txpool2 "github.com/ledgerwatch/erigon-lib/txpool"
"github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
"github.com/ledgerwatch/log/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/ledgerwatch/erigon/consensus/parlia"

"github.com/ledgerwatch/erigon/cmd/rpcdaemon/interfaces"
"github.com/ledgerwatch/erigon/cmd/sentry/download"
"github.com/ledgerwatch/erigon/common"
Expand All @@ -71,9 +75,6 @@ import (
"github.com/ledgerwatch/erigon/turbo/shards"
"github.com/ledgerwatch/erigon/turbo/snapshotsync"
stages2 "github.com/ledgerwatch/erigon/turbo/stages"
"github.com/ledgerwatch/log/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
)

// Config contains the configuration options of the ETH protocol.
Expand Down Expand Up @@ -170,7 +171,11 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
}
types.SetHeaderSealFlag(chainConfig.IsHeaderWithSeal())
log.Info("Initialised chain configuration", "config", chainConfig, "genesis", genesis.Hash())
systemcontracts.GenesisHash = genesis.Hash()
// Apply special hacks for BSC params
if chainConfig.Parlia != nil {
params.ApplyBinanceSmartChainParams()
vm.ApplyBinanceSmartChainEIPs()
}

ctx, ctxCancel := context.WithCancel(context.Background())
kvRPC := remotedbserver.NewKvServer(ctx, chainKv)
Expand Down
14 changes: 11 additions & 3 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ package params

import "math/big"

// GasLimitBoundDivisor it can be changed by BSC
var (
GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations.
)

const (
GasLimitBoundDivisor uint64 = 256 // The bound divisor of the gas limit, used in update calculations.
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.
MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be.
GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block.

MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis.
ForkIDSize uint64 = 4 // The length of fork id
Expand Down Expand Up @@ -172,3 +176,7 @@ var (
MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be.
DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
)

func ApplyBinanceSmartChainParams() {
GasLimitBoundDivisor = 256
}
5 changes: 3 additions & 2 deletions turbo/stages/headerdownload/header_algos.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"time"

"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/log/v3"

"github.com/ledgerwatch/erigon/cmd/rpcdaemon/interfaces"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/dbutils"
Expand All @@ -27,7 +29,6 @@ import (
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/log/v3"
)

// Implements sort.Interface so we can sort the incoming header in the message by block height
Expand Down Expand Up @@ -485,7 +486,7 @@ func InitPreverifiedHashes(chain string) (map[common.Hash]struct{}, uint64) {
encodings = ropstenPreverifiedHashes
height = ropstenPreverifiedHeight
default:
log.Warn("Preverified hashes not found for", "chain", chain)
log.Trace("Preverified hashes not found for", "chain", chain)
return nil, 0
}
return DecodeHashes(encodings), height
Expand Down

0 comments on commit 7b07e99

Please sign in to comment.