moneroexamples / onion-monero-blockchain-explorer

Onion Monero Blockchain Explorer
https://xmrchain.net
BSD 3-Clause "New" or "Revised" License
361 stars 269 forks source link

[Feature Request] Calculate Minimum Transaction Fee for each Block #276

Open ACK-J opened 2 years ago

ACK-J commented 2 years ago

This is a selfish request as I am creating a chart at the moment which needs this information and there is no historical source which I can pull the data from. I will recalculate the values myself but it would be really cool if the XMR block explorer advertised the base transaction fee for the block, even if it was an estimate.

https://www.getmonero.org/2017/12/11/A-note-on-fees.html

https://github.com/monero-project/monero/blob/master/tests/unit_tests/fee.cpp

moneroexamples commented 2 years ago

Is it something that you could calculate on your side from existing info? Or there is some piece of information missing that should be exposed by the explorer?

ACK-J commented 2 years ago

There is very little documentation or understanding surrounding how the "base fee" is calculated, it seems there are a lot of moving parts. I've been trying to figure it out for myself to write a blog post to help others. If the block explorer automatically did this, I think it would also help people understand more about the fee paid in a transaction, relational to the base they had to pay.

https://github.com/monero-project/monero/blob/b6a029f222abada36c7bc6c65899a4ac969d7dee/src/wallet/wallet2.cpp#L7349-L7362

I think there is certain information needed that needs to be calculated for each block, but I am not certain. Also I have a 0.2 xmr bounty outstanding for anyone who makes it possible to get the base transaction fee of an arbitrary block on-chain, its not a lot of xmr but its something.

moneroexamples commented 2 years ago

Monero daemon has RPC get_dynamic_base_fee_estimate which is use by monero wallet:

https://github.com/monero-project/monero/blob/master/src/wallet/wallet2.cpp#L7338

If that would help, I could expose that?

ACK-J commented 2 years ago

Yea that would work! But would this work for past blocks or just for the newest one?

moneroexamples commented 2 years ago

I think its for the current ones only.

ACK-J commented 2 years ago

Would you know how to make it work for any arbitrary block? My problem is that I need to know the average "base transaction fee" over a 100,000 block period starting at block #2566273.

moneroexamples commented 2 years ago

At the moment I'm not sure. Would have too look into it in more depth. Maybe you could ask on reddit if there is some easy way?

moneroexamples commented 2 years ago

Have you check the json api for the explorer: https://github.com/moneroexamples/onion-monero-blockchain-explorer#apinetworkinfo It returns fee_per_kb which is estimate of a fee per kb (10 blocks).

ACK-J commented 2 years ago

Yea it looks like it makes an RPC call to get it, I don't think it would allow me to return the fee_per_kb of an arbitrary block :/ https://github.com/moneroexamples/onion-monero-blockchain-explorer/blob/aa96ce2927c050fabe17154a3bdfb09be83a632f/src/MempoolStatus.cpp#L239-L241

moneroexamples commented 2 years ago

Its only based on current blocks. Is there any API in monero itself to get a fee estimate for any block?

ACK-J commented 2 years ago

I dont believe so, but I wish there was one

ACK-J commented 1 year ago

Would you be able to expose the get_dynamic_base_fee_estimate wallet2 function as an API endpoint? This way sites like moneroj.net can track it from now on.