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

block import is broken with verkle #30878

Open
gballet opened this issue Dec 9, 2024 · 3 comments
Open

block import is broken with verkle #30878

gballet opened this issue Dec 9, 2024 · 3 comments
Assignees
Labels

Comments

@gballet
Copy link
Member

gballet commented Dec 9, 2024

Following a successful geth init with a custom genesis block, geth import will fail.

It goes off the rails, checking if the triedb has been Initialized at https://github.com/ethereum/go-ethereum/blob/master/core/genesis.go#L295

Initialized will go over the layers, and what happens is that there is only one layer, and it's keyed with types.EmptyRootHash, which is not a valid node value for verkle. In fact, the tree itself shouldn't be empty to begin with, so this value should not show up, regardless of whether or not verkle is supported:

(dlv) print tree.layers
map[github.com/ethereum/go-ethereum/common.Hash]github.com/ethereum/go-ethereum/triedb/pathdb.layer [
	[86,232,31,23,27,204,85,166,255,131,69,230,146,192,248,110,91,72,224,27,153,108,173,192,1,98,47,181,227,99,180,33]: *github.com/ethereum/go-ethereum/triedb/pathdb.diskLayer {
		root: github.com/ethereum/go-ethereum/common.Hash [86,232,31,23,27,204,85,166,255,131,69,230,146,192,248,110,91,72,224,27,153,108,173,192,1,98,47,181,227,99,180,33],
		id: 0,
		db: *(*"github.com/ethereum/go-ethereum/triedb/pathdb.Database")(0xc0001c7590),
		nodes: *(*"github.com/VictoriaMetrics/fastcache.Cache")(0xc00046e000),
		buffer: *(*"github.com/ethereum/go-ethereum/triedb/pathdb.buffer")(0xc0004de860),
		stale: false,
		lock: (*sync.RWMutex)(0xc000333844),}, 
]

The culprit is loadLayers(), which will call ReadAccountTrieNode, which will in turn return nil. As a result, it will create a new empty layer using EmptyRootHash as a root.

@rjl493456442 rjl493456442 self-assigned this Dec 9, 2024
@gballet
Copy link
Member Author

gballet commented Dec 9, 2024

@holiman you wanted to have a way to reproduce the issue:

  • Get the kaustinen genesis block
    genesis_kaustinen7.json
  • Run go run ./cmd/geth --datadir=<dir> --cache.preimages --override.verkle=1730214000 init genesis.json
  • Run go run ./cmd/geth --datadir=<dir> --cache.preimages --override.verkle=1730214000 --bootnodes "enode://548ff025abb1522c5257f50765abd21754b7ea7159a176a9b96c738ee6456fc378a11c09a62d55d92684634cd32a9cad498f5649256caf693dab77f961a169f6@167.235.68.89:30303?discport=30303,enode://7a46b1126d2c602e2d567a75aa3cc2577d93ea2bfcc524d115f985689516159c94a339f3984bbce28eb8b35d49494d1ec7be55f361c7768ae43993bc5b88eb77@128.140.104.94:30303?discport=30303,enode://a21d8ecaaea7a199a479672ae11b11afc1b55dce4851d278cae11fd4cf5452866f40890cb7262c3430f9f249d7091ebab39f148740c267f3f3b505c6d27391fe@128.140.104.96:30303?discport=30303,enode://145e00c57c837fe19d431bb33cb964b747616cc6be57e350936f13fe51ab4fab5bb167fb38c8399d9b0d687d317466d2c4d0bff2c83068ffa77c4ed16f5f7b28@195.201.139.113:30303?discport=30303,enode://9ceb22af386b10ba283cd60f7e83772585e47946e7dddc6029e9acd79730095ea8e5e6ba8619c30149e002084b9bb83ef62e0765cd30c9626667b29ea8f3389e@49.13.196.169:30303?discport=30303,enode://e1157ce974bd103852a6df269a772dbcf308f628b185e6fc2774f8eddc127c1309a7f023dfaae922dfe32c5170aa7085245dbe4b88931b21d3ee4bb290b77418@195.201.36.62:30303?discport=30303" --authrpc.jwtsecret <secret> --syncmode full

Notice that it complains about the genesis hash being incorrect.

@gballet
Copy link
Member Author

gballet commented Dec 9, 2024

The above comment points out that there is a much bigger issue than just block import: using a nil genesis block is no longer a workeable solution.

This causes this line to consider that we are not in verkle mode, even when we are. But even if we could somehow set this flag properly, it will still be missing important information like the state root hash.

The inescapable conclusion, in my view is:

  • the whole genesis block needs to be loaded from the db each time the block is created. If it's in the DB, it should be assumed to be correct.
  • If some compatibility checks are needed when "updating" the kernel, then peform the checks in this very context.

@rjl493456442
Copy link
Member

I can repro the issue and can confirm guillaume's analysis is correct

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

No branches or pull requests

2 participants