-
Notifications
You must be signed in to change notification settings - Fork 208
Add disable_cross_region_sharing param #922
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| use super::{ | ||
| Bundle, BundleRefund, BundleReplacementData, BundleReplacementKey, BundleVersion, MempoolTx, | ||
| Order, RawTransactionDecodable, TransactionSignedEcRecoveredWithBlobs, TxWithBlobsCreateError, | ||
| LAST_BUNDLE_VERSION, | ||
| Metadata, Order, RawTransactionDecodable, TransactionSignedEcRecoveredWithBlobs, | ||
| TxWithBlobsCreateError, LAST_BUNDLE_VERSION, | ||
| }; | ||
| use alloy_consensus::constants::EIP4844_TX_TYPE_ID; | ||
| use alloy_eips::eip2718::Eip2718Error; | ||
|
|
@@ -153,6 +153,9 @@ pub struct RawBundleMetadata { | |
| /// bundleHash, externally set unique identifier for the bundle | ||
| #[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>, | ||
| } | ||
|
|
||
| impl RawBundleMetadata { | ||
|
|
@@ -231,6 +234,12 @@ impl RawBundleMetadata { | |
| version, | ||
| )); | ||
| } | ||
| if self.disable_cross_region_sharing.is_some() { | ||
| return Err(RawBundleConvertError::FieldNotSupportedByVersion( | ||
| "disable_cross_region_sharing".to_owned(), | ||
| version, | ||
| )); | ||
| } | ||
|
Comment on lines
+237
to
+242
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The V1 rejection added here isn't covered by |
||
| Ok(()) | ||
| } | ||
| BundleVersion::V2 => Ok(()), | ||
|
|
@@ -377,7 +386,8 @@ impl RawBundle { | |
| max_timestamp: metadata.max_timestamp.filter(|t| *t != 0), | ||
| signer: metadata.signing_address, | ||
| refund_identity: metadata.refund_identity, | ||
| metadata: Default::default(), | ||
| metadata: Metadata::default() | ||
| .with_disable_cross_region_sharing(metadata.disable_cross_region_sharing), | ||
| dropping_tx_hashes: metadata.dropping_tx_hashes, | ||
| refund, | ||
| version, | ||
|
|
@@ -417,6 +427,7 @@ impl RawBundle { | |
| delayed_refund: value.refund.as_ref().map(|br| br.delayed), | ||
| version: Some(Self::encode_version(value.version)), | ||
| bundle_hash: value.external_hash, | ||
| disable_cross_region_sharing: value.metadata.disable_cross_region_sharing, | ||
| }, | ||
| } | ||
| } | ||
|
|
@@ -1018,6 +1029,8 @@ mod tests { | |
| r#" "refundPercent": 1 "#, | ||
| r#" "refundRecipient": "0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5" "#, | ||
| r#" "refundTxHashes": ["0x75662ab9cb6d1be7334723db5587435616352c7e581a52867959ac24006ac1fe"] "#, | ||
| r#" "delayedRefund": true "#, | ||
| r#" "disableCrossRegionSharing": true "#, | ||
| ]; | ||
|
|
||
| for field in extra_invalid_fields { | ||
|
|
||
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.
Minor API note: the new field semantically represents "disable" (a bool flag), and modelling it as
Option<bool>invites three states βNone,Some(false),Some(true)β where only two are meaningful. If the goal is to round-trip the wire-formatOption<bool>faithfully, this is fine, but consider if the internalMetadatacould store a plainbool(defaulting to false) and only the wireRawBundleMetadatakeeps theOption. As written,NoneandSome(false)are indistinguishable in behaviour but produce different serialized output, which can lead to roundtrip surprises.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.
Option is used to have correct RawBuilder -> Bundle -> RawBundle conversion