Skip to content
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

Apophenia: parachain oracle system #1936

Closed
wants to merge 20 commits into from

Conversation

a-moreira
Copy link

@a-moreira a-moreira commented Aug 27, 2023

Project Abstract

The main goal of the Apophenia project is to be a trustless oracle chain available to the Dotsama ecosystem.

Apophenia achieves oracle functionality by providing a set of modules that can be used to register and consume data from a variety of external sources. These are organized in the form of feeds.

Essentially, this means:

  • Registering new feeds (aka. sources)
  • Consuming data from a registered feeds via XCM or chain events.
  • A staking / slashing mechanism to ensure the game-theoretic elements of the process

Grant level

  • Level 1: Up to $10,000, 2 approvals
  • Level 2: Up to $30,000, 3 approvals
  • Level 3: Unlimited, 5 approvals (for >$100k: Web3 Foundation Council approval)

Application Checklist

  • The application template has been copied and aptly renamed (project_name.md).
  • I have read the application guidelines.
  • Payment details have been provided (bank details via email or BTC, Ethereum (USDC/DAI) or Polkadot/Kusama (USDT) address in the application).
  • The software delivered for this grant will be released under an open-source license specified in the application.
  • The initial PR contains only one commit (squash and force-push if needed).
  • The grant will only be announced once the first milestone has been accepted (see the announcement guidelines).
  • I prefer the discussion of this application to take place in a private Element/Matrix channel. My username is: @_______:matrix.org (change the homeserver if you use a different one)

cc @FaisalAl-Tameemi

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@FaisalAl-Tameemi
Copy link

I have read and hereby sign the Contributor License Agreement.

1 similar comment
@a-moreira
Copy link
Author

I have read and hereby sign the Contributor License Agreement.

Copy link
Collaborator

@Noc2 Noc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the application. However, we usually don't support the research phase of the project and the delivery of, for example, a whitepaper. Could you remove this from the application? Additionally, the default deliverables (0.a...) should be part of each milestone table. Also, could you compare your Oracle solution to other existing Oracle solutions, see https://wiki.polkadot.network/docs/build-open-source?

@Noc2 Noc2 added the changes requested The team needs to clarify a few things first. label Aug 28, 2023
@FaisalAl-Tameemi
Copy link

@Noc2 Thanks for the feedback. In regards to alternatives, @a-moreira and I can see that most of the projects under Oracle are inactive. For those that are active, here's a quick comparison:

  • interBTC: specialized for Bitcoin quotes, we intend to be a generalized oracle solution instead.

  • DIA: current solution available on Astar as ink! smart contracts. Like Laminar and Chainlink. data is pushed on-chain by centralized (and usually manually verified) offchain services.

  • Bridgestate: focused on collateralization values of bridges.

  • Tellor: a full fledged solution which we are ultimately building towards, however, as it stands the consumer parachains need to be EVM compatible, have smart contracts enabled and install a separate pallet to gain oracle functionality. In our case, simply using XCM queries is sufficient to gain full functionality. We intend to use similar game-theoretic and statistical techniques to validate data across different feeds.

  • Laminar: Data has to be actively pushed from external sources, triggered offchain. Overall it's a pallet to be included. Overall it contains some of the same restrictions as DIA and Chainlink.

@a-moreira a-moreira requested a review from Noc2 September 2, 2023 14:47
applications/apophenia.md Outdated Show resolved Hide resolved
applications/apophenia.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@takahser takahser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FaisalAl-Tameemi

@Noc2 Thanks for the feedback. In regards to alternatives, @a-moreira and I can see that most of the projects under Oracle are inactive. For those that are active, here's a quick comparison (...)

Could you incorporate that information into the proposal, ideally into the Ecosystem Fit section? It's generally better to have all the relevant information in one place (the proposal) rather than having it scattered all over this thread.

Copy link
Collaborator

@takahser takahser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-moreira I took a closer look and added a few more comments. Feel free to check again.

applications/apophenia.md Outdated Show resolved Hide resolved
applications/apophenia.md Outdated Show resolved Hide resolved
applications/apophenia.md Outdated Show resolved Hide resolved
| **0c.** | Testing and Testing Guide | Core functions will be fully covered by comprehensive unit tests to ensure functionality and robustness. In the guide, we will describe how to run these tests. |
| **0d.** | Docker | We will provide a Dockerfile(s) that can be used to test all the functionality delivered with this milestone. |
| 1. | XCM request-response model | Use XCM messages as the main interface for requesting and receiving oracle data. |
| 2. | Research more ways to validate offchain data | Research and implement ways to ensure that offchain workers are providing valid data and have some level of protection again known attack vectors. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't support research as part of a grant. If you can't present the research results when applying for the proposal, it's always possible to do a follow-up grant.

applications/apophenia.md Outdated Show resolved Hide resolved
applications/apophenia.md Outdated Show resolved Hide resolved
@takahser takahser self-assigned this Sep 12, 2023

As Subslice, our primary focus lies within the DotSama ecosystem, where we are actively engaged in various development initiatives. Our core belief centers around our capacity to introduce solutions that can significantly enhance the usability and adoption of Polkadot/Kusama. We intend to achieve this objective by conceiving and executing utility-driven projects, which is why we have a keen interest in developing a native oracle solution within this ecosystem.

In an ideal scenario, oracles should operate with complete autonomy, but attaining this level of autonomy requires a monumental effort. It is worth noting that Polkadot presently boasts one of the most advanced governance systems in the blockchain sphere, which serves as a great source of inspiration for us. In our future plans, we aspire to leverage such governance structures to establish a genuinely decentralized oracle system. While existing solutions like ChainLink are commendable, they still exhibit a significant degree of centralization.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While existing solutions like ChainLink are commendable, they still exhibit a significant degree of centralization.

