Fee Voting - zoobc/zoobc-core GitHub Wiki
Fee voting is a feature to scale the minimum fee on the network by executing a set of actions. The fee-scale will be used to scale down/up all the minimum fee across all transaction type.
if tx.Fee < feeScale * txType.MinimumFee {
  Error("NotEnoughFee")
}
Fee scale will be adjusted in consensus within 3 steps separated in 2 phase in one month cycle:
- 
Commit Phase 1st - 14th days of month. 
- 
Reveal Phase 15th - last day of month. 
- 
Adjustment first block of month. 
- 
Commit PhaseNode owner submit the commitment of their vote in form of 32 bytes data. Ideally this data will be the hash of FeeVoteInfo, but it can be anything because the goal of this transaction type is tocommitandhidethe vote at the same time.- 
Transaction Type: Sender submit their vote commitment by submitting CommitFee transaction type. 
- 
Restrictions: - 
Sender, only node owner. 
- 
Frequency, can only be submitted once, per-phase,per-node_owner.
- 
Time, commit-phase (1st - 14th day of month) 
- 
If there is none of Fee Vote Commit include in block, all incoming Fee Vote Commit will accept but only one can include in block and the others will be prune from mempool. 
 
- 
 
- 
- 
Reveal PhaseNode owner submit the actual information of hash submitted in CommitPhase. - 
Transaction Type: Sender submit the reveals to the node by posting previously saved FeeVoteInfo via Reveal Fee 
- 
Restrictions: - Sender, only node owner.
- Frequency, once per-phaseper-node_owner.
- Time, reveal-phase (15th - last day of month)
- State, hash of this reveal object must be already in node's fee_vote_commitment_votetable.
 
 
- 
- 
AdjustmentThe adjustment process is triggered on the end of reveal-phaseand indicated by the creation of the first block of the month.- 
The medianof revealed votes on current voting-period is selected.
- 
The selected value is scaled to the original SendMoneyminimum fee.newScale = median / SendMoney.OriginalMinFee
- 
The newScalevalue is constrained, by comparing topreviousScaleand clamped it to1/2*previousScaleif lower than half previous scale, and2*previousScaleif higher than twice previous scale.newPrevRatio = newScale / previousScale if newPrevRatio < 0.5 { newScale = 0.5 * previousScale } else if newPrevRatio > 2.0 { newScale = 2.0 * previousScale }
- 
Finally newScalewill be finalized and inserted tofee_scaletable applied to the next block minimumFee.
- 
note: to avoid floating point value, scale is multiplied to constant.OneZBC
 
- 
- 
Data- 
FeeVoteInfo FeeVoteInfo is object for the node-owner to vote the next new fee. No Field Length (byte) Type 0 RecentBlockHash 32 byte 1 RecentBlockHeight 4 uint32 2 FeeVote 8 int64 RecentBlockHash: is the latest BlockHash value when this object is created. RecentBlockHeight: is the height of RecentBlockHash FeeVote: next minimum fee the owner want to vote on. - 
Bytes Sequence In CommitFee we need to hash the FeeVoteInfo, to do that we convert the object to its bytes sequence in the exact order and size of the above table. 
 
- 
 
-