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

Long running operation set to done before dependencies are done #200

Open
lenkan opened this issue Mar 1, 2024 · 7 comments
Open

Long running operation set to done before dependencies are done #200

lenkan opened this issue Mar 1, 2024 · 7 comments

Comments

@lenkan
Copy link
Collaborator

lenkan commented Mar 1, 2024

Note sure if you would consider this a bug, but I thought I would flag it because the behavior is not expected to me.

Actual Behaviour

When an operation has dependencies, it's done status is set to true before the dependencies are done. For example, when an AID with witnesses is creating a registry, you get:

{
  name: 'registry.EMr2ZK2Y5CpACEM6iHJQPrI4oHk7xg6QjUK_Uw0YFFld',
  metadata: {
    anchor: {
      i: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK',
      s: '0',
      d: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK'
    },
    depends: {
      name: 'witness.EMr2ZK2Y5CpACEM6iHJQPrI4oHk7xg6QjUK_Uw0YFFld',
      metadata: [Object],
      done: false,
      error: null,
      response: null
    }
  },
  done: true,
  error: null,
  response: {
    anchor: {
      i: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK',
      s: '0',
      d: 'EHmDHffYsNVW8-T-IRD2zcLEopTcE96ZugeKWY_GdxRK'
    }
  }
}

Notice how the top-level operation is done, but it's dependencies are not. The same happens when issuing credentials:

{
  name: 'credential.EAM5C0JG9_zpMhKg97t-Rw9QaeKiYpPPXhmQQXr0GM8m',
  metadata: {
    ced: {
      ...
    },
    depends: {
      name: 'witness.EAM5C0JG9_zpMhKg97t-Rw9QaeKiYpPPXhmQQXr0GM8m',
      metadata: { sn: 2 },
      done: false,
      error: null,
      response: null
    }
  },
  done: true,
  error: null,
  response: {
    ced: {
      ...
    }
  }
}

Expected behaviour

Top level operation done should also depend on its child operations. So something like this done = depends.done === true ? self.done : false

Notes

This could be implemented at client level of course. But i suspect others will run into the same issue unless this is well documented.

@psteniusubi
Copy link
Contributor

@iFergal
Copy link
Collaborator

iFergal commented Oct 18, 2024

So depends isn't really a "thing" in KERIA. It's just metadata stored with the operation that the client interprets. Given the current code structure, it could make sense to recursively check to make sure operations are done.

However, I'm a bit torn though as we will eventually need event driven support (see #290). It would be problematic to not be able to emit the event because the dependent events are not done, and this adds complexity of checking if the dependencies are done at emit time.

So in an event driven architecture, the client ends up needing to aggregate the event completions anyway, I think. Maybe it's better if they are consistent and better documented. What do you think?

@lenkan
Copy link
Collaborator Author

lenkan commented Oct 18, 2024

Ok. Yes I had a similar feeling when I looked into that code recently.

For now, I think it is probably fine to leave as is and it would be up to the client to do the right thing.

But I still find it a bit odd that the registry operation is considered done without the witness receipts. That is at least how I interpret the first example.

@iFergal
Copy link
Collaborator

iFergal commented Oct 18, 2024

The registry operation calls findAnchoringSealEvent - which from a quick glance, seems like it waits until it's fully witnessed. Perhaps there's a bug there.

@SmithSamuelM
Copy link
Contributor

It depends on what the role of the particular participant is. FindAnchoringSealEvent finds events anchored in KELs in the LMDB database. The rules for what events are "accepted" or first seen in a KEL depend on the relation of the participant to a given KEL. If the participant is a Controller of the KEL then it will be accepted without witness receipts. If the participant is a Delegator of the KEL then is will NOT be accepted without witness receipts. If the participant is a witness of the KEL then is will be accepted with only the self generated receipt not fully receipted. IF the participant is anyone else i.e a Watcher the the event will NOT be accepted into the KEL until is is fully receipted and if delegated until the anchoring seal has been find in the Delegators's KEL.

@SmithSamuelM
Copy link
Contributor

THis is one reason why I strongly suggest that KERIA agents should run local watchers and then make decisions based on the status of the local watcher's KEL not a local controller's KEL.

@SmithSamuelM
Copy link
Contributor

Or at least unit tests should understand what they are testing for. Is is the view of the KEL that a watcher will see or the view of the KEL as some other participant will see? It matters for the test.

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

No branches or pull requests

4 participants