feat: Add delivered HTTP call contexts to subnet call context manager #10489
Conversation
|
✅ No security or compliance issues detected. Reviewed everything up to d9a98fe. Security Overview
Detected Code Changes
|
schneiderstefan
left a comment
There was a problem hiding this comment.
This PR LGTM, as it's just some protobuf to/froms, but I have some high-level questions on where this is going.
At what point do we remove items from this list? Is there a bound on how much it can grow and/or can a malicious replica force that these entries are kept for an unreasonable amount of time?
@schneiderstefan the asynchonous refund phase will last for one minute, after which the context will be removed entirely. Replicas that haven't submitted a refund share until then are assumed to be offline/behind and their entire allowance will be refunded. Currently we target 100 HTTP requests per second, which would lead to 6000 contexts over one minute: ic/rs/config/src/execution_environment.rs Lines 201 to 204 in bfcd00b |
Currently, all HTTP request contexts are stored in the same collection of the subnet call context manager. They are removed once consensus delivers a response to the canister.
In the future, there will be a second "asynchronous refund" phase as part of the context's life cycle: After consensus delivers the HTTP response and an initial refund, consensus may continue to deliver asynchronous refunds, that correspond to shares which didn't make it into the original response.
To do this, the context needs to persist even after a response was delivered.
This PR proposes to support this by introducing a second collection, which will hold such delivered contexts. Whenever a response is delivered, the corresponding context is moved into the new collection.
An alternative would have been to mark the context as "delivered", e.g. by setting a boolean flag. However, introducing a second collection has some natural advantages:
Note that for compatibility reasons, the new collection is still unused.