Skip to content

Commit b5851ff

Browse files
committed
fix worker
fix config.go fix WaitGroup is reused before previous Wait has returned issue fix: add OverrideBerlin
1 parent 6193a73 commit b5851ff

File tree

9 files changed

+30
-9
lines changed

9 files changed

+30
-9
lines changed

cmd/geth/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
155155
// makeFullNode loads geth configuration and creates the Ethereum backend.
156156
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
157157
stack, cfg := makeConfigNode(ctx)
158+
if ctx.GlobalIsSet(utils.OverrideBerlinFlag.Name) {
159+
cfg.Eth.OverrideBerlin = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideBerlinFlag.Name))
160+
}
158161
if ctx.GlobalIsSet(utils.OverrideArrowGlacierFlag.Name) {
159162
cfg.Eth.OverrideArrowGlacier = new(big.Int).SetUint64(ctx.GlobalUint64(utils.OverrideArrowGlacierFlag.Name))
160163
}

core/blockchain.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,14 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
481481
}
482482
// Need persist and prune diff layer
483483
if bc.db.DiffStore() != nil {
484+
bc.wg.Add(1)
484485
go bc.trustedDiffLayerLoop()
485486
}
487+
bc.wg.Add(1)
486488
go bc.untrustedDiffLayerPruneLoop()
487489
if bc.pipeCommit {
488490
// check current block and rewind invalid one
491+
bc.wg.Add(1)
489492
go bc.rewindInvalidHeaderBlockLoop()
490493
}
491494
return bc, nil
@@ -2408,7 +2411,10 @@ func (bc *BlockChain) updateFutureBlocks() {
24082411

24092412
func (bc *BlockChain) rewindInvalidHeaderBlockLoop() {
24102413
recheck := time.NewTicker(rewindBadBlockInterval)
2411-
defer recheck.Stop()
2414+
defer func() {
2415+
recheck.Stop()
2416+
bc.wg.Done()
2417+
}()
24122418
for {
24132419
select {
24142420
case <-recheck.C:
@@ -2421,10 +2427,9 @@ func (bc *BlockChain) rewindInvalidHeaderBlockLoop() {
24212427

24222428
func (bc *BlockChain) trustedDiffLayerLoop() {
24232429
recheck := time.NewTicker(diffLayerFreezerRecheckInterval)
2424-
bc.wg.Add(1)
24252430
defer func() {
2426-
bc.wg.Done()
24272431
recheck.Stop()
2432+
bc.wg.Done()
24282433
}()
24292434
for {
24302435
select {
@@ -2554,10 +2559,9 @@ func (bc *BlockChain) removeDiffLayers(diffHash common.Hash) {
25542559

25552560
func (bc *BlockChain) untrustedDiffLayerPruneLoop() {
25562561
recheck := time.NewTicker(diffLayerPruneRecheckInterval)
2557-
bc.wg.Add(1)
25582562
defer func() {
2559-
bc.wg.Done()
25602563
recheck.Stop()
2564+
bc.wg.Done()
25612565
}()
25622566
for {
25632567
select {

core/genesis.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ func (e *GenesisMismatchError) Error() string {
156156
//
157157
// The returned chain configuration is never nil.
158158
func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig, common.Hash, error) {
159-
return SetupGenesisBlockWithOverride(db, genesis, nil, nil)
159+
return SetupGenesisBlockWithOverride(db, genesis, nil, nil, nil)
160160
}
161161

162-
func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideArrowGlacier, overrideTerminalTotalDifficulty *big.Int) (*params.ChainConfig, common.Hash, error) {
162+
func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, overrideBerlin, overrideArrowGlacier, overrideTerminalTotalDifficulty *big.Int) (*params.ChainConfig, common.Hash, error) {
163163
if genesis != nil && genesis.Config == nil {
164164
return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig
165165
}
@@ -206,6 +206,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, override
206206
}
207207
// Get the existing chain configuration.
208208
newcfg := genesis.configOrDefault(stored)
209+
if overrideBerlin != nil {
210+
newcfg.BerlinBlock = overrideBerlin
211+
}
209212
if overrideArrowGlacier != nil {
210213
newcfg.ArrowGlacierBlock = overrideArrowGlacier
211214
}

core/state_processor_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func TestStateProcessorErrors(t *testing.T) {
5454
MuirGlacierBlock: big.NewInt(0),
5555
MirrorSyncBlock: big.NewInt(0),
5656
BrunoBlock: big.NewInt(0),
57+
EulerBlock: big.NewInt(0),
5758
BerlinBlock: big.NewInt(0),
5859
LondonBlock: big.NewInt(0),
5960
Ethash: new(params.EthashConfig),

eth/backend.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
139139
if err != nil {
140140
return nil, err
141141
}
142-
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideArrowGlacier, config.OverrideTerminalTotalDifficulty)
142+
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideBerlin, config.OverrideArrowGlacier, config.OverrideTerminalTotalDifficulty)
143143
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
144144
return nil, genesisErr
145145
}

eth/ethconfig/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ type Config struct {
214214
// CheckpointOracle is the configuration for checkpoint oracle.
215215
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
216216

217+
// Berlin block override (TODO: remove after the fork)
218+
OverrideBerlin *big.Int `toml:",omitempty"`
219+
217220
// Arrow Glacier block override (TODO: remove after the fork)
218221
OverrideArrowGlacier *big.Int `toml:",omitempty"`
219222

eth/ethconfig/gen_config.go

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

les/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
9292
if err != nil {
9393
return nil, err
9494
}
95-
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideArrowGlacier, config.OverrideTerminalTotalDifficulty)
95+
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, config.Genesis, config.OverrideBerlin, config.OverrideArrowGlacier, config.OverrideTerminalTotalDifficulty)
9696
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
9797
return nil, genesisErr
9898
}

params/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ var (
169169
BerlinBlock: big.NewInt(0),
170170
MirrorSyncBlock: big.NewInt(0),
171171
BrunoBlock: big.NewInt(0),
172+
EulerBlock: big.NewInt(0),
172173
LondonBlock: big.NewInt(0),
173174
Ethash: new(EthashConfig),
174175
}

0 commit comments

Comments
 (0)