parlia: reject header with non-nil WithdrawalsHash
(#1884)
* parlia: reject header with `WithdrawalsHash` before shanghai fork * log: output chainconfig when start up * eth: fix TestOptionMaxPeersPerIP failure of goroutine order
This commit is contained in:
parent
41f0667ce1
commit
52e2cb86a5
@ -262,7 +262,7 @@ func TestT8n(t *testing.T) {
|
|||||||
output: t8nOutput{alloc: true, result: true},
|
output: t8nOutput{alloc: true, result: true},
|
||||||
expOut: "exp.json",
|
expOut: "exp.json",
|
||||||
},
|
},
|
||||||
// TODO: Cancun not ready
|
// TODO(Nathan): Cancun not ready
|
||||||
/*
|
/*
|
||||||
{ // Cancun tests
|
{ // Cancun tests
|
||||||
base: "./testdata/28",
|
base: "./testdata/28",
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0"
|
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 parlia:1.0 rpc:1.0 txpool:1.0 web3:1.0"
|
||||||
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
|
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -539,15 +539,16 @@ var (
|
|||||||
Category: flags.MinerCategory,
|
Category: flags.MinerCategory,
|
||||||
}
|
}
|
||||||
MinerDelayLeftoverFlag = &cli.DurationFlag{
|
MinerDelayLeftoverFlag = &cli.DurationFlag{
|
||||||
Name: "miner.delayleftover",
|
Name: "miner.delayleftover",
|
||||||
Usage: "Time reserved to finalize a block",
|
Usage: "Time reserved to finalize a block",
|
||||||
Value: ethconfig.Defaults.Miner.DelayLeftOver,
|
Value: ethconfig.Defaults.Miner.DelayLeftOver,
|
||||||
|
Category: flags.MinerCategory,
|
||||||
}
|
}
|
||||||
MinerNewPayloadTimeout = &cli.DurationFlag{
|
MinerNewPayloadTimeout = &cli.DurationFlag{
|
||||||
Name: "miner.newpayload-timeout",
|
Name: "miner.newpayload-timeout",
|
||||||
Usage: "Specify the maximum time allowance for creating a new payload",
|
Usage: "Specify the maximum time allowance for creating a new payload",
|
||||||
Value: ethconfig.Defaults.Miner.NewPayloadTimeout,
|
Value: ethconfig.Defaults.Miner.NewPayloadTimeout,
|
||||||
Category: flags.MinerCategory,
|
// Category: flags.MinerCategory,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account settings
|
// Account settings
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
cmath "github.com/ethereum/go-ethereum/common/math"
|
cmath "github.com/ethereum/go-ethereum/common/math"
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
"github.com/ethereum/go-ethereum/consensus"
|
||||||
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
"github.com/ethereum/go-ethereum/consensus/misc/eip1559"
|
||||||
|
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/forkid"
|
"github.com/ethereum/go-ethereum/core/forkid"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
@ -566,6 +567,24 @@ func (p *Parlia) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify existence / non-existence of withdrawalsHash.
|
||||||
|
if header.WithdrawalsHash != nil {
|
||||||
|
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
||||||
|
}
|
||||||
|
// Verify the existence / non-existence of excessBlobGas
|
||||||
|
cancun := chain.Config().IsCancun(header.Number, header.Time)
|
||||||
|
if !cancun && header.ExcessBlobGas != nil {
|
||||||
|
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||||
|
}
|
||||||
|
if !cancun && header.BlobGasUsed != nil {
|
||||||
|
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
|
||||||
|
}
|
||||||
|
if cancun {
|
||||||
|
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// All basic checks passed, verify cascading fields
|
// All basic checks passed, verify cascading fields
|
||||||
return p.verifyCascadingFields(chain, header, parents)
|
return p.verifyCascadingFields(chain, header, parents)
|
||||||
}
|
}
|
||||||
@ -1924,7 +1943,7 @@ func applyMessage(
|
|||||||
chainConfig *params.ChainConfig,
|
chainConfig *params.ChainConfig,
|
||||||
chainContext core.ChainContext,
|
chainContext core.ChainContext,
|
||||||
) (uint64, error) {
|
) (uint64, error) {
|
||||||
// TODO: state.Prepare should be called here, now accessList related EIP not affect systemtxs
|
// TODO(Nathan): state.Prepare should be called here, now accessList related EIP not affect systemtxs
|
||||||
// EIP1153 may cause a critical issue in the future
|
// EIP1153 may cause a critical issue in the future
|
||||||
// Create a new context to be used in the EVM environment
|
// Create a new context to be used in the EVM environment
|
||||||
context := core.NewEVMBlockContext(header, chainContext, nil)
|
context := core.NewEVMBlockContext(header, chainContext, nil)
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -291,13 +290,17 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||||||
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
||||||
return nil, genesisErr
|
return nil, genesisErr
|
||||||
}
|
}
|
||||||
log.Info("")
|
log.Info("Initialised chain configuration", "config", chainConfig)
|
||||||
log.Info(strings.Repeat("-", 153))
|
// Description of chainConfig is empty now
|
||||||
for _, line := range strings.Split(chainConfig.Description(), "\n") {
|
/*
|
||||||
log.Info(line)
|
log.Info("")
|
||||||
}
|
log.Info(strings.Repeat("-", 153))
|
||||||
log.Info(strings.Repeat("-", 153))
|
for _, line := range strings.Split(chainConfig.Description(), "\n") {
|
||||||
log.Info("")
|
log.Info(line)
|
||||||
|
}
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
log.Info("")
|
||||||
|
*/
|
||||||
|
|
||||||
bc := &BlockChain{
|
bc := &BlockChain{
|
||||||
chainConfig: chainConfig,
|
chainConfig: chainConfig,
|
||||||
|
@ -66,8 +66,8 @@ type Genesis struct {
|
|||||||
GasUsed uint64 `json:"gasUsed"`
|
GasUsed uint64 `json:"gasUsed"`
|
||||||
ParentHash common.Hash `json:"parentHash"`
|
ParentHash common.Hash `json:"parentHash"`
|
||||||
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
|
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
|
||||||
ExcessBlobGas *uint64 `json:"excessBlobGas,omitempty" toml:",omitempty"` // EIP-4844, TODO: remove tag `omitempty` after cancun fork
|
ExcessBlobGas *uint64 `json:"excessBlobGas,omitempty" toml:",omitempty"` // EIP-4844, TODO(Nathan): remove tag `omitempty` after cancun fork
|
||||||
BlobGasUsed *uint64 `json:"blobGasUsed,omitempty" toml:",omitempty"` // EIP-4844, TODO: remove tag `omitempty` after cancun fork
|
BlobGasUsed *uint64 `json:"blobGasUsed,omitempty" toml:",omitempty"` // EIP-4844, TODO(Nathan): remove tag `omitempty` after cancun fork
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadGenesis(db ethdb.Database) (*Genesis, error) {
|
func ReadGenesis(db ethdb.Database) (*Genesis, error) {
|
||||||
|
@ -366,9 +366,7 @@ func (dl *diskLayer) generateRange(ctx *generatorContext, trieId *trie.ID, prefi
|
|||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
if nodes != nil {
|
if nodes != nil {
|
||||||
// TODO(Nathan): why block is zero?
|
tdb.Update(root, types.EmptyRootHash, 0, trienode.NewWithNodeSet(nodes), nil)
|
||||||
block := uint64(0)
|
|
||||||
tdb.Update(root, types.EmptyRootHash, block, trienode.NewWithNodeSet(nodes), nil)
|
|
||||||
tdb.Commit(root, false)
|
tdb.Commit(root, false)
|
||||||
}
|
}
|
||||||
resolver = func(owner common.Hash, path []byte, hash common.Hash) []byte {
|
resolver = func(owner common.Hash, path []byte, hash common.Hash) []byte {
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"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/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var votesManagerCounter = metrics.NewRegisteredCounter("votesManager/local", nil)
|
var votesManagerCounter = metrics.NewRegisteredCounter("votesManager/local", nil)
|
||||||
@ -28,8 +27,7 @@ type Backend interface {
|
|||||||
type VoteManager struct {
|
type VoteManager struct {
|
||||||
eth Backend
|
eth Backend
|
||||||
|
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
chainconfig *params.ChainConfig
|
|
||||||
|
|
||||||
chainHeadCh chan core.ChainHeadEvent
|
chainHeadCh chan core.ChainHeadEvent
|
||||||
chainHeadSub event.Subscription
|
chainHeadSub event.Subscription
|
||||||
@ -45,12 +43,10 @@ type VoteManager struct {
|
|||||||
engine consensus.PoSA
|
engine consensus.PoSA
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVoteManager(eth Backend, chainconfig *params.ChainConfig, chain *core.BlockChain, pool *VotePool, journalPath, blsPasswordPath, blsWalletPath string, engine consensus.PoSA) (*VoteManager, error) {
|
func NewVoteManager(eth Backend, chain *core.BlockChain, pool *VotePool, journalPath, blsPasswordPath, blsWalletPath string, engine consensus.PoSA) (*VoteManager, error) {
|
||||||
voteManager := &VoteManager{
|
voteManager := &VoteManager{
|
||||||
eth: eth,
|
eth: eth,
|
||||||
|
|
||||||
chain: chain,
|
chain: chain,
|
||||||
chainconfig: chainconfig,
|
|
||||||
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
|
||||||
syncVoteCh: make(chan core.NewVoteEvent, voteBufferForPut),
|
syncVoteCh: make(chan core.NewVoteEvent, voteBufferForPut),
|
||||||
pool: pool,
|
pool: pool,
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"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/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,9 +43,8 @@ type VoteBox struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VotePool struct {
|
type VotePool struct {
|
||||||
chain *core.BlockChain
|
chain *core.BlockChain
|
||||||
chainconfig *params.ChainConfig
|
mu sync.RWMutex
|
||||||
mu sync.RWMutex
|
|
||||||
|
|
||||||
votesFeed event.Feed
|
votesFeed event.Feed
|
||||||
scope event.SubscriptionScope
|
scope event.SubscriptionScope
|
||||||
@ -69,10 +67,9 @@ type VotePool struct {
|
|||||||
|
|
||||||
type votesPriorityQueue []*types.VoteData
|
type votesPriorityQueue []*types.VoteData
|
||||||
|
|
||||||
func NewVotePool(chainconfig *params.ChainConfig, chain *core.BlockChain, engine consensus.PoSA) *VotePool {
|
func NewVotePool(chain *core.BlockChain, engine consensus.PoSA) *VotePool {
|
||||||
votePool := &VotePool{
|
votePool := &VotePool{
|
||||||
chain: chain,
|
chain: chain,
|
||||||
chainconfig: chainconfig,
|
|
||||||
receivedVotes: mapset.NewSet[common.Hash](),
|
receivedVotes: mapset.NewSet[common.Hash](),
|
||||||
curVotes: make(map[common.Hash]*VoteBox),
|
curVotes: make(map[common.Hash]*VoteBox),
|
||||||
futureVotes: make(map[common.Hash]*VoteBox),
|
futureVotes: make(map[common.Hash]*VoteBox),
|
||||||
|
@ -160,7 +160,7 @@ func testVotePool(t *testing.T, isValidRules bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create vote pool
|
// Create vote pool
|
||||||
votePool := NewVotePool(params.TestChainConfig, chain, mockEngine)
|
votePool := NewVotePool(chain, mockEngine)
|
||||||
|
|
||||||
// Create vote manager
|
// Create vote manager
|
||||||
// Create a temporary file for the votes journal
|
// Create a temporary file for the votes journal
|
||||||
@ -175,7 +175,7 @@ func testVotePool(t *testing.T, isValidRules bool) {
|
|||||||
file.Close()
|
file.Close()
|
||||||
os.Remove(journal)
|
os.Remove(journal)
|
||||||
|
|
||||||
voteManager, err := NewVoteManager(newTestBackend(), params.TestChainConfig, chain, votePool, journal, walletPasswordDir, walletDir, mockEngine)
|
voteManager, err := NewVoteManager(newTestBackend(), chain, votePool, journal, walletPasswordDir, walletDir, mockEngine)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create vote managers")
|
t.Fatalf("failed to create vote managers")
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
@ -64,7 +63,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config contains the configuration options of the ETH protocol.
|
// Config contains the configuration options of the ETH protocol.
|
||||||
@ -148,21 +146,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, trie.NewDatabase(chainDb), config.Genesis, nil)
|
|
||||||
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
|
||||||
return nil, genesisErr
|
|
||||||
}
|
|
||||||
log.Info("")
|
|
||||||
log.Info(strings.Repeat("-", 153))
|
|
||||||
for _, line := range strings.Split(chainConfig.Description(), "\n") {
|
|
||||||
log.Info(line)
|
|
||||||
}
|
|
||||||
log.Info(strings.Repeat("-", 153))
|
|
||||||
log.Info("")
|
|
||||||
|
|
||||||
if err := pruner.RecoverPruning(stack.ResolvePath(""), chainDb, config.TriesInMemory); err != nil {
|
if err := pruner.RecoverPruning(stack.ResolvePath(""), chainDb, config.TriesInMemory); err != nil {
|
||||||
log.Error("Failed to recover state", "error", err)
|
log.Error("Failed to recover state", "error", err)
|
||||||
}
|
}
|
||||||
|
chainConfig, genesisHash, err := core.LoadChainConfig(chainDb, config.Genesis)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
eth := &Ethereum{
|
eth := &Ethereum{
|
||||||
config: config,
|
config: config,
|
||||||
@ -253,7 +243,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
if config.BlobPool.Datadir != "" {
|
if config.BlobPool.Datadir != "" {
|
||||||
config.BlobPool.Datadir = stack.ResolvePath(config.BlobPool.Datadir)
|
config.BlobPool.Datadir = stack.ResolvePath(config.BlobPool.Datadir)
|
||||||
}
|
}
|
||||||
// TODO: blob is not ready now, it will cause panic.
|
// TODO(Nathan): blob is not ready now, it will cause panic.
|
||||||
// blobPool := blobpool.New(config.BlobPool, eth.blockchain)
|
// blobPool := blobpool.New(config.BlobPool, eth.blockchain)
|
||||||
|
|
||||||
if config.TxPool.Journal != "" {
|
if config.TxPool.Journal != "" {
|
||||||
@ -261,7 +251,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
}
|
}
|
||||||
legacyPool := legacypool.New(config.TxPool, eth.blockchain)
|
legacyPool := legacypool.New(config.TxPool, eth.blockchain)
|
||||||
|
|
||||||
// eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool, blobPool})
|
// TODO(Nathan): eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool, blobPool})
|
||||||
eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool})
|
eth.txPool, err = txpool.New(new(big.Int).SetUint64(config.TxPool.PriceLimit), eth.blockchain, []txpool.SubPool{legacyPool})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -291,7 +281,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
// Create voteManager instance
|
// Create voteManager instance
|
||||||
if posa, ok := eth.engine.(consensus.PoSA); ok {
|
if posa, ok := eth.engine.(consensus.PoSA); ok {
|
||||||
// Create votePool instance
|
// Create votePool instance
|
||||||
votePool := vote.NewVotePool(chainConfig, eth.blockchain, posa)
|
votePool := vote.NewVotePool(eth.blockchain, posa)
|
||||||
eth.votePool = votePool
|
eth.votePool = votePool
|
||||||
if parlia, ok := eth.engine.(*parlia.Parlia); ok {
|
if parlia, ok := eth.engine.(*parlia.Parlia); ok {
|
||||||
if !config.Miner.DisableVoteAttestation {
|
if !config.Miner.DisableVoteAttestation {
|
||||||
@ -313,7 +303,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||||||
blsPasswordPath := stack.ResolvePath(conf.BLSPasswordFile)
|
blsPasswordPath := stack.ResolvePath(conf.BLSPasswordFile)
|
||||||
blsWalletPath := stack.ResolvePath(conf.BLSWalletDir)
|
blsWalletPath := stack.ResolvePath(conf.BLSWalletDir)
|
||||||
voteJournalPath := stack.ResolvePath(conf.VoteJournalDir)
|
voteJournalPath := stack.ResolvePath(conf.VoteJournalDir)
|
||||||
if _, err := vote.NewVoteManager(eth, chainConfig, eth.blockchain, votePool, voteJournalPath, blsPasswordPath, blsWalletPath, posa); err != nil {
|
if _, err := vote.NewVoteManager(eth, eth.blockchain, votePool, voteJournalPath, blsPasswordPath, blsWalletPath, posa); err != nil {
|
||||||
log.Error("Failed to Initialize voteManager", "err", err)
|
log.Error("Failed to Initialize voteManager", "err", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -330,9 +330,9 @@ func (d *Downloader) UnregisterPeer(id string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronise tries to sync up our local blockchain with a remote peer, both
|
// LegacySync tries to sync up our local blockchain with a remote peer, both
|
||||||
// adding various sanity checks and wrapping it with various log entries.
|
// adding various sanity checks and wrapping it with various log entries.
|
||||||
func (d *Downloader) Synchronise(id string, head common.Hash, td *big.Int, ttd *big.Int, mode SyncMode) error {
|
func (d *Downloader) LegacySync(id string, head common.Hash, td *big.Int, ttd *big.Int, mode SyncMode) error {
|
||||||
err := d.synchronise(id, head, td, ttd, mode, false, nil)
|
err := d.synchronise(id, head, td, ttd, mode, false, nil)
|
||||||
|
|
||||||
switch err {
|
switch err {
|
||||||
|
@ -1034,7 +1034,7 @@ func testBlockHeaderAttackerDropping(t *testing.T, protocol uint) {
|
|||||||
// Simulate a synchronisation and check the required result
|
// Simulate a synchronisation and check the required result
|
||||||
tester.downloader.synchroniseMock = func(string, common.Hash) error { return tt.result }
|
tester.downloader.synchroniseMock = func(string, common.Hash) error { return tt.result }
|
||||||
|
|
||||||
tester.downloader.Synchronise(id, tester.chain.Genesis().Hash(), big.NewInt(1000), nil, FullSync)
|
tester.downloader.LegacySync(id, tester.chain.Genesis().Hash(), big.NewInt(1000), nil, FullSync)
|
||||||
if _, ok := tester.peers[id]; !ok != tt.drop {
|
if _, ok := tester.peers[id]; !ok != tt.drop {
|
||||||
t.Errorf("test %d: peer drop mismatch for %v: have %v, want %v", i, tt.result, !ok, tt.drop)
|
t.Errorf("test %d: peer drop mismatch for %v: have %v, want %v", i, tt.result, !ok, tt.drop)
|
||||||
}
|
}
|
||||||
|
@ -797,6 +797,7 @@ func TestOptionMaxPeersPerIP(t *testing.T) {
|
|||||||
defer sink.Close()
|
defer sink.Close()
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
time.Sleep(time.Duration((tryNum-1)*200) * time.Millisecond)
|
||||||
go func(num int) {
|
go func(num int) {
|
||||||
err := handler.handler.runEthPeer(sink, func(peer *eth.Peer) error {
|
err := handler.handler.runEthPeer(sink, func(peer *eth.Peer) error {
|
||||||
wg.Done()
|
wg.Done()
|
||||||
|
@ -242,7 +242,7 @@ func (h *handler) doSync(op *chainSyncOp) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run the sync cycle, and disable snap sync if we're past the pivot block
|
// Run the sync cycle, and disable snap sync if we're past the pivot block
|
||||||
err := h.downloader.Synchronise(op.peer.ID(), op.head, op.td, h.chain.Config().TerminalTotalDifficulty, op.mode)
|
err := h.downloader.LegacySync(op.peer.ID(), op.head, op.td, h.chain.Config().TerminalTotalDifficulty, op.mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package les
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
@ -107,13 +106,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Info("")
|
log.Info("Initialised chain configuration for les.client", "config", chainConfig)
|
||||||
log.Info(strings.Repeat("-", 153))
|
// Description of chainConfig is empty now
|
||||||
for _, line := range strings.Split(chainConfig.Description(), "\n") {
|
/*
|
||||||
log.Info(line)
|
log.Info("")
|
||||||
}
|
log.Info(strings.Repeat("-", 153))
|
||||||
log.Info(strings.Repeat("-", 153))
|
for _, line := range strings.Split(chainConfig.Description(), "\n") {
|
||||||
log.Info("")
|
log.Info(line)
|
||||||
|
}
|
||||||
|
log.Info(strings.Repeat("-", 153))
|
||||||
|
log.Info("")
|
||||||
|
*/
|
||||||
|
|
||||||
peers := newServerPeerSet()
|
peers := newServerPeerSet()
|
||||||
merger := consensus.NewMerger(chainDb)
|
merger := consensus.NewMerger(chainDb)
|
||||||
|
@ -259,7 +259,7 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
|
|||||||
// Sanitize the timeout config for creating payload.
|
// Sanitize the timeout config for creating payload.
|
||||||
newpayloadTimeout := worker.config.NewPayloadTimeout
|
newpayloadTimeout := worker.config.NewPayloadTimeout
|
||||||
if newpayloadTimeout == 0 {
|
if newpayloadTimeout == 0 {
|
||||||
log.Warn("Sanitizing new payload timeout to default", "provided", newpayloadTimeout, "updated", DefaultConfig.NewPayloadTimeout)
|
// log.Warn("Sanitizing new payload timeout to default", "provided", newpayloadTimeout, "updated", DefaultConfig.NewPayloadTimeout)
|
||||||
newpayloadTimeout = DefaultConfig.NewPayloadTimeout
|
newpayloadTimeout = DefaultConfig.NewPayloadTimeout
|
||||||
}
|
}
|
||||||
if newpayloadTimeout < time.Millisecond*100 {
|
if newpayloadTimeout < time.Millisecond*100 {
|
||||||
|
@ -140,7 +140,7 @@ func New(diskdb ethdb.Database, config *Config) *Database {
|
|||||||
// mechanism also ensures that at most one **non-readOnly** database
|
// mechanism also ensures that at most one **non-readOnly** database
|
||||||
// is opened at the same time to prevent accidental mutation.
|
// is opened at the same time to prevent accidental mutation.
|
||||||
if ancient, err := diskdb.AncientDatadir(); err == nil && ancient != "" && !db.readOnly {
|
if ancient, err := diskdb.AncientDatadir(); err == nil && ancient != "" && !db.readOnly {
|
||||||
offset := uint64(0) //TODO(Nathan)
|
offset := uint64(0) //TODO(Nathan): just for passing compilation
|
||||||
freezer, err := rawdb.NewStateHistoryFreezer(ancient, false, offset)
|
freezer, err := rawdb.NewStateHistoryFreezer(ancient, false, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to open state history freezer", "err", err)
|
log.Crit("Failed to open state history freezer", "err", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user