Skip to content

Commit dde2da0

Browse files
authored
all: remove ethash pow, only retain shims needed for consensus and tests (#27178)
* all: remove ethash pow, only retain shims needed for consensus and tests * all: thank you linter * all: disallow launching Geth in legacy PoW mode * cmd/env/internal/t8ntool: remove dangling ethash flag
1 parent ac3418d commit dde2da0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+210
-5484
lines changed

cmd/devp2p/internal/ethtest/testdata/genesis.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"eip155Block": 0,
77
"eip158Block": 0,
88
"byzantiumBlock": 0,
9+
"terminalTotalDifficultyPassed": true,
910
"ethash": {}
1011
},
1112
"nonce": "0xdeadbeefdeadbeef",

cmd/evm/internal/t8ntool/block.go

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/ethereum/go-ethereum/common/hexutil"
2929
"github.com/ethereum/go-ethereum/common/math"
3030
"github.com/ethereum/go-ethereum/consensus/clique"
31-
"github.com/ethereum/go-ethereum/consensus/ethash"
3231
"github.com/ethereum/go-ethereum/core/types"
3332
"github.com/ethereum/go-ethereum/crypto"
3433
"github.com/ethereum/go-ethereum/log"
@@ -74,11 +73,9 @@ type bbInput struct {
7473
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
7574
Clique *cliqueInput `json:"clique,omitempty"`
7675

77-
Ethash bool `json:"-"`
78-
EthashDir string `json:"-"`
79-
PowMode ethash.Mode `json:"-"`
80-
Txs []*types.Transaction `json:"-"`
81-
Ommers []*types.Header `json:"-"`
76+
Ethash bool `json:"-"`
77+
Txs []*types.Transaction `json:"-"`
78+
Ommers []*types.Header `json:"-"`
8279
}
8380

