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

env.block.random in queries returns a single byte of zero #1624

Open
luca992 opened this issue Feb 27, 2024 · 2 comments
Open

env.block.random in queries returns a single byte of zero #1624

luca992 opened this issue Feb 27, 2024 · 2 comments

Comments

@luca992
Copy link
Contributor

luca992 commented Feb 27, 2024

In queries, env.block.random returns a Vec<u8>[0] (a byte array with a single byte which is zero).

If randomness in queries is unsupported (which it appears it is), I think this behavior is dangerous and can lead to someone unknowing using the query block "random" as an actual random, when it is not random at all.

It would make much more sense to just return None in this case to completely avoid misuse.

@assafmo
Copy link
Member

assafmo commented Feb 27, 2024

It is indeed not supported in queries since the source of randomness is the block header.

@luca992
Copy link
Contributor Author

luca992 commented Feb 27, 2024

Yeah, understandable. Just returning None will prevent a lot of future easily avoidable problems then I think

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

No branches or pull requests

2 participants