graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.92k stars 978 forks source link

[Feature] Building the ability for the graph-node to index private transactions `priv_getLogs` in private EVM-based blockchains like Hyperledger Besu #3542

Open 0xisk opened 2 years ago

0xisk commented 2 years ago

Do you want to request a feature or report a bug? Feature

What is the current behavior? TheGraph is not able to index the private transactions in the Hyperledger Besu EVM-based chain by enabling the privacy features.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior? The ability to use the subgraph with our graph-node to read and index the private transaction events in EVM-based private blockchains.

More explanations: In searching for the reasons that block the graph-node to read the events, I asked the following question in ConsenSys Quorum-Besu channel:

Isk — 11/29/2021 I'm running Quorum Dev Quickstart (https://github.com/ConsenSys/quorum-dev-quickstart) and setup a private permissioned Besu running with Tessera nodes. I've added an event into the example contract (SimpleStorage.sol) event Set(uint amount, address sender);

And running the /quorum-test-network/smart_contracts/scripts/private_tx.jsbetween Member1 and Member3, but the issue was that I couldn't read any events happened in the set() function.

Q: Is Tessera blocking the Event emitter features in the blockchain? or how to reach and read the emitted events happened? Discord question link

Then, got the following answer:

taccatisid — 11/30/2021 How do you fetch those events? There is a priv_getLogs method that is the equivalent of eth_getLogs for private transactions (https://besu.hyperledger.org/en/stable/Reference/API-Methods/#priv_getlogs). Discord answer link

Basically, Besu is using a different EVM API method for the private transactions which is priv_getLogs but on the other hand, the graph-node is depending on the eth_getLogs method on reading the events from any open and public JSON RPC equivalent network.

So if this would be a useful feature to be added in the graph-node, am suggesting starting research on implementing it. After having a fast look into the code, I think the starting point would be from these scripts:

  1. adapter.rs
  2. chain.rs
  3. ethereum_adapter.rs
azf20 commented 2 years ago

Hi! Thanks for the write up. Two things - firstly Graph Node is currently moving towards relying on firehose based (rather than RPC based) indexing methods, so I don't think we would add an additional getLogs method here. Secondly I don't know if there is sufficient demand for private blockchain use-cases (Graph Node is predominantly focused on data from public blockchains)

mfolnovic commented 2 years ago

Just stumbled upon this and wanted to express an interest in this. We are also starting using Besu+Tessera+Graph Node.

Thank you all for amazing work on Graph Node so far!

mfolnovic commented 2 years ago

@azf20 Would you be interested in receiving PR on this?

@iskdrews I'm planning on working on this next week. Just wanted to check if you already started working on this?

0xisk commented 2 years ago

@mfolnovic yes I am happy to collaborate with you on implementing this, I need guidance on it. I was waiting for getting an approval on implementing this feature from TheGraph team.

mfolnovic commented 2 years ago

@iskdrews I did a quick PoC to verify your proposal and it works. But at the moment, I'm stuck with:

https://discord.com/channels/905194001349627914/938504958909747250/977063311415853067 (Hyperledger Foundation) https://discord.com/channels/438038660412342282/791444480628490290/977054461061124097 (graphprotocol)

Any help would be appreciated! :)

0xisk commented 2 years ago

@mfolnovic thanks much! I have sent you a friend request on Discord so we can start planning together on this. I as well posted this proposal in the ConsenSys Besu channel for getting feedback: https://discord.com/channels/697535391594446898/743193040197386451/976850555584540702

github-actions[bot] commented 2 years ago

Looks like this issue has been open for 6 months with no activity. Is it still relevant? If not, please remember to close it.