Skip to content

smite-scenarios: deduplicate executor variable resolvers - #232

Merged
morehouse merged 1 commit into
lnfuzz:masterfrom
erickcestari:refactor-exec-func
Sep 9, 2026
Merged

smite-scenarios: deduplicate executor variable resolvers#232
morehouse merged 1 commit into
lnfuzz:masterfrom
erickcestari:refactor-exec-func

Conversation

@erickcestari

Copy link
Copy Markdown
Contributor

The 17 resolve_* functions differed only in the matched variant, and the two consume_sent_* functions only in the affine type they voided.

Generate the resolvers with a define_resolver! macro that shares one type_mismatch panic, and replace the consumers with a single consume_affine that takes the expected VariableType.

@Chand-ra Chand-ra left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM!

&FundingTransaction
);

/// Consumes an affine variable, leaving its slot void so it cannot be used

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: Rust doesn't have "voids". What we're doing is replacing the used variable with None.

Something like this would perhaps be better?

Consumes an affine variable, replacing it with `None` to prevent double-use.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are using the term void in the codebase to refer to a None Variable.

For example: https://github.com/erickcestari/smite/blob/7ab8dfbc37ec56a86c06ab1619f1b82637579d71/smite-ir/src/tests.rs#L1999

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You're right. A comment there says:

// SendMessage is last and has void output.

which uses void in the same breadth as you do here. I don't like it there either, but I guess it is a colloquial for the project atp and hence fine.

Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs
Comment thread smite-scenarios/src/executor.rs Outdated
Comment thread smite-scenarios/src/executor.rs Outdated
The 17 `resolve_*` functions differed only in the matched variant, and
the two `consume_sent_*` functions only in the affine type they voided.

Generate the resolvers with a `define_resolver!` macro that shares one
`type_mismatch` panic, and replace the consumers with a single
`consume_affine` that takes the expected `VariableType`.
@morehouse
morehouse merged commit 6f7ccbd into lnfuzz:master Sep 9, 2026
5 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