Concordium / concordium-client

A command line client to interact with the concordium-node
Apache License 2.0
8 stars 6 forks source link

GASaccounts #152

Closed sderuiter closed 2 years ago

sderuiter commented 2 years ago

Can someone either explain the logic for oldGASaccount and newGASaccount to me, or point me to a document that explains this? I think block rewards feed this account (partially?) but I’m unable to fully understand this concept.

For reference: I’m trying to calculate the sum of all block rewards in a given day (hoping that I could take the difference of two amounts).

abizjak commented 2 years ago

The notion of the GAS account exists to smooth out transaction fees over time. Since all bakers have to execute all blocks. The rough idea is that transaction fees don't go directly to the baker, but instead some of it goes to the baker directly, and some to the GAS account (and some to the foundation). The proportions are determined by the value of these parameters http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/struct.TransactionFeeDistribution.html

At the same time, in addition to direct transaction fees for the block that they have produced, the baker gets a share of the value of the GAS account from the past blocks (recall that this value is accumulated from each block according to the fraction http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/struct.TransactionFeeDistribution.html#structfield.gas_account )

In addition to this, GAS reward is used to reward inclusion of "special transactions" that are not directly paid by the sender, such as account creations and update instructions, and inclusion of finalization proofs. The fractions that determine the distribution are at the following link http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/struct.GASRewards.html

So for block rewards we

sderuiter commented 2 years ago

🤔, far more complicated than I ever could have imagined.

Another question to try to achieve the same thing: bakers get more rewards when #txs increases (in general). Is there a way to calculate the total transaction fees paid (on a given day)?

abizjak commented 2 years ago

Each block summary has a list of transactions, and each account transaction, which are the only ones that contribute transaction fees, has a cost field http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/struct.AccountTransactionDetails.html#structfield.cost which is the amount of fees they paid.

So at least this way you can calculate how many fees were paid. I can't remember a quicker way at the moment.

sderuiter commented 2 years ago

Yes, that's a field I'm familiar with, but this approach forces me to search all 3M+ blocks for all transactions to calculate tx fees. If that is the only way for now, I'll hold off on improving my APY estimates.