Skip to content

Link ANTLR4 Miniscript grammar - #1007

Merged
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
Nuhiat-Arefin:docs/antlr4-miniscript-grammar
Jul 29, 2026
Merged

Link ANTLR4 Miniscript grammar#1007
apoelstra merged 1 commit into
rust-bitcoin:masterfrom
Nuhiat-Arefin:docs/antlr4-miniscript-grammar

Conversation

@Nuhiat-Arefin

Copy link
Copy Markdown
Contributor

Adds a README link to the ANTLR4 grammar for Miniscript expressions in the antlr/grammars-v4 repository.

@satsfy satsfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept NACK
EDIT: cancelled the NACK given more recent comments

From my point of view, this doesn't add value for rust-miniscript users. It reads as promotion for the author's own grammar. The grammar also only covers surface syntax with the type system out of scope, so it's of limited use for real tooling anyway. If anything, it should not be occupying space on the project's main README.md because this has not been a need of rust-miniscript users up until now.

ANTLR also does not support Rust targets. Any use-case I can think of is built on top of rust-miniscript, not within it.

Could you provide some stronger justification for including this antlr grammar?

@trevarj

trevarj commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Concept NACK from me as well.

We aren't using ANTLR4 for parser generation (or any parser/lexer generator), so I don't really see the correlation.

@apoelstra

Copy link
Copy Markdown
Member

I'm gonna say concept ACK.

It's true that this has nothing to do with rust-miniscript, the Rust library. But this library is also the central hub for Miniscript research in general, since the other main implementation is built into Core and not designed to be so extensible.

@apoelstra

Copy link
Copy Markdown
Member

We may want to move this eventually to an "other resources" section. And I guess we ought to link Dmitry's Alloy implementation too, which actually found some bugs here.

@apoelstra

Copy link
Copy Markdown
Member

@Nuhiat-Arefin can you add an "Other Resources" section, above "Release Notes", and add this there instead of near the top of the README?

Assisted-by: OpenAI GPT-5
@Nuhiat-Arefin
Nuhiat-Arefin force-pushed the docs/antlr4-miniscript-grammar branch from 6a44c07 to 1ab21c1 Compare July 27, 2026 11:49
@Nuhiat-Arefin

Copy link
Copy Markdown
Contributor Author

@Nuhiat-Arefin can you add an "Other Resources" section, above "Release Notes", and add this there instead of near the top of the README?

Done

@Nuhiat-Arefin

Copy link
Copy Markdown
Contributor Author

Concept NACK

From my point of view, this doesn't add value for rust-miniscript users. It reads as promotion for the author's own grammar. The grammar also only covers surface syntax with the type system out of scope, so it's of limited use for real tooling anyway. If anything, it should not be occupying space on the project's main README.md because this has not been a need of rust-miniscript users up until now.

ANTLR also does not support Rust targets. Any use-case I can think of is built on top of rust-miniscript, not within it.

Could you provide some stronger justification for including this antlr grammar?

The main justification I had in mind is grammar-based and differential fuzzing. Random byte level mutations tend to produce malformed expressions that are rejected during shallow syntax checks. A grammar aware generator can preserve enough structure to produce valid or near valid Miniscript expressions, allowing fuzzing to exercise deeper paths in rust-miniscript. It can also help compare syntactic acceptance across independent implementations.

@satsfy

satsfy commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

grammar-based and differential fuzzing [...] grammar aware generator can preserve enough structure to produce valid or near valid Miniscript expressions, allowing fuzzing to exercise deeper paths in rust-miniscript.

More effective fuzzing would be a good outcome. I think the follow-up here would be to implement a PoC for grammar fuzzing. Which tools can do that? How to achieve it in rust-miniscript?

@apoelstra apoelstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 1ab21c1; successfully ran local tests

@Nuhiat-Arefin

Copy link
Copy Markdown
Contributor Author

grammar-based and differential fuzzing [...] grammar aware generator can preserve enough structure to produce valid or near valid Miniscript expressions, allowing fuzzing to exercise deeper paths in rust-miniscript.

More effective fuzzing would be a good outcome. I think the follow-up here would be to implement a PoC for grammar fuzzing. Which tools can do that? How to achieve it in rust-miniscript?

I am not proposing integrating this grammar into rust-miniscript’s fuzzing infrastructure. Independent researchers and other implementations can use tools such as LibAFL Nautilus or Grammarinator to generate structured inputs for fuzzing and differential testing.

I have already conducted grammar-based differential fuzzing with LibAFL Nautilus and reported issues in nBitcoin, embit, and bitcoinerlab/miniscript.

The README addition is only intended to make the grammar discoverable as an independent Miniscript resource that the community can maintain.

@satsfy satsfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK 1ab21c1

Moving link to "other resources" and, now knowing the goal of making rust-miniscript a central hub, it tips the scale for this PR so I approve.

If I may ask, feel free to ignore these if they take too much of your time, but the answers would be useful for anyone who wants to fuzz miniscript later:

  • What did the fuzzer find? Links to the issues would help.
  • How does the grammar get into the fuzzer? Is there a conversion step?
  • How do you decide an input is a bug? The parser disagreeing with the grammar is not a bug by itself, since the grammar accepts whitespace and rust-miniscript does not.

@apoelstra
apoelstra merged commit 64816cd into rust-bitcoin:master Jul 29, 2026
14 checks passed
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.

4 participants