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

CongestionTracker: #21164

Merged
merged 1 commit into from
Feb 13, 2025
Merged

CongestionTracker: #21164

merged 1 commit into from
Feb 13, 2025

Conversation

mystenmark
Copy link
Contributor

  • Witnesses congestion failures from checkpointed effects
  • Returns a suggested gas price given a set of input objects

@mystenmark mystenmark requested review from aschran and bmwill February 10, 2025 21:04
@mystenmark mystenmark temporarily deployed to sui-typescript-aws-kms-test-env February 10, 2025 21:04 — with GitHub Actions Inactive
Copy link

vercel bot commented Feb 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 13, 2025 4:34pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 4:34pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 13, 2025 4:34pm

Comment on lines +1394 to +1400
if state.is_fullnode(epoch_store) {
state.congestion_tracker.process_checkpoint_effects(
transaction_cache_reader,
&checkpoint,
&effects,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't care that this won't be called in-order right?

Copy link
Contributor

Choose a reason for hiding this comment

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

If you want you can move this logic down into where we already have a checkpoint data loaded in order to eliminate redundant loads that'll happen here as well as down there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not worried about the out of order-ness - we already use the checkpoint timestamps to ensure we have recent data, and up-to-date FNs will naturally process checkpoints in order anyway. If the FN isn't up to date the data will be useless no matter what.

Comment on lines +91 to +110
} else {
cleared_events.push((
gas_price,
effect
.input_shared_objects()
.into_iter()
.filter_map(|object| match object {
InputSharedObject::Mutate((id, _, _)) => Some(id),
InputSharedObject::Cancelled(_, _)
| InputSharedObject::ReadOnly(_)
| InputSharedObject::ReadDeleted(_, _)
| InputSharedObject::MutateDeleted(_, _) => None,
})
.collect::<Vec<_>>(),
));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume we only care if we don't have congested objects, not just that the txn succeeded (which is why this logic doesn't actually look at the success status)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

congested objects indicates that the tx was aborted due to congestion.

Copy link
Contributor

@halfprice halfprice left a comment

Choose a reason for hiding this comment

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

Sorry for the late review @mystenmark . This LGTM with some minor comments!

}
std::cmp::Ordering::Equal => {
// there were both successes and cancellations.
info.lowest_executed_gas_price
Copy link
Contributor

Choose a reason for hiding this comment

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

Can highest_cancelled_gas_price > lowest_executed_gas_price? If so, I wonder if this should be max(lowest_executed_gas_price, highest_cancelled_gas_price)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case the last success and last cancel time indicate that the events are from the same checkpoint. So no, I don't believe the highest cancelled could be higher than the lowest executed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I guess it could, because a transaction could have been cancelled because it was also using some other even more expensive object. But in this case lowest executed is still probably the right thing.

}

fn update_for_cancellation(&mut self, now: CheckpointTimestamp, gas_price: u64) {
self.last_cancellation_time = now;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does now ever differ from self.last_cancellation_time? Seems this is only called in the scope of one checkpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can differ because there may not be any cancellations in the most recently processed checkpoint, in which case this wouldn't be called.

crates/sui-core/src/congestion_tracker.rs Show resolved Hide resolved
entry.into_mut().update_for_cancellation(now, *gas_price);
}
Entry::Vacant(entry) => {
let info = CongestionInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this branch take self.get_congestion_info(*object) into consideration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so since that would be from the previous checkpoint. We consult it in the second loop to determine whether cleared events should be added, as explained in the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

If previous checkpoint is not considered, meaning all the CongestionInfo are just created in this loop, does "now" ever differ from self.last_cancellation_time when calling update_for_cancellation (from my other comment)? Or do I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm not sure I understand the question - I'm setting last_cancellation_time equal to now so no it would not differ?

- Witnesses congestion failures from checkpointed effects
- Returns a suggested gas price given a set of input objects
entry.into_mut().update_for_cancellation(now, *gas_price);
}
Entry::Vacant(entry) => {
let info = CongestionInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

If previous checkpoint is not considered, meaning all the CongestionInfo are just created in this loop, does "now" ever differ from self.last_cancellation_time when calling update_for_cancellation (from my other comment)? Or do I miss something?

@mystenmark mystenmark merged commit d4a321c into main Feb 13, 2025
47 checks passed
@mystenmark mystenmark deleted the mlogan-gas-info branch February 13, 2025 19:35
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