Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geth does not start in --dev mod with empty blockchain and custom genesis block #24453

Closed
DimaStebaev opened this issue Feb 22, 2022 · 4 comments · Fixed by #24693
Closed

Geth does not start in --dev mod with empty blockchain and custom genesis block #24453

DimaStebaev opened this issue Feb 22, 2022 · 4 comments · Fixed by #24693
Labels

Comments

@DimaStebaev
Copy link

System information

Geth version: 1.10.16
OS & Version: Ubuntu 21.10 Implish

Expected behaviour

If run

geth --datadir /tmp/blockchain/ init genesis.json
geth --datadir /tmp/blockchain --dev

geth starts in develop mode.

Actual behaviour

geth fails with an error:

Fatal: Could not open database: open /tmp/blockchain/geth/chaindata/ancient/headers.cidx: no such file or directory

Steps to reproduce the behaviour

  1. Create valid genesis block and write in to genesis.json file
  2. Run geth --datadir /tmp/blockchain/ init genesis.json
  3. Run geth --datadir /tmp/blockchain --dev

Backtrace

INFO [02-22|17:03:03.930] Starting Geth in ephemeral dev mode... 
INFO [02-22|17:03:03.931] Maximum peer count                       ETH=50 LES=0 total=50
INFO [02-22|17:03:03.931] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [02-22|17:03:03.931] Set global gas cap                       cap=50,000,000
INFO [02-22|17:03:04.078] Using developer account                  address=0x426b4b03F4d92Fc4c45dC9858B9D62BC9625C853
INFO [02-22|17:03:04.078] Allocated cache and file handles         database=/tmp/blockchain/geth/chaindata cache=512.00MiB handles=524,288 readonly=true
Fatal: Could not open database: open /tmp/blockchain/geth/chaindata/ancient/headers.cidx: no such file or directory
@MariusVanDerWijden
Copy link
Member

We discussed this issue a bit internally and all agreed that this should not be done.
The --dev mode should be ephemeral and you should rather use a custom chain for your testing.
We should fix the error message and investigate why this error is thrown though

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.001 ETH (2.71 USD @ $2709.84/ETH) attached to it.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 1 month from now.
Please review their action plans below:

1) shantanusoni72 has applied to start work (Funders only: approve worker | reject worker).

I will first try to reproduce the issue to analyse the issue and will solve the issue.

Learn more on the Gitcoin Issue Details page.

@s1na
Copy link
Contributor

s1na commented Mar 1, 2022

This has surfaced since #24298. The error is thrown because init doesn't open the freezer and hence create the empty table index files. On starting --dev we first open the freezer db in readonly mode and that fails because no freezer files exist.

One easy fix is this:

diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index 6077c43cc..1698ce5db 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -206,7 +206,7 @@ func initGenesis(ctx *cli.Context) error {
        defer stack.Close()

        for _, name := range []string{"chaindata", "lightchaindata"} {
-               chaindb, err := stack.OpenDatabase(name, 0, 0, "", false)
+               chaindb, err := stack.OpenDatabaseWithFreezer(name, 0, 0, "", "", false)
                if err != nil {
                        utils.Fatalf("Failed to open database: %v", err)
                }

With this patch it's business as usual and dev mode starts fine. Or do we want to actively prevent this practice and only display a better error for it? I'm not sure how best to do that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants