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 dist.sys] Augment fastnft to deal with many input and output objects per transactions #39

Merged
merged 4 commits into from
Dec 13, 2021

Conversation

gdanezis
Copy link
Collaborator

@gdanezis gdanezis commented Dec 8, 2021

This handles the issue #8 . It involves:

  • Augmenting the 'Order' struct with 'input_objects' returning object refs.
  • Modifying the 'handle_order' to check and lock multiple objects.
  • Add an 'execute' to 'Order' that takes input objects and returns output objects.
  • Modify the 'handle_confirmation_order' to handle many input / outputs.

Out of scope:

@gdanezis gdanezis changed the title Augment fastnft to deal with many input and output objects per transactions [fastx dist.sys] Augment fastnft to deal with many input and output objects per transactions Dec 8, 2021
@gdanezis gdanezis marked this pull request as draft December 8, 2021 22:38
Comment on lines 342 to 343
if let Some(_existing_signed_order) = lock {
if _existing_signed_order.order == signed_order.order {
Copy link
Contributor

Choose a reason for hiding this comment

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

So here you're correctly avoiding any shadowing issue by not putting signed_order.order in your pattern, great!
But you could also do, perhaps more simply, if lock == Some(signed_order.order)

Copy link
Collaborator Author

@gdanezis gdanezis Dec 10, 2021

Choose a reason for hiding this comment

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

Hm, but I need to do something different in all three cases:

  • Some(lock) == lock

  • Some(lock) =/= lock

  • None

          if let Some(existing_signed_order) = lock {
              if existing_signed_order.order == signed_order.order {
                  // For some reason we are re-inserting the same order. Not optimal but correct.
                  continue;
              } else {
                  // We are trying to set the lock to a different order, this is unsafe.
                  return Err(FastPayError::OrderLockReset);
              }
          }
    

So if I do the equality test instead of the let binding, then I will have to add a subsequent if to test if it is none, not equal, and then return the Err, right? Is there a better pattern?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah sorry I read too fast. This may be useful, but it's equivalent to what you have;
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b09a069e4a42cb50528ca5c871d73967

Copy link
Collaborator Author

@gdanezis gdanezis left a comment

Choose a reason for hiding this comment

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

Quick comments to attract @patrickkuo attention to returns.

// Add new object, init locks and remove old ones
self.insert_object(output_object);
self.init_order_lock(output_ref);
}

let info = self.make_object_info(object_id)?;
Ok(info)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@patrickkuo I am now at the point when I am thinking what the 'handle_order' and 'handle_confirmation_order' should return, since now many objects could be changed / created / deleted by an order. Since you are looking at the client, what are your thoughts on what you need? We would have to make the authority return this.

Copy link
Contributor

@patrickkuo patrickkuo Dec 10, 2021

Choose a reason for hiding this comment

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

Since I don't have a complete list of client operation at the moment so I will suggest we leave it for now?

The ops I knew we need on objects so far are:
Create, Transfer, Split, Combine, and Delete (and Clone?), I will create an issue to discuss this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lets make an issue to discuss all this, and leave this question out of this PR -- thanks!

@gdanezis gdanezis marked this pull request as ready for review December 10, 2021 12:27
@gdanezis gdanezis force-pushed the manyinputtransactions branch from fd31f8c to 5e6655f Compare December 10, 2021 18:44
Copy link
Contributor

@patrickkuo patrickkuo left a comment

Choose a reason for hiding this comment

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

one small comment, otherwise LGTM

}
OrderKind::Call(c) => {
let sender = c.sender.to_address_hack();
OrderKind::Call(_c) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

is _c intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, changed it to 'c'

@gdanezis gdanezis merged commit ba61dd4 into main Dec 13, 2021
@gdanezis gdanezis deleted the manyinputtransactions branch December 13, 2021 19:32
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