-
Notifications
You must be signed in to change notification settings - Fork 698
Refactor openInitializeChainDb for Execution/Consensus split #4169
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4169 +/- ##
==========================================
- Coverage 33.41% 33.11% -0.31%
==========================================
Files 461 462 +1
Lines 55901 55976 +75
==========================================
- Hits 18681 18534 -147
- Misses 33921 34179 +258
+ Partials 3299 3263 -36 |
❌ 9 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
4ac62dd to
1826ff4
Compare
0bab452 to
7b16439
Compare
cmd/nitro/init.go
Outdated
| if chainConfig == nil { | ||
| chainConfig, err = getChainConfig(config, initDataReader, executionDB) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| } | ||
|
|
||
| parsedInitMessage, err := getConsensusParsedInitMsg(ctx, config, chainId, l1Client, rollupAddrs, chainConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part in particular, might different a bit in logic from the current chainConfig lifecycle which is as follows:
readOnlyDB, err := stack.OpenDatabaseWithOptions
if err == nil {
chainConfig := gethexec.TryReadStoredChainConfig(readOnlyDB)
if chainConfig != nil {
validateBlockChain(l2BlockChain, chainConfig)
return rebuildLocalWasm(... l2BlockChain, executionDB, ...)
}
}
var chainConfig *params.ChainConfig
if config.Init.GenesisJsonFile != "" {
chainConfig = gen.Config
}
if initDataReader == nil {
chainConfig = gethexec.TryReadStoredChainConfig(executionDB)
if chainConfig == nil { return error }
else {
if chainConfig == nil {
chainConfig, err = chaininfo.GetChainConfig(...)
if err != nil {return err}
}
}
validateBlockChain(l2BlockChain, chainConfig)
return rebuildLocalWasm(... l2BlockChain, executionDB, ...)And now is:
..., chainConfig, err := openExistingExecutionDB
// if evaluated to true then chainConfig is also nil
if executionDB == nil {
..., chainConfig, ..., err = getInit(config)
if chainConfig == nil {
chainConfig, err = getChainConfig(config, initDataReader, executionDB)
}
}
if chainConfig == nil { return error }
validateBlockChain(l2BlockChain, chainConfig)
return rebuildLocalWasm(... l2BlockChain, executionDB, ...)
diegoximenes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about checking if it is easy to extend a bold test so it can test getGenesisAssertionCreationInfo and validateGenesisAssertion?
If it is easy then the test can be implemented 🙂
| Require(t, err) | ||
| } | ||
|
|
||
| func TestOpenDownloadedExecutionDB(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also create a test for openExistingExecutionDB.
You can move openExistingExecutionDB out of the main package, so it is able to be imported by system test.
You can create a system test that starts a L2 chain, create some blocks, stop the chain, and then calls openExistingExecutionDB.
Something similar to TestDatabaseConversion.
Then you can check if it is properly able to read executionDB, reading a block hash with rawdb.ReadCanonicalHash for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice so I created ticket NIT-4268 to do on another PR as I thought it would make things look more organized if done separately. But please let me know if you prefer this to be done in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented them in 67f56ab
pmikolajczyk41
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throwing two secondary comments for now
Today openInitializeChainDb has procedures related to both Execution and Consensus components. So we split them into target functions related specifically to either Execution and Consensus. Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Add checkDBDir tests Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
- Create new config package to expose and organize init and config nitro functionality. - Add new system_tests for openExistingExecutionDB and getConsensusParsedInitMsg Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
416a75e to
67f56ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diegoximenes these are the system_tests I included for openExistingExecutionDB and getConsensusParsedInitMsg. As a result of exposing those functions I created config package under cmd/nitro; not sure if config is too generic of a name. Still looking at how to test getGenesisAssertionCreationInfo without introducing too much code, will update after trying some more.
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Today
openInitializeChainDbhas procedures related to both Execution and Consensus components. So we split them into target functions related specifically to either Execution and Consensus.Now
openInitializeChainDbcan be thought of as:closes NIT-4199
closes NIT-4268