aeternity / ae_mdw

Aeternity Middleware in Elixir
26 stars 10 forks source link

expose historic average gas price data #1861

Open janmichek opened 1 month ago

janmichek commented 1 month ago

It should be possible as discussed here

image

https://github.com/aeternity/aescan/issues/857

sborrazas commented 1 month ago

@hanssv is there any way to obtain the gas price from a previous historical block and not just top blocks?

hanssv commented 1 month ago

No, there is no way to retrieve historical data in the same format as the newly added endpoint. There is a (fair) bit of scanning and computing involved so adding this for an arbitrary height is not a great idea as @dincho explain. For the top height it is cached, but that approach doesn't scale.

I don't know the context, but isn't this exactly the kind of data you'd expect the mdw to computed during sync/scan and then provide?

sborrazas commented 1 month ago

@hanssv the mdw services stay at the top node height at all times, and even if we started syncing the node from height 0 we do not stop the node, get the top height data and have the node resume the syncing. Also, the mdw syncing might be too fast for the node syncing or the other way round. We can only implement it if we can reliably obtain information from the past

hanssv commented 1 month ago

Sorry, what? Isn't the mdw a service that aggregates, stores and provides historical data? (For example it provides information about transactions where one of the values is gas price, so how you couldn't yourself compute historical gas prices is beyond me?) If the node is supposed to provide all the necessary data in an aggregated format I'm not sure what the purpose of the mdw is?

sborrazas commented 1 month ago

mdw grabs the node blocks from height 0 and begins processing them all up until the end using node functions, indexing information that the node does not provide via it's public API

hanssv commented 1 month ago

👍 sounds like indexing historical gas prices fits that description perfectly - you would have to do a little bit of arithmetics, but doing that once while going from 0 to the top is definitely the right way. (Compared to digging up an hours worth of microblocks to compute it on-the-fly)

sborrazas commented 1 month ago

👍 sounds like indexing historical gas prices fits that description perfectly - you would have to do a little bit of arithmetics, but doing that once while going from 0 to the top is definitely the right way. (Compared to digging up an hours worth of microblocks to compute it on-the-fly)

Cool, we'll try to mimic the arithmetics the node does. Thank you 🙏