nucypher / nucypher-porter

Gateway to TACo nodes of the threshold network
GNU Affero General Public License v3.0
2 stars 8 forks source link

Consider increasing learning timeout #49

Closed cygnusv closed 11 months ago

cygnusv commented 1 year ago

Occasionally, I'm getting timeouts:

david@Davids-MacBook-Pro-2 nucypher-contracts % curl -X GET <redacted>/get_ursulas -H "Content-Type: application/json" -d '{"quantity": 3}'
{"result": {"failure_message": "Execution stopped before completion - not enough available values (1 failures recorded)", "failures": [{"value": "0xb15d5A4e2be34f4bE154A1b08a94Ab920FfD8A41", "error": "HTTPSConnectionPool(host='<redacted>', port=9151): Read timed out. (read timeout=2)"}]}, "version": "3.1.1"}%  

It's possible that current default learning delay of 2 seconds is too short. See:

https://github.com/nucypher/nucypher-porter/blob/799a08ce833bf16dd6c2a867be4e60dba1faf103/porter/main.py#L49

derekpierre commented 1 year ago

I may have confused you with my responses previously.

This _SHORT_LEARNING_DELAY delay is the staggering of the learning task when rotating to a new teacher to ask about its nodes. It's the time between learning from one teacher, and starting to learn from another teacher. See https://github.com/nucypher/nucypher/blob/v7.0.0/nucypher/network/nodes.py#L508. It's a class variable for Learner which Porter modifies for itself

I suspect the timeout in the exception you observed above is from nucypher's RestMiddleware object used by Learner when attempting to get information about a node which is done here - https://github.com/nucypher/nucypher/blob/v7.0.0/nucypher/network/middleware.py#L118.

That has a constant timeout of 2s. Porter is a subclass of Learner and is therefore subjected to the same timeout. So really this is a Middleware/Learner object issue in nucypher.

More generally, questions have been raised in nucypher about the hardcoding of timeouts as opposed to them being parameterized. See:

cygnusv commented 1 year ago

Great finding! That timeout=2 is very hidden.