good morning!!!!

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • github/maticnetwork/bor
  • open/bor
2 results
Show changes
Showing
with 916 additions and 49 deletions
...@@ -11,11 +11,11 @@ import ( ...@@ -11,11 +11,11 @@ import (
"time" "time"
"github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/command/server/proto"
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/tracers" "github.com/ethereum/go-ethereum/eth/tracers"
"github.com/ethereum/go-ethereum/ethstats" "github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/graphql" "github.com/ethereum/go-ethereum/graphql"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/metrics/influxdb" "github.com/ethereum/go-ethereum/metrics/influxdb"
...@@ -38,10 +38,13 @@ type Server struct { ...@@ -38,10 +38,13 @@ type Server struct {
backend *eth.Ethereum backend *eth.Ethereum
grpcServer *grpc.Server grpcServer *grpc.Server
tracer *sdktrace.TracerProvider tracer *sdktrace.TracerProvider
config *Config
} }
func NewServer(config *Config) (*Server, error) { func NewServer(config *Config) (*Server, error) {
srv := &Server{} srv := &Server{
config: config,
}
// start the logger // start the logger
setupLogger(config.LogLevel) setupLogger(config.LogLevel)
...@@ -66,11 +69,22 @@ func NewServer(config *Config) (*Server, error) { ...@@ -66,11 +69,22 @@ func NewServer(config *Config) (*Server, error) {
} }
srv.node = stack srv.node = stack
// setup account manager (only keystore)
{
keydir := stack.KeyStoreDir()
n, p := keystore.StandardScryptN, keystore.StandardScryptP
if config.Accounts.UseLightweightKDF {
n, p = keystore.LightScryptN, keystore.LightScryptP
}
stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p))
}
// register the ethereum backend // register the ethereum backend
ethCfg, err := config.buildEth() ethCfg, err := config.buildEth(stack)
if err != nil { if err != nil {
return nil, err return nil, err
} }
backend, err := eth.New(stack, ethCfg) backend, err := eth.New(stack, ethCfg)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -82,7 +96,7 @@ func NewServer(config *Config) (*Server, error) { ...@@ -82,7 +96,7 @@ func NewServer(config *Config) (*Server, error) {
// graphql is started from another place // graphql is started from another place
if config.JsonRPC.Graphql.Enabled { if config.JsonRPC.Graphql.Enabled {
if err := graphql.New(stack, backend.APIBackend, config.JsonRPC.Cors, config.JsonRPC.Modules); err != nil { if err := graphql.New(stack, backend.APIBackend, config.JsonRPC.Cors, config.JsonRPC.VHost); err != nil {
return nil, fmt.Errorf("failed to register the GraphQL service: %v", err) return nil, fmt.Errorf("failed to register the GraphQL service: %v", err)
} }
} }
...@@ -94,18 +108,8 @@ func NewServer(config *Config) (*Server, error) { ...@@ -94,18 +108,8 @@ func NewServer(config *Config) (*Server, error) {
} }
} }
// setup account manager (only keystore) // sealing (if enabled) or in dev mode
{ if config.Sealer.Enabled || config.Developer.Enabled {
keydir := stack.KeyStoreDir()
n, p := keystore.StandardScryptN, keystore.StandardScryptP
if config.Accounts.UseLightweightKDF {
n, p = keystore.LightScryptN, keystore.LightScryptP
}
stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p))
}
// sealing (if enabled)
if config.Sealer.Enabled {
if err := backend.StartMining(1); err != nil { if err := backend.StartMining(1); err != nil {
return nil, err return nil, err
} }
......
package server
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestServer_DeveloperMode(t *testing.T) {
// get the default config
config := DefaultConfig()
// enable developer mode
config.Developer.Enabled = true
config.Developer.Period = 2 // block time
// start the server
server, err1 := NewServer(config)
if err1 != nil {
t.Fatalf("failed to start server: %v", err1)
}
// record the initial block number
blockNumber := server.backend.BlockChain().CurrentBlock().Header().Number.Int64()
var i int64 = 0
for i = 0; i < 10; i++ {
// We expect the node to mine blocks every `config.Developer.Period` time period
time.Sleep(time.Duration(config.Developer.Period) * time.Second)
currBlock := server.backend.BlockChain().CurrentBlock().Header().Number.Int64()
expected := blockNumber + i + 1
if res := assert.Equal(t, currBlock, expected); res == false {
break
}
}
// stop the server
server.Stop()
}
...@@ -2,21 +2,28 @@ package server ...@@ -2,21 +2,28 @@ package server
import ( import (
"context" "context"
"encoding/hex"
"fmt" "fmt"
"math/big"
"reflect"
"strings" "strings"
"github.com/ethereum/go-ethereum/command/server/pprof" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/command/server/proto" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/cli/server/pprof"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enode"
gproto "github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
grpc_net_conn "github.com/mitchellh/go-grpc-net-conn"
) )
func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.PprofResponse, error) { func (s *Server) Pprof(req *proto.PprofRequest, stream proto.Bor_PprofServer) error {
var payload []byte var payload []byte
var headers map[string]string var headers map[string]string
var err error var err error
ctx := context.Background()
switch req.Type { switch req.Type {
case proto.PprofRequest_CPU: case proto.PprofRequest_CPU:
payload, headers, err = pprof.CPUProfile(ctx, int(req.Seconds)) payload, headers, err = pprof.CPUProfile(ctx, int(req.Seconds))
...@@ -26,14 +33,42 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr ...@@ -26,14 +33,42 @@ func (s *Server) Pprof(ctx context.Context, req *proto.PprofRequest) (*proto.Ppr
payload, headers, err = pprof.Profile(req.Profile, 0, 0) payload, headers, err = pprof.Profile(req.Profile, 0, 0)
} }
if err != nil { if err != nil {
return nil, err return err
} }
resp := &proto.PprofResponse{ // open the stream and send the headers
Payload: hex.EncodeToString(payload), err = stream.Send(&proto.PprofResponse{
Headers: headers, Event: &proto.PprofResponse_Open_{
Open: &proto.PprofResponse_Open{
Headers: headers,
Size: int64(len(payload)),
},
},
})
if err != nil {
return err
} }
return resp, nil
// Wrap our conn around the response.
conn := &grpc_net_conn.Conn{
Stream: stream,
Request: &proto.PprofResponse_Input{},
Encode: grpc_net_conn.SimpleEncoder(func(msg gproto.Message) *[]byte {
return &msg.(*proto.PprofResponse_Input).Data
}),
}
if _, err := conn.Write(payload); err != nil {
return err
}
// send the eof
err = stream.Send(&proto.PprofResponse{
Event: &proto.PprofResponse_Eof{},
})
if err != nil {
return err
}
return nil
} }
func (s *Server) PeersAdd(ctx context.Context, req *proto.PeersAddRequest) (*proto.PeersAddResponse, error) { func (s *Server) PeersAdd(ctx context.Context, req *proto.PeersAddRequest) (*proto.PeersAddResponse, error) {
...@@ -107,3 +142,116 @@ func (s *Server) ChainSetHead(ctx context.Context, req *proto.ChainSetHeadReques ...@@ -107,3 +142,116 @@ func (s *Server) ChainSetHead(ctx context.Context, req *proto.ChainSetHeadReques
s.backend.APIBackend.SetHead(req.Number) s.backend.APIBackend.SetHead(req.Number)
return &proto.ChainSetHeadResponse{}, nil return &proto.ChainSetHeadResponse{}, nil
} }
func (s *Server) Status(ctx context.Context, _ *empty.Empty) (*proto.StatusResponse, error) {
apiBackend := s.backend.APIBackend
syncProgress := apiBackend.SyncProgress()
resp := &proto.StatusResponse{
CurrentHeader: headerToProtoHeader(apiBackend.CurrentHeader()),
CurrentBlock: headerToProtoHeader(apiBackend.CurrentBlock().Header()),
NumPeers: int64(len(s.node.Server().PeersInfo())),
SyncMode: s.config.SyncMode,
Syncing: &proto.StatusResponse_Syncing{
StartingBlock: int64(syncProgress.StartingBlock),
HighestBlock: int64(syncProgress.HighestBlock),
CurrentBlock: int64(syncProgress.CurrentBlock),
},
Forks: gatherForks(s.config.chain.Genesis.Config, s.config.chain.Genesis.Config.Bor),
}
return resp, nil
}
func headerToProtoHeader(h *types.Header) *proto.Header {
return &proto.Header{
Hash: h.Hash().String(),
Number: h.Number.Uint64(),
}
}
var bigIntT = reflect.TypeOf(new(big.Int)).Kind()
// gatherForks gathers all the fork numbers via reflection
func gatherForks(configList ...interface{}) []*proto.StatusResponse_Fork {
var forks []*proto.StatusResponse_Fork
for _, config := range configList {
kind := reflect.TypeOf(config)
for kind.Kind() == reflect.Ptr {
kind = kind.Elem()
}
skip := "DAOForkBlock"
conf := reflect.ValueOf(config).Elem()
for i := 0; i < kind.NumField(); i++ {
// Fetch the next field and skip non-fork rules
field := kind.Field(i)
if strings.Contains(field.Name, skip) {
continue
}
if !strings.HasSuffix(field.Name, "Block") {
continue
}
fork := &proto.StatusResponse_Fork{
Name: strings.TrimSuffix(field.Name, "Block"),
}
val := conf.Field(i)
switch field.Type.Kind() {
case bigIntT:
rule := val.Interface().(*big.Int)
if rule != nil {
fork.Block = rule.Int64()
} else {
fork.Disabled = true
}
case reflect.Uint64:
fork.Block = int64(val.Uint())
default:
continue
}
forks = append(forks, fork)
}
}
return forks
}
func convertBlockToBlockStub(blocks []*types.Block) []*proto.BlockStub {
var blockStubs []*proto.BlockStub
for _, block := range blocks {
blockStub := &proto.BlockStub{
Hash: block.Hash().String(),
Number: block.NumberU64(),
}
blockStubs = append(blockStubs, blockStub)
}
return blockStubs
}
func (s *Server) ChainWatch(req *proto.ChainWatchRequest, reply proto.Bor_ChainWatchServer) error {
chain2HeadChanSize := 10
chain2HeadCh := make(chan core.Chain2HeadEvent, chain2HeadChanSize)
headSub := s.backend.APIBackend.SubscribeChain2HeadEvent(chain2HeadCh)
defer headSub.Unsubscribe()
for {
msg := <-chain2HeadCh
err := reply.Send(&proto.ChainWatchResponse{Type: msg.Type,
Newchain: convertBlockToBlockStub(msg.NewChain),
Oldchain: convertBlockToBlockStub(msg.OldChain),
})
if err != nil {
return err
}
}
}
package server
import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
"github.com/stretchr/testify/assert"
)
func TestGatherBlocks(t *testing.T) {
type c struct {
ABlock *big.Int
BBlock *big.Int
}
type d struct {
DBlock uint64
}
val := &c{
BBlock: new(big.Int).SetInt64(1),
}
val2 := &d{
DBlock: 10,
}
expect := []*proto.StatusResponse_Fork{
{
Name: "A",
Disabled: true,
},
{
Name: "B",
Block: 1,
},
{
Name: "D",
Block: 10,
},
}
res := gatherForks(val, val2)
assert.Equal(t, res, expect)
}
package cli
import (
"context"
"fmt"
"strings"
"github.com/ethereum/go-ethereum/internal/cli/server/proto"
"github.com/golang/protobuf/ptypes/empty"
)
// StatusCommand is the command to output the status of the client
type StatusCommand struct {
*Meta2
}
// Help implements the cli.Command interface
func (p *StatusCommand) Help() string {
return `Usage: bor status
Output the status of the client`
}
// Synopsis implements the cli.Command interface
func (c *StatusCommand) Synopsis() string {
return "Output the status of the client"
}
// Run implements the cli.Command interface
func (c *StatusCommand) Run(args []string) int {
flags := c.NewFlagSet("status")
if err := flags.Parse(args); err != nil {
c.UI.Error(err.Error())
return 1
}
borClt, err := c.BorConn()
if err != nil {
c.UI.Error(err.Error())
return 1
}
status, err := borClt.Status(context.Background(), &empty.Empty{})
if err != nil {
c.UI.Error(err.Error())
return 1
}
c.UI.Output(printStatus(status))
return 0
}
func printStatus(status *proto.StatusResponse) string {
printHeader := func(h *proto.Header) string {
return formatKV([]string{
fmt.Sprintf("Hash|%s", h.Hash),
fmt.Sprintf("Number|%d", h.Number),
})
}
forks := make([]string, len(status.Forks)+1)
forks[0] = "Name|Block|Enabled"
for i, d := range status.Forks {
forks[i+1] = fmt.Sprintf("%s|%d|%v", d.Name, d.Block, !d.Disabled)
}
full := []string{
"General",
formatKV([]string{
fmt.Sprintf("Num peers|%d", status.NumPeers),
fmt.Sprintf("Sync mode|%s", status.SyncMode),
}),
"\nCurrent Header",
printHeader(status.CurrentHeader),
"\nCurrent Block",
printHeader(status.CurrentBlock),
"\nSyncing",
formatKV([]string{
fmt.Sprintf("Current block|%d", status.Syncing.CurrentBlock),
fmt.Sprintf("Highest block|%d", status.Syncing.HighestBlock),
fmt.Sprintf("Starting block|%d", status.Syncing.StartingBlock),
}),
"\nForks",
formatList(forks),
}
return strings.Join(full, "\n")
}
package main package cli
import ( import (
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
......
...@@ -634,7 +634,7 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context, ...@@ -634,7 +634,7 @@ func (s *PublicBlockChainAPI) GetTransactionReceiptsByBlock(ctx context.Context,
} }
if len(txs) != len(receipts) { if len(txs) != len(receipts) {
return nil, fmt.Errorf("txs length doesn't equal to receipts' length", len(txs), len(receipts)) return nil, fmt.Errorf("txs length %d doesn't equal to receipts' length %d", len(txs), len(receipts))
} }
txReceipts := make([]map[string]interface{}, 0, len(txs)) txReceipts := make([]map[string]interface{}, 0, len(txs))
...@@ -1422,10 +1422,12 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber ...@@ -1422,10 +1422,12 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation // newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction { func newRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction {
var baseFee *big.Int var baseFee *big.Int
blockNumber := uint64(0)
if current != nil { if current != nil {
baseFee = misc.CalcBaseFee(config, current) baseFee = misc.CalcBaseFee(config, current)
blockNumber = current.Number.Uint64()
} }
return newRPCTransaction(tx, common.Hash{}, 0, 0, baseFee, config) return newRPCTransaction(tx, common.Hash{}, blockNumber, 0, baseFee, config)
} }
// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation. // newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
......
...@@ -98,6 +98,7 @@ type Backend interface { ...@@ -98,6 +98,7 @@ type Backend interface {
GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error)
GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) GetBorBlockTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error)
SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription
ChainConfig() *params.ChainConfig ChainConfig() *params.ChainConfig
Engine() consensus.Engine Engine() consensus.Engine
......
...@@ -31,7 +31,7 @@ func (s *PublicBlockChainAPI) appendRPCMarshalBorTransaction(ctx context.Context ...@@ -31,7 +31,7 @@ func (s *PublicBlockChainAPI) appendRPCMarshalBorTransaction(ctx context.Context
if borTx != nil { if borTx != nil {
formattedTxs := fields["transactions"].([]interface{}) formattedTxs := fields["transactions"].([]interface{})
if fullTx { if fullTx {
marshalledTx := newRPCTransaction(borTx, blockHash, blockNumber, txIndex, nil, s.b.ChainConfig()) marshalledTx := newRPCTransaction(borTx, blockHash, blockNumber, txIndex, block.BaseFee(), s.b.ChainConfig())
// newRPCTransaction calculates hash based on RLP of the transaction data. // newRPCTransaction calculates hash based on RLP of the transaction data.
// In case of bor block tx, we need simple derived tx hash (same as function argument) instead of RLP hash // In case of bor block tx, we need simple derived tx hash (same as function argument) instead of RLP hash
marshalledTx.Hash = txHash marshalledTx.Hash = txHash
......
...@@ -17,3 +17,8 @@ func (b *LesApiBackend) GetRootHash(ctx context.Context, starBlockNr uint64, end ...@@ -17,3 +17,8 @@ func (b *LesApiBackend) GetRootHash(ctx context.Context, starBlockNr uint64, end
func (b *LesApiBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription { func (b *LesApiBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
return b.eth.blockchain.SubscribeStateSyncEvent(ch) return b.eth.blockchain.SubscribeStateSyncEvent(ch)
} }
// SubscribeChain2HeadEvent subscribe head/fork/reorg events.
func (b *LesApiBackend) SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription {
return b.eth.BlockChain().SubscribeChain2HeadEvent(ch)
}
...@@ -72,6 +72,9 @@ type LightChain struct { ...@@ -72,6 +72,9 @@ type LightChain struct {
running int32 // whether LightChain is running or stopped running int32 // whether LightChain is running or stopped
procInterrupt int32 // interrupts chain insert procInterrupt int32 // interrupts chain insert
disableCheckFreq int32 // disables header verification disableCheckFreq int32 // disables header verification
// Bor
chain2HeadFeed event.Feed
} }
// NewLightChain returns a fully initialised light chain using information // NewLightChain returns a fully initialised light chain using information
...@@ -561,6 +564,11 @@ func (lc *LightChain) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) ...@@ -561,6 +564,11 @@ func (lc *LightChain) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
return lc.scope.Track(new(event.Feed).Subscribe(ch)) return lc.scope.Track(new(event.Feed).Subscribe(ch))
} }
// SubscribeChain2HeadEvent registers a subscription of Reorg/head/fork events.
func (lc *LightChain) SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription {
return lc.scope.Track(lc.chain2HeadFeed.Subscribe(ch))
}
// DisableCheckFreq disables header validation. This is used for ultralight mode. // DisableCheckFreq disables header validation. This is used for ultralight mode.
func (lc *LightChain) DisableCheckFreq() { func (lc *LightChain) DisableCheckFreq() {
atomic.StoreInt32(&lc.disableCheckFreq, 1) atomic.StoreInt32(&lc.disableCheckFreq, 1)
......
...@@ -155,6 +155,8 @@ public class AndroidTest extends InstrumentationTestCase { ...@@ -155,6 +155,8 @@ public class AndroidTest extends InstrumentationTestCase {
// //
// This method has been adapted from golang.org/x/mobile/bind/java/seq_test.go/runTest // This method has been adapted from golang.org/x/mobile/bind/java/seq_test.go/runTest
func TestAndroid(t *testing.T) { func TestAndroid(t *testing.T) {
t.Skip("Bor: We do not test this")
// Skip tests on Windows altogether // Skip tests on Windows altogether
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
t.Skip("cannot test Android bindings on Windows, skipping") t.Skip("cannot test Android bindings on Windows, skipping")
......
This diff is collapsed.
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
const ( const (
VersionMajor = 0 // Major version component of the current release VersionMajor = 0 // Major version component of the current release
VersionMinor = 2 // Minor version component of the current release VersionMinor = 2 // Minor version component of the current release
VersionPatch = 12 // Patch version component of the current release VersionPatch = 14 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string VersionMeta = "stable" // Version metadata to append to the version string
) )
......
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0/protoc-3.12.0-linux-x86_64.zip #!/bin/bash
sudo unzip protoc-3.12.0-linux-x86_64.zip -d /usr/local/bin
# Install protobuf
PROTOC_ZIP=protoc-3.12.0-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.12.0/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
# Change permissions to use the binary
sudo chmod 755 -R /usr/local/bin/protoc
sudo chmod 755 -R /usr/local/include
# Install golang extensions (DO NOT CHANGE THE VERSIONS)
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0 go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.25.0
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
This diff is collapsed.
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/bor" "github.com/ethereum/go-ethereum/consensus/bor"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
...@@ -111,6 +112,14 @@ func buildNextBlock(t *testing.T, _bor *bor.Bor, chain *core.BlockChain, block * ...@@ -111,6 +112,14 @@ func buildNextBlock(t *testing.T, _bor *bor.Bor, chain *core.BlockChain, block *
copy(header.Extra[32:], validatorBytes) copy(header.Extra[32:], validatorBytes)
} }
if chain.Config().IsLondon(header.Number) {
header.BaseFee = misc.CalcBaseFee(chain.Config(), block.Header())
if !chain.Config().IsLondon(block.Number()) {
parentGasLimit := block.GasLimit() * params.ElasticityMultiplier
header.GasLimit = core.CalcGasLimit(parentGasLimit, parentGasLimit)
}
}
state, err := chain.State() state, err := chain.State()
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
...@@ -119,12 +128,12 @@ func buildNextBlock(t *testing.T, _bor *bor.Bor, chain *core.BlockChain, block * ...@@ -119,12 +128,12 @@ func buildNextBlock(t *testing.T, _bor *bor.Bor, chain *core.BlockChain, block *
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
sign(t, header, signer) sign(t, header, signer, borConfig)
return types.NewBlockWithHeader(header) return types.NewBlockWithHeader(header)
} }
func sign(t *testing.T, header *types.Header, signer []byte) { func sign(t *testing.T, header *types.Header, signer []byte, c *params.BorConfig) {
sig, err := secp256k1.Sign(crypto.Keccak256(bor.BorRLP(header)), signer) sig, err := secp256k1.Sign(crypto.Keccak256(bor.BorRLP(header, c)), signer)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
......