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

🐛 Stream representation Is non-deterministic #14

Open
ccamel opened this issue Oct 14, 2024 · 0 comments
Open

🐛 Stream representation Is non-deterministic #14

ccamel opened this issue Oct 14, 2024 · 0 comments

Comments

@ccamel
Copy link
Member

ccamel commented Oct 14, 2024

Issue

The current implementation of the Stream.WriteTerm function for streams outputs a pointer as part of the stream’s representation, which results in non-deterministic behavior.

prolog/engine/stream.go

Lines 82 to 86 in ea00e9b

// WriteTerm outputs the Stream to an io.Writer.
func (s *Stream) WriteTerm(w io.Writer, _ *WriteOptions, _ *Env) error {
_, err := fmt.Fprintf(w, "<stream>(%p)", s)
return err
}

Analysis

Using the pointer (%p) to represent the stream makes the output non-deterministic, as pointer values change between executions. This is particularly problematic in our case, where we use the Prolog engine in our blockchain. Determinism is critical for ensuring consistent state, reproducibility, and validation across distributed nodes.

test :- 
  current_output(Out), 
  write_term(Out, []).

?- test.
<stream>(0x1400015b380)
@github-project-automation github-project-automation bot moved this to 📋 Backlog in 💻 Development Oct 14, 2024
@ccamel ccamel moved this from 📋 Backlog to 📆 To do in 💻 Development Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📆 To do
Development

No branches or pull requests

1 participant