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

Introduce typed holes; improve disconnect support in human-readable encoding #169

Merged
merged 7 commits into from
Aug 28, 2023

Conversation

apoelstra
Copy link
Collaborator

This introduces the notion of "typed holes" which can be used as placeholders in the text encoding of Simplicity. It uses these holes for disconnect, so that at commitment time users can set their right children to placeholders. The old behavior, which allowed putting a complete expression into disconnect that wouldn't be committed to, was dangerous.

Comment on lines 178 to 184
let cmr_str = /*if let node::Inner::Witness(..) = node.inner() {
String::new()
} else {
format!("-- cmr {:.8}...", node.cmr())
};
} else { */
format!("-- cmr {}...", node.cmr())
+ &format!(" -- imr {}...", node.imr().as_ref().map(ToString::to_string).unwrap_or("???".to_string()))
// };
;
Copy link
Collaborator

Choose a reason for hiding this comment

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

04f8ffa: We probably want to remove the special case for witness entirely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, this code just shouldn't be there. Or we should step back and consider whether we want to add CMRs, IMRs, or both (and how). Right now it's an ad-hoc choice based on what I currently needed to generate blog posts.

Copy link
Collaborator

@uncomputable uncomputable Aug 22, 2023

Choose a reason for hiding this comment

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

I think we should print the CMR for all nodes since it exists. As for the IMR, the ??? string might be confusing, because it looks like a bug in our software. I think we should remove it. Alternatively we could print something like (malleable) for witness IMRs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think malleable is misleading. How about [undetermined]? Or even [undetermined at commitment time] since we've got a lot of room for characters here.

Copy link
Collaborator

@uncomputable uncomputable left a comment

Choose a reason for hiding this comment

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

04f8ffa: Looks good. Unfortunately most of the example programs don't yet compile. In particular bip340.simpl causes errors on the latest commit because the holes are not filled somehow.

@apoelstra
Copy link
Collaborator Author

Rebased and renamed last commit. No other changes. I will fix the example programs tomorrow.

@apoelstra
Copy link
Collaborator Author

FIxed the example programs. Deleted the hidden and disconnect ones, since those test bugs that are no longer architecturally possible.

Copy link
Collaborator

@uncomputable uncomputable left a comment

Choose a reason for hiding this comment

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

7494aab: The example programs work now. Let's resolve the printing of CMRs and IMRs, and then this PR is ready to be merged.

@apoelstra
Copy link
Collaborator Author

Ok, added commit which tweaks the printing output.

@sanket1729
Copy link
Member

I don't know what exactly is the issue. But as of 5465612
the following program does not rountrip. It can be disassembled. But cannot be assembled again.

sanket1729:~/rust-simplicity$ ./target/debug/simpcli disassemble 4MmyAAAACgRswIQKEGMTtoNQNpVbfx0Z7yNAFvcHOnVjPKpYTxVfJS0O0xfn5YYSBrFWbcQRgECZn3AgG8A= > ./simpcli/example_programs/test.simpl
sanket1729:~/rust-simplicity$ ./target/debug/simpcli assemble ./simpcli/example_programs/test.simpl 
Expression `main` not found.

Copy link
Collaborator

@uncomputable uncomputable left a comment

Choose a reason for hiding this comment

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

5465612: The formatting looks good.

I could reproduce @sanket1729's error on my end. The disassembly output has a main, but the assembler doesn't find it.

Copy link
Collaborator

@uncomputable uncomputable left a comment

Choose a reason for hiding this comment

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

5465612 ACK. Sanket's bug is already present on master.

@uncomputable uncomputable merged commit ad82c92 into master Aug 28, 2023
@uncomputable
Copy link
Collaborator

I opened #173

@uncomputable uncomputable deleted the 2023-06--simplang branch August 28, 2023 17:45
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