diff --git a/crates/fuzz/src/crdt_fuzzer.rs b/crates/fuzz/src/crdt_fuzzer.rs index c855d5f4..7abc9744 100644 --- a/crates/fuzz/src/crdt_fuzzer.rs +++ b/crates/fuzz/src/crdt_fuzzer.rs @@ -347,6 +347,7 @@ where N: Fn(u8, &mut [T]) -> Vec, T: Clone + Debug + Send + 'static, { + println!("Minifying..."); std::panic::set_hook(Box::new(|_info| { // ignore panic output // println!("{:?}", _info); diff --git a/crates/fuzz/tests/test.rs b/crates/fuzz/tests/test.rs index 8690810a..03c7ae25 100644 --- a/crates/fuzz/tests/test.rs +++ b/crates/fuzz/tests/test.rs @@ -8573,1372 +8573,81 @@ fn fast_snapshot_2() { vec![FuzzTarget::All], &mut [ Handle { - site: 25, - target: 25, - container: 193, - action: Generic(GenericAction { - value: I32(1644825), - bool: false, - key: 393216, - pos: 27487790694400, - length: 1808504320951916800, - prop: 18446744073709551385, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, + site: 187, + target: 122, + container: 36, action: Generic(GenericAction { value: Container(Unknown(255)), bool: true, - key: 436207615, - pos: 1808504320765729049, - length: 16131858541569448217, - prop: 16131858542891098079, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(-14614783), - bool: true, - key: 4294967295, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 1808505174692462591, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 538976296, - pos: 1808505174690352095, - length: 1808504321102911769, - prop: 1808504323367835929, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(85530905), - bool: false, - key: 421075225, - pos: 18446744073709551615, - length: 16131858680869027839, - prop: 18437701552104792031, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 421075225, - pos: 16131771927245691161, - length: 2314895150467243999, - prop: 1808722877991345952, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075369), - bool: true, - key: 6425, - pos: 1801439850948198400, - length: 1808505037875910937, - prop: 18446744073709551513, - }), - }, - SyncAll, - Undo { - site: 255, - op_len: 4227596287, - }, - SyncAll, - Handle { - site: 33, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4227539233, - pos: 18384011580076532219, - length: 18446744073709551615, - prop: 18157382442381606911, - }), - }, - SyncAll, - Handle { - site: 33, - target: 33, - container: 33, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 554827775, - pos: 1297035798778028321, - length: 16421219282251206401, - prop: 18446744073695002595, - }), - }, - SyncAll, - Handle { - site: 33, - target: 33, - container: 33, - action: Generic(GenericAction { - value: Container(Unknown(251)), - bool: true, - key: 4227858431, - pos: 18157383382357244923, - length: 2387226643631176699, - prop: 18446744073694945569, - }), - }, - SyncAll, - Handle { - site: 239, - target: 129, - container: 207, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 3755999231, - pos: 18446743935731621855, - length: 18446744073709551615, - prop: 16140901064495857663, - }), - }, - Handle { - site: 25, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858541569448217, - length: 16077885992209473503, - prop: 1808504324286832587, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: true, - key: 0, - pos: 18446742974197923840, - length: 18446744073709551615, - prop: 18446744073709551615, - }), - }, - Handle { - site: 25, - target: 25, - container: 34, - action: Generic(GenericAction { - value: I32(-57089), - bool: true, - key: 4294967295, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 1808504324286840831, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(-544138983), - bool: true, - key: 3755991007, - pos: 16126228219801118943, - length: 1808504320951967711, - prop: 1808504320951916834, - }), - }, - Handle { - site: 25, - target: 25, - container: 0, - action: Generic(GenericAction { - value: I32(0), - bool: true, - key: 85530905, - pos: 18446743081993181632, - length: 18446744073709551615, - prop: 8319119878197870591, - }), - }, - Undo { - site: 115, - op_len: 1936946035, - }, - Handle { - site: 255, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 1936946035, - pos: 8319119876378817395, - length: 8319119876378817395, - prop: 8319119876378817395, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(25)), - bool: true, - key: 421075225, - pos: 16131858204548733209, - length: 2314885568395206623, - prop: 1808505174690352095, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 25, - pos: 1808476725365964800, - length: 11031876360607176985, - prop: 18446744073709551615, - }), - }, - SyncAll, - Handle { - site: 25, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 4279834905, - pos: 10455415605511192575, - length: 2945318833950285791, - prop: 16131858456979185696, - }), - }, - Handle { - site: 192, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 3750828543, - pos: 16131858542891098079, - length: 18446744073170575327, - prop: 18446744073709551615, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(25)), - bool: true, - key: 421075225, - pos: 16131858204548733209, - length: 2314885568395206623, - prop: 1808505174690352095, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 25, - pos: 18446462598732840960, - length: 18446744073709551615, - prop: 18446744073709551615, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 538976296, - pos: 1808505174690352095, - length: 1808504321102911769, - prop: 1808504323367835929, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(435231001), - bool: true, - key: 421075392, - pos: 18446744073709551385, - length: 16131893865241116671, - prop: 8319119876378817395, - }), - }, - Undo { - site: 115, - op_len: 1936946035, - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(-544138983), - bool: true, - key: 3755991007, - pos: 16126228219801118943, - length: 1808504320951967711, - prop: 1808504320951916834, - }), - }, - Handle { - site: 25, - target: 25, - container: 0, - action: Generic(GenericAction { - value: I32(0), - bool: true, - key: 85530905, - pos: 18446743081993181632, - length: 18446744073709551615, - prop: 16131858542891106303, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(421117957), - bool: true, - key: 4294967065, - pos: 18446744073709551615, - length: 16131858542891106303, - prop: 18446744073170575327, - }), - }, - Handle { - site: 25, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858541569448217, - length: 16077885992209473503, - prop: 1808504324286832587, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: true, - key: 0, - pos: 1808504213156659200, - length: 18417779746705245465, - prop: 18446744073709551615, - }), - }, - Handle { - site: 255, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858542885935385, - length: 14690495831856439263, - prop: 1808504320964943839, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: false, - key: 0, - pos: 18446744069414584320, - length: 18446744073709551615, - prop: 18446744073709551615, - }), - }, - Handle { - site: 25, - target: 34, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4294967295, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 18381750949675392991, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(-538976367), - bool: true, - key: 685760479, - pos: 16131858456979185696, - length: 1811037595742312729, - prop: 1849036717598251289, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(421068800), - bool: true, - key: 432014617, - pos: 18446744073694419225, - length: 18446744073709551615, - prop: 8319119876378845151, - }), - }, - Undo { - site: 115, - op_len: 1936946035, - }, - Handle { - site: 25, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858541569448217, - length: 16077885992209473503, - prop: 1808504324286832587, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 538976296, - pos: 1808505174690352095, - length: 1808504321102911769, - prop: 1808504323367835929, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(85530905), - bool: false, - key: 2568558873, - pos: 18446744073709551615, - length: 16131858542885935615, - prop: 16131858542891098079, - }), - }, - Handle { - site: 255, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858542885935385, - length: 14690495831856439263, - prop: 1808504320964943839, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 538978527, - pos: 1808722877991345952, - length: 1808504359606622489, - prop: 1808504939427207449, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(421075225), - bool: true, - key: 421075392, - pos: 18446744073709551385, - length: 16131893865241116671, - prop: 8319119876378817395, - }), - }, - Undo { - site: 115, - op_len: 1936946035, - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 421075225, - pos: 16131771927245691161, - length: 2314895150467243999, - prop: 16131836552657231648, - }), - }, - Handle { - site: 25, - target: 255, - container: 127, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858541569448217, - length: 16077885992209473503, - prop: 1808504324286832587, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: true, - key: 0, - pos: 1808504213156659200, - length: 18417779746705245465, - prop: 18446744073709551615, - }), - }, - Handle { - site: 255, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858542885935385, - length: 14690495831856439263, - prop: 1808504320964943839, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: false, - key: 0, - pos: 18446744069414584320, - length: 18444492273895866367, - prop: 18446744073709551615, - }), - }, - Handle { - site: 25, - target: 34, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4294967295, - pos: 18446744073709515519, - length: 18446744073709551615, - prop: 18381750949675392991, - }), - }, - Handle { - site: 25, - target: 5, - container: 25, - action: Generic(GenericAction { - value: I32(-538976367), - bool: true, - key: 685760479, - pos: 0, - length: 1, - prop: 1849036717598251289, - }), - }, - Undo { - site: 115, - op_len: 1936946035, - }, - SyncAll, - Handle { - site: 0, - target: 0, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 488447261, - pos: 7453, - length: 0, - prop: 0, - }), - }, - ], - ) -} - -#[test] -fn out_of_bounds() { - test_multi_sites( - 5, - vec![FuzzTarget::All], - &mut [ - Handle { - site: 200, - target: 19, - container: 19, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 320019219, - pos: 1374463283923456787, - length: 1374472080016478995, - prop: 1374463283923456787, - }), - }, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(320017171), - bool: true, - key: 320017171, - pos: 1374463309693260563, - length: 1374463283923456531, - prop: 202940420883, - }), - }, - Handle { - site: 171, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(1091769107), - bool: true, - key: 335483667, - pos: 18446743056122319635, - length: 13165911456529954486, - prop: 13165911456529954486, - }), - }, - SyncAll, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(320017217), - bool: true, - key: 320017171, - pos: 18446744073709551379, - length: 1441151880758558719, - prop: 6562610054654268258, - }), - }, - SyncAllUndo { - site: 131, - op_len: 2206434179, - }, - Handle { - site: 35, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(321655571), - bool: true, - key: 95860406, - pos: 13165911456517980160, - length: 13165911456529954486, - prop: 18137885445146982070, - }), - }, - Handle { - site: 0, - target: 0, - container: 255, - action: Generic(GenericAction { - value: Container(Tree), - bool: true, - key: 4288914339, - pos: 18446744073709551412, - length: 18446744073709551615, - prop: 18446673704965373951, - }), - }, - Handle { - site: 35, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(321655571), - bool: true, - key: 95860406, - pos: 13165911456517980160, - length: 13165911456529954486, - prop: 18137885445146982070, + key: 4287627263, + pos: 4902828863, + length: 9335720388467884032, + prop: 226866784668584321, }), }, Handle { site: 27, - target: 19, - container: 19, + target: 27, + container: 27, action: Generic(GenericAction { - value: I32(320017171), + value: I32(454761243), bool: true, - key: 320017171, - pos: 1374463283923456787, - length: 1374463283923456787, - prop: 9444913841941189395, + key: 2812782503, + pos: 12080808863958804391, + length: 12080808863958804391, + prop: 12080808863958804391, }), }, SyncAllUndo { - site: 131, - op_len: 2206434179, + site: 167, + op_len: 2812782503, }, - Undo { - site: 255, - op_len: 2214592511, - }, - ], - ); -} - -#[test] -fn out_of_bounds2() { - test_multi_sites( - 5, - vec![FuzzTarget::All], - &mut [ Handle { - site: 200, - target: 19, - container: 19, + site: 27, + target: 27, + container: 49, action: Generic(GenericAction { - value: I32(320017171), + value: I32(875640369), bool: true, - key: 320017171, - pos: 13382931975044141843, - length: 13382931975044184505, - prop: 13382931975044184505, - }), - }, - SyncAll, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(-875836653), - bool: true, - key: 50331647, - pos: 18446744069448270338, - length: 1306609049538134015, - prop: 12370169553823465472, + key: 454761243, + pos: 1953184666628070298, + length: 144115188075855871, + prop: 4557431447142210354, }), }, Handle { - site: 19, - target: 19, - container: 19, + site: 93, + target: 52, + container: 27, action: Generic(GenericAction { - value: Container(Tree), + value: I32(1061109567), bool: true, - key: 2745410467, - pos: 11791448172606497699, - length: 11791448172606497699, - prop: 11791448172606497699, - }), - }, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(-875883757), - bool: true, - key: 4294967243, - pos: 18446742982821544450, - length: 2450523354990379007, - prop: 12370169174473834514, - }), - }, - Handle { - site: 39, - target: 7, - container: 7, - action: Generic(GenericAction { - value: I32(825307441), - bool: true, - key: 825307441, - pos: 18446744073695998257, - length: 18446744073709551615, - prop: 18446744073709551615, - }), - }, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: I32(-875883757), - bool: true, - key: 4294967243, - pos: 18446742982821544450, - length: 2450523354990379007, - prop: 12370169174473834514, - }), - }, - Handle { - site: 19, - target: 19, - container: 19, - action: Generic(GenericAction { - value: Container(Text), - bool: false, - key: 4278321666, - pos: 144686934122299391, - length: 12345211003553849858, - prop: 12370169555311111083, + key: 1061109567, + pos: 1953184666628079423, + length: 1953184666628070235, + prop: 12041247832392499326, }), }, SyncAllUndo { - site: 19, - op_len: 117901063, + site: 167, + op_len: 2812782503, }, - ], - ) -} - -#[test] -fn tree_none() { - test_multi_sites( - 5, - vec![FuzzTarget::All], - &mut [ Handle { - site: 17, - target: 17, - container: 17, + site: 27, + target: 27, + container: 27, action: Generic(GenericAction { - value: I32(286331137), + value: I32(1499027801), bool: true, - key: 286331153, - pos: 1229782938247303443, - length: 1229782938247303441, - prop: 1229782938247303441, + key: 1499027801, + pos: 6438275382588823897, + length: 6438275382588823897, + prop: 6438275382588823897, }), }, - Handle { - site: 17, - target: 17, - container: 17, - action: Generic(GenericAction { - value: I32(1118481), - bool: true, - key: 286331157, - pos: 17, - length: 2676586395008836901, - prop: 2676586395008836901, - }), - }, - Handle { - site: 238, - target: 37, - container: 37, - action: Generic(GenericAction { - value: I32(623191333), - bool: true, - key: 623191333, - pos: 2676586395008836901, - length: 1225019780861338917, - prop: 1229782941887959313, - }), - }, - Handle { - site: 17, - target: 17, - container: 17, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 286331153, - pos: 1229782938247303441, - length: 1229782938247303441, - prop: 1229782938247339793, - }), - }, - Sync { from: 181, to: 181 }, - Sync { from: 183, to: 181 }, - Handle { - site: 17, - target: 17, - container: 17, - action: Generic(GenericAction { - value: I32(286331665), - bool: true, - key: 286331153, - pos: 1229782938247303441, - length: 1229782938247303441, - prop: 1229782938247303441, - }), - }, - Handle { - site: 53, - target: 37, - container: 37, - action: Generic(GenericAction { - value: I32(9509), - bool: true, - key: 286331153, - pos: 2676586394672032273, - length: 2676586395008836901, - prop: 10414647441244210, - }), - }, - ], - ) -} - -#[test] -fn checkout_text_err() { - test_multi_sites( - 5, - vec![FuzzTarget::All], - &mut [ - Handle { - site: 25, - target: 25, - container: 193, - action: Generic(GenericAction { - value: I32(1644825), - bool: false, - key: 393216, - pos: 27487790694400, - length: 1808504320951976800, - prop: 18446744073709551385, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 436207615, - pos: 1808504320951916825, - length: 16131858542891077913, - prop: 18437701552104792031, - }), - }, - SyncAll, - Handle { - site: 25, - target: 34, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4294967295, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 18381750949675392991, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(-538976367), - bool: true, - key: 685760479, - pos: 16131858456979185696, - length: 1811037595742312729, - prop: 1849036717598251289, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(421068800), - bool: true, - key: 432014617, - pos: 18446744073694419225, - length: 18446744073709551615, - prop: 16131858542891098079, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858204548733209, - length: 2314885568395206623, - prop: 1808505174690352095, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 25, - pos: 1808476725365964800, - length: 11031876360607176985, - prop: 18446744073709486086, - }), - }, - SyncAll, - Handle { - site: 33, - target: 33, - container: 255, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 553582865, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 18446744073709551615, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(25)), - bool: true, - key: 421075225, - pos: 16131858204548733209, - length: 2314885568395206623, - prop: 1808505174690352095, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 25, - pos: 1808476725365964800, - length: 1808505037875966233, - prop: 18446744073709551385, - }), - }, - SyncAll, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(223)), - bool: true, - key: 538976296, - pos: 1808505174690352095, - length: 1808504321102911769, - prop: 1808504323367835929, - }), - }, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(85530905), - bool: false, - key: 421075225, - pos: 18446744073709551615, - length: 16131858680869027839, - prop: 18437701552104792031, - }), - }, - SyncAll, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(421117957), - bool: true, - key: 4294967065, - pos: 18446744073709551615, - length: 16131858542891106303, - prop: 18446744073170575327, - }), - }, - SyncAll, - Undo { - site: 115, - op_len: 1936946035, - }, - Handle { - site: 25, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858541569448217, - length: 16077885992209473503, - prop: 1808504324286832587, - }), - }, - Handle { - site: 25, - target: 25, - container: 25, - action: Generic(GenericAction { - value: I32(421075225), - bool: true, - key: 0, - pos: 1808504213156659200, - length: 18417779746705245465, - prop: 18446744073709551615, - }), - }, - SyncAll, - Handle { - site: 255, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 421075225, - pos: 16131858542885935385, - length: 14690495831856439263, - prop: 1808504320964943839, - }), - }, - SyncAll, - Handle { - site: 25, - target: 34, - container: 25, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4294967295, - pos: 18446744073709551615, - length: 18446744073709551615, - prop: 18381750949675392991, - }), - }, - SyncAll, - Undo { - site: 115, - op_len: 1936946035, - }, - SyncAll, - Handle { - site: 0, - target: 0, - container: 0, - action: Generic(GenericAction { - value: I32(85530905), - bool: false, - key: 2568558873, - pos: 18446744073709551615, - length: 16131858542885935615, - prop: 16131858542891098079, - }), - }, - ], - ) -} - -#[test] -fn tree_none_2() { - test_multi_sites( - 5, - vec![FuzzTarget::All], - &mut [ - Handle { - site: 33, - target: 33, - container: 33, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 2165440511, - pos: 18446713166840815823, - length: 18446744073695002623, - prop: 9300496180473495551, - }), - }, - Handle { - site: 0, - target: 22, - container: 255, - action: Generic(GenericAction { - value: Container(List), - bool: true, - key: 3823363055, - pos: 18230571291581218791, - length: 18157382442382598433, - prop: 288225960857959419, - }), - }, - Handle { - site: 33, - target: 255, - container: 255, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4227539233, - pos: 18157383382357244923, - length: 18158513695410093051, - prop: 18157383382357244923, - }), - }, - Handle { - site: 222, - target: 222, - container: 33, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 4294967295, - pos: 16421231524240645393, - length: 16429131436923020259, - prop: 18446743120224969699, - }), - }, - SyncAll, - Handle { - site: 223, - target: 47, - container: 255, - action: Generic(GenericAction { - value: Container(Unknown(227)), - bool: true, - key: 4280418275, - pos: 2387225707395678207, - length: 18157383382357244705, - prop: 18157110720653425422, - }), - }, - Handle { - site: 239, - target: 227, - container: 227, - action: Generic(GenericAction { - value: Container(Text), - bool: true, - key: 555819352, - pos: 2387470198964822305, - length: 2883820151245971745, - prop: 18446744069970395169, - }), - }, - SyncAll, - Handle { - site: 33, - target: 33, - container: 33, - action: Generic(GenericAction { - value: Container(Unknown(255)), - bool: true, - key: 554827775, - pos: 1297035798778028321, - length: 16421219282251206529, - prop: 18446744073695002595, - }), - }, - SyncAll, - Undo { - site: 123, - op_len: 2071690107, + SyncAllUndo { + site: 37, + op_len: 2812782503, }, ], ) @@ -9950,6 +8659,178 @@ fn minify() { 5, |n, actions| test_multi_sites(n, vec![FuzzTarget::All], actions), |_, actions| actions.to_vec(), - vec![], + vec![ + Handle { + site: 187, + target: 122, + container: 36, + action: Generic(GenericAction { + value: Container(Unknown(255)), + bool: true, + key: 4287627263, + pos: 4902828863, + length: 9335720388467884032, + prop: 226866784668584321, + }), + }, + Handle { + site: 27, + target: 27, + container: 27, + action: Generic(GenericAction { + value: I32(454761243), + bool: true, + key: 2812782503, + pos: 12080808863958804391, + length: 12080808863958804391, + prop: 12080808863958804391, + }), + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + Handle { + site: 27, + target: 27, + container: 49, + action: Generic(GenericAction { + value: I32(875640369), + bool: true, + key: 454761243, + pos: 1953184666628070298, + length: 144115188075855871, + prop: 4557431447142210354, + }), + }, + Checkout { + site: 63, + to: 457129791, + }, + Handle { + site: 93, + target: 52, + container: 27, + action: Generic(GenericAction { + value: I32(1061109567), + bool: true, + key: 1061109567, + pos: 1953184666628079423, + length: 1953184666628070235, + prop: 12041247832392499326, + }), + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2805114791, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + Handle { + site: 167, + target: 167, + container: 167, + action: Generic(GenericAction { + value: Container(Tree), + bool: true, + key: 2812782503, + pos: 12080808863958804391, + length: 12080808863958804391, + prop: 12080808863958804391, + }), + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + Handle { + site: 27, + target: 27, + container: 27, + action: Generic(GenericAction { + value: I32(1499027801), + bool: true, + key: 1499027801, + pos: 6438275382588823897, + length: 6438275382588823897, + prop: 6438275382588823897, + }), + }, + Undo { + site: 89, + op_len: 1499027801, + }, + Undo { + site: 89, + op_len: 1499027801, + }, + Undo { + site: 89, + op_len: 1499027801, + }, + Undo { + site: 89, + op_len: 1499027801, + }, + Undo { + site: 89, + op_len: 1499027801, + }, + Undo { + site: 89, + op_len: 2812782425, + }, + SyncAllUndo { + site: 37, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 2812782503, + }, + SyncAllUndo { + site: 167, + op_len: 454761383, + }, + Handle { + site: 27, + target: 27, + container: 218, + action: Generic(GenericAction { + value: I32(454761243), + bool: true, + key: 454761243, + pos: 18446744073694550811, + length: 13924878376503476223, + prop: 17802464409370431, + }), + }, + ], ) } diff --git a/crates/loro-internal/src/handler.rs b/crates/loro-internal/src/handler.rs index 09aa64d9..a63fb983 100644 --- a/crates/loro-internal/src/handler.rs +++ b/crates/loro-internal/src/handler.rs @@ -31,9 +31,7 @@ use std::{ ops::Deref, sync::{Arc, Mutex, Weak}, }; - use tracing::{debug, error, info, instrument, trace}; - mod tree; pub use tree::TreeHandler; diff --git a/crates/loro-internal/src/undo.rs b/crates/loro-internal/src/undo.rs index de6a0422..f3647455 100644 --- a/crates/loro-internal/src/undo.rs +++ b/crates/loro-internal/src/undo.rs @@ -13,6 +13,7 @@ use tracing::{debug_span, info_span, instrument}; use crate::{ change::get_sys_timestamp, cursor::{AbsolutePosition, Cursor}, + delta::TreeExternalDiff, event::{Diff, EventTriggerKind}, version::Frontiers, ContainerDiff, DocDiff, LoroDoc, @@ -122,7 +123,7 @@ fn transform_cursor( #[derive(Debug)] pub struct UndoManager { peer: PeerID, - container_remap: FxHashMap, + container_remap: Arc>>, inner: Arc>, } @@ -425,6 +426,8 @@ impl UndoManager { doc, peer, )))); let inner_clone = inner.clone(); + let remap_containers = Arc::new(Mutex::new(FxHashMap::default())); + let remap_containers_clone = remap_containers.clone(); doc.subscribe_root(Arc::new(move |event| match event.event_meta.by { EventTriggerKind::Local => { // TODO: PERF undo can be significantly faster if we can get @@ -454,6 +457,23 @@ impl UndoManager { } EventTriggerKind::Import => { let mut inner = inner_clone.try_lock().unwrap(); + + for e in event.events { + if let Diff::Tree(tree) = &e.diff { + for item in &tree.diff { + let target = item.target; + if let TreeExternalDiff::Create { .. } = &item.action { + // If the concurrent event is a create event, it may bring the deleted tree node back, + // so we need to remove it from the remap of the container. + remap_containers_clone + .lock() + .unwrap() + .remove(&target.associated_meta_container()); + } + } + } + } + inner.undo_stack.compose_remote_event(event.events); inner.redo_stack.compose_remote_event(event.events); } @@ -467,7 +487,7 @@ impl UndoManager { UndoManager { peer, - container_remap: Default::default(), + container_remap: remap_containers, inner, } } @@ -607,7 +627,7 @@ impl UndoManager { peer: self.peer, counter: span.span, }, - &mut self.container_remap, + &mut self.container_remap.lock().unwrap(), Some(&remote_change_clone), &mut |diff| { info_span!("transform remote diff").in_scope(|| { @@ -628,7 +648,7 @@ impl UndoManager { cursor, &remote_diff.try_lock().unwrap(), doc, - &self.container_remap, + &self.container_remap.lock().unwrap(), ); }