8481
type cliqueInput struct {
@@ -162,42 +159,13 @@ func (i *bbInput) ToBlock() *types.Block {
162159
// SealBlock seals the given block using the configured engine.
163160
func (i *bbInput) SealBlock(block *types.Block) (*types.Block, error) {
164161
switch {
165-
case i.Ethash:
166-
return i.sealEthash(block)
167162
case i.Clique != nil:
168163
return i.sealClique(block)
169164
default:
170165
return block, nil
171166
}
172167
}
173168

174-
// sealEthash seals the given block using ethash.
175-
func (i *bbInput) sealEthash(block *types.Block) (*types.Block, error) {
176-
if i.Header.Nonce != nil {
177-
return nil, NewError(ErrorConfig, fmt.Errorf("sealing with ethash will overwrite provided nonce"))
178-
}
179-
ethashConfig := ethash.Config{
180-
PowMode: i.PowMode,
181-
DatasetDir: i.EthashDir,
182-
CacheDir: i.EthashDir,
183-
DatasetsInMem: 1,
184-
DatasetsOnDisk: 2,
185-
CachesInMem: 2,
186-
CachesOnDisk: 3,
187-
}
188-
engine := ethash.New(ethashConfig, nil, true)
189-
defer engine.Close()
190-
// Use a buffered chan for results.
191-
// If the testmode is used, the sealer will return quickly, and complain
192-
// "Sealing result is not read by miner" if it cannot write the result.
193-
results := make(chan *types.Block, 1)
194-
if err := engine.Seal(nil, block, results, nil); err != nil {
195-
panic(fmt.Sprintf("failed to seal block: %v", err))
196-
}
197-
found := <-results
198-
return block.WithSeal(found.Header()), nil
199-
}
200-
201169
// sealClique seals the given block using clique.
202170
func (i *bbInput) sealClique(block *types.Block) (*types.Block, error) {
203171
// If any clique value overwrites an explicit header value, fail
@@ -267,28 +235,8 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
267235
withdrawalsStr = ctx.String(InputWithdrawalsFlag.Name)
268236
txsStr = ctx.String(InputTxsRlpFlag.Name)
269237
cliqueStr = ctx.String(SealCliqueFlag.Name)
270-
ethashOn = ctx.Bool(SealEthashFlag.Name)
271-
ethashDir = ctx.String(SealEthashDirFlag.Name)
272-
ethashMode = ctx.String(SealEthashModeFlag.Name)
273238
inputData = &bbInput{}
274239
)
275-
if ethashOn && cliqueStr != "" {
276-
return nil, NewError(ErrorConfig, fmt.Errorf("both ethash and clique sealing specified, only one may be chosen"))
277-
}
278-
if ethashOn {
279-
inputData.Ethash = ethashOn
280-
inputData.EthashDir = ethashDir
281-
switch ethashMode {
282-
case "normal":
283-
inputData.PowMode = ethash.ModeNormal
284-
case "test":
285-
inputData.PowMode = ethash.ModeTest
286-
case "fake":
287-
inputData.PowMode = ethash.ModeFake
288-
default:
289-
return nil, NewError(ErrorConfig, fmt.Errorf("unknown pow mode: %s, supported modes: test, fake, normal", ethashMode))
290-
}
291-
}
292240
if headerStr == stdinSelector || ommersStr == stdinSelector || txsStr == stdinSelector || cliqueStr == stdinSelector {
293241
decoder := json.NewDecoder(os.Stdin)
294242
if err := decoder.Decode(inputData); err != nil {

cmd/evm/internal/t8ntool/flags.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,6 @@ var (
125125
Name: "seal.clique",
126126
Usage: "Seal block with Clique. `stdin` or file name of where to find the Clique sealing data.",
127127
}
128-
SealEthashFlag = &cli.BoolFlag{
129-
Name: "seal.ethash",
130-
Usage: "Seal block with ethash.",
131-
}
132-
SealEthashDirFlag = &cli.StringFlag{
133-
Name: "seal.ethash.dir",
134-
Usage: "Path to ethash DAG. If none exists, a new DAG will be generated.",
135-
}
136-
SealEthashModeFlag = &cli.StringFlag{
137-
Name: "seal.ethash.mode",
138-
Usage: "Defines the type and amount of PoW verification an ethash engine makes.",
139-
Value: "normal",
140-
}
141128
RewardFlag = &cli.Int64Flag{
142129
Name: "state.reward",
143130
Usage: "Mining reward. Set to -1 to disable",

cmd/evm/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,6 @@ var blockBuilderCommand = &cli.Command{
179179
t8ntool.InputWithdrawalsFlag,
180180
t8ntool.InputTxsRlpFlag,
181181
t8ntool.SealCliqueFlag,
182-
t8ntool.SealEthashFlag,
183-
t8ntool.SealEthashDirFlag,
184-
t8ntool.SealEthashModeFlag,
185182
t8ntool.VerbosityFlag,
186183
},
187184
}

cmd/geth/genesis_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ var customGenesisTests = []struct {
4141
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
4242
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
4343
"timestamp" : "0x00",
44-
"config" : {}
44+
"config" : {
45+
"terminalTotalDifficultyPassed": true
46+
}
4547
}`,
4648
query: "eth.getBlock(0).nonce",
4749
result: "0x0000000000001338",
@@ -59,9 +61,10 @@ var customGenesisTests = []struct {
5961
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
6062
"timestamp" : "0x00",
6163
"config" : {
62-
"homesteadBlock" : 42,
63-
"daoForkBlock" : 141,
64-
"daoForkSupport" : true
64+
"homesteadBlock" : 42,
65+
"daoForkBlock" : 141,
66+
"daoForkSupport" : true,
67+
"terminalTotalDifficultyPassed" : true
6568
}
6669
}`,
6770
query: "eth.getBlock(0).nonce",
@@ -111,8 +114,10 @@ func TestCustomBackend(t *testing.T) {
111114
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
112115
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
113116
"timestamp" : "0x00",
114-
"config" : {}
115-
}`
117+
"config" : {
118+
"terminalTotalDifficultyPassed": true
119+
}
120+
}`
116121
type backendTest struct {
117122
initArgs []string
118123
initExpect string

cmd/geth/main.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ var (
6666
utils.SmartCardDaemonPathFlag,
6767
utils.OverrideCancun,
6868
utils.EnablePersonal,
69-
utils.EthashCacheDirFlag,
70-
utils.EthashCachesInMemoryFlag,
71-
utils.EthashCachesOnDiskFlag,
72-
utils.EthashCachesLockMmapFlag,
73-
utils.EthashDatasetDirFlag,
74-
utils.EthashDatasetsInMemoryFlag,
75-
utils.EthashDatasetsOnDiskFlag,
76-
utils.EthashDatasetsLockMmapFlag,
7769
utils.TxPoolLocalsFlag,
7870
utils.TxPoolNoLocalsFlag,
7971
utils.TxPoolJournalFlag,
@@ -120,14 +112,11 @@ var (
120112
utils.MaxPeersFlag,
121113
utils.MaxPendingPeersFlag,
122114
utils.MiningEnabledFlag,
123-
utils.MinerThreadsFlag,
124-
utils.MinerNotifyFlag,
125115
utils.MinerGasLimitFlag,
126116
utils.MinerGasPriceFlag,
127117
utils.MinerEtherbaseFlag,
128118
utils.MinerExtraDataFlag,
129119
utils.MinerRecommitIntervalFlag,
130-
utils.MinerNoVerifyFlag,
131120
utils.MinerNewPayloadTimeout,
132121
utils.NATFlag,
133122
utils.NoDiscoverFlag,
@@ -142,13 +131,11 @@ var (
142131
utils.VMEnableDebugFlag,
143132
utils.NetworkIdFlag,
144133
utils.EthStatsURLFlag,
145-
utils.FakePoWFlag,
146134
utils.NoCompactionFlag,
147135
utils.GpoBlocksFlag,
148136
utils.GpoPercentileFlag,
149137
utils.GpoMaxGasPriceFlag,
150138
utils.GpoIgnoreGasPriceFlag,
151-
utils.MinerNotifyFullFlag,
152139
configFileFlag,
153140
}, utils.NetworkFlags, utils.DatabasePathFlags)
154141

@@ -224,8 +211,6 @@ func init() {
224211
attachCommand,
225212
javascriptCommand,
226213
// See misccmd.go:
227-
makecacheCommand,
228-
makedagCommand,
229214
versionCommand,
230215
versionCheckCommand,
231216
licenseCommand,
@@ -438,9 +423,7 @@ func startNode(ctx *cli.Context, stack *node.Node, backend ethapi.Backend, isCon
438423
// Set the gas price to the limits from the CLI and start mining
439424
gasprice := flags.GlobalBig(ctx, utils.MinerGasPriceFlag.Name)
440425
ethBackend.TxPool().SetGasPrice(gasprice)
441-
// start mining
442-
threads := ctx.Int(utils.MinerThreadsFlag.Name)
443-
if err := ethBackend.StartMining(threads); err != nil {
426+
if err := ethBackend.StartMining(); err != nil {
444427
utils.Fatalf("Failed to start mining: %v", err)
445428
}
446429
}

cmd/geth/misccmd.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ import (
2020
"fmt"
2121
"os"
2222
"runtime"
23-
"strconv"
2423
"strings"
2524

26-
"github.com/ethereum/go-ethereum/cmd/utils"
27-
"github.com/ethereum/go-ethereum/consensus/ethash"
2825
"github.com/ethereum/go-ethereum/internal/version"
2926
"github.com/ethereum/go-ethereum/params"
3027
"github.com/urfave/cli/v2"
@@ -41,30 +38,6 @@ var (
4138
Usage: "Version to check",
4239
Value: version.ClientName(clientIdentifier),
4340
}
44-
makecacheCommand = &cli.Command{
45-
Action: makecache,
46-
Name: "makecache",
47-
Usage: "Generate ethash verification cache (for testing)",
48-
ArgsUsage: "<blockNum> <outputDir>",
49-
Description: `
50-
The makecache command generates an ethash cache in <outputDir>.
51-
52-
This command exists to support the system testing project.
53-
Regular users do not need to execute it.
54-
`,
55-
}
56-
makedagCommand = &cli.Command{
57-
Action: makedag,
58-
Name: "makedag",
59-
Usage: "Generate ethash mining DAG (for testing)",
60-
ArgsUsage: "<blockNum> <outputDir>",
61-
Description: `
62-
The makedag command generates an ethash DAG in <outputDir>.
63-
64-
This command exists to support the system testing project.
65-
Regular users do not need to execute it.
66-
`,
67-
}
6841
versionCommand = &cli.Command{
6942
Action: printVersion,
7043
Name: "version",
@@ -96,36 +69,6 @@ and displays information about any security vulnerabilities that affect the curr
9669
}
9770
)
9871

99-
// makecache generates an ethash verification cache into the provided folder.
100-
func makecache(ctx *cli.Context) error {
101-
args := ctx.Args().Slice()
102-
if len(args) != 2 {
103-
utils.Fatalf(`Usage: geth makecache <block number> <outputdir>`)
104-
}
105-
block, err := strconv.ParseUint(args[0], 0, 64)
106-
if err != nil {
107-
utils.Fatalf("Invalid block number: %v", err)
108-
}
109-
ethash.MakeCache(block, args[1])
110-
111-
return nil
112-
}
113-
114-
// makedag generates an ethash mining DAG into the provided folder.
115-
func makedag(ctx *cli.Context) error {
116-
args := ctx.Args().Slice()
117-
if len(args) != 2 {
118-
utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`)
119-
}
120-
block, err := strconv.ParseUint(args[0], 0, 64)
121-
if err != nil {
122-
utils.Fatalf("Invalid block number: %v", err)
123-
}
124-
ethash.MakeDataset(block, args[1])
125-
126-
return nil
127-
}
128-
12972
func printVersion(ctx *cli.Context) error {
13073
git, _ := version.VCS()
13174

0 commit comments

Comments
 (0)