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

SIMD-0197: Chili Peppers #197

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
147 changes: 147 additions & 0 deletions proposals/0197-chilli-peppers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
simd: '0197'
title: Chilli Peppers
authors:
- Firedancer Team
category: Standard
type: Core
status: Review
created: 2024-11-19
feature: (fill in with feature tracking issues once accepted)
---


## Summary

This proposal adds a new consumable resource governing tiered memory bandwidth usage similar to the way that Compute Units seek to govern CPU usage.

Check failure on line 16 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 148]

proposals/0197-chilli-peppers.md:16:81 MD013/line-length Line length [Expected: 80; Actual: 148]

Check failure on line 16 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 148]

proposals/0197-chilli-peppers.md:16:81 MD013/line-length Line length [Expected: 80; Actual: 148]
Tiered memory bandwidth will become a performance bottleneck as transaction throughput and total state size increase. This proposal serves to outline changes to the Solana protocol that would enable:

Check failure on line 17 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 199]

proposals/0197-chilli-peppers.md:17:81 MD013/line-length Line length [Expected: 80; Actual: 199]

Check failure on line 17 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 199]

proposals/0197-chilli-peppers.md:17:81 MD013/line-length Line length [Expected: 80; Actual: 199]
Deterministic, easily computable and cluster-wide separation of state into hot and cold tiers

Check failure on line 18 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 93]

proposals/0197-chilli-peppers.md:18:81 MD013/line-length Line length [Expected: 80; Actual: 93]

Check failure on line 18 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 93]

proposals/0197-chilli-peppers.md:18:81 MD013/line-length Line length [Expected: 80; Actual: 93]
A new transaction level resource requesting the transfer of state from cold to hot
Block level constraints on the total cold to hot state transition
These added features will allow for a pricing market for the bandwidth from cold state to hot state (via priority fees), and allow block producers to more optimally pack blocks to get the highest possible throughput on already hot state and constrain access to cold state to be within bounds that the validator network will be able to keep up with.

Check failure on line 21 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 348]

proposals/0197-chilli-peppers.md:21:81 MD013/line-length Line length [Expected: 80; Actual: 348]

Check failure on line 21 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 348]

proposals/0197-chilli-peppers.md:21:81 MD013/line-length Line length [Expected: 80; Actual: 348]



## Motivation

In commodity hardware (for fixed cost), there is a fundamental tradeoff between the the size of accessible state and the bandwidth of random access to that state. On-chip caches >> RAM >> SSD >> HDD >> NAS increase by orders of magnitude in size, while falling by orders of magnitude in bandwidth.

Check failure on line 27 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 297]

proposals/0197-chilli-peppers.md:27:81 MD013/line-length Line length [Expected: 80; Actual: 297]

Check failure on line 27 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 297]

proposals/0197-chilli-peppers.md:27:81 MD013/line-length Line length [Expected: 80; Actual: 297]
For Solana (or any blockchain), treating all state as equivalent (regardless of its usage patterns) means that either total state size will

Check failure on line 28 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 139]

proposals/0197-chilli-peppers.md:28:81 MD013/line-length Line length [Expected: 80; Actual: 139]

Check failure on line 28 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 139]

proposals/0197-chilli-peppers.md:28:81 MD013/line-length Line length [Expected: 80; Actual: 139]
be limited by the size of RAM, or the throughput of the network will be limited to the bandwidth of disks. Actual usage patterns

Check failure on line 29 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 128]

proposals/0197-chilli-peppers.md:29:81 MD013/line-length Line length [Expected: 80; Actual: 128]

Check failure on line 29 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 128]

proposals/0197-chilli-peppers.md:29:81 MD013/line-length Line length [Expected: 80; Actual: 128]
(and expectations for future usage patterns as the network grows) show that a relatively small amount of the total state is accessed

Check failure on line 30 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 132]

proposals/0197-chilli-peppers.md:30:81 MD013/line-length Line length [Expected: 80; Actual: 132]

Check failure on line 30 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 132]

proposals/0197-chilli-peppers.md:30:81 MD013/line-length Line length [Expected: 80; Actual: 132]
frequently, and most of the state is accessed infrequently.
This usage pattern allows a hot/cold tiered state design to allow the total state size available from disk, while achieving the

Check failure on line 32 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 127]

proposals/0197-chilli-peppers.md:32:81 MD013/line-length Line length [Expected: 80; Actual: 127]

Check failure on line 32 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 127]

proposals/0197-chilli-peppers.md:32:81 MD013/line-length Line length [Expected: 80; Actual: 127]
throughput available from RAM.

## New Terminology

Chili Peppers (State Units?) - a consumable resource representing the number of bytes loaded into the "hot store" (active, frequently

Check failure on line 37 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 133]

proposals/0197-chilli-peppers.md:37:81 MD013/line-length Line length [Expected: 80; Actual: 133]

Check failure on line 37 in proposals/0197-chilli-peppers.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Line length [Expected: 80; Actual: 133]

proposals/0197-chilli-peppers.md:37:81 MD013/line-length Line length [Expected: 80; Actual: 133]
accessed memory) for state operations on the Solana blockchain. Each Chili Pepper corresponds directly to one byte of data loaded, providing
a precise mechanism to quantify and limit the resources consumed by transactions in terms of state memory usage.
Note that Chili Peppers required for a transaction are not the size of hot state touched by the transaction, but rather the amount of cold
state made hot or new state allocated. Transactions that are only accessing already hot state would require 0 Chili Peppers.

Block Chili Pepper Limit - The maximum number of Chili Peppers that can be requested in a single block.

Block Chili Pepper Clock - a cumulative measure of the total Chili Peppers requested since the genesis of the blockchain. At the beginning of each block, the Block State Unit Clock is updated to reflect the cumulative total of Chili Peppers consumed up to that point, ensuring a monotonically increasing record of state consumption.

Account Chili Pepper Clock Timestamp - each account in the "hot" state needs to keep track of the value of the Block Chili Pepper Clock the last time it was accessed (read or written to). This allows determination of which accounts are hot and which are cold.

Hot Cache Size - A new predefined constant, termed "Hot Cache Size" corresponds approximately to the size of the hot state supported
Copy link
Contributor

Choose a reason for hiding this comment

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

How is the size determined?

Choose a reason for hiding this comment

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

Most likely by deciding what the "standard" size of a solana network box should be and backing into how much should be used for account state. For example, given the small amount of new-state actually referenced per block, I would guess we could set this at 50gb and it would be 99% good...

Copy link
Contributor

Choose a reason for hiding this comment

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

ok. "hot cache size" = 50gb. then, how about "Block Chili Pepper Limit"?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about forking situations?

The chili pepper meter read from the sysvar will only represent the bytes loaded on current fork. But the
total "hot cache" could is global and shared by the all forks. And the bytes loaded from current fork will only be taking part of the global "hot cache".

Maybe we should allow some percentage of lee-way to take into account of forking situation?
If so, how much percentage to allow, i.e. 10%, 20%?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking a bit more. "hot cache size" (50gb) is the physical memory capacity, right?

chili pepper meter measures just the bytes of the account's data loaded from disk. But there are other extra cost in addition to the account's data bytes to load, such as account's index, account's chili-pepper store etc. The actual physical memory will be larger than the chili pepper bytes?

If we are targeting 50gb physical memory, should we take into accounts of those extra cost and reduce them from the physical memory budget? If so, how much should we reduce?

by the validator network. An account is designated as hot if it was last
accessed within this threshold of the current Block Chili Pepper Clock
(Account Chili Pepper Clock Timestamp > Block Chili Pepper Clock - Hot Cache Size), otherwise it is designated
as cold.


## Detailed Design

### Integration with ComputeBudget Program

