Commit Graph

42 Commits

Author SHA1 Message Date
mergify[bot] 65233160c4
v2.0: increase writeable accounts cost hashmap size (backport of #3009) (#3019)
increase writeable accounts cost hashmap size (#3009)

(cherry picked from commit 9f822c2f2c)

Co-authored-by: Brennan <brennan.watt@anza.xyz>
2024-10-01 10:49:23 -07:00
mergify[bot] 9e90b001e9
v2.0: fix: set allocation size to 0 for transactions known to fail (backport of #2966) (#2989)
fix: set allocation size to 0 for transactions known to fail (#2966)

(cherry picked from commit 443246dee0)

Co-authored-by: Justin Starry <justin@anza.xyz>
2024-09-27 14:20:12 +08:00
mergify[bot] 4f704d84b3
v2.0: [ed25519] Use `verify_strict` for signature verification in ed25519 precompile (backport of #1876) (#2179)
[ed25519] Use `verify_strict` for signature verification in ed25519 precompile (#1876)

* use `verify_strict` for signature verification in ed25519 precompile

* add test

* clippy

* increase ed25519 precompile cost constant by 5%

* put ed25519 strict verification cost change under feature gate

---------

Co-authored-by: Emanuele Cesena <ecesena@jumptrading.com>
(cherry picked from commit ddda6c30a3)

Co-authored-by: samkim-crypto <skim13@cs.stanford.edu>
2024-08-02 10:30:50 +09:00
mergify[bot] 0001afe8ed
v2.0: Refactor cost tracking (backport of #1954) (#1975)
* Refactor cost tracking (#1954)

* Refactor and additional metrics for cost tracking (#1888)

* Refactor and add metrics:
- Combine remove_* and update_* functions to reduce locking on cost-tracker and iteration.
- Add method to calculate executed transaction cost by directly using actual execution cost and loaded accounts size;
- Wireup histogram to report loaded accounts size;
- Report time of block limits checking;
- Move account counters from ExecuteDetailsTimings to ExecuteAccountsDetails;

* Move committed transactions adjustment into its own function

* remove histogram for loaded accounts size due to performance impact

(cherry picked from commit f8630a3522)

* rename cost_tracker.account_data_size to better describe its purpose is to tracker per-block new account allocation

---------

Co-authored-by: Tao Zhu <82401714+tao-stones@users.noreply.github.com>
Co-authored-by: Tao Zhu <tao@solana.com>
2024-07-03 14:59:02 -05:00
Tao Zhu f8ae688668
Revert "v2.0: Refactor and additional metrics for cost tracking (backport of #1888) (#1900) (#1937)
Revert "v2.0: Refactor and additional metrics for cost tracking (backport of #1888) (#1900)"

This reverts commit 0aef62eac7.
2024-07-01 10:33:44 -06:00
mergify[bot] 0aef62eac7
v2.0: Refactor and additional metrics for cost tracking (backport of #1888) (#1900)
* Refactor and additional metrics for cost tracking (#1888)

* Refactor and add metrics:
- Combine remove_* and update_* functions to reduce locking on cost-tracker and iteration.
- Add method to calculate executed transaction cost by directly using actual execution cost and loaded accounts size;
- Wireup histogram to report loaded accounts size;
- Report time of block limits checking;
- Move account counters from ExecuteDetailsTimings to ExecuteAccountsDetails;

* Move committed transactions adjustment into its own function

(cherry picked from commit c3fadacf69)

* rename cost_tracker.account_data_size to better describe its purpose is to tracker per-block new account allocation

---------

Co-authored-by: Tao Zhu <82401714+tao-stones@users.noreply.github.com>
Co-authored-by: Tao Zhu <tao@solana.com>
2024-06-28 16:09:36 -05:00
Tao Zhu 3668d104fe
charging CU for loaded accounts data size (#1356) 2024-06-20 11:54:20 -05:00
Tao Zhu d049a79f21
Wire scheduler up to adjust actual loaded accounts size cost for committed transactions (#1547)
* wire up scheduler to adjust actual loaded accounts size cost for committed transactions

* update tests
2024-06-07 12:29:46 -05:00
Joe C 0bf34e5ca1
Compute Budget: add `frozen-abi` feature (#1606)
compute budget: add `frozen-abi` feature
2024-06-05 09:20:50 -05:00
Joe C 62eb4cc068
Add Compute Budget Crate (#1121) 2024-06-01 01:38:19 -05:00
Kevin Heavey cadba689cb
Make solana-frozen-abi optional in all remaining crates (#1278)
* put most AbiExample derivations behind a cfg_attr

* feature gate all `extern crate solana_frozen_abi_macro;`

* use cfg_attr wherever we were deriving both AbiExample and AbiEnumVisitor

* fix cases where AbiEnumVisitor was still being derived unconditionally

* fix a case where AbiExample was derived unconditionally

* fix more cases where both AbiEnumVisitor and AbiExample were derived unconditionally

* two more cases where AbiExample and AbiEnumVisitor were unconditionally derived

* fix remaining unconditional derivations of AbiEnumVisitor

* fix cases where AbiExample is the first thing derived

* fix most remaining unconditional derivations of AbiExample

* move all `frozen_abi(digest =` behind cfg_attr

* replace incorrect cfg with cfg_attr

* fix one more unconditionally derived AbiExample

* feature gate AbiExample impls

* add frozen-abi feature to required Cargo.toml files

* make frozen-abi features activate recursively

* fmt

* add missing feature gating

* fix accidentally changed digest

* activate frozen-abi in relevant test scripts

* don't activate solana-program's frozen-abi in sdk dev-dependencies

* update to handle AbiExample derivation on new AppendVecFileBacking enum

* revert toml formatting

* remove unused frozen-abi entries from address-lookup-table Cargo.toml

* remove toml references to solana-address-lookup-table-program/frozen-abi

* update lock file

* remove no-longer-used generic param
2024-05-17 14:42:58 +02:00
Tao Zhu 8a55087d8e
Use ahash in cost tracker (#1252)
* add bench for cost-tracker

* use `ahash` in cost_tracker
2024-05-08 19:22:11 -05:00
Tao Zhu d3f0be1472
Forwarder to own forward_packet_batches_by_accounts batches (#1234)
* Forwarder to own forward_packet_batches_by_accounts batches

* move clear batches after each forwarding
2024-05-08 08:43:55 -05:00
Tao Zhu b1b6b9d631
Update cost-tracker to return more updated costs after successful try_add call (#1141) 2024-05-02 11:52:43 -05:00
Justin Starry 09241ae9c3
Use reserved account keys list to restrict tx write locks (#541)
* Plumb through reserved account keys set

* Plumb through tests
2024-04-13 09:37:58 +08:00
steviez 9076348ef4
Make CostTracker aware of inflight transactions (#437)
When a leader is packing a Bank, transactions costs are added to the
CostTracker and then later updated or removed, depending on if the
tx is committed. However, it is possible for a Bank to be frozen while
there are several tx's in flight.

CostUpdateService submits a metric with cost information almost
immediately after a Bank has been frozen. The result is that we have
observed cost details being submitted before some cost removals take
place, which causes a massive over-reporting of the block cost
compared to actual.

This PR adds a field to track the number of transactions that are
inflight, and adds a simple mechanism to try to allow that value to
settle to zero before submitting the datapoint. The number of inflight
tx's is submitted with the datapoint, so even if the value does not
settle to zero, we can still detect this case and know the metric is
tainted.

Co-authored-by: Andrew Fitzgerald <apfitzge@gmail.com>
2024-03-29 07:34:12 -05:00
Tao Zhu 9770cd9083
add precompile signature metrics to cost tracker (#133) 2024-03-08 00:48:35 +00:00
Tao Zhu 8f3f06cc7f
Combine builtin and BPF compute cost in cost model (#29)
* Combine builtin and BPF execution cost into programs_execution_cost since VM has started to consume CUs uniformly

* update tests

* apply suggestions from code review
2024-03-07 09:23:49 -06:00
Tao Zhu c1613517bf
assert simple vote tx const cost (#100)
* assert simple vote tx const cost
2024-03-06 11:08:49 -06:00
Andrew Fitzgerald 5e4332ee35
Feature Impl: cost model uses number of requested write locks (#34820) 2024-01-22 09:22:49 -08:00
Tao Zhu d0b793a6fd
remove old comment (#34775) 2024-01-15 16:39:10 -06:00
Tao Zhu 613f0ff226
removed obsolete field from cost_tracker (#34762) 2024-01-12 17:54:02 -06:00
Tao Zhu 86c88d7ff6
Remove feature set from compute budget processor (#34472)
remove feature_set from compute_budget_processor
2023-12-15 15:01:02 -06:00
Tao Zhu 7360f48eb5
remove unnecessary wrapper function (#34428)
* remove unnecessary wrapper function

* add test to FeeStructure
2023-12-15 14:56:19 -06:00
Tao Zhu f214a8220f
cleanup feature code after mainnet-beta activation (#34208)
* cleanup feature code after mainnet-beta activation
* rebase then cleanup references to activated feature
2023-12-15 13:14:51 -06:00
Jon Cinque cfb16ab76a
sdk: Upgrade to borsh 1.2.1 (#34355)
* sdk: Update to borsh 1, revert borsh 0.9 / 0.10

* Restore borsh 0.10 and 0.9 support

* Update sbf lockfile

* Add borsh 0.10 implementations for stake types

* Fix weirdness on whitespace

* Update to borsh 1.2.1

* Update changelog

* compute-budget: Move `pack` under dev-context-only-utils

* Revert test to use HashMap

* transaction-status: Add comment about borsh version
2023-12-08 13:18:10 +01:00
Andrew Fitzgerald 6d703edd2e
check vote costs against block limits in would_fit (#34207) 2023-11-22 13:19:13 -08:00
Tao Zhu 510b6b949f
Split compute budget instructions process from struct (#33852)
* Split compute budget instruction processing from ComputeBudget struct itself, so CB instructions can be processed elsewhere without involving ComputeBudget

* updated tests

* avoid built ComputeBudget from dated ComputeBudgetLimits in this refactoring PR

* Clean-up program-runtime/src/compute_budget_processor.rs

* Add test for a corner case that deprecated instruction is used to request units greater than max limit;
* Update code to handle the corner case.
2023-10-26 22:12:56 -05:00
Kevin Heavey af7fd32f4c
chore: fix some typos (#33833)
* fix spelling of "retrieved"
* fix spelling of "should"
* fix spelling of "comparisons"
2023-10-25 16:21:53 +02:00
Tao Zhu af9c754690
Crates have identical build.rs to frozen-abi can just be symlink (#33787)
crates have identical build.rs to frozen-abi can just be symlink
2023-10-21 13:33:10 -05:00
steviez c98c24bd6d
Revert "Split compute budget instructions process from struct itself … (#33784)
Revert "Split compute budget instructions process from struct itself (#33513)"

This reverts commit c73bebe984. This
was found to be a consensus breaking change.
2023-10-20 15:53:45 +02:00
Tao Zhu c73bebe984
Split compute budget instructions process from struct itself (#33513)
* Split compute budget instruction processing from ComputeBudget struct itself, allow compute_budget_instructions be processed elsewhere without having to instantiate ComputeBudget

* updated tests
2023-10-19 11:10:42 -05:00
Tao Zhu a41c15e47e
Separate vote cost (#33230)
* Separate simple-vote transaction cost from non-vote transaction cost

* remove is_simple_vote flag from transaction UsageCostDetails

* update test and comment

* set static usage cost for SimpleVote transaction
2023-09-25 15:02:08 -05:00
Tao Zhu 8b8a21a52f
cleanup feature: enable request heap frame instruction #30076 (#33243)
* cleanup feature: enable request heap frame instruction #30076

* update sbf tests

* removed out dated comments and test
2023-09-18 16:06:24 -05:00
Tao Zhu dfaec7897a
loaded accounts data size cost does not apply to vote transaction (#33235)
* loaded accounts data size cost does not apply to vote transaction

* add a test for vote cost
2023-09-14 17:22:51 -05:00
Alexander Meißner bbb57be0a5
Refactor - Move interfaces of address-lookup-table into the program SDK (#33165)
* Adds a module `address_lookup_table` to the SDK.

* Adds a module `address_lookup_table::instruction` to the SDK.

* Adds a module `address_lookup_table::error` to the SDK.

* Adds a module `address_lookup_table::state` to the SDK.

* Moves AddressLookupTable into SDK as well.

* Moves AddressLookupTableAccount into address_lookup_table.

* Adds deprecation messages.

* Disentangles dependencies across cargo files.
2023-09-11 21:10:40 +02:00
Alexander Meißner 9e703f85de
Upgrades Rust to 1.72.0 & nightly-2023-08-25 (#32961)
* allow pedantic invalid cast lint

* allow lint with false-positive triggered by `test-case` crate

* nightly `fmt` correction

* adapt to rust layout changes

* remove dubious test

* Use transmute instead of pointer cast and de/ref when check_aligned is false.

* Renames clippy::integer_arithmetic to clippy::arithmetic_side_effects.

* bump rust nightly to 2023-08-25

* Upgrades Rust to 1.72.0

---------

Co-authored-by: Trent Nelson <trent@solana.com>
2023-09-01 07:26:13 +00:00
Jon Cinque 8c14886891
sdk: Limited Borsh 0.9 support (Pubkey and helpers) (#32511)
* sdk: Implement Borsh 0.9 traits on Pubkey

* Alphabetize cargo.toml

* Add backwards-compatible borsh file

* Add borsh0_10.rs for more clarity

* Deprecate `borsh` utils, use borsh0_10 everywhere

* Mark borsh 0.9 helpers as deprecated

* Add macros for deriving helper impls

* Add borsh 0.9 tests

* Refactor tests into macro
2023-08-02 23:15:24 +02:00
Tao Zhu 62b9fcfa76
cleanup feature: Use default units per instruction in fee calculation (#32570)
* cleanup feature: Use default units per instruction in fee calculation
2023-07-21 18:37:58 -05:00
Tao Zhu c69bc00f69
cost model could double count builtin instruction cost (#32422)
1. add tests to demo builtin cost could be double counted;
2. quick fix for now
2023-07-17 15:50:13 -05:00
Pankaj Garg 7177dd9809
Remove calculate_fee()'s dependency on ComputeBudget (#32487) 2023-07-14 12:25:04 -07:00
Pankaj Garg 4674b0099f
Move CostModel and CostTracker to its own crate (#32354)
* Move CostModel and CostTracker to its own crate

* compile new crate and update imports

* update sbf Cargo.lock

* fix AbiExample

* fix cargo sort

* Fix AbiExample
2023-07-06 10:08:18 -07:00