massa icon indicating copy to clipboard operation
massa copied to clipboard

Do we need fee + gas_price ? Why not just fee or just gas_price ?

Open sebastien-forestier opened this issue 2 years ago • 12 comments

Let's see this example :

block size = 1000
max gas per block = 1000
priority = (max_gas * gas_price + fee) / size

Operation 1:
        max_gas = 1000
        gas_price = 0
        fee = 10000
        size = 10
-> priority = 1000

Operation 2:
        max_gas = 100
        gas_price = 2
        fee = 10000
        size = 100
-> priority = 102

With this settings, op1 is preferred while op2 brings much more money and maybe also allows more smart contract operations.

This reminds us that the Knapsack problem is NP-complete and maybe our heuristic is not the best, but also that setting the fee allows some degree of freedom to manipulate the priority, so a first question is: do we really need to set a fee ? Could we have only gas like in Ethereum ?

Then, a possible priority could be the following:

priority = (max_gas * gas_price) / (size + alpha * max_gas)

or even

priority = gas_price / size

sebastien-forestier avatar Mar 08 '22 17:03 sebastien-forestier

With priority = gas_price / size you could set a big gas_price and max_gas=0. Why not priority = max_gas*gas_price / size ?

qdrn avatar Mar 08 '22 18:03 qdrn

For now gas price is specific to the ExecuteSC OperationType whereas the fee is in every operation

AureliaDolo avatar Mar 09 '22 08:03 AureliaDolo

Interesting discussion there : https://github.com/ethereum/EIPs/pull/4488/commits/74570b55dc5a091e4ab46fdf0f139f6a1ee013a6

sebastien-forestier avatar Mar 10 '22 21:03 sebastien-forestier

This issue is stale! (no activity for 60 days)

github-actions[bot] avatar May 10 '22 18:05 github-actions[bot]

ping

damip avatar May 11 '22 07:05 damip

The ressources in question are:

  • per-slot computational power limits (op.max_gas)
  • block space usage (op.serialized_data.len())

And we need to pay a fee (op.fee) for them.

What we used to call op.fee + gas_price*max_gas will now be called op.fee. gas_price will be removed because it is redundant.

Final decision: we need to remove "gas_price" and only keep "fee" and "max_gas".

damip avatar Sep 23 '22 09:09 damip

What we used to call op.fee + gas_price*max_gas will now be called op.fee. gas_price will be removed because it is redundant.

Final decision: we need to remove "gas_price" and only keep "fee" and "max_gas".

I don't understand why we remove gas_price and not fee. I think max_gas is more easy to understand and fee is confusing.

AurelienFT avatar Sep 23 '22 09:09 AurelienFT

What we used to call op.fee + gas_price*max_gas will now be called op.fee. gas_price will be removed because it is redundant. Final decision: we need to remove "gas_price" and only keep "fee" and "max_gas".

I don't understand why we remove gas_price and not fee. I think max_gas is more easy to understand and fee is confusing.

Currently, "fee" only accounts for paying for block space usage and max_gas*gas_price accounts for paying for block gas

With this change "fee" would account for how much we pay for all the resources we will be using (max_gas of block gas and op.serialized.len() bytes of block space).

damip avatar Sep 23 '22 09:09 damip

Currently, "fee" only accounts for paying for block space usage and max_gas*gas_price accounts for paying for block gas

I see but why we pay for block space ? Only execution computation should matter and block creator will try to include the most ops in it to have the most gas

AurelienFT avatar Sep 23 '22 11:09 AurelienFT

Currently, "fee" only accounts for paying for block space usage and max_gas*gas_price accounts for paying for block gas

I see but why we pay for block space ? Only execution computation should matter and block creator will try to include the most ops in it to have the most gas

For each block they produce, the block producer has 2 finite resources: MAX_BLOCK_SIZE (a given op consumes op.serialized_data.len() of that resource) and MAX_BLOCK_GAS (a given op consumes op.max_gas of that resource) and each op yields op.fee coins of reward. The goal of the block producer is to choose and pack ops in their block in a way that maximizes the total reward.

This is related to the multi-dimensional knapsack problem: https://en.wikipedia.org/wiki/Knapsack_problem#Multi-dimensional_knapsack_problem

damip avatar Sep 23 '22 11:09 damip

Currently, "fee" only accounts for paying for block space usage and max_gas*gas_price accounts for paying for block gas

I see but why we pay for block space ? Only execution computation should matter and block creator will try to include the most ops in it to have the most gas

As you said you set a fee and then it's up to the block creator to chose the operations given the constraints on the max block size and max block gas. You can view it as paying for block space and computational power are those are the two constraints.

qdrn avatar Sep 24 '22 11:09 qdrn

Work issue: https://github.com/massalabs/massa/issues/3140

damip avatar Oct 10 '22 06:10 damip