-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(cli): adds --dump-state
cli cmd
#496
base: main
Are you sure you want to change the base?
Conversation
crates/cli/src/main.rs
Outdated
_ = &mut state_dumper => {} | ||
} | ||
|
||
state_dumper.dump().await; |
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.
@itegulov inspecting the state dump we always get:
"l1BatchNumber": null,
This is problematic when you attempt to load that same dumped state:
thread 'main' panicked at crates/core/src/node/in_memory.rs:925:13:
encountered a block with no batch; this is not supposed to happen
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Updating the value to not be null
resolves the issue but shouldn't l1BatchNumber
never be null
?
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.
Very strange, this shouldn't happen indeed. Do you have an example of how I can reproduce this behaviour?
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.
Yes, to reproduce ./target/release/anvil-zksync --state-interval 1 --dump-state state.json fork --fork-url mainnet
Seems specific to forking?
@@ -33,3 +33,5 @@ serde_json.workspace = true | |||
tokio.workspace = true | |||
tracing.workspace = true | |||
tracing-subscriber.workspace = true | |||
flate2.workspace = true | |||
tempfile = "3" |
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.
Please add the version to root workspace, this way we can ensure all our crates depend on the same version to avoid dependency bloat
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.
Added it as dev-dependency as its only used in the unit test.
.state_interval | ||
.map(Duration::from_secs) | ||
.unwrap_or(Duration::from_secs(60)); // Default to 60 seconds | ||
let preserve_historical_states = config.preserve_historical_states; |
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.
nit: move inside the if
below so it's clear these are only relevant when dump_state
is present
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.
Actually, looking at the code it seems like PeriodicStateDumper
is designed to work even if dump_path
is not present. So I would remove the whole if
here.
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.
Yup, nice catch. Done ✅
crates/cli/src/main.rs
Outdated
|
||
state_dumper.dump().await; | ||
|
||
std::process::exit(0); |
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.
If this is going to be our "exit point" then could you move BlockProducer
here as well? So it's a part of select!
and is not spawned on its own.
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.
Done ✅
Also, would love to see an e2e test for this |
@itegulov added e2e tests for |
What 💻
--dump-state
cli cmd--state-interval
cli cmdWhy ✋
Evidence 📷
Include screenshots, screen recordings, or
console
output here demonstrating that your changes work as intendedUsage
Run the following command, wait ~60 secs and view
state.json
file:Forking: