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

[fastx authority] Unify lock checks on order and certificate #313

Merged
merged 2 commits into from
Jan 31, 2022

Conversation

gdanezis
Copy link
Collaborator

This PR addresses issue #296 - we use a unified logic to check all locks for an order when we first handle the order and when we handle the certificate. And return all errors relating to missing or wrong version objects, rather than just the first.

&self,
order: &Order,
object_ref: ObjectRef,
object: Option<Object>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Option here seems a bit odd because the call will always fail if object is None. Perhaps we should take an Object here and do the "object not found" at the call site?

Would also be less bothered about this if the function was not pub because then it's clear that it's an internal API + that some wonkiness may exist.

Copy link
Collaborator Author

@gdanezis gdanezis Jan 30, 2022

Choose a reason for hiding this comment

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

This is an internal API. We are now non-pub for both. And we call with Object, not Option.

}
fp_ensure!(
!all_objects.is_empty(),
FastPayError::InsufficientObjectNumber
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pre-existing issue, but I find this error name a bit confusing (sounds like it could refer to object sequence numbers). It looks like we only raise it when there are zero input objects, so perhaps we could rename it to (e.g.) NoObjectInputs? Alternatively, if we also want to raise it in cases where there are too few/too many input objects for the order type, we could call it something like ObjectInputArityViolation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -300,7 +296,17 @@ impl AuthorityState {
recipient: Address,
mut gas_object: Object,
) -> FastPayResult<ExecutionStatus> {
let gas_used = gas::calculate_object_transfer_cost(&inputs[0]);
if inputs.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pre-existing issue, but should we check that the size of inputs is exactly one? If there are "extra" mutable inputs, they will (I think) not appear as outputs in the TransactionEffects and may have order locks set that are never cleared.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Totally. In fact #314 is about the non-transfer case.

fastx_types/src/error.rs Outdated Show resolved Hide resolved
fastx_types/src/error.rs Outdated Show resolved Hide resolved
match self.check_one_lock(order, object_ref, object) {
Ok((object_ref, object)) => all_objects.push((object_ref, object)),
Err(e) => {
errors.push(e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have some (minor) concerns about this. Returning every error to the client instead of short-circuiting is definitely better from a UX perspective, but it also forces the authority to do extra work that it cannot charge the client for.

However, I'm ok with this because (a) the work done seems fairly cheap, (b) I don't think this change gives an attacker any more DDOS-ing power--even if we kept the short-circuiting policy, the attacker can give the authority a long list of valid objects with an invalid one at the end. But thought I would at least raise this issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My thinking here is similar. Its a trade-off between how much we read from the DB, and how many times an order/cert is submitted to discover all missing objects.

@gdanezis gdanezis force-pushed the clean-up-authority-errors branch from 9058c03 to fc96555 Compare January 31, 2022 11:06
@gdanezis gdanezis merged commit 945fa41 into main Jan 31, 2022
@gdanezis gdanezis deleted the clean-up-authority-errors branch January 31, 2022 11:36
@lxfind
Copy link
Contributor

lxfind commented Jan 31, 2022

Hey @gdanezis this PR's change covers most of the code that will be changed in #300, which means massive merge conflict/rewrite for me :)
In the future though, it would be better if we could avoid touching same code at the same time. Thanks!

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