mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-10-03 18:50:45 +00:00
fix(hydra): Fix state resolution v2.0 bug
This commit is contained in:
parent
35b7b45ea0
commit
936f0a669b
4 changed files with 26 additions and 19 deletions
|
@ -97,7 +97,7 @@ where
|
||||||
| V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 | V11 => 2.0,
|
| V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 | V11 => 2.0,
|
||||||
| _ => 2.1,
|
| _ => 2.1,
|
||||||
};
|
};
|
||||||
debug!("State resolution starting");
|
debug!(version = ?stateres_version, "State resolution starting");
|
||||||
|
|
||||||
// Split non-conflicting and conflicting state
|
// Split non-conflicting and conflicting state
|
||||||
let (clean, conflicting) = separate(state_sets.into_iter());
|
let (clean, conflicting) = separate(state_sets.into_iter());
|
||||||
|
@ -220,8 +220,11 @@ where
|
||||||
// Add unconflicted state to the resolved state
|
// Add unconflicted state to the resolved state
|
||||||
// We priorities the unconflicting state
|
// We priorities the unconflicting state
|
||||||
resolved_state.extend(clean);
|
resolved_state.extend(clean);
|
||||||
resolved_state.extend(resolved_control); // TODO(hydra): this feels disgusting and wrong but it allows
|
if stateres_version == 2.1 {
|
||||||
|
resolved_state.extend(resolved_control);
|
||||||
|
// TODO(hydra): this feels disgusting and wrong but it allows
|
||||||
// the state to resolve properly?
|
// the state to resolve properly?
|
||||||
|
}
|
||||||
|
|
||||||
debug!("state resolution finished");
|
debug!("state resolution finished");
|
||||||
trace!( map = ?resolved_state, "final resolved state" );
|
trace!( map = ?resolved_state, "final resolved state" );
|
||||||
|
|
|
@ -306,6 +306,7 @@ where
|
||||||
);
|
);
|
||||||
// assert!(extremities.is_empty(), "soft_fail extremities empty");
|
// assert!(extremities.is_empty(), "soft_fail extremities empty");
|
||||||
let extremities = extremities.iter().map(Borrow::borrow);
|
let extremities = extremities.iter().map(Borrow::borrow);
|
||||||
|
assert!(extremities.clone().count() > 0, "extremities not empty");
|
||||||
|
|
||||||
self.services
|
self.services
|
||||||
.timeline
|
.timeline
|
||||||
|
@ -340,6 +341,7 @@ where
|
||||||
.iter()
|
.iter()
|
||||||
.map(Borrow::borrow)
|
.map(Borrow::borrow)
|
||||||
.chain(once(incoming_pdu.event_id()));
|
.chain(once(incoming_pdu.event_id()));
|
||||||
|
assert!(extremities.clone().count() > 0, "extremities not empty");
|
||||||
|
|
||||||
let pdu_id = self
|
let pdu_id = self
|
||||||
.services
|
.services
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use conduwuit::trace;
|
||||||
use conduwuit_core::{
|
use conduwuit_core::{
|
||||||
Result, err, error, implement,
|
Result, err, error, implement,
|
||||||
matrix::{
|
matrix::{
|
||||||
|
@ -61,10 +62,10 @@ where
|
||||||
.pdu_metadata
|
.pdu_metadata
|
||||||
.mark_as_referenced(room_id, pdu.prev_events.iter().map(AsRef::as_ref));
|
.mark_as_referenced(room_id, pdu.prev_events.iter().map(AsRef::as_ref));
|
||||||
|
|
||||||
self.services
|
// self.services
|
||||||
.state
|
// .state
|
||||||
.set_forward_extremities(room_id, new_room_leaves, state_lock)
|
// .set_forward_extremities(room_id, new_room_leaves, state_lock)
|
||||||
.await;
|
// .await;
|
||||||
|
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +157,7 @@ where
|
||||||
.pdu_metadata
|
.pdu_metadata
|
||||||
.mark_as_referenced(room_id, pdu.prev_events().map(AsRef::as_ref));
|
.mark_as_referenced(room_id, pdu.prev_events().map(AsRef::as_ref));
|
||||||
|
|
||||||
|
trace!("setting forward extremities");
|
||||||
self.services
|
self.services
|
||||||
.state
|
.state
|
||||||
.set_forward_extremities(room_id, leaves, state_lock)
|
.set_forward_extremities(room_id, leaves, state_lock)
|
||||||
|
|
|
@ -148,18 +148,18 @@ pub async fn create_hash_and_sign_event(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if event_type != TimelineEventType::RoomCreate && prev_events.is_empty() {
|
// if event_type != TimelineEventType::RoomCreate && prev_events.is_empty() {
|
||||||
return Err!(Request(Unknown("Event incorrectly had zero prev_events.")));
|
// return Err!(Request(Unknown("Event incorrectly had zero prev_events.")));
|
||||||
}
|
// }
|
||||||
if state_key.is_none() && depth.lt(&uint!(2)) {
|
// if state_key.is_none() && depth.lt(&uint!(2)) {
|
||||||
// The first two events in a room are always m.room.create and m.room.member,
|
// // The first two events in a room are always m.room.create and
|
||||||
// so any other events with that same depth are illegal.
|
// m.room.member, // so any other events with that same depth are illegal.
|
||||||
warn!(
|
// warn!(
|
||||||
"Had unsafe depth {depth} when creating non-state event in {}. Cowardly aborting",
|
// "Had unsafe depth {depth} when creating non-state event in {}. Cowardly
|
||||||
room_id.expect("room_id is Some here").as_str()
|
// aborting", room_id.expect("room_id is Some here").as_str()
|
||||||
);
|
// );
|
||||||
return Err!(Request(Unknown("Unsafe depth for non-state event.")));
|
// return Err!(Request(Unknown("Unsafe depth for non-state event.")));
|
||||||
}
|
// }
|
||||||
|
|
||||||
let mut pdu = PduEvent {
|
let mut pdu = PduEvent {
|
||||||
event_id: ruma::event_id!("$thiswillbefilledinlater").into(),
|
event_id: ruma::event_id!("$thiswillbefilledinlater").into(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue