From 3863f6f693e3f3d06ee53f67cff4e7afb4334e13 Mon Sep 17 00:00:00 2001 From: ArielElp <86294909+ArielElp@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:47:13 +0200 Subject: [PATCH] fix: ignore fee token contract is the fee formula (#1123) * Ignore fee token contract is the fee formula * discounter_multiplier_fix * change_phrasing Co-authored-by: Steve Goodman <39279277+stoobie@users.noreply.github.com> * fix typo Co-authored-by: Steve Goodman <39279277+stoobie@users.noreply.github.com> --------- Co-authored-by: Steve Goodman <39279277+stoobie@users.noreply.github.com> --- .../pages/Network_Architecture/fee-mechanism.adoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/fee-mechanism.adoc b/components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/fee-mechanism.adoc index 2647cfb497..5e543647d0 100644 --- a/components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/fee-mechanism.adoc +++ b/components/Starknet/modules/architecture_and_concepts/pages/Network_Architecture/fee-mechanism.adoc @@ -21,8 +21,8 @@ The following formula describes the overall fee, stem:[F], for a transaction: ++++ \begin{align} F = \text{gas_price}\cdot&\Bigg(\max_k v_k w_k + \\ -& + \; \text{da_calldata_cost}\left(2n+2(m-1) + \ell + 3t + \sum\limits_{i=1}^t q_i\right)\\ -& - \; \text{contract_update_discount}\cdot n - 240 \\ +& + \; \text{da_calldata_cost}\left(2(n-1)+2(m-1) + \ell + 3t + \sum\limits_{i=1}^t q_i\right)\\ +& - \; \text{contract_update_discount}\cdot (n-1) - 240 \\ & + \; \text{message_calldata_cost}\cdot\left(3t + \sum\limits_{i=1}^t q_i\right) \\ & + \; \text{storage_write_cost}\cdot t\Bigg) \end{align} @@ -33,8 +33,8 @@ where: * stem:[$v$] is a vector that represents resource usage, where each of its entries, stem:[$v_k$], corresponds to different resource types: Cairo steps and number of applications of each builtin. + For more information see xref:#calculation_of_computation_costs[Calculation of computation costs]. -* stem:[$n$] is xref:#storage_updates[the number of unique contracts updated], which also includes changes to classes of existing contracts and contract deployments, even if the storage of the newly deployed contract is untouched. In other words, stem:[$n\ge\ell$]. -* stem:[$m$] is the number of values updated, not counting multiple updates for the same key. Notice that stem:[$m\ge 1$] is always true, because the sequencer's balance is always updated, which does not incur any fee. +* stem:[$n$] is xref:#storage_updates[the number of unique contracts updated], which also includes changes to classes of existing contracts and contract deployments, even if the storage of the newly deployed contract is untouched. In other words, stem:[$n\ge\ell$]. Notice that stem:[$n\ge 1$] always holds, because the fee token contract is always updated, which does not incur any fee. +* stem:[$m$] is the number of values updated, not counting multiple updates for the same key. Notice that stem:[$m\ge 1$] always holds, because the sequencer's balance is always updated, which does not incur any fee. * stem:[$t$] is the number of L2->L1 messages sent, where the corresponding payload sizes are denoted by stem:[$q_1,...,q_t$]. * stem:[$\ell$] is the number of contracts whose class was changed, which happens on contract deployment and when applying the `replace_class` syscall. * stem:[$w$] is the xref:#calculation_of_computation_costs[`CairoResourceFeeWeights`] vector. @@ -185,7 +185,7 @@ The following formula describes the storage update fee for a transaction: [stem] ++++ -\underbrace{\textit{gas_price}\left(\text{da_calldata_cost} \cdot 2n - \text{contract_update_discount}\cdot n\right)}_{\text{contract addresses + new nonce and number of storage updates +\underbrace{\textit{gas_price}\left(\text{da_calldata_cost} \cdot 2(n-1) - \text{contract_update_discount}\cdot (n-1)\right)}_{\text{contract addresses + new nonce and number of storage updates }} \\ + \\ @@ -195,7 +195,7 @@ The following formula describes the storage update fee for a transaction: where: -* stem:[$n$] is xref:#storage_updates[the number of unique contracts updated], which also includes changes to classes of existing contracts and contract deployments, even if the storage of the newly deployed contract is untouched. In other words, stem:[$n\ge\ell$]. +* stem:[$n$] is xref:#storage_updates[the number of unique contracts updated], which also includes changes to classes of existing contracts and contract deployments, even if the storage of the newly deployed contract is untouched. In other words, stem:[$n\ge\ell$]. Notice that stem:[$n\ge 1$] always holds, because the fee token contract is always updated at the end of each transaction, in order to update the sequencer's and the sender's balances. The fee token contract update is not taken into account when computing the fee. * stem:[$m$] is the number of values updated, not counting multiple updates for the same key. Notice that stem:[$m\ge 1$] always holds, because the sequencer's balance is updated at the end of each transaction. The sequencer's balance update is not taken into account when computing the fee. * stem:[\text{contract_update_discount}] is 312 gas, which is discounted for every updated contract. This discount is a result of the fact that out of the stem:[$2n$] words caused by updating contracts, stem:[$n$] words are short, including at most 6 non-zero bytes: +