Skip to content
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

fix(mempool): allow internal batch dependencies #549

Open
wants to merge 11 commits into
base: next-block-producer
Choose a base branch
from

Conversation

Mirko-von-Leipzig
Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig commented Nov 13, 2024

This PR fixes a crash when a batch contained both a parent and child transaction.

In addition, this PR improves the error presentation when the node crashes.


Background: client integration tests were stalling when run against the new mempool based block-producer. This PR fixes the bug that causes this.

The stall occurred because the block-producer component exited, but the node continued on as it only crashes if a component errors. This PR rectifies this behaviour; we now crash the node if any component ends. In addition, this PR improves the errors by identifying the failing component.

This PR also merges in next. This was required to properly compare and debug the client integration tests. It might be best to review the last few commits instead.

Mirko-von-Leipzig and others added 11 commits November 2, 2024 10:14
Clippy issue rust-lang/rust-clippy#12281 was fixed
in v1.81. We now have MSRV of 1.82 allowing us to remove our workaround.

More specifically, #[async_trait] was triggering this lint, and as of 1.81 no
longer does.
* refactor: improve `ApplyBlockErrors` variants

* docs: update `CHANGELOG.md`

* refactor: address review comments
* Update state.rs

* docs: Update expect()

* chore: Lints
Improve block-producer top-level errors.
@Mirko-von-Leipzig Mirko-von-Leipzig marked this pull request as ready for review November 13, 2024 13:07
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

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

Overall LGTM, but not too familiar with the context of the graph which was causing the issue in the first place so leaving a few comments while I check out the rest of the codebase

//
// Map all outcomes to an error, and provide component context.
let (id, err) = match component_result {
Ok((id, Ok(_))) => (id, Err(anyhow::anyhow!("Component completed unexpectedly"))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Possibly marginally more useful to output which component completed succesfully here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This context gets added lower down, since we first have to map the ID to component name.

Ok((id, Err(err))) => (id, Err(err)),
Err(join_err) => (join_err.id(), Err(join_err).context("Joining component task")),
};
let component = component_ids.get(&id).unwrap_or(&"unknown");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this error/panic instead of defaulting to "unknown"? Looks like it shouldn't really happen

Err(err) => err.id(),
};
let task = task_ids.get(&task_id).unwrap_or(&"unknown");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment about panicking instead of defaulting to "unknown"

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left a couple of small comments inline.

@@ -278,6 +282,17 @@ mod tests {
assert_eq!(err, expected);
}

#[test]
fn insert_with_internal_parent_succeeds() {
//! Ensure that a batch with internal dependencies can be inserted.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this should be a simple comment (i.e., //), right?

Comment on lines 91 to +94
&mut self,
id: BatchJobId,
transactions: Vec<TransactionId>,
parents: BTreeSet<TransactionId>,
mut parents: BTreeSet<TransactionId>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add an explanation of what parents is to the doc comment for this function? (e.g., we should mention that parents may contain transactions also in transactions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants