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

Customizable genesis files #271

Merged

Conversation

uprendis
Copy link
Collaborator

Rework genesis file format and genesis processing:

  • There may be multiple genesis files for the same network, featuring different starting data (varying by starting epoch and a degree of pruning). Archive genesis files will allow to start an archive node without processing all network transactions
  • Genesis file consists of network header and enveloped zip container, which stores 3 self-hashed files (S) for blocks, epochs and EVM data. Unlike previous format, it allows to start reading data right away without a separate decoding phase
  • (S) Self-hashed file (stream without random access) allows to read data from an untrusted source with a guarantee that either data will match the hash or an error will be raised. It requires to know the hash of the file in advance. It works similarly to torrent files, where file is separated into hashed pieces, thus doesn't require reading a file twice

Other changes:

  • erase "sfc" API namespace
  • allow deterministic state pruning with --prune.exact
  • optimize EVM DB verification command
  • allow non-zero addresses for internal txs

@hadv
Copy link
Contributor

hadv commented Mar 24, 2022

@uprendis Will we include below branch also into this PR?

https://github.com/uprendis/go-opera/commits/feature/add-fileshash-tests

cmd/opera/launcher/snapshotcmd.go Outdated Show resolved Hide resolved
evmcore/tx_pool.go Outdated Show resolved Hide resolved
@uprendis
Copy link
Collaborator Author

@uprendis Will we include below branch also into this PR?

https://github.com/uprendis/go-opera/commits/feature/add-fileshash-tests

Sure, I thought we'll add it after this PR. You can make a PR straight into this branch feature/customizable-genesis-file

@hadv
Copy link
Contributor

hadv commented Mar 24, 2022

@uprendis Will we include below branch also into this PR?
https://github.com/uprendis/go-opera/commits/feature/add-fileshash-tests

Sure, I thought we'll add it after this PR. You can make a PR straight into this branch feature/customizable-genesis-file

okay just thought you forgot to include it into this PR. If you have plan to add it later after this PR then it's fine.

@cyberbono3
Copy link
Collaborator

@uprendis what kind of manual testing scenarios should be performed to ensure your code works as expected?

@uprendis
Copy link
Collaborator Author

uprendis commented Apr 3, 2022

Here's the interface:
--genesis flag:
You can use to specify a genesis file of the new format. Previous format isn't supported

--genesis.allowExperimental:
Add this flag to run an unknown genesis file. There's a hardcoded list of known genesis files in cmd/opera/launcher/params.go , which currently contains genesis files of testnet: https://github.com/uprendis/lachesis_launch/blob/feature/add-snapsync-instruction/docs/genesis-files.md

opera --datadir /datadir/ export genesis output.g --export.evm.mode=ext-mpt
Generation of genesis file from current datadir
There's 3 modes for --export.evm.mode:

  • none: doesn't export any EVM data
  • mpt: exports only MPT data (used for pruned genesis files, like in the wiki table)
  • ext-mpt: exports only MPT data and preimages (used for full genesis files, like in the wiki table)
    Ideally, genesis file should be generated in a beginning of an epoch. It'll work otherwise too, but will contain excessive data. You may make node pause in a beginning of an epoch either by hardcoding it, or by using this branch: uprendis:feature/extend-exitwhensynced with flag --exitwhensynced.epoch 6226

opera snapshot prune-state --prune.exact
Addition of new flag --prune.exact which makes it use a leveldb DB instead of a memory bloom filter for memorizing used MPT items. This way, it'll erase exactly all unused MPT items and the process will be deterministic. It's handy for generation of pruned genesis files

I may suggest such testcases:

  • Try to sync up testnet from different genesis files using either fullsync or snapsync and verify that they return the same data via API (unless this data is pruned in genesis file)
  • Try to generate custom genesis files and verify that it works as expected. Try to repeat generation of genesis files for epoch 6226 for testnet and verify that you get the exact same files

@uprendis uprendis mentioned this pull request Apr 27, 2022
Copy link
Collaborator

@cyberbono3 cyberbono3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. I suggest to add some testing since it is a big PR.

@uprendis uprendis merged commit a1ea9dc into Fantom-foundation:develop May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants