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

Validator memorizes values about previous calls to oracle #59

Open
djrtwo opened this issue Oct 16, 2017 · 6 comments
Open

Validator memorizes values about previous calls to oracle #59

djrtwo opened this issue Oct 16, 2017 · 6 comments
Assignees

Comments

@djrtwo
Copy link
Collaborator

djrtwo commented Oct 16, 2017

Issue

Right now, the validator reinitializes a new Oracle when checking estimate safety regardless of any previous checks to estimate safety and any intermittent results/calculations. This is a huge source of inefficiencies.

Proposed implementation

  • Validator keeps Oracle data around (as long as needed).
  • Validator updates Oracle data upon receiving new message
    • Oracles should all implement a method update_estimate_cache (not sure about name) that is called upon receiving a new message. Cache would be dependent on Oracle type.
    • Implementation decision:
      • Validator can either keep a dict of Oracles (one per candidate estimate) -- updating each upon new messages, and removing particular Oracles as candiate_estimates become non-relevant
      • OR Validator only has one Oracle and the Oracle is responsible for organizing info per candidate estimate.
@djrtwo
Copy link
Collaborator Author

djrtwo commented Oct 16, 2017

@naterush More details need to be fleshed out. Just wanted to get this up before you dive into memoization tonight.

@djrtwo djrtwo added the DEVCON3 label Oct 17, 2017
@naterush
Copy link
Collaborator

naterush commented Oct 17, 2017

Thanks for adding this. I've started work here and should be able to get up a WIP branch tomorrow.

Not sure what the best trade-off is here. Seems to me the best option might actually be having the validators keep a list of edges between other validators per estimate (or every 10 blocks). If we make them directed, I think we can translate freely between any type or lower-bound-side-effects-free-oracle we want (aversary, turans, clique, etc). Will give a bit of a more formal argument for this tomorrow, too.

I'll keep banging away at it tomorrow - should have a good couple hours to get a preliminary WIP up so we can discuss :)

@naterush
Copy link
Collaborator

Here's how I'm approaching it as of now:

  1. When a validator checks estimate safety on some estimate for the first time, we create the directed edges in the view and store them. It is also possible we could store the messages themselves that make these edges valid - and this might be the more future proof solution - but I don't think it's necessary as of now.
  2. If there are fewer edges than could possibly exist for a node to meet their safety threshold, then we don't check safety at all.
  3. Whenever new messages are received, we update the edges for all estimates for which we are currently storing edges for.
  4. As soon as there are enough edges that we can possibly detect safety, we check safety (they have to "poke" the estimate safety check again - but maybe this isn't the best). If they detect estimate safety on that estimate, we delete the edges that we have for that estimate + any estimates that are implicitly finalized and/or "anti-finalized" by that estimate.

Things might be a bit more complicated than is worthwhile - but I think if we decide to simplify most of the logic for updating edges (or storing the viewables) can be re-used.

@djrtwo
Copy link
Collaborator Author

djrtwo commented Oct 17, 2017

This looks good. A couple of questions:

  • Should the view be responsible for creating/maintaining edges or should the Oracle? I like the idea of the oracle maintaining the cache relevant to it and the view being dumb, but I could be persuaded otherwise.
  • 1: Should we only store edges related to an estimate once we check estimate safety on it or should we start storing edges once we see a new estimate?
  • As for 2, I think the Oracle should be responsible for this quick check. So the validator would ask the oracle if safe on that estimate, and the oracle can use the Turan shortcut. Rather than the validator/view needing to know about the Turan shortcut.

Sweet! super cool stuff

@djrtwo
Copy link
Collaborator Author

djrtwo commented Oct 17, 2017 via email

@naterush
Copy link
Collaborator

@zramsay zramsay changed the title Validator memoizes values about previous calls to oracle Validator memorizes values about previous calls to oracle Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants