Comment on page
To ensure the system's sustainability, actors must be compensated for correctly performing their roles and giving the protocol finality.
Unless otherwise specified, the measures and rules presented here apply to cases in which the Sequencer and Aggregator roles are decentralised (i.e., when there are no Trusted Sequencer and no Trusted Aggregator).
The native currency used in L2 is
Bridged BNB, which originates from L1. This is the currency that is used to pay L2 transaction fees. It can be transferred at a 1:1 exchange ratio from L1 to L2 and vice versa.
The Sequencer earns the transaction fees paid by L2 users for submitting transactions, and thus gets paid directly in
Bridged BNB. The amount of fees paid depends on the gas price, which is set by users based on how much they are willing to pay for the execution of their transactions.
To incentivize the Aggregator for each batch sequenced, the Sequencer must lock a number of ZKC tokens in the L1
ZKChain.solContract proportional to the number of batches in the sequence. The number of ZKC tokens locked per batch sequenced is saved in the variable
The below diagram depicts the various fees and rewards earned by the protocol's actors.
To maximize its income, the Sequencer prioritizes transactions with higher gas prices. Furthermore, there is a threshold below which it is unprofitable for the Sequencer to execute transactions because the fees earned from L2 users are less than the fees paid for sequencing fees (plus L1 sequencing transaction fee).
Users must ensure that their transaction fees are greater than this threshold in order for the Sequencer to be incentivized to process their transactions.
The net BNB value earned by the Sequencer for sequencing a batch sequence is represented by the following expression:
Sequencer net BNB income = totalL2TxGasFee−(L1SeqTxGasFees+ZKC/BNBbatchFee∗nBatches)where:
totalL2TxGasFeesis the total sum of fees gathered from all L2 transactions included in the sequence of batches,
L1SeqTxGasFeeis the Sequencing transaction gas fee paid in L1,
batchFeeis the storage variable in ZKChain.sol contract,
nBatchesis the number of batches in the sequence,Aggregation RewardThe Aggregator also needs compensation for correctly fulfilling its role.The number of ZKC tokens earned by the Aggregator each time it aggregates a sequence, denoted by
batchReward, is determined by the total contract ZKC balance and the number of batches aggregated.The ZKC earned per batch aggregated is calculated by the L1
ZK Chain.solcontract prior to sequence aggregation using the following expression:batchReward=“ Quantity of batches not aggregated yet”“ contract ZKC balance”The following expression represents the total amount of BNB value that the Aggregator will earn for the aggregation of a sequence of batches: “AggregatornetBNBincome”=ZKC/BNBbatchReward∗nBatches−L1AggTxGasFeewhere:
L1AggTxGasFeeis the Aggregation transaction gas fee paid in L1,
batchRewardis the quantity of ZKC earned per batch aggregated,
nBatchesis the number of batches in the sequence,
ZKC/BNBis the price of ZKC token expressed in BNB.Variable
batchFeeis auto-adjusted with every aggregation of a sequence by an independent Aggregator.This happens when the Trusted Aggregator isn't working properly and the
batchFeevariable needs to be changed to encourage aggregation. Further information on the Trusted Aggregator's inactivity or malfunctioning is provided in upcoming sections.An internal method called
_updateBatchFee, is used to adjust
batchFeestorage variable.function _updateBatchFee(uint64 newLastVerifiedBatch) internalThe admin defines two storage variables that are used to tune the fee adjustment function:
veryBatchTimeTarget: it is the targeted time of the verification of a batch, so the
batchFeevariable will be updated to achieve this target, and
multiplierBatchFee: it is the batch fee multiplier, with 3 decimals that ranges from 1000 to 1024.The function
_updateBatchFeefirst determines how many of the aggregated batches are late. That is, those who are in the sequence but have not yet been aggregated.Second, how much time has passed, as indicated by
diffBatchesvariable represents the difference between late batches and those below the target, and its value is limited by a constant called
MAX BATCH MULTIPLIER, which is set to 12.