Construct init msg without consensus#4395
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4395 +/- ##
==========================================
- Coverage 34.56% 32.75% -1.81%
==========================================
Files 495 495
Lines 58648 58744 +96
==========================================
- Hits 20272 19242 -1030
- Misses 34772 36150 +1378
+ Partials 3604 3352 -252 |
❌ 10 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
bragaigor
left a comment
There was a problem hiding this comment.
overall looks good, just some minor comments
There was a problem hiding this comment.
Pull request overview
This PR refactors the init message restoration logic by splitting the monolithic GetConsensusParsedInitMsg function into three separate, purpose-specific functions. This improves code clarity and maintainability by explicitly separating the three distinct paths for constructing init messages: from parent chain (consensus), from genesis file, or from stored chain config.
Changes:
- Replaced
GetConsensusParsedInitMsgwith three focused functions:GetParsedInitMsgFromConsensus,GetParsedInitMsgFromGenesis, andGetParsedInitMsgFromChainConfig - Updated
GetInitto return*core.Genesisinstead of*params.ArbOSInitto support the new genesis-based init message construction - Updated all call sites across the codebase to use the appropriate new function based on context
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/nitro/init/init.go | Core refactoring: splits GetConsensusParsedInitMsg into three separate functions and updates GetInit return signature to include genesis object |
| cmd/nitro/init/init_test.go | Updates test helper to handle new GetInit return signature and extract ArbOSInit from genesis when available |
| system_tests/nitro_init_test.go | Renames and expands test to cover both new non-consensus functions (GetParsedInitMsgFromGenesis and GetParsedInitMsgFromChainConfig) and removes unused chaininfo import |
| system_tests/genesis_assertion_test.go | Updates call to use new GetParsedInitMsgFromConsensus function |
| system_tests/common_test.go | Updates call to use new GetParsedInitMsgFromConsensus function |
| system_tests/bold_customda_challenge_test.go | Updates call to use new GetParsedInitMsgFromConsensus function |
| system_tests/bold_challenge_protocol_test.go | Updates call to use new GetParsedInitMsgFromConsensus function |
| changelog/pmikolajczyk-nit-4242.md | Documents the new capability to restore init message from genesis |
Comments suppressed due to low confidence (1)
cmd/nitro/init/init.go:1116
- The previous implementation logged a warning when creating an init message without reading from the parent chain ("Created fake init message as L1Reader is disabled..."). This warning has been removed. Consider adding a log message here to maintain visibility when the init message is constructed from the chain config fallback path, especially since this case indicates that neither parent chain reader nor genesis file are available.
func GetParsedInitMsgFromChainConfig(chainConfig *params.ChainConfig) (*arbostypes.ParsedInitMessage, error) {
serializedChainConfig, err := json.Marshal(chainConfig)
if err != nil {
return nil, err
}
parsedInitMessage := &arbostypes.ParsedInitMessage{
ChainId: chainConfig.ChainID,
InitialL1BaseFee: arbostypes.DefaultInitialL1BaseFee,
ChainConfig: chainConfig,
SerializedChainConfig: serializedChainConfig,
}
return parsedInitMessage, nil
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
diegoximenes
left a comment
There was a problem hiding this comment.
In this PR a new GetExecutionParsedInitMsg func should be created, that only relies on local config, such as genesis.json, to build the parsed init message.
In this PR, both GetConsensusParsedInitMsg and GetExecutionParsedInitMsg should be called, and a warning generated if they don't match.
Tsahi said at some point that he wants to fail node startup if there is a mismatch.
At this point I think this is too aggressive, and logging a warning is enough.
Please, bring that topic to be discussed in a standup.
Change OpenInitializeExecutionDB signature to accept a consensusParsedInitMessage *arbostypes.ParsedInitMessage, that can be nil if config.Node.ParentChainReader.Enable is set to false.
Move this code block
Lines 1065 to 1069 in 0b4a8fa
Maybe a func to abstract that code block can improve code readability.
In this other task https://linear.app/offchain-labs/issue/NIT-4201/consensus-calls-executionvalidate-to-check-parsedinitmessage, when only running an Execution node, only GetExecutionParsedInitMsg will be called.
This task describes how the Consensus node will provide its parsed init message later to Execution, so it can validate if there is a mismatch.
Makes sense?
Previously we had a single method
GetConsensusParsedInitMsgfor restoring init message. Depending on a boolean flag as one of its parameters, nitro either talked with parent chain, or directly used chain config it got from the previous step. This PR replaces this with 3 functions:GetParsedInitMsgFromConsensus- as name suggests, nitro reads the message directly from the parent chain (and then checks its chain config compatibility with the config it got from the previous step)GetParsedInitMsgFromGenesis- if genesis object is available, nitro restores the init message from it; no consensus involvedGetParsedInitMsgFromChainConfig- the old fallback: in case neither parent chain (consensus) nor genesis is available, nitro restores the message from the chain config it got fromgethexec.TryReadStoredChainConfigcloses NIT-4242