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

Add witness module #93

Merged

Conversation

uncomputable
Copy link
Collaborator

@uncomputable uncomputable commented Oct 8, 2024

Make witness JSON parsing via serde optional. Introduce witness modules as an alternative way to provide witness data. Witness modules are written directly inside the Simfony source code.

@uncomputable uncomputable force-pushed the 2024-10-witness-module branch 2 times, most recently from 81aef08 to ad4b247 Compare October 8, 2024 19:38
@uncomputable
Copy link
Collaborator Author

Ok, wow, the fuzzer found a bug

@apoelstra
Copy link
Contributor

Neat! Concept ACK. Though I imagine in the future this will become a weird corner of the language that is only really used by the web IDE.

@uncomputable
Copy link
Collaborator Author

I moved most changes to #94. The fuzzer bug has to do with the witness module, which kind of lives inside the parse tree and kind of doesn't.

@uncomputable uncomputable marked this pull request as draft October 8, 2024 19:58
We introduce a witness module that can be put anywhere inside the source
file. Like in Rust, there can be at most one module of the same name.

mod witness {
    const Alice: Signature = 0xabde...;
    const Bob: Signature = 0x1234...;
}

The witness module is optional and witness data can still be provided
via JSON. The Simfony program parser ignores any witness modules. A
separate parser parses the witness modules.

Most lines of this commit are boilerplate that the witness module parser
introduces.
Use fmt::Display to print WitnessValues as a witness module. This can be
parsed via ParseFromStr back into WitnessValues.

Rename parse_witness_rtt to parse_witness_json_rtt to disambiguate the
it from new the target parse_witness_module_rtt.

Run cargo fmt inside the `fuzz` crate.
@uncomputable
Copy link
Collaborator Author

uncomputable commented Oct 9, 2024

I fixed the fuzzer.

Writing witness data directly into the program is a huge feature for the IDE, but I agree that it feels kind of weird. Keeping the program parser separate from the witness parser will allow us to remove the feature if we no longer need it.

@uncomputable uncomputable marked this pull request as ready for review October 9, 2024 11:10
Copy link
Contributor

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK e3ed903 successfully ran local tests

@uncomputable uncomputable merged commit f877c7b into BlockstreamResearch:master Oct 10, 2024
11 checks passed
@uncomputable uncomputable deleted the 2024-10-witness-module branch October 10, 2024 16:56
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.

2 participants