mina icon indicating copy to clipboard operation
mina copied to clipboard

Add block command verifier test subcommand

Open cjjdespres opened this issue 11 months ago • 3 comments

Explain your changes:

A new advanced test subcommand has been added, that can be invoked with:

mina advanced test verify-block-commands --block-file <FILE> --log-dir <DIR>

It will verify the commands in a precomputed block json file. By default it will verify the file contained in _build/default/src/lib/mina_block/tests/hetzner-itn-1-1795.json (the file downloaded and cached when building the mina_block tests) and will use the current working directory for log output. Both flags are optional.

Explain how you tested your changes:

I ran the command on my development laptop with a few combinations of different options. I also ran it with the environment variable PICKLES_PROFILING=true exported, to confirm that the internal pickles timing logs in the verifier were also output (to stdout) when running the command.

Checklist:

  • [x] Dependency versions are unchanged
  • [ ] Modified the current draft of release notes with details on what is completed or incomplete within this project
  • [ ] Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • [ ] Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • [ ] All tests pass (CI will check this if you didn't)
  • [x] Serialized types are in stable-versioned modules

cjjdespres avatar Mar 27 '25 17:03 cjjdespres

I'm not that familiar with ocaml yet, so I'm interested to know if there is a more idiomatic way of exposing Verifier.Prod.Worker_state for testing.

cjjdespres avatar Mar 27 '25 17:03 cjjdespres

This appears to be broken (doesn't compile) after the recent verifier changes, so I'll have to fix this up. Also, I should probably add this command to the test suite somewhere, once I figure out where that would be.

cjjdespres avatar Apr 15 '25 17:04 cjjdespres

Force-pushed to fix the existing code - it wasn't compiling against the new verifier interface. Fortunately, I was able to change the test code so it now uses the Verifier.Dummy verifier instead of creating a Verifier.Prod worker. Now I don't have to touch the verifier interface at all.

cjjdespres avatar May 05 '25 17:05 cjjdespres

Had to force-push to update to latest compatible, and adapt this to the signature_kind refactor - I put in some temporary signature kind parsing that can be removed once we figure out the user-facing side to that.

Edit - that didn't work, so we must not have completed enough of the refactor to have that be configurable yet. Now it's just the default signature kind for the build profile. I added a line warning about profile mismatches as well.

cjjdespres avatar Jul 25 '25 20:07 cjjdespres

Looks like Context_logger is some dynamic scoping magic. If possible we should get rid of it as it's anti-pattern.

glyh avatar Jul 27 '25 08:07 glyh

!ci-build-me

cjjdespres avatar Jul 28 '25 20:07 cjjdespres

Looks like Context_logger is some dynamic scoping magic. If possible we should get rid of it as it's anti-pattern.

It's not the best - I remember it using thread-local storage with Async to hold a common logger to output trace log info.

Also, wait until you see how PICKLES_PROFILING=true works (if you haven't seen it before):

https://github.com/MinaProtocol/mina/blob/f079c4f4bf9fc196f2873814b1d476da4280ae57/src/lib/pickles/common.ml#L56-L71

Not especially tool-friendly.

cjjdespres avatar Jul 28 '25 20:07 cjjdespres

I renamed the command time-block-command-verification to emphasize that this command is intended for benchmarking, not really for validating blocks on its own. Also, I had all the logging go to either stdout or a file depending on whether or not --test-log-file. Until the pickles profiling is made structured, it's handy to be able to separate the test output and trace lines from the pickles profiling output.

cjjdespres avatar Jul 28 '25 20:07 cjjdespres

I've also added a brief changelog entry. (This PR predates the new changelog system).

cjjdespres avatar Jul 28 '25 20:07 cjjdespres