Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Convex-Dev/design.git into …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
mikera committed Sep 6, 2024
2 parents 9af5f63 + cdcc25a commit 77e381c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cad/006_memory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 19 additions & 1 deletion cad/010_transactions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,28 @@ 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.

### 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.
Expand Down

0 comments on commit 77e381c

Please sign in to comment.