graphprotocol / graph-network-subgraph

The subgraph, the smart contracts, the tests, and documents for the Graph Explorer Decentralized Application
MIT License
70 stars 45 forks source link

block numbers in arbitrum deployment appear bugged #249

Open mentheosis opened 11 months ago

mentheosis commented 11 months ago

when querying allocations from https://thegraph.com/hosted-service/subgraph/graphprotocol/graph-network-arbitrum - the fields createdAtBlockNumber and closedAtBlockNumber appear to return invalid values - e.g. this result:

"allocations": [ { "id": "0x0001b044ebd481afef0545f431fe275980e69e09", "createdAtBlockNumber": 18176693, "createdAt": 1695207989 },

that timestamp is for today, but that blocknumber was in 2022 on arbitrum Can anyone from the foundation plz advise? I believe this is a bug in the subgraph

juanmardefago commented 10 months ago

That's not actually a bug, but an intended feature. The contracts in Arbitrum use the L1 block number internally, so the subgraph has to also do that as well, so what you are actually seeing is the L1 block number for that moment in time, rather than the L2 block number (which is what I'm assuming you were thinking it was)

mentheosis commented 10 months ago

On the mainnet deployment, its possible to query allocations, take the closedAtBlockNumber, and then query something like delegatedStaked where block=closedAtBlockNumber. This is not possible for arbitrum allocations with the feature as youve described., because the block number in the where clause is the arbitrumBlockNumber not the L1 block.

Would you consider including the arbitrumBlockNumber as an additional valuable field in this schema? Or can you recommend a way to look up arbitrum block number by timestamp or something? (also note that arbitrum block number is distinct from L2 block number per these docs: https://docs.arbitrum.io/for-devs/concepts/differences-between-arbitrum-ethereum/block-numbers-and-time)

juanmardefago commented 10 months ago

If you are trying to use the block number (L1 block number) to run time-travel queries, then yeah, it's not gonna work as you expect it. We could add the L2 block number that would allow you to run that query though, as you mentioned.

BTW, when we talk about L1 block number, we are talking about the L1 block number that's currently accesible in L2 (what the docs you linked call L2 block.number) and when we talk about L2 block number, we talk about the native L2 block (what the docs you linked call arbitrum block number)

juanmardefago commented 10 months ago

Not sure when we could release this though, as we are quite busy trying to ship other features. Hopefully soon though!

mentheosis commented 10 months ago

ok, I will eagerly await whenever its able to be prioritized, thanks!