dusk-network / rusk

The reference Dusk platform implementation and tools
Mozilla Public License 2.0
155 stars 59 forks source link

Implement Moving Average Gas Price #1841

Open miloszm opened 3 months ago

miloszm commented 3 months ago

Summary

According to Economic Protocol Design document, Chapter 3, we need a SMA (Simple Moving Average) of the gas price implementation. Last N=5760 blocks should be included in the average.

Possible solution design or implementation

We need a system field which would hold the average, as well as the current first gas price, as well as a counter. Care needs to be taken to include averages only from final (or close enough to final) blocks.

Additional context

Please refer to the document: Dusk Economics - by POL Finance and Emanuele Francioni (Chapter 3) This issue is also related and needed for the Economic Protocol Scenario 3 Implementation - see epic #1690

autholykos commented 3 months ago

After some discussion, we agreed to go with the current implementation as a "poor man version" of sort for the SMA calculation. The proper solution should likely be implemented at the consensus level, by having the consensus process performing calculations and communicating those to Rusk as part of the block acceptance procedure. This also has the advantage to avoid introducing the concept of "block" in Rusk (or the TC) and managing finality