From 194a7d1ca01e1d77bd52514efb5e2a9dac3a47c5 Mon Sep 17 00:00:00 2001 From: ArielElp <86294909+ArielElp@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:25:33 +0200 Subject: [PATCH 1/4] Ignore fee token contract is the fee formula --- .../pages/Network_Architecture/fee-mechanism.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 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..88ffdaa706 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,7 +21,7 @@ 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{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 - 240 \\ & + \; \text{message_calldata_cost}\cdot\left(3t + \sum\limits_{i=1}^t q_i\right) \\ & + \; \text{storage_write_cost}\cdot t\Bigg) @@ -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\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 and the sender's balances. The fee token address is not taken 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: + From 8676bd228d699a917040ecdcd4356825d91ee828 Mon Sep 17 00:00:00 2001 From: ArielElp <86294909+ArielElp@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:32:54 +0200 Subject: [PATCH 2/4] discounter_multiplier_fix --- .../pages/Network_Architecture/fee-mechanism.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 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 88ffdaa706..d81ea0e4f5 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 @@ -22,7 +22,7 @@ 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(2(n-1)+2(m-1) + \ell + 3t + \sum\limits_{i=1}^t q_i\right)\\ -& - \; \text{contract_update_discount}\cdot n - 240 \\ +& - \; \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} @@ -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 2(n-1) - \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 }} \\ + \\ From 33b475cb459b87170eaa30785d58f798802a5a64 Mon Sep 17 00:00:00 2001 From: ArielElp <86294909+ArielElp@users.noreply.github.com> Date: Sun, 11 Feb 2024 10:37:02 +0200 Subject: [PATCH 3/4] change_phrasing Co-authored-by: Steve Goodman <39279277+stoobie@users.noreply.github.com> --- .../pages/Network_Architecture/fee-mechanism.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d81ea0e4f5..9126f0504c 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 @@ -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$]. 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 and the sender's balances. The fee token address is not taken contract update is not taken into account when computing the 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 at the end of each transaction, in order to update the sequencer 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: + From bf57167986d522749c29c0feeaee4a175c247368 Mon Sep 17 00:00:00 2001 From: ArielElp <86294909+ArielElp@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:03:01 +0200 Subject: [PATCH 4/4] fix typo Co-authored-by: Steve Goodman <39279277+stoobie@users.noreply.github.com> --- .../pages/Network_Architecture/fee-mechanism.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9126f0504c..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 @@ -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$]. 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 and the sender's balances. The fee token contract update is not taken into account when computing the 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 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: +