-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow Porter Operational timeout parameters for /decrypt
#53
Conversation
/decrypt
and /reencrypt
/decrypt
/decrypt
/decrypt
Looks good in general, but I'm wondering about potential DoS vectors if we allow timeouts to be defined as input parameters. |
Great point - we could put a max cap on the timeout? Perhaps that cap can have a default value, but be overridden by an env variable? That way the Porter operator can make adjustments to the timeout ... open to other ideas ... Is that something we want to apply to other endpoints eg. The biggest concern is us simply hardcoding a timeout in the code that is potentially insufficient. |
Configuration via environment variables or some config file are good. We wouldn't want to make a release just to increment a default timeout. |
/decrypt
/decrypt
… and python API).
…lue (default that can be modified via an environment variable).
…timeout. Ensure that timeout for decryption is always passed to ThresholdDecryptionClient.
386612f
to
ce5af4e
Compare
…_TIMEOUT so that it always matches the default timeout used in `nucypher`.
/decrypt
/decrypt
Pipfile
Outdated
nucypher-core = "==0.13.0" # must be the same as nucypher | ||
flask-cors = "*" | ||
prometheus-flask-exporter = "*" | ||
|
||
[dev-packages] | ||
nucypher = {git = "https://github.com/nucypher/nucypher.git", editable = true, ref = "v7.0.0-rc.10", extras = ["dev"]} # needed for testerchain, and must be editable | ||
nucypher = {git = "https://github.com/nucypher/nucypher.git", editable = true, ref = "v7.0.0", extras = ["dev"]} # needed for testerchain, and must be editable |
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.
Should these values be updated to latest version (v7.0.3)?
DEFAULT_PORT = 9155 | ||
|
||
MAX_GET_URSULAS_TIMEOUT = os.getenv("PORTER_GET_URSULAS_TIMEOUT", default=15) | ||
MAX_DECRYPTION_TIMEOUT = os.getenv( | ||
"PORTER_MAX_DECRYPTION_TIMEOUT", |
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.
Can envvars be documented somewhere?
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 was thinking the threshold docs, and the repos readme.
Those will be done separately.
value_factory=value_factory, | ||
target_successes=quantity, | ||
timeout=timeout, | ||
stagger_timeout=1, |
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 timeout?
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 the timeout between obtaining batches of values for processing - https://github.com/nucypher/nucypher/blob/main/nucypher/utilities/concurrency.py#L322.
In this case batches of staking provider addresses.
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.
LGTM! I just left a suggestion
if timeout and timeout > self.MAX_GET_URSULAS_TIMEOUT: | ||
self.log.warn( | ||
f"Provided sampling timeout ({timeout}s) exceeds " | ||
f"maximum ({self.MAX_GET_URSULAS_TIMEOUT}s); " | ||
f"using {self.MAX_GET_URSULAS_TIMEOUT}s instead" | ||
) | ||
timeout = self.MAX_GET_URSULAS_TIMEOUT | ||
else: | ||
timeout = timeout or self.MAX_GET_URSULAS_TIMEOUT |
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 a blocker, but something we can address in the future: if I understand well, we are not checking in the tests that if the provided timeout > MAX_GET_URSULAS_TIMEOUT, the timeout must be MAX_GET_URSULAS_TIMEOUT.
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.
You're right. I'll look into testing that separately. #56
Type of PR:
Required reviews:
What this does:
Allow Porter to accept optional timeout values for performing TACo decrypt operation.
While this will be provided, In order for web apps to actually use it,
nucypher-ts
/taco-api
will need to be updated to allow timeout to optionally specified.Issues fixed/closed:
Fixes #49 .
Depends on
nucypher
PR - nucypher/nucypher#3337Follow-up for
/reencrypt
filed in #54 .Why it's needed:
Notes for reviewers: