Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Update kip-162
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 committed Mar 25, 2024
1 parent b2b81d9 commit ca8b4ed
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions KIPs/kip-162.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,49 +198,41 @@ def EffectiveGasPrice(header: Header, tx: Transaction):
maxPriorityFeePerGas = tx.maxPriorityFeePerGas
else:
maxFeePerGas = tx.gasPrice
maxPriorityFeePerGas = tx.gasPrice
maxPriorityFeePerGas = tx.gasPrice # Option A
maxPriorityFeePerGas = 0 # Option B
maxPriorityFeePerGas = tx.maxPriorityFeePerGas # Option C (only for Klaytn tx types)
return min(header.baseFeePerGas + maxPriorityFeePerGas, maxFeePerGas)
```
- **Option A**. Effective gas price is equal to `gasPrice`. The sender pays the full price as declared in the `gasPrice`. The transactions are reliably included in the blocks because this nonzero priority fee will make the transactions high priority. A side effect is that the senders either pay larger price than before, or has to precisely predict the base fee in order to save the gas fee. This policy is identical to [EIP-1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md).
```py
maxFeePerGas = tx.gasPrice
maxPriorityFeePerGas = tx.gasPrice
effectiveGasPrice = min(header.baseFeePerGas + maxPriorityFeePerGas, maxFeePerGas)
= tx.gasPrice
```
- **Option B**. Effective gas price is equal to `baseFeePerGas`. The sender pays the base fee regardless of the `gasPrice` field. The sender gets to pay what she had been paying today. The gas fee is still highly predictable. A side effect is that transactions might be delayed in the event of network congestion because the blocks will be filled with transactions paying nonzero priority fee.
```py
maxFeePerGas = tx.gasPrice
maxPriorityFeePerGas = 0
effectiveGasPrice = min(header.baseFeePerGas + maxPriorityFeePerGas, maxFeePerGas)
= header.baseFeePerGas
```
- **Option C (only applicable to Klaytn tx types)**. Add the transaction field `maxPriorityFeePerGas`. Either add an optional field to the existing type or define new tx types. The details are orthogonal to the current proposal.
Effective price example. Prices are in 'ston' (1e-9).
| baseFeePerGas | transaction | EffectiveGasPrice | EffectivePriorityFeePerGas |
| baseFeePerGas | transaction | effectiveGasPrice | effectivePriorityFeePerGas |
|-|-|-|-|
| 25 | {type: 0, gasPrice: 51}, **Option A** | 51 | 26 |
| 25 | {type: 0, gasPrice: 51}, **Option B** | 25 | 0 |
| 25 | {type: 8, gasPrice: 51, maxPriorityFeePerGas: 1}, **Option C** | 26 | 1 |
| 25 | {type: 2, maxFeePerGas: 51, maxPriorityFeePerGas: 1} | 26 | 1 |
# Backward compatibility
## Continued use of other transaction types
Depends on which of the options A,B,C we follow, but either way all transaction types should work.
Legacy (type 0) transactions, EIP-2920 AccessList (type 1) transactions, and Klaytn transaction types (types 8+) will work and be included in blocks. Those transactions have `gasPrice` field but no `maxFeePerGas` nor `maxPriorityFeePerGas` fields.
TODO: choose option A or B
- Option A: Those transactions may experience sudden increase in gas costs because previously they only paid `baseFeePerGas` but now they have to pay `gasPrice`. To reduce the impact, `eth_gasPrice` implementations may return a number slightly higher than the `baseFeePerGas`.
- Option B: Those transactions may experience delay in the event of congested network. However, since Klaytn has large block spaces and frequent block time, such a delay should be an exceptional event.
- Option C: SDKs and apps using the old format or existing type may experience delay because those transactions are considered zero priority fee. The ecosystem may upgrade to utilize the priority fee feature in Klaytn tx types.
## EVM opcodes
The `GASPRICE` (0x3a) opcode is backwards compatible because it had been correctly returning the effective gas price before `DRAGON_FORK_BLOCK_NUMBER`. The `BASEFEE` (0x48) opcode remains the same; returns the base fee per gas of the currently executing block.
Expand Down

0 comments on commit ca8b4ed

Please sign in to comment.