mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
fix dev mode instantiation with preexisting datadir and add docs to clarify the code that was broken.
This commit is contained in:
parent
a7f13bb5ba
commit
2f82dee875
2 changed files with 6 additions and 24 deletions
|
|
@ -294,24 +294,6 @@ func prepare(ctx *cli.Context) {
|
|||
case ctx.IsSet(utils.HoodiFlag.Name):
|
||||
log.Info("Starting Geth on Hoodi testnet...")
|
||||
|
||||
case ctx.IsSet(utils.DeveloperFlag.Name):
|
||||
log.Info("Starting Geth in ephemeral dev mode...")
|
||||
log.Warn(`You are running Geth in --dev mode. Please note the following:
|
||||
|
||||
1. This mode is only intended for fast, iterative development without assumptions on
|
||||
security or persistence.
|
||||
2. The database is created in memory unless specified otherwise. Therefore, shutting down
|
||||
your computer or losing power will wipe your entire block data and chain state for
|
||||
your dev environment.
|
||||
3. A random, pre-allocated developer account will be available and unlocked as
|
||||
eth.coinbase, which can be used for testing. The random dev account is temporary,
|
||||
stored on a ramdisk, and will be lost if your machine is restarted.
|
||||
4. Mining is enabled by default. However, the client will only seal blocks if transactions
|
||||
are pending in the mempool. The miner's minimum accepted gas price is 1.
|
||||
5. Networking is disabled; there is no listen-address, the maximum number of peers is set
|
||||
to 0, and discovery is disabled.
|
||||
`)
|
||||
|
||||
case !ctx.IsSet(utils.NetworkIdFlag.Name):
|
||||
log.Info("Starting Geth on Ethereum mainnet...")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1792,12 +1792,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
}
|
||||
log.Info("Using developer account", "address", developer.Address)
|
||||
|
||||
// Create a new developer genesis block or reuse existing one
|
||||
// configure default developer genesis which will be used unless a
|
||||
// datadir is specified and a chain is preexisting at that location.
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(ctx.Uint64(DeveloperGasLimitFlag.Name), &developer.Address)
|
||||
|
||||
// If a datadir is specified, ensure that any preexisting chain in that location
|
||||
// has a configuration that is compatible with dev mode: it must be merged at genesis.
|
||||
if ctx.IsSet(DataDirFlag.Name) {
|
||||
chaindb := tryMakeReadOnlyDatabase(ctx, stack)
|
||||
if rawdb.ReadCanonicalHash(chaindb, 0) != (common.Hash{}) {
|
||||
// validate that the stored genesis config compatible with dev-mode:
|
||||
// it must be merged at genesis
|
||||
genesis, err := core.ReadGenesis(chaindb)
|
||||
if err != nil {
|
||||
Fatalf("Could not read genesis from database: %v", err)
|
||||
|
|
@ -1812,9 +1815,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
}
|
||||
}
|
||||
chaindb.Close()
|
||||
} else {
|
||||
// if no datadir is specified, dev mode runs ephemerally in memory
|
||||
cfg.Genesis = core.DeveloperGenesisBlock(ctx.Uint64(DeveloperGasLimitFlag.Name), &developer.Address)
|
||||
}
|
||||
if !ctx.IsSet(MinerGasPriceFlag.Name) {
|
||||
cfg.Miner.GasPrice = big.NewInt(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue