-
Notifications
You must be signed in to change notification settings - Fork 42
feat: initial attempt at replicator integration #1049
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
base: bmuddha/executor/block-tracker
Are you sure you want to change the base?
Changes from all commits
7592a78
0975b98
0a6a559
62454bf
d0da5c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,3 +41,14 @@ impl Default for ValidatorConfig { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| impl ReplicationMode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Returns the remote URL if this node participates in replication. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Returns `None` for `Standalone` mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pub fn remote(&self) -> Option<Url> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| match self { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Self::Standalone => None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Self::StandBy(u) | Self::ReplicatOnly(u) => Some(u.clone()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+45
to
+54
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. 🧹 Nitpick | 🔵 Trivial Add direct coverage for the mode-to-remote mapping. This helper now decides whether Minimal coverage example+#[cfg(test)]
+mod tests {
+ use super::ReplicationMode;
+ use url::Url;
+
+ #[test]
+ fn remote_returns_expected_value_for_each_mode() {
+ let url = Url::parse("nats://localhost:4222").unwrap();
+
+ assert_eq!(ReplicationMode::Standalone.remote(), None);
+ assert_eq!(
+ ReplicationMode::StandBy(url.clone()).remote(),
+ Some(url.clone())
+ );
+ assert_eq!(
+ ReplicationMode::ReplicatOnly(url.clone()).remote(),
+ Some(url)
+ );
+ }
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,6 @@ | ||||||||||||||||
| pub type Slot = u64; | ||||||||||||||||
| /// Ordinal position of a transaction within a slot. | ||||||||||||||||
| pub type TransactionIndex = u32; | ||||||||||||||||
|
Comment on lines
+2
to
+3
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. 🧹 Nitpick | 🔵 Trivial Clarify that The new rustdoc reads like callers can rely on ordering within a slot, but current processor paths still emit Possible doc tweak-/// Ordinal position of a transaction within a slot.
+/// Logical transaction position within a slot.
+///
+/// Note: current processor paths may still emit `0` here; true per-slot
+/// ordinals will be introduced with the planned ledger rewrite.
pub type TransactionIndex = u32;Based on learnings: In magicblock-processor, transaction indexes were always set to 0 even before the changes in PR 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
|
|
||||||||||||||||
| /// A macro that panics when running a debug build and logs the panic message | ||||||||||||||||
| /// instead when running in release mode. | ||||||||||||||||
|
|
||||||||||||||||
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.
Replace
.expect()with proper error handling.Per coding guidelines, using
.expect()in production code undermagicblock-*/**is a major issue requiring proper error handling.🔧 Proposed fix
let replication_service = if let Some((broker, is_fresh_start)) = broker { - let messages_rx = dispatch.replication_messages.take().expect( - "replication channel should always exist after init", - ); + let messages_rx = dispatch.replication_messages.take().ok_or_else(|| { + ApiError::FailedToStartReplicationService( + "replication channel missing after init".to_string(), + ) + })?; ReplicationService::new( broker, mode_tx.clone(), accountsdb.clone(), ledger.clone(), dispatch.transaction_scheduler.clone(), messages_rx, token.clone(), is_fresh_start, ) .await? } else { None };Note: You may need to add a
FailedToStartReplicationServicevariant toApiErroror use an existing appropriate variant. As per coding guidelines: "Treat any usage of.unwrap()or.expect()in production Rust code as a MAJOR issue."🤖 Prompt for AI Agents