Skip to content

Use simplicity-sys for running test programs #117

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

Closed

Conversation

m-kus
Copy link
Contributor

@m-kus m-kus commented Mar 25, 2025

This PR shows how to reproduce the type inference error: instead of using BitMachine we switch to the C backend

@uncomputable
Copy link
Collaborator

Feel free to rebase this PR

@m-kus m-kus force-pushed the simplicity-sys-runner branch from fc27a3f to 766ddb9 Compare March 31, 2025 15:46
@uncomputable uncomputable self-assigned this Apr 1, 2025
@uncomputable
Copy link
Collaborator

uncomputable commented Apr 1, 2025

SIGSEGV: invalid memory reference looks pretty bad. I will investigate.

The error appears for all example programs. Likely, some safety condition for the FFI Bit Machine execution function is not fulfilled.

@uncomputable
Copy link
Collaborator

uncomputable commented Apr 1, 2025

Ok, two issues:

  1. The run_program function passes a null pointer for the Elements environment. This will lead to segmentation faults for programs with introspection jets. Maybe, this will lead to segmentation faults for all Elements programs (all compiled Simfony programs). We should hide the FFI function better and update its documentation to warn callers.
  2. self.program.redeem().encode_to_vec() creates an unpruned program. Pruning is a compression which is mandatory by consensus. The run_program function assumes correct pruning and might run into undefined behavior if this is not the case. Again, we should warn callers.

@uncomputable
Copy link
Collaborator

I was able to reproduce the error using a slightly modified branch.

test tests::type_error_regression ... FAILED

failures:

---- tests::type_error_regression stdout ----
[src/lib.rs:402:13] program_bytes.to_lower_hex_string() = "e3f4d900000000022c800000004180548142484186031d828164cdb89cd75dcbc1e84ea7a320719cbfc6dc95e5194f9eca996d55a7b2d768c511e2a310e1806216c60e671544245742660022ae160c5e14b09ec0c2a17584bf5c548c85961c02b6efc010c031590000000103822c80000000c1c182a40a05c1b2170a30445fea038d226980c2e6f7e4be9e895848d1fd97f2100db43004cb4eaddefc507820142e1c605defb50a3eeb43e8e2e90243456d2f12614b1995dc46128037a36dd3f9760030f02028fc42609bc5c4a6f13a1848e019ef88de2e7a3c1561d1828b3be0f290def9feebf54da94249472c0f0f0285c5267e0aad66c82658ec0c7f2a5a2cc38c3f61a892acd0da3a133ff9ead668873dc60f0d0284e2e3f188205bc05070a0b8880640e370"
[src/lib.rs:402:13] witness_bytes.to_lower_hex_string() = ""

thread 'tests::type_error_regression' panicked at src/lib.rs:419:31:
Unexpected error: TypeInferenceUnification

Cargo.toml Outdated
@@ -26,7 +26,7 @@ pest = "2.1.3"
pest_derive = "2.7.1"
serde = { version = "1.0.188", features = ["derive"], optional = true }
serde_json = { version = "1.0.105", optional = true }
simplicity-lang = { git = "https://github.com/BlockstreamResearch/rust-simplicity", rev = "2f52e22483079ace09e76754222220b5c230a9d0" }
simplicity-lang = { git = "https://github.com/BlockstreamResearch/rust-simplicity", rev = "2f52e22483079ace09e76754222220b5c230a9d0", features = ["test-utils"]}

Choose a reason for hiding this comment

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

Use the released version?

@m-kus m-kus force-pushed the simplicity-sys-runner branch from 7309b08 to 2d47335 Compare April 15, 2025 10:38
@m-kus
Copy link
Contributor Author

m-kus commented Apr 15, 2025

Closing this as #118 is resolved now

@m-kus m-kus closed this Apr 15, 2025
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.

3 participants