graph-node icon indicating copy to clipboard operation
graph-node copied to clipboard

[Feature] Internal native asset transfers

Open spennyp opened this issue 2 years ago • 7 comments

Description

Currently, there is no way to track internal native asset (ex. ETH) transfers inside of an event handler.

This is because internal transactions are not tracked. This is problematic for figuring out the correct flow of assets during an event.

Specifically, we ran into this issue when creating the 0x community subgraphs. Since internal native asset transfers cannot be tracked, it is not possible to index and assemble full 0x trades in a subgraph using the graph-node without call handlers (which are not supported everywhere).

Ideally, there would be an array of internal transactions as part of the transaction class, where each one would at least have the native asset amount that was transferred. I.e can access these in an event handler like: event.transaction.internalTransfers

For example, you can see internal transactions for a transaction in etherscan: Screenshot 2024-01-29 at 15 51 20

Could use a feature flag to turn this on like the receipts flag is used today, so internal transactions are off by default speeding up indexing.

This was originally mentioned here (https://github.com/graphprotocol/graph-node/issues/297) in 2018, and was planned as part of "phase 2" but was never implemented.

Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.

No response

Some information to help us out

  • [ ] Tick this box if you plan on implementing this feature yourself.
  • [X] I have searched the issue tracker to make sure this issue is not a duplicate.

spennyp avatar Jan 29 '24 23:01 spennyp

I'm facing the same challenge. I building a subgraph that tracks token swap on a certain dex on Polygon, and when the swap involves the native asset MATIC, I can't parse it from the event logs.

idan-orbs avatar Feb 12 '24 11:02 idan-orbs

interesting to see how it's hard to track these transfers while with Smart Accounts being a reality, these type of transfers will be more and more needed to create great UX. Didn't check but ... hasn't been created an EIP to propose a sort of event-like emitted when internal transfers with value > 0 happens?

70nyIT avatar Feb 29 '24 23:02 70nyIT

I'm not aware of an EIP for that @70nyIT, but indeed I think that could be an interesting addition to the client I think the original request would also require tracing so it might also not be available everywhere @spennyp?

azf20 avatar Mar 12 '24 12:03 azf20

Yes, we need tracing (this is why such an EIP could be a huge benefit to have this feature without relying on Archive Nodes). Or at least, this is the only way I've found so far to access those info.

70nyIT avatar Mar 12 '24 13:03 70nyIT

@azf20 in case you missed it - there's an EIP to solve this problem proposed by Vitalik https://ethereum-magicians.org/t/eip-7708-eth-transfers-emit-a-log/20034/10

70nyIT avatar May 27 '24 09:05 70nyIT

This is the last thing I need to fully adopt the graph for all my on chain data needs. I currently have an custom aka complicated solution for indexing native asset transfers for smart contract accounts. I would really appreciate this feature!

stewart-lore avatar Jun 11 '24 14:06 stewart-lore

just curious, what's your flow @stewart-lore ? debug trace each block or a different approach?

70nyIT avatar Jun 12 '24 14:06 70nyIT