Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
umbrella document for cost model
Browse files Browse the repository at this point in the history
  • Loading branch information
tao-stones committed Oct 7, 2021
1 parent 72848be commit 58b2437
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/src/cost_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Cost Model
---

## Motivation

Needs a method to calculate transaction's cost that captures the work required by validator to process it.

## Solution

### Transaction Cost calculation
Cost is measured in `compute unit`, which describes required computational work (eg., CPU).

Transaction cost is closely echoing proposed Comprehensive Fee Structure (#16984), it is the sum of following components:
1. signature cost, is the number of signatures in a transaction multiplied with fixed signature cost;
2. write lock cost, is number of writable accounts in transaction multiplied with fixed write_lock cost;
3. data byte cost, is transaction's data size multiple by fixed cost per bytes rate;
4. instruction execution cost, is the sum of cost of instructions in transaction. System built in instruction has fixed cost, while bpf instructions are collected in runtime.

Methods to determine fixed cost for above components are described in issue #19627.
å
### Transaction Cost composition
*** subject to change ***
In addition to above components, Transaction Cost also tracks the writable accounts in transactions. This additional information could be used by block producers to limit the number of transactions for the same account, by limiting cost allowed per account, hence improving block's parallelism.

##


~
~
~
~
~
~

0 comments on commit 58b2437

Please sign in to comment.