Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions crates/rbuilder-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct Metadata {
/// Order refund identity.
pub refund_identity: Option<Address>,
/// `RawBundle` field, round-tripped through `Bundle`. Not consumed by rbuilder.
pub disable_cross_region_sharing: Option<bool>,
pub disable_cross_region_sharing: bool,
}

impl Default for Metadata {
Expand All @@ -73,7 +73,7 @@ impl Metadata {
received_at_timestamp,
is_system: false,
refund_identity: None,
disable_cross_region_sharing: None,
disable_cross_region_sharing: false,
}
}

Expand All @@ -99,25 +99,18 @@ impl Metadata {
self.refund_identity = refund_identity;
}

pub fn with_disable_cross_region_sharing(
mut self,
disable_cross_region_sharing: Option<bool>,
) -> Self {
pub fn with_disable_cross_region_sharing(mut self, disable_cross_region_sharing: bool) -> Self {
self.disable_cross_region_sharing = disable_cross_region_sharing;
self
}

pub fn set_disable_cross_region_sharing(&mut self, disable_cross_region_sharing: Option<bool>) {
self.disable_cross_region_sharing = disable_cross_region_sharing;
}
}

impl InMemorySize for Metadata {
fn size(&self) -> usize {
mem::size_of::<time::OffsetDateTime>() + // received_at_timestamp
mem::size_of::<Option<Address>>() + // refund_identity
mem::size_of::<bool>() + // is_system
mem::size_of::<Option<bool>>() // disable_cross_region_sharing
mem::size_of::<bool>() // disable_cross_region_sharing
}
}

Expand Down
10 changes: 7 additions & 3 deletions crates/rbuilder-primitives/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ pub struct RawBundleMetadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_hash: Option<B256>,
/// Disable multiplexing bundle to other region builders.
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_cross_region_sharing: Option<bool>,
#[serde(default, skip_serializing_if = "is_false")]
pub disable_cross_region_sharing: bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wire-format compatibility note: the old Option<bool> accepted "disable_cross_region_sharing": null from clients (deserialized to None). With plain bool, an explicit null will now fail deserialization. Omitting the field still works because of #[serde(default)], but if any external producer sends explicit null, it will break. If you want to keep tolerating that, use #[serde(default, deserialize_with = "...")] to coerce null to false, or keep the Option<bool> only on RawBundleMetadata and convert at the boundary.

}

fn is_false(b: &bool) -> bool {
!*b
}

impl RawBundleMetadata {
Expand Down Expand Up @@ -234,7 +238,7 @@ impl RawBundleMetadata {
version,
));
}
if self.disable_cross_region_sharing.is_some() {
if self.disable_cross_region_sharing {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtle behavior change: previously validate_fields errored on Some(false) (because is_some() was checked), now it only errors when the flag is actually true. This is arguably more correct, but if any caller relied on V1 rejecting bundles that explicitly serialized "disable_cross_region_sharing": false, that rejection is gone. Worth confirming this is intended.

return Err(RawBundleConvertError::FieldNotSupportedByVersion(
"disable_cross_region_sharing".to_owned(),
version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<ConfigType: LiveBuilderConfig> SyntheticOrdersSource<ConfigType> {
received_at_timestamp: time::OffsetDateTime::from_unix_timestamp(0).unwrap(),
is_system: false,
refund_identity: None,
disable_cross_region_sharing: None,
disable_cross_region_sharing: false,
},
dropping_tx_hashes: Default::default(),
refund: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/rbuilder/src/backtest/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ mod test {
refund_identity: None,
version: Some(RawBundle::encode_version(LAST_BUNDLE_VERSION)),
bundle_hash: None,
disable_cross_region_sharing: None,
disable_cross_region_sharing: false,
},
})),
}
Expand Down
Loading