Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umbrella document for cost model #20517

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/src/implemented-proposals/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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackcmay pointed out that signature cost should not be used in block packing decision since signature verification is done outside slot.

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.

##


~
~
~
~
~
~