kroma-network / go-ethereum

go-ethereum for Kroma
GNU Lesser General Public License v3.0
45 stars 23 forks source link

Make scroll geth diff maintainable #2

Closed chokobole closed 7 months ago

chokobole commented 1 year ago

Rationale

To make zk rollup to work for the first time, we applied a lot of scroll diff to our geth in #1.

But this makes us 1) to maintain codes difficult and 2) some of diffs are not complete, I believe...

To solve 1) (in other words, to minimize difference between our geth and ethereum geth) we need to modify some parts slightly better.

To solve 2) When running geth with zk trie on, I believe all the database should be loaded with zk trie config on. But it seems it doesn't do that. I think we can do this by modifying NewDatabaseWithConfig instead of loading zk config from the caller side.

Implementation

  1. Currently, I don't have specific idea.. Any suggestions?

  2. Loading database based on zk trie at once

// core/state/database.go
func NewDatabaseWithConfig(db ethdb.Database, config *trie.Config) Database {
  if config == nil {
    // read genesis from rawdb and load zktrie config
  } 
  // apply zktrie config here
}

// trie/database.go
func NewDatabaseWithConfig(diskdb ethdb.KeyValueStore, config *Config) *Database {
  if config == nil {
    // read genesis from rawdb and load zktrie config
  }
  // apply zktrie config here
}
jyc228 commented 7 months ago

If we change the behavior of config to zk when nil, many tests will fail. It would take a lot of time and effort to get this to pass. It is also expected to have the same effect as changing the behavior of geth when run without parameters. Finally, as geth has continued to evolve, it has added support for verkle and path db in config, and these new options only work when the associated parameters are set.

For this reason, I don't recommend modifying them in their current state.