-
Notifications
You must be signed in to change notification settings - Fork 20
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
Gateway discovery and verification protocol #342
Comments
I like the proposed solution, imo it's super important that new gateways (or even end consumers running their own gateways) can permissionlessly start interacting with the network without establishing trust outside the network. The proposed approach seems to achieve that in a straightforward way. I think this is much preferable to #94 - if the registry is permissioned it precludes consumer-run gateways or new permissionless gateways, and if it's permissionless it doesn't prevent the attack, so we'd need to implement something like this anyways. |
hey @gusinacio having read this proposal in detail I think it makes sense. I also favour it to a TAP registry. |
You can provide your aggregator for all requests in the headers and then you don't need to worry about it. The only drawback to it is that you are paying for traffic related to those few bytes for every request. |
Problem statement
We have a system where indexers must manually add the aggregator endpoint for specific gateways and we'd like to facilitate the onboarding of new gateways.
But new gateways may be malicious and we need to make sure that the cost to attack is higher than the value they can extract. We currently limit the amount an indexer can lose with the setting
max_amount_willing_to_lose
but this must be scaled accordingly to the number of queries per second, so if an attacker targets these big indexers, just themax_amount_willing_to_lose
isn't enough to stop a profit on this attack.Expectation proposal
We propose an off-chain agreement protocol where gateways can send a registration request and indexers can verify if it's possible to aggregate receipts.
Gateway TAP state machine
Behaviour
Currently, our system has only two states:
Allowed
andDenied
. Every gateway that is not on thetap_aggregator_endpoints
map is denied as soon as tap-agent tries to create aSenderAccount
and can't find the aggregator value.With this proposal, we update our system to have different behaviors depending on which state a sender is.
Unregistered state
This state demands that the sender sends a tap-aggregator header within the first request so it can register the sender and start aggregating. If a query sent by a unregistered sender doesn't have the header, we deny right away with a possible error: "Sender not registered".
We should aggregate the first receipt to verify that the tap-aggregator is working and we can communicate with it. If it works we update to a
Verifying
state otherwise we change to aBlocked
state.Verifying state
In this state, every RAV request should not fail until we reach a certain amount (configurable) where we can trust the sender and transition it to an
Allowed
state. If any of the RAV requests fail, we transition to aBlocked
stateBlocked state
In this state, we have a backoff retry process where we keep trying to aggregate the receipts that we have. In case we have a successful aggregation, we transition to a Verifying state.
We should not spend that much resources trying to aggregate, so after some time of backoff (it can be configurable but with small defaults like 1 day), we stop trying to aggregate it.
Senders that are blocked can request to update their tap-aggregator by sending another query, but they won't have their query processed. When indexers get a new receipt, the system should try again in a tentative way to verify the gateway (stopping after the same backoff period).
Allowed state
It's the current normal operation, each sender has a max unaggregated fee that they are allowed to serve before being denied. In case the pending fees is over the escrow balance or the unaggregated fee is bigger than
max_willing_to_lose
, we transition toDeny
state.Deny state
We already have this state in the current system. In this state, we wait for the escrow balance to update, or we keep retrying every 30 seconds to do a RAV request which lowers the unaggregated fee. We then transition to
Allowed
state resuming operation.Tap Aggregator Header
For a gateway to update its tap-aggregator, it must send a signed receipt by one of its signers on the tap contracts. The query handler already demands a receipt
Database modification
deny_list
table to asender_state
table.New error responses
Alternative considerations
Register route
Instead of sending the aggregator through a header, a specific
/register
route could be used so we could save traffic on query handler by not sending through a header and just receiving a direct request. This new request would need to receive a receipt that should be aggregated and verified, updating it to the verifying state.Tap Registry
We also have #94 as another possible solution but it requires a new contract and a new subgraph which is not worth it at the current time. Also, we'd need the same verification protocol to guarantee stability.
Synchronous communication between indexer-service and tap-agent
We used async communication by sharing the same database between those two components, if in any case it seems necessary synchronous communication, we should consider using #84. This should have a deep discussion because this means that indexer-service now would need to know tap-agent address.
The text was updated successfully, but these errors were encountered: