Commit 3e0ca42
[CRE] [1/5] Gateway handler for confidential relay (#21638)
* [CRE] [1/5] Gateway handler for confidential relay
Add a new gateway handler type "confidential-compute-relay" that fans out
enclave JSON-RPC requests to relay DON nodes and aggregates responses
using F+1 quorum. Supports secrets_get and capability_exec methods.
Part of #21635
* Fix exhaustive switch lint and tidy integration-tests modules
Add missing api.ConflictError and api.LimitExceededError cases to both
switch statements in handler.go. Run go mod tidy on integration-tests
and integration-tests/load.
* Fix goimports formatting in gateway_job.go
* Use ServiceName constants and add RequestTimeoutSec to relay handler
- Replace string literals with ServiceNameVault, ServiceNameWorkflows,
ServiceNameConfidential constants in all handler constructors.
- Add RequestTimeoutSec to confidentialRelayHandlerConfig, set to
gateway timeout minus 1s (matching vault handler pattern). Ensures
the handler times out before the gateway, returning a clean error
instead of the gateway killing the connection.
* Add comment explaining requestTimeoutSec - 1 in relay handler
* Use fmt.Errorf instead of errors.New with string concatenation
Replace errors.New(x.Error() + ...) and fmt.Sprintf + errors.New
patterns with fmt.Errorf throughout the relay handler and aggregator.
Use %w for error wrapping where appropriate.
Add comment clarifying sendResponse deletes expired requests.
* Improve F+1 quorum comment in relay aggregator
Explain why F+1 is correct: relay nodes proxy already-aggregated DON
responses through deterministic translation, so honest nodes produce
byte-identical outputs.
* Move requestTimeoutSec - 1 to call site for relay handler
Make the buffer visible where handlers are wired up instead of hiding
it inside the constructor. The vault handler does the same subtraction
internally; a follow-up should unify both to use this pattern.
* Extract deleteActiveRequest from sendResponse
sendResponse no longer has the side effect of deleting from
activeRequests. Callers explicitly call deleteActiveRequest after
sendResponse, making the cleanup visible at every call site.
* Rename sendResponse to sendResponseAndCleanup, fix cleanup-on-error bug
The old sendResponse skipped the delete if SendResponse failed, leaving
the request in activeRequests forever. Now the delete always runs
regardless of send outcome. The method name makes the cleanup explicit.
* Handle errQuorumUnobtainable explicitly in aggregation switch
* Merge errorResponse into sendErrorResponseAndCleanup
* Move error sanitization into sendResponseAndCleanup
* Inline send+cleanup into sendResponseAndCleanup and sendSuccessResponseAndCleanup
* Unify sendResponseAndCleanup to handle both success and error paths
* Simplify `sendResponseAndCleanup`.
* Fix exhaustive lint: restore missing switch cases in recordMetrics and constructErrorResponse
* Suppress exhaustive switch warning.
* fan out relay requests to don nodes concurrently
* Clean up confidential relay concurrency test helper
* Remove redundant loop variable copy in relay fanout
* Use atomic counter for relay node send errors
* use cre settings for relay gateway rate limits
* Fail fast when relay quorum becomes impossible
* Run gomodtidy to fix CI module drift
---------
Co-authored-by: pavel-raykov <pavel.raykov@smartcontract.com>
Co-authored-by: vreff <104409744+vreff@users.noreply.github.com>1 parent 92db8e0 commit 3e0ca42
6 files changed
Lines changed: 1232 additions & 10 deletions
File tree
- core/services/gateway
- handlers/confidentialrelay
- deployment/cre/jobs/pkg
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
0 commit comments