To facilitate the utilization of Chili Peppers, every transaction on the Solana network will be required to use the ComputeBudget program to request the maximum number of Chili Peppers they require. Alongside existing functionalities, a new instruction will be introduced to specify the requested State Units for the transaction. This ensures that developers have the flexibility to request resources based on the anticipated needs of their transactions, within the constraints of the block's Chili Peppers capacity.
The new ComputeBudgetInstruction will be as follows:

```rust
discriminant: 5
ComputeBudgetInstruction::SetChiliPepperLimit(u32)
```

The 32-bit unsigned integer in the instruction indicates the number of Chili Peppers requested for the transaction.

### Block Chili Pepper Clock

The Block Chili Pepper Clock serves as a cumulative measure of the total Chili Peppers requested since the genesis of the blockchain. At the beginning of each block, the Block State Unit Clock is updated to reflect the cumulative total of Chili Peppers requested up to that point, ensuring a monotonically increasing record of state consumption.

Computing the block Chili Pepper clock:

```python
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this incentivize people to over request chili pepper? What's the downside for over request chili pepper?

block_chili_pepper_clock = prev_block_chili_pepper_clock + sum(txn.requested_chili_peppers for txn in block.txns)
```

Implemented as a 64-bit unsigned integer (uint64), this clock is updated at the beginning of every block to reflect the total Chili Peppers requested since the chain's genesis. This monotonically increasing value is stored in a dedicated system variable (sysvar), ensuring that it remains accessible and immutable throughout the blockchain's operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

begining or end?

Without actually looking up the account, how would a block know how many chili peper are actually used?

Choose a reason for hiding this comment

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

accessing the meta-data for an account needs to be accounted for via chili-peppers as well?

The new sysvar will have identifier: `SysvarB1ockChiliPepperC1ock111111111111111111`

```rust
struct SysvarBlockChiliPepperClock {
uint64_t state_unit_clock;
Copy link
Contributor

Choose a reason for hiding this comment

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

rename state_unit_clock.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: change it to rust code (not c code), since it is using rust syntax highlight.

}
```



### Account Chili Pepper Clock Timestamp

The Account Chili Pepper Clock Timestamp is an integral component within each "hot" account, representing the account's interaction with the blockchain's
state management resources. This clock is dynamically set to match the current Block Chili Pepper Clock at any instance an account is accessed (read or written to) within a given block.
These clocks are also implemented as 64-bit unsigned integers. Whenever a hot account is read from or written to within a block, its Account State Unit Clock is updated to match the current Block State Unit Clock.
All accounts will have a Chili Pepper Clock Timestamp, which will only exist for accounts which are hot, and is discarded for accounts which are cold. All implementations should keep track of the current hot accounts.

#### Hot and Cold Account Designation

An account is designated as cold when its Account Chili Pepper Clock Timestamp falls behind the current Block Chili Pepper Clock by more than the Hot Cache Size parameter.
An account which has never existed is considered cold. An account that is deleted is still considered hot until its state unit clock lapses into cold. Creating an account against a
deleted account which is still hot, will create the hot account again.

#### Storage and Management

To manage the Account State Unit Clocks efficiently, Solana employs a table, associating each hot account with its respective Chili Pepper Clock Timestamp. This table enables the dynamic tracking and updating of account states, facilitating the transition of accounts between hot and cold statuses based on their activity.
Copy link
Contributor

Choose a reason for hiding this comment

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

How to handle validator restart? Should we document the restart process too?

Copy link
Contributor

Choose a reason for hiding this comment

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

An account that is deleted is still considered hot until its state unit clock lapses into cold. Creating an account against a
deleted account which is still hot, will create the hot account again.

A note for ourselves.

This implies a change for our account's db and snapshot. We will need to keep track of all deleted accounts, while is still hot in the cache. This can increase the snapshot size, account's index size? What changes will be required for our accounts-db cleaning and shrinking process?

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: State Unit Clocks? Can we standardize the name to just use chili pepper clock?

