-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - Use a fixed state hasher in bevy_reflect for deterministic Reflect::reflect_hash() across processes #7583
Conversation
It's hard to imagine a case where we wouldn't want this. Why should this be a feature, rather than always enabled? |
Yeah, I guess the possibility of DOS attacks through bevy_reflect are pretty far fetched. I guess if anything it should probably an opt-in feature to make it runtime-seeded. Hard-coding to always use fixed state |
crates/bevy_reflect/src/reflect.rs
Outdated
use bevy_utils::FixedState; | ||
|
||
#[inline] | ||
pub fn reflect_hasher() -> bevy_utils::AHasher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This should probably have a doc stating what it does, how/where it's used, and when/why to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also done :)
Conflicts: - crates/bevy_reflect/src/list.rs
2f08657
to
9ce4f42
Compare
Sorry for the noise, still figuring out how the "reviewers" system on github works |
bors r+ |
…eflect_hash() across processes (#7583) # Objective - bevy_ggrs uses `reflect_hash` in order to produce checksums for its world snapshots. These checksums are sent between clients in order to detect desyncronization. - However, since we currently use `async::AHasher` with the `std` feature, this means that hashes will always be different for different peers, even if the state is identical. - This means bevy_ggrs needs a way to get a deterministic (fixed) hash. ## Solution - ~~Add a feature to use `bevy_utils::FixedState` for the hasher used by bevy_reflect.~~ - Always use `bevy_utils::FixedState` for initializing the bevy_reflect hasher. --- ## Changelog - bevy_reflect now uses a fixed state for its hasher, which means the output of `Reflect::reflect_hash` is now deterministic across processes.
Build failed (retrying...): |
…eflect_hash() across processes (#7583) # Objective - bevy_ggrs uses `reflect_hash` in order to produce checksums for its world snapshots. These checksums are sent between clients in order to detect desyncronization. - However, since we currently use `async::AHasher` with the `std` feature, this means that hashes will always be different for different peers, even if the state is identical. - This means bevy_ggrs needs a way to get a deterministic (fixed) hash. ## Solution - ~~Add a feature to use `bevy_utils::FixedState` for the hasher used by bevy_reflect.~~ - Always use `bevy_utils::FixedState` for initializing the bevy_reflect hasher. --- ## Changelog - bevy_reflect now uses a fixed state for its hasher, which means the output of `Reflect::reflect_hash` is now deterministic across processes.
…eflect_hash() across processes (bevyengine#7583) - bevy_ggrs uses `reflect_hash` in order to produce checksums for its world snapshots. These checksums are sent between clients in order to detect desyncronization. - However, since we currently use `async::AHasher` with the `std` feature, this means that hashes will always be different for different peers, even if the state is identical. - This means bevy_ggrs needs a way to get a deterministic (fixed) hash. - ~~Add a feature to use `bevy_utils::FixedState` for the hasher used by bevy_reflect.~~ - Always use `bevy_utils::FixedState` for initializing the bevy_reflect hasher. --- - bevy_reflect now uses a fixed state for its hasher, which means the output of `Reflect::reflect_hash` is now deterministic across processes.
Objective
reflect_hash
in order to produce checksums for its world snapshots. These checksums are sent between clients in order to detect desyncronization.async::AHasher
with thestd
feature, this means that hashes will always be different for different peers, even if the state is identical.Solution
Add a feature to usebevy_utils::FixedState
for the hasher used by bevy_reflect.bevy_utils::FixedState
for initializing the bevy_reflect hasher.Changelog
Reflect::reflect_hash
is now deterministic across processes.