You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an epoch based protocol, where epochs themselves are based on the block timestamp, not the block number. This protocol is ran on top of Arbitrum One kind of a blockchain, and has a variable block time.
Inside the protocol, there are different kinds of state and transitions between these states, like token vesting, reward payments and so on. Some of these states are changed upon user transaction, eg reward withdrawal. Yet others are calculated "passively" – based on epochs.
In order to collect all these states inside a subgraph, I have handlers both on relevant events and on new blocks.
On a new block, I use block.timestamp to calculate if a new epoch has begun. And if so, I call contracts to get current states of rewards.
On events, I then update these states. Together, I have a full picture.
However, I could simplify implementation greatly if I would be able to gather data at the end of the epoch. But the quirk is that I never know in advance when the epoch is going to end! Because block time is variable – I can never be sure there wouldn't be one more block before the epoch change.
A see only one way to address that: make it possible to issue a contract call on a previous block. Right now graph-ts's ethereum::call doesn't allow to specify the block number.
Maybe a generalisation makes sense, and it should be any past block. For my use case, just previous block would be enough.
I hope this all makes sense! Thank you for your awesome work 🙏
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
I have the following use-case.
I have an epoch based protocol, where epochs themselves are based on the block timestamp, not the block number. This protocol is ran on top of Arbitrum One kind of a blockchain, and has a variable block time.
Inside the protocol, there are different kinds of state and transitions between these states, like token vesting, reward payments and so on. Some of these states are changed upon user transaction, eg reward withdrawal. Yet others are calculated "passively" – based on epochs.
In order to collect all these states inside a subgraph, I have handlers both on relevant events and on new blocks.
On a new block, I use block.timestamp to calculate if a new epoch has begun. And if so, I call contracts to get current states of rewards.
On events, I then update these states. Together, I have a full picture.
However, I could simplify implementation greatly if I would be able to gather data at the end of the epoch. But the quirk is that I never know in advance when the epoch is going to end! Because block time is variable – I can never be sure there wouldn't be one more block before the epoch change.
A see only one way to address that: make it possible to issue a contract call on a previous block. Right now graph-ts's
ethereum::call
doesn't allow to specify the block number.Maybe a generalisation makes sense, and it should be any past block. For my use case, just previous block would be enough.
I hope this all makes sense! Thank you for your awesome work 🙏
Beta Was this translation helpful? Give feedback.
All reactions