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
Running federated node via CLI #447
Conversation
…ableNode certificate deterministic certificate filename generation via common name
…s; Integrate with local filesystem paths in dev and non-dev modes.
…he essentials, pushing preinit logic into UrsulaConfiguration.produce
…ion of multi inheretance
b37ab09
to
d615587
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncomfortable with this pattern:
instance_of_foo = Bar(...)
That's what seems to be emerging here, and I'm not sure why. Perhaps it's part of the logic trying to move toward factory style?
Also... missleware?
nucypher/crypto/api.py
Outdated
full_filepath, | ||
force: bool = True, | ||
full_filepath: str, | ||
force: bool = True, # TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To set Force to False by default, but, I changed my mind for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
nucypher/network/nodes.py
Outdated
self._interface_signature_object = interface_signature | ||
|
||
# TODO: This gets messy when it is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to move this comment down here? Haven't you obsoleted it above? Maybe just comment it out for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - it's obsolete - needs cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
@@ -34,6 +43,12 @@ class WrongMode(TypeError): | |||
Raise when a Character tries to use another Character as decentralized when the latter is federated_only. | |||
""" | |||
|
|||
@classmethod | |||
def from_tls_hosting_power(cls, tls_hosting_power: TLSHostingPower, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fucking interesting, man.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I'm not using this anywhere yet, but if we continue to init VerifiableNode
in the same fashion we do now, this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this.
def certificate(self): | ||
return self._crypto_power.power_ups(TLSHostingPower).keypair.certificate | ||
@property | ||
def common_name(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. Not kidding around.
So, common name is always from the cert? Surely it makes sense to check that it matches the checksum address before returning it?
Or are we in pretending-this-is-not-a-mixin pattern here?
Perhaps as I read on, it will become clearer. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the thinking here is that common name is always from the certificate, which needs to better better validated. with regard to mixins, I've had a similar question while working with Learner
and VerifiableNode
. Is this class a mixin? If not, then I'm inclined to localize the attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't presently have a vision of it other than as a mixin, although there's no inherent reason that it can't be an inventory item.
@@ -46,21 +47,31 @@ class NotEnoughTeachers(RuntimeError): | |||
pass | |||
|
|||
def __init__(self, | |||
always_be_learning: bool = False, | |||
start_learning_on_same_thread: bool = False, | |||
start_learning_now: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umm, yeah - good change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
examples/finnegans-wake-federated.py
Outdated
always_be_learning=True, | ||
known_certificates_dir=CERTIFICATE_DIR, | ||
) # TODO: 289 | ||
ALICE = AliceConfiguration(network_middleware=RestMiddleware(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What am I dealing with here? This thing returns an Alice
? Is this to be the canonical way to get an Alice
? That seems like an anti-pattern to me. Why can't the user init the class they want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the bottom of this call, there is a chained method call to .produce()
which outputs an Alice. You can still init any Character directly, of course, but while debugging demo-code I wanted to use temporary directories as a means of handling the nodes runtime files, which is cleaner / easier to do with config.
FWIW I actually intend to reset this module before taking this PR off WIP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great.
@@ -14,17 +14,21 @@ | |||
class NodeConfiguration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, config has grown to be something of a mirror of Character
, as you expressed concern it might. I still think I like it, but I'm joining you in your trepidation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same - I like like the benefits of having a layer between the filesystem and the character but also dislike the additional complexity. Overall Im +1 on NodeConfiguration
classes.
I think the factory-style pattern relieves some tension regarding Character initialization.
cli/demos/finnegans-wake-demo.py
Outdated
rest_port=rest_port, | ||
db_name='ursula-{}.db'.format(rest_port), | ||
federated_only=federated_only) | ||
URSULA = UrsulaConfiguration(temp=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar concern to the one I raised above - is this to be the canonical way to get a Character?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecated ✔️
nucypher/network/middleware.py
Outdated
@@ -7,10 +7,10 @@ | |||
|
|||
class RestMiddleware: | |||
|
|||
def consider_arrangement(self, arrangement): | |||
def consider_arrangement(self, arrangement, certificate_filepath): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change. Why do we ever want to pass in a cert other than the one that belongs to the Ursula in the arrangement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ - removed.
nucypher/characters/lawful.py
Outdated
@@ -242,7 +242,7 @@ def get_treasure_map(self, alice_verifying_key, label): | |||
if not self.known_nodes and not self._learning_task.running: | |||
# Quick sanity check - if we don't know of *any* Ursulas, and we have no | |||
# plans to learn about any more, than this function will surely fail. | |||
raise self.NotEnoughUrsulas | |||
raise Ursula.NotEnoughUrsulas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this change either. Do we really want this exception only to live on Ursula
(and thus require Ursula
to be imported everywhere we raise it?).
...and if we do, then is NotEnoughUrsulas
still a good name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - I do no think we want to require the import of Ursula in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Not sure If I understand. Is there a specific place in the pull request you are referring to? |
9858388
to
e4252ec
Compare
…recruits Ursulas from the blockchain
… preperation for futher integration.
2cbb4b1
to
17d35a2
Compare
I'm unsure why CI is failing all builds with |
fb75a89
to
9631804
Compare
9631804
to
76b87da
Compare
The Issue was that a new version of APIStar has been released: https://github.com/encode/apistar/releases. Pinned version |
@@ -34,7 +34,6 @@ | |||
def spin_up_ursula(rest_port, db_name, teachers=(), certificate_dir=None): | |||
metadata_file = "examples-runtime-cruft/node-metadata-{}".format(rest_port) | |||
|
|||
asyncio.set_event_loop(asyncio.new_event_loop()) # Ugh. Awful. But needed until we shed the DHT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we planning to remove asyncio completely? I think we might be able to use it for task scheduling (ie: kfrag expiration)
always_be_learning: bool = False, | ||
start_learning_on_same_thread: bool = False, | ||
start_learning_now: bool = False, | ||
learn_on_same_thread: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the need to move it to a different thread than the one you start it on?
if save_metadata and known_metadata_dir is None: | ||
raise ValueError("Cannot save nodes without a known_metadata_dir") | ||
|
||
known_nodes = known_nodes or tuple() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much better than before.
@@ -385,20 +378,26 @@ class Ursula(Character, VerifiableNode, Miner): | |||
# TLSHostingPower still can enjoy default status, but on a different class | |||
_default_crypto_powerups = [SigningPower, EncryptingPower] | |||
|
|||
class NotEnoughUrsulas(Learner.NotEnoughTeachers, MinerAgent.NotEnoughMiners): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move this here? Mostly because Ursula
is here?
@@ -34,6 +43,12 @@ class WrongMode(TypeError): | |||
Raise when a Character tries to use another Character as decentralized when the latter is federated_only. | |||
""" | |||
|
|||
@classmethod | |||
def from_tls_hosting_power(cls, tls_hosting_power: TLSHostingPower, *args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like my concerns are addressed now, with the exception that I think that exceptions stemming from a dearth of nodes (Learners or Ursulas) rightly belong on Character
(or a similarly universally positioned class).
No description provided.