From 3a76ec04e2bb9abd4177e9fa66b60a695c1eb4c5 Mon Sep 17 00:00:00 2001 From: Luther Kroe <42369792+kroezone@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:19:34 +0100 Subject: [PATCH 1/3] Update README.md --- cad/006_memory/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cad/006_memory/README.md b/cad/006_memory/README.md index 34785b8..42850b5 100644 --- a/cad/006_memory/README.md +++ b/cad/006_memory/README.md @@ -37,7 +37,9 @@ Whenever a transaction is executed on the CVM, Memory Consumption is calculated Memory Consumption is computed at the end of each transaction, and is defined as: -`Memory Consumption = [Size of CVM state at end of transaction] - [Size of CVM state at start of transaction] +``` +Memory Consumption = [Size of CVM state at end of transaction] - [Size of CVM state at start of transaction] +``` If a transaction has zero Memory Consumption, it will complete normally with no effect from the Memory Accounting subsystem From 9cbe999ff5a8c9d3aa1c57bd63fc502182eb3b63 Mon Sep 17 00:00:00 2001 From: Luther Kroe <42369792+kroezone@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:20:58 +0100 Subject: [PATCH 2/3] Fix :fees field in CAD10 --- cad/010_transactions/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cad/010_transactions/README.md b/cad/010_transactions/README.md index 7f09adb..f699440 100644 --- a/cad/010_transactions/README.md +++ b/cad/010_transactions/README.md @@ -112,7 +112,7 @@ Transaction results MUST be returned in a `Result` record which contains the fol - `:eaddr` - the Address of execution where the error was raised - `:mem` - Integer amount of memory consumed by the transaction (may be omitted if zero, may be negative for a refund) - `:juice` - Execution juice for the transaction - - `:fee` - Total fee paid in Convex coppers, including memory cost + - `:fees` - Total fee paid in Convex coppers, including memory cost An an optimisation, peers MAY avoid creating `Result` records if they have no requirement to report results back to clients. From cdcc25a170e357b2be01358edf7e3e85b156e952 Mon Sep 17 00:00:00 2001 From: Luther Kroe <42369792+kroezone@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:27:01 +0100 Subject: [PATCH 3/3] Add fees section in CAD010 --- cad/010_transactions/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cad/010_transactions/README.md b/cad/010_transactions/README.md index f699440..54d7a53 100644 --- a/cad/010_transactions/README.md +++ b/cad/010_transactions/README.md @@ -116,6 +116,24 @@ Transaction results MUST be returned in a `Result` record which contains the fol An an optimisation, peers MAY avoid creating `Result` records if they have no requirement to report results back to clients. +### Fees + +Total fees for a successful transaction are calculated as: + +``` +(juice used + transaction base cost) * juice price + memory costs +``` + +See [CAD007](../007_juice) for more details on juice cost calculation. + +See [CAD006](../006_memory) for more details on memory cost calculation. + +Memory costs MUST be zero if no memory was used, or if the origin account had sufficient memory allowance to cover the increase in state size caused by the transaction. + +In the case of a failed transaction, memory fees MUST be zero (since state changes are rolled back) + +If a transaction failed signature or sequence verification, the base transaction cost is paid by the peer that submitted the erroneous transaction. + ### Verification If the client trusts the peer, the returned result may be assumed as evidence that the transaction has succeeded.