Integrate API adapters into witnet-rust node #2050
Replies: 5 comments 8 replies
-
This would indeed be a breaking change because data source URLs with special patterns should be dealt differently than regular ones . Namely, may a node lack credentials for some API, it should refrain from performing the retrieval and commitment. |
Beta Was this translation helpful? Give feedback.
-
An interesting and much needed thread. The question is how do we handle private api keys when requests are public and logged onchain. burner api-keys are not readily available. Integrating API adapters into the node itself seems like a good solution. data sources with unique/ special patterns is a breaking change agreed aesedepece- So if a node lacks credentials it is disqualified from participating in retrievals/commitments for that request. sure- maybe we can keep the data request homogenous if the perhaps even since the protobuf schema for [edit] suggesting new APIs for node operators to adopt could be accomplished by time-locking requests - > so operators see the opportunity to add that API to the registry before the request is processed. Will do some more thinking about this... |
Beta Was this translation helpful? Give feedback.
-
Thanks @aesedepece for letting me know about existence of this thread. Not knowning about it before, and thinking about how private APIs could be supported in a best-effort approach by the Witnet network, I couldn't help but coming up w/ a very similar approach as the alternative design proposed proposed by @drcpu-github like one year ago. However, just like @aesedepece, I do agree the implementation could involve a breaking-change in the protocol, or perhaps not:
|
Beta Was this translation helpful? Give feedback.
-
Let me elaborate on my former comment:
I don't care if this is a breaking change, consensus-wise. This above is truly my main concern. A bit of history on crowd-attestationEver since we started designing Witnet, we had this clear idea in mind that for the crowd-attestation mechanism to work, we needed to make sure that the census from which we were randomly sampling witnesses was as big as possible. The underlying principle was always this: it is highly unlikely for an attacker to control a small committee out of a big population of nodes. From that principle, there was a very immediate takeaway: all witnesses must have the same capabilities. That decision shaped up Witnet as a totally generic oracle over HTTP. If you can get some piece of data over HTTP, you can have it retrieved, attested and delivered to your smart contract using Witnet. No need for the data providers to make any change to their APIs, and no need for the node operators to add "adapters" to specific APIs. Already at that point (late 2017), we had started thinking on other "universal" capabilities that we could implement to make the most of the crowd-attestation mechanism. From that brainstorming, there were two different capabilities that stood out. The first one, a RNG, we landed in October 2021. The other one, generalistic offchain computation of WASM code, is yet to be explored. On custom capabilitiesAt that point, the "all witnesses must have the same capabilities" was not that written into stone. However, what really made us rule out the possibility of having "custom capabilities" was the added complexity. This "added complexity" was much related to what @parodyBit mentioned above. When different nodes have different capabilities, the protocol needs to provide specific mechanisms for:
For the sake of being able to deliver the protocol in a reasonable time frame, we preferred to keep it simple, and removed the concept of custom capabilities from our design around spring / summer 2018, when we realized it would really clash with the kind of eligibility and reputation mechanism that we were implementing, because of points 3 to 5 above. General comment on private APIsOk, first I'd like to clarify a few things about private APIs. For first, a private API is one that requires "credentials". Credentials:
There are at least two main types of these private APIs. They look the same from a request and response standpoint, but they're very different in nature:
I think we all will agree, that Type 2 APIs are completely incompatible with any kind of third party oracles, specially those based on crowd-attestation, because of the risk of abuse of the credentials by an attacker. There is some research on solving this through cryptographic enclaves and the like, but this approach has been extensively proven to be vulnerable to side channel attacks carried out by the operator of the system that hosts the enclave, or by any other neighbor processes hosted by the same processor (specially scary for nodes run on the cloud). So let me assume that this discussion is all about type 1 APIs: those that require credentials solely for rate limiting or billing, and that don't handle any PII or privileged access to resources. API adaptersThat's where the concept of API adapters fit in. Generally speaking, API adapters are some kind of custom capabilities that the nodes can opt-in for. In its most strict form, API adapters are pieces of code that the nodes need to install and configure in order to be able to read from specific APIs and to expose those data points to the entire network. That's how Chainlink adapters work. In a more loosely coupled model, API adapters could take form of a configuration file local to each node in which FQDNs are mapped to access tokens configured by the node operator. I think this is what @drcpu-github, @parodyBit and @guidiaz are suggesting. ... to be continued ... |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if there is any way a node can prove that they have access to an API key? One obvious proof is if that node has already solved a data request with this API with a non-error result. But not sure how to bootstrap that. Because if we cannot have a proof and rely on trusting what nodes say, then a malicious user can run a node that claims to support any kind of API. Maybe that's not a problem because of the reputation system, but if the number of different APIs grows then I expect the average number of nodes per API to be quite small, so it may be easy to attack some niche APIs. |
Beta Was this translation helpful? Give feedback.
-
Problem
A lot of API's require that you specify an API key for requesting certain data. This is obviously not ideal in the context of a public blockchain since you don't want your private API keys lingering around on the blockchain until eternity.
Current solutions
Integrate API adapters into witnet-rust node
An alternative design that is more in line with the decentralized ethos of Witnet could be to allow creation of data requests with an API-key variable. A node operator could then fill in said variable with his own private API-key before launching a query to the API-service.
This could work as follows:
witnet.toml
configuration file.https://api.service.com/{request_something}?api-key={my_api_key}
.If a data requester wants to request data from a 'new' API (i.e. an API for which node operators don't have an API key), they would have to properly incentivize node operators to create one. I imagine it would be possible for a data requester to discuss the necessity of a new API beforehand with node operators in some off-chain channel such as Discord, or they just create a data request with proper incentives and launch it.
Node operators who are monitoring the blockchain see that it would be economically interesting to add this API to the capabilities of their nodes. After a couple of data requests failed (over the course of a day or so), enough node operators should have upgraded the API-querying capabilities of their nodes for the data request to be successful if it really is economically interesting to serve it.
As far as I can tell, this design would not necessarily need to be activated using TAPI as it is not a consensus-breaking update. However, given the implications, it's probably a good idea to use TAPI for it anyway.
Problems with the alternative solution
The main problem with this design is that it can potentially be gamed by node-operators. It would be possible for someone to craft a data request querying an exotic API in an attempt to influence the reputation of a certain set of (own) nodes.
There are however two counteracting effects in a healthy ecosystem of node-operators. Healthy means we assume there are a significant number of unique node operators which have an economic interest in keeping the network honest.
What are your thoughts on this idea?
Beta Was this translation helpful? Give feedback.
All reactions