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 async message updates and add unit test #4766

Open
wants to merge 4 commits into
base: mainnet_2_3
Choose a base branch
from

Conversation

sydhds
Copy link
Contributor

@sydhds sydhds commented Oct 22, 2024

No description provided.

Copy link
Contributor

@Leo-Besancon Leo-Besancon left a comment

Choose a reason for hiding this comment

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

Great work! The various tested scenarios are nice

@sydhds sydhds requested a review from damip October 28, 2024 10:34
@@ -83,7 +83,9 @@ impl ActiveHistory {
return HistorySearchResult::Present(SetUpdateOrDelete::Set(msg));
}
Some(SetUpdateOrDelete::Update(msg_update)) => {
current_updates.apply(msg_update.clone());
let mut combined_message_update = msg_update.clone();
Copy link
Member

Choose a reason for hiding this comment

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

I think current_updates does not need to be mut anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it still does because of line 88 :)

current_updates.apply(msg_update.clone());
let mut combined_message_update = msg_update.clone();
combined_message_update.apply(current_updates);
current_updates = combined_message_update;
}
Some(SetUpdateOrDelete::Delete) => return HistorySearchResult::Absent,
Copy link
Member

Choose a reason for hiding this comment

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

how about this ? if the current_updates actually creates an element while it was deleted before... can it happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

  • If we Delete then Set, the latest Set is taken into account and we break before
  • If we Delete then Update, I don't think it's possible. If it happens it's ok to return Absent in my mind, but it would be a bug no?

@@ -287,7 +287,7 @@ impl SpeculativeAsyncPool {
}
Present(SetUpdateOrDelete::Update(msg_update)) => {
current_changes.entry(message_id).and_modify(|e| {
e.apply(msg_update.clone());
*e = msg_update.clone();
Copy link
Member

Choose a reason for hiding this comment

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

why was this changed ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It did work before, but it technically applied the current_changes twice (the returned msg_update already took them into account, so we directly replace it)

@Leo-Besancon
Copy link
Contributor

@sydhds unless you think otherwise, I think we can merge this one :)

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.

3 participants