It is confusing to use both state unit clocks and chili pepper clock` in the document.


### Error Cases for State Units Implementation

Here are common error scenarios related to State Units and their respective handling mechanisms:

#### Exceeding Block Chili Pepper Limit

- **Error Description**: This error occurs when a transaction's requested Chili Peppers exceed the remaining capacity of the Block Chili Pepper Clock for the current block.
- **Handling**: The block is marked as invalid and cannot be processed.

#### Invalid Chili Pepper Request

- **Error Description**: A transaction specifies an invalid number of Chili Peppers, either by requesting more than a predefined maximum limit per transaction or by formatting the request improperly.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two perspectives for the usage of the chili pepper.

  • leader's perspective
  • replayer's perspective

Should we separately document their behaviors regarding chili peppers change?

- **Handling**: The transaction is invalidated, and an "Invalid Chili Pepper Request" error message is issued. Developers must ensure that Chili Pepper requests conform to protocol specifications, including proper formatting and adherence to maximum limits.

#### Account State Unit Clock Synchronization Failure

#### Accessing Cold Account

- **Error Description**: A transaction attempts to interact with an account that has been designated as "cold" due to its Chili Pepper Clock Timestamp falling below the "Hot Cache Size" threshold relative to the current Block Chili Pepper Clock, without requesting sufficient Chili Peppers.
- **Handling**: The transaction is rejected with a "Cold Account Access Attempted" error.

Choose a reason for hiding this comment

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

Accessing a cold account and a non-existent account without sufficient chili peppers to account for the meta-data associated with an account should return the same error. This would allow us to keep the meta-data in a cold state as well and prevents the dos attack of referencing large numbers of non-existent accounts just to crush the slower back end database where the cold is stored.


## Alternatives Considered

What alternative designs were considered and what pros/cons does this feature
have relative to them?

## Impact

How will the implemented proposal impacts dapp developers, validators, and core contributors?
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to expand this section.
How will this impact dapp developers?

Choose a reason for hiding this comment

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

calculating chilli peppers could be mostly hidden by the client sdk so I would guess once people update to them, there should be almost zero effect

Copy link
Contributor

@HaoranYi HaoranYi Nov 20, 2024

Choose a reason for hiding this comment

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

every transaction on the Solana network will be required to use the ComputeBudget program to request the maximum number of Chili Peppers they require.

Wouldn't the dapp have to specify the Chili pepper in the transactions? In order to do so, will they need to know whether the account is hot or cold?

Copy link
Contributor

Choose a reason for hiding this comment

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

How many chili-pepper bytes should the user specify when requesting a transactions?
Should it be the account's data + accounts' index data + account's chili-pepper store, because bringing an account into global cache will incur other costs than jus the accounts' data?


## Security Considerations

What security implications/considerations come with implementing this feature?
Copy link
Contributor

Choose a reason for hiding this comment

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

Answers for these questions?

Choose a reason for hiding this comment

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

chili peppers are a consumable resource without cost? Does this mean I can

  1. put a single txn with all the chili peppers possible on a block
  2. a high enough priority fee to guarantee it gets put into the block

and lock out everybody elses ability to retrieve cold accounts?

I would guess we would limit the max chili peppers a single txn could request to be the max number of accounts it could reference times 10m... Given ALUT, that would be a lot of chili peppers.. all of them

I would suggest we make chili peppers be representative of actual SOL so that it would cost to do this attack where we only actually charge for actual cold access?! a real head scratcher...

Choose a reason for hiding this comment

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

A block builder sees a txn, notices it references unknown accounts, notices it does not have the chili peppers required to account for the meta data for those unknown accounts, does not include that txn

I am now thinking hitting cold meta data needs to be super expensive..

Are there any implementation-specific guidance or pitfalls?


## Backwards Compatibility

This proposal requires changes to the Solana Runtime Protocol and the ComputeBudget program. It is not backwards compatible and will require updates to existing programs and transactions to specify State Unit requirements. A transition period and comprehensive developer support will be essential to implement these changes smoothly across the ecosystem.
Loading