Replies: 1 comment 1 reply
-
Sounds like a fun project! First I think you may have the the
You set
re: how to test your Ord impl.Main thing here is to check for transitivity, that is, if a < b and b < c then a < c. This may seem obvious but it's easy to break this property if you are not careful. The best way to test for this is to use a property testing framework like Lines 285 to 299 in 90d22b7 stepping back a bitWrapping all of your datatypes into a generic Consider moving your CRDT logic up a level to the higher level structures instead. For example: type Actor = Uuid;
type TimeStamp = (u64, Actor);
struct Entity {
// each field has it's own crdt container
position: LWWReg<Vector2<f32>, TimeStamp>
velocity: LWWReg<Vector2<f32>, TimeStamp>
inventory: Orswot<Item, Actor>
//...
}
impl crdts::CvRDT for Entity {
// Ship the Entity structs between clients and merge those instead of merging
fn merge(&mut self, other: Entity) {
self.position.merge(other.position);
self.velocity.merge(other.velocity);
self.inventory.merge(other.inventory);
}
} I obviously don't know the details of how your engine but the main ideas here is:
Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Hi there!
I am working on a new version of the open source SmartShape Engine written 100% in Rust using wgpu.
One of the main features I am investigating is making the new engine data driven + collaborative in a decentralized way. For example, if a user changes the color of an object, that object would change color for all the other users.
Here is an example that uses some WASM properties to synchronize the state of the WASM modules between multiple instances: https://twitter.com/kettlecorn/status/1620567336704180225 It's very low level and transparent. But IMHO it does cover the elephant in the room for larger projects: consistency and concurrency.
So I am trying to use CRDTs instead. The goal is to store the entire state of the 3D application in a CRDT and communicate the CRDT operations on the network to synchronize that state along multiple instances.
To do that, I need to store things like Vector and Matrix in such CRDT. I have started working with the crdts crate. To implement the state as a
crdts::Map<uuid::Uuid, crdts::Orswot<String, Value>, Value>
. In order for this to work,Value
must implementOrd
andPartialOrd
.So here is what I came up with:
I know that makes no mathematical sense to use the norm this way. But I don't actually intend to actually sort/compare vectors and/or matrices in my code to compute anything.
It builds just fine.
But I am just wondering if that "trick" doesn't fall short in terms of the expectations the
crdts::Orswot
andcrdts::Map
implementations have ofOrd
andPartialOrd
. And how to test it properly/thoroughly to make sure the required CRDT properties are indeed preserved.Beta Was this translation helpful? Give feedback.
All reactions