Could you explain how/why Apophenia is less centralised than ChainLink?

* **Laminar**: Data has to be actively pushed from external sources, triggered offchain. Overall it's a pallet to be included. It has some of the same restrictions as DIA.
* **DIA**: current solution available on Astar as ink! smart contracts. Like Laminar, data is pushed on-chain by centralized (and usually manually verified) offchain services.
* **Acurast**: It's a multi-chain decentralized execution layer which provides a way register and run an arbitrary script (in Javascript) on the Acurast network. In that sense, it's more comparable to Phala Network and other TEE generalized solutions. While this can be used to create an Oracle prototype, it doesn't solve the problem with a data science approach.
* **Chainlink Pallet**: It's a pallet to be included in other parachains. It's a good solution, but it's not native to the DotSama ecosystem. Another note to add is that the last commit was 2 years ago.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a good solution, why do we need another oracle pallet then? For example, you could simply update the current pallet instead. I'd be open to a discussion to fund something like that btw.

applications/apophenia.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@takahser takahser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-moreira thanks for the updates. It looks better, but I still think some of the deliverables are quite vague. Also, in order to justify yet another oracle solution, you'd have to bring some kind of novelty to the table which IMO currently is not convincingly being demonstrated here. A sequence diagram might help here as well.

For these reasons I won't approve the proposal in its current form but I'm open to changing my mind, depending on how this proposal evolves. That being said, I'm marking it as ready for review and ping the team, so others can have a look and share their opinion on it as well.

| **2.** | Implement offchain data validation | Design and implement an anamoly detection algorithm to ensure that offchain workers are providing valid data and protect against malicious or invalid data (known attack vector in off-chain workers). |
| **3a.** | E2E tests - RPC | We will have E2E tests using RPC calls|
| **3b.** | E2E tests - XCM | We will have E2E tests using XCM. |
| **3c.** | E2E tests - Attack Vectors | Create a test suite simulating off-chain workers attach vectors (malicious / invalid data). |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| **3c.** | E2E tests - Attack Vectors | Create a test suite simulating off-chain workers attach vectors (malicious / invalid data). |
| **3c.** | E2E tests - Attack Vectors | Create a test suite simulating off-chain workers attack vectors (malicious / invalid data). |

Comment on lines +239 to +240
| **2.** | Design and implement Staking / Slashing mechanism | Research and implement game-theoretic ways of making the oracle system safe. |
| **3.** | Design and implement fee structures | Add a fee structure that takes into account all the features mentioned above. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These specifications are very vague. For example, what would this game theory be based on and how would it work? What exactly do you refer to by "above"?

| **1**.| Aggregation | Implement statistically sound aggregation methods so we can integrate them in the slashing mechanism. |
| **2.** | Design and implement Staking / Slashing mechanism | Research and implement game-theoretic ways of making the oracle system safe. |
| **3.** | Design and implement fee structures | Add a fee structure that takes into account all the features mentioned above. |
| **4.** | Tutorials and Showcase | Create online media to showcase the usage of the project as well as prepare in-person presentations for the DotSama community. |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to integrate this into 0b. Documentation or another 0_x_ deliverable. Usually the deliverables 1.+ are used for code deliverables.

| **0d.** | Docker | We will provide a Dockerfile(s) that can be used to test all the functionality delivered with this milestone. |
| **1a.** | XCM request-response model - Part A (request) | Implement `query_feed()` extrinsic which is triggered via an XCM `Transact` instruction. It receives a `feed_key`, `validation_threshold`, `expiry_threshold` as arguments. The metadata of the already registered feed should contain all other details specifying where the data is fetched from. The XCM message sender should also specify a `ReportTransactStatus` instruction. |
| **1b.** | XCM request-response model - Part B (response) | Send a `QueryResponse` XCM instruction to the data requester containing the fetched or cached data from the specified `feed_key`. The response object will contain a `value` and `validation_threshold`. |
| **2.** | Implement offchain data validation | Design and implement an anamoly detection algorithm to ensure that offchain workers are providing valid data and protect against malicious or invalid data (known attack vector in off-chain workers). |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more details on how the "anamoly detection algorithm" would work?

* **Laminar**: Data has to be actively pushed from external sources, triggered offchain. Overall it's a pallet to be included. It has some of the same restrictions as DIA.
* **DIA**: current solution available on Astar as ink! smart contracts. Like Laminar, data is pushed on-chain by centralized (and usually manually verified) offchain services.
* **Acurast**: It's a multi-chain decentralized execution layer which provides a way register and run an arbitrary script (in Javascript) on the Acurast network. In that sense, it's more comparable to Phala Network and other TEE generalized solutions. While this can be used to create an Oracle prototype, it doesn't solve the problem with a data science approach.
* **Chainlink Pallet**: It's a pallet to be included in other parachains. It's a good solution, but it's not native to the DotSama ecosystem. Another note to add is that the last commit was 2 years ago.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could you add Kylin as well here?
  • Phala's phat contract may also be worth to have a look yet.

@takahser takahser added ready for review The project is ready to be reviewed by the committee members. and removed changes requested The team needs to clarify a few things first. labels Sep 21, 2023
@semuelle
Copy link
Member

pinging @a-moreira & @FaisalAl-Tameemi

@Noc2
Copy link
Collaborator

Noc2 commented Oct 4, 2023

I'm closing this due to inactivity. Let me know if I should reopen it.

@Noc2 Noc2 closed this Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review The project is ready to be reviewed by the committee members.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants