-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve GatewayContract design #186
Comments
Two questions from me.
What is the rationale to use How about renaming |
1, 2 and 3: We have two options:
For the second point (The dapp is verifying the signatures), I'm wondering if it's not possible to embed the GatewayContract into the dapp directly. you need to call the proxy on the contract implemented by GatewayCaller: abstract contract GatewayCaller {
function fulfillRequest(
uint256 requestID,
bytes memory decryptedCts,
bytes[] memory signatures
) {
...
(will call myCallback)
}
} contract MyDapp is GatewayCaller {
myCallback(uint256 requestId, bool value) internal {
...
}
} Maybe with this model, we can even pass stored parameters (stored with GatewayCaller) directly as parameter of the function. |
I agree for 4/ For 5/, this is out of scope: decryption are free for now but will be charged and monitored by ZWS offchain. They'll probably ignore request for a non-paying users. No opinion on 6/7/8 |
|
I don't understand your second point to " embed the GatewayContract into the dapp directly." I need more details. |
The idea would be to keep the gateway contract "just" to emit events, but the cts list, and requestId are handled by the dapp. The dapp would contains:
The Gateway contract contains:
To init a decryption, you'd call a dapp function These methods (fulFillRequest, requestDecryption, getCts) are included in what we call today |
With this method, we could have 100% trustless since the fulfillRequest is in the dapp. |
Implementation of what you suggest is done in this PR : #217 |
We have to discuss further the specifications of GatewayContract, here is a (non-exhaustive) list of the suggestions to improve its design:
1/ Don't make it upgradable, this is actually needed for a real trustless version - to avoid the problems with
requestID
logic in the upgradeable case - instead the dapp developer could always optionally add a setter function in his dApp to change the gateway address if he really wish to. Remember this is acceptable since GatewayContract is not part of the core fhevm protocol.2/ Also note that to get a real trustless decryption method example, the
onlyGateway
modifier inside the callback of the dApp could be dropped - even if the dev still uses the GatewayContract for high availability and simpler integration.3/ Don't use the
onlyRelayer
modifier onGatewayContract:fulfillRequest
, especially if we implement 0/ this will be needed, to ensure decryption can always be available for the dApp (no "relayer censorship"is possible), and because no more owner of contract is needed since it is not a proxy and we should remove theaddRelayer
function, if we agree to implement this.4/ Remove
payable
modifier fromGatewayContract:fulfillRequest
: in this case it would make sense to also remove themsgValue
from theGatewayContract:requestDecryption
function and fromEventDecryption
event -> breaking changes on gateway service then because of new function and event selectors. We also discussed this point already with @manoranjith. It reduces risks, and I don't think there is any good use case which really needs a payable callback.5/ We should write clear specifications for Gateway payment, Ghazi asked many questions around this unsolved issue, but it is still unclear if some onchain payment from the requesting dApp/user should happen and how to handle it exactly. This point is also closely related the offchain logic to avoid DDOS, maybe use something more sensible than the today hardcoded gasLimit of
750_000
. This point is a huge topic in itself.6/ Minor improvement: use custom errors instead of revert strings in requires, to save some gas. This is not specific to GatewayContract btw, we have same issue in many core contracts well.
7/ Minor improvement: rename the
EventDecryption
to something more explicit, such asDecryptionRequest
maybe. breaking change as well on Gateway service if we do this btw8/ Should we increase the
MAX_DELAY
constant to something bigger than the current value of 1 day?The text was updated successfully, but these errors were encountered: