Commit Graph

282 Commits

Author SHA1 Message Date
HaoranYi 304333405c Revert deprecate executable feature (#309)
* revert deprecate executable feature

* add native loader account transfer test

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2024-03-20 16:28:38 -05:00
Dmitri Makarov 264f4dfdd0 [SVM] Move RuntimeConfig to program-runtime (#96)
RuntimeConfig doesn't use anything SVM specific and logically belongs
in program runtime rather than SVM.  This change moves the definition
of RuntimeConfig struct from the SVM crate to program-runtime and
adjusts `use` statements accordingly.
2024-03-09 13:27:11 -06:00
Pankaj Garg 46b9586630
SVM: Move SVM code to its own crate folder (#35119) 2024-02-06 16:06:32 -08:00
Pankaj Garg 3cf5dd2afb
SVM: Move RuntimeConfig to svm folder (#35085) 2024-02-05 13:49:36 -08:00
Tao Zhu 51eaa2b9cc
cleanup feature code after activation (#34695)
cleanup feature checking code
2024-01-12 14:28:50 -06:00
Tao Zhu 88f8d11da2
program-test consumes some units as native (#34714)
program-test consumes some units as native;
harden a unit test wrt if builtin consumes units;
2024-01-10 09:05:30 -06:00
Justin Starry 5f74fc4f16
Update genesis processing to have a fallback collector id for tests (#34135)
* Update genesis processing to have a fallback collector id for tests

* DCOU-ify the collector id for tests parameter (#1902)

* wrap test_collector_id in DCOU

* rename param to collector_id_for_tests

* fix program test

* fix dcou

---------

Co-authored-by: Brooks <brooks@prumo.org>
2024-01-10 08:34:41 +08:00
chalda 8330dee95d
[program-test] adding method warp_to_epoch (#34620)
* [program-test] adding method warp_to_epoch

* formatting fix
2024-01-03 10:58:22 -07:00
Justin Starry 88af74d1d0
refactor: optional `stake_history` arg is never `None` (#34556)
refactor: optional stake_history arg is never none
2023-12-22 10:44:28 +08:00
Jon Cinque 8a8466cd86
spl: Bump token-2022 to v1 (#34412)
* Update toml and lockfiles

* account-decoder: Add group and group member extensions

* transaction-status: Add token group + pointer extensions

* program-test: Update token-2022 binary
2023-12-21 20:19:10 -05:00
HaoranYi 531d69fd10
pass feature_set to BorrowedAccount (#34542)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-12-21 20:03:17 +01:00
Brooks 25f0f377c6
program-test uses Bank::new_with_paths() (#34549) 2023-12-21 07:00:28 -05:00
Ryo Onodera 0873705c1b
Define register_unique_recent_blockhash_for_test (#33880) 2023-10-27 12:30:45 +09:00
Pankaj Garg 9d42cd7efe
Initialize fork graph in program cache during bank_forks creation (#33810)
* Initialize fork graph in program cache during bank_forks creation

* rename BankForks::new to BankForks::new_rw_arc

* fix compilation

* no need to set fork_graph on insert()

* fix partition tests
2023-10-23 09:32:41 -07:00
Ryo Onodera 5a963529a8
Add BankWithScheduler for upcoming scheduler code (#33704)
* Add BankWithScheduler for upcoming scheduler code

* Remove too confusing insert_without_scheduler()

* Add doc comment as a bonus

* Simplify BankForks::banks()

* Add derive(Debug) on BankWithScheduler
2023-10-21 15:56:43 +09:00
Alexander Meißner a5c7c999e2
Bump solana_rbpf to v0.8.0 (#33679)
* Bumps solana_rbpf to v0.8.0

* Adjustments:
Replaces declare_syscall!() with declare_builtin_function!().
Removes Config::encrypt_runtime_environment.
Simplifies error propagation.
2023-10-20 21:39:50 +02:00
Justin Starry 3bfa0d291a
feature flag cleanup: cap_bpf_program_instruction_accounts (#33746) 2023-10-19 08:15:35 +08:00
Jon Cinque d33758171b
token-2022: Update to use program build with zk-ops enabled (#33747)
token-2022: Update to use version with zk-ops enabled
2023-10-18 21:39:01 +02:00
Jon Cinque de38b05ad1
spl: Bump token-2022 and friends (#33453)
* token: Update to 4.0.0

* token-2022: Bump and support new account and instruction types

* Update token-2022 in fetch_spl / program-test

* Fixup downstream uses

* Mint and destination were flipped in 0.9.0

* Don't use `convert_pubkey`

* Bump spl dependencies to versions which avoid recompilations
2023-09-29 19:12:06 +02:00
HaoranYi d25d53e979
Fix bug of same-epoch stake deactivation after stake redelegation (#32606)
* fix stake deactivation in the same epoch after redelegation bug

add tests

refactor common code into fn

avoid early return

add feature gate for the new stake redelegate behavior

move stake tests out of cli

add stake-program-test crate

reimplemnt stake test with program-test

remove stake-program-test crate

reviews

add setup.rs

remove clippy

reveiws

* reviews

* review comments

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-09-25 16:35:40 -05: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 dcad8f01bd
banks-server: Support versioned transactions (#33005) 2023-08-28 23:08:41 +02:00
HaoranYi 910b0f5d12
fix sbf sysvar test (#32803)
* fix sbf sysvar test

* typo

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-21 09:49:48 -06:00
Brooks 9a6cf3f528
Renames SnapshotRequestType to SnapshotRequestKind (#32907) 2023-08-21 07:12:20 -04:00
steviez a4c8cc3ce0
Remove improper uses of &Arc<Bank> (#32802)
In most cases, either a &Bank or an Arc<Bank> is more proper.
- &Bank is used if the function only needs a momentary reference
- Arc<Bank> is used if the function needs its' own copy

This PR leaves several instances of &Arc<Bank> around; these instances
are situations where a clone may only happen conditionally.
2023-08-18 16:46:34 -05:00
Jon Cinque 760559157c
program-test: Fix realloc in native mode (#32818) 2023-08-14 13:56:03 +02:00
Jon Cinque 194c959aa8
program-test: Prohibit setting the compute unit limit past `i64::MAX` (#32807)
program-test: Prohibit setting the compute unit limit past the max
2023-08-11 18:30:22 +02:00
Jon Cinque c73a56faf8
stake: Rename `StakeStateWithFlags` -> `StakeStateV2` (#32795) 2023-08-11 01:07:21 +02:00
Pankaj Garg f4287d70bb
Move accounts-db code to its own crate (#32766) 2023-08-09 13:03:36 -07:00
Jon Cinque 8e4a9a94ed
sdk: Add new version of `StakeState` to avoid breaking downstream users (#32736)
* sdk: Rename `StakeState` -> `StakeStateWithFlags`

* Add back `StakeFlags` with a deprecation warning
2023-08-09 00:05:40 +02:00
Ashwin Sekar fa3506631a
stake: deprecate on chain warmup/cooldown rate and config (#32723)
* stake: deprecate on chain warmup/cooldown rate and config

* Pr feedback: Deprecate since 1.16.7

Co-authored-by: Jon Cinque <me@jonc.dev>

---------

Co-authored-by: Jon Cinque <me@jonc.dev>
2023-08-07 13:23:24 -07:00
HaoranYi 906121645c
Test epoch rewards sysvar in program test (#32293)
* Add epoch rewards sysvar test to program test

* Add a test to check epoch rewards sysvar inside/outisde reward interval

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-28 10:50:11 -05:00
steviez 20a7cdd43d
Restrict access to Bank's HardForks (#32180)
* Restrict access to Bank's HardForks

Callers could previously obtain a a lock to read/write HardForks from
any Bank. This would allow any caller to modify, and creates the
opportunity for inconsistent handling of what is considered a valid hard
fork (ie too old).

This PR adds a function to Bank so consistent sanity checks can be
applied; the caller will already have a Bank as that is where they would
have obtained the HardForks from in the first place. Additionally,
change the getter to return a copy of HardForks (simple Vec).

* Allow hard fork at bank slot if bank is not yet frozen
2023-06-20 23:44:43 -05:00
HaoranYi 2e9aeff8dd
Enable partitioned epoch reward by feature id (#32174)
enable partitioned epoch reward feature by feature id
update stake rewards tests with partitioned epoch rewards feature enable

Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-06-20 12:12:50 -05:00
galactus 2ceabd9368
Simd 47 syscall sysvar last restart slot (#31957)
* add sysvar and logic for last restart slot

* cleanup

* add test for getting last restart slot from account

* format code

* add some basic rustdoc

* copy+paste error

* feature flag for last_restart_slot

* add to sysvars.md

* updated wording in sysvars.md

* rename sol_get_last_restart_slot_sysvar > sol_get_last_restart_slot

* create sbf C header for sol_get_last_restart_slot

* cleanup imports

* reverted hardened_unpack workaround

* cleanup imports

* cleanup logs + blank lines

* Implementing ui changes for last restart slot, nit

* Some more nit change and implementing the UI for sysvar

* fixing the CI

* Minor clippy fix

* format changes

* changes suggested by mvines and lichtso

* increase timeout in local_cluster test

* fix code format

* use keypair for feature flag from mvines

* delete test.json file

* Revert "increase timeout in local_cluster test"

This reverts commit a67465ae22.

* last restart slot should be always less than or equal to current slot

* fixing bug

* changes after  steviez comments

* format issue fixed

* fixing the comment on premature application of future hardfork

* nit change in test

Co-authored-by: steviez <steven@solana.com>

* reverting sysvar_cache.rs because change was not necessary

---------

Co-authored-by: steve-gg <grooviegermanikus@gmail.com>
Co-authored-by: steviez <steven@solana.com>
2023-06-16 20:14:02 +00:00
Alexander Meißner 520c647918
Refactor - Merges `BuiltinPrograms` into `LoadedPrograms` (#31654)
* Merges BuiltinPrograms into LoadedPrograms.

* Prevents built-ins from being pruned.
2023-05-18 22:18:28 +02:00
Illia Bobyr 43c0f05ca0
Bumps base64 from 0.13.1 to 0.21.0. (#31522)
Changes:

  marshallpierce/rust-base64@v0.13.1...v0.21.0

`base64::{encode,decode}` are now deprecated in favor of an API that
explicitly selects an `Engine`.  Migrated all calls to the new API.
2023-05-11 11:34:58 -07:00
Brooks 6e342ded42
clippy: Removes redundant async blocks (#31526) 2023-05-09 09:35:38 -04:00
Alexander Meißner ae75c7cb3f
Refactoring - Remove redundant definition of `BuiltinProgram` (#31429)
* Replaces BuiltinProgram in the program-runtime with the one from solana_rbpf.

* Adjusts the runtimes built-ins to use Arc<LoadedProgram>.

* Adjusts the tests and benchmarks.
2023-05-02 23:01:28 +02:00
Alessandro Decina 117a194b73
Account data direct mapping (#28053)
* AccountSharedData: make data_mut() private

This ensures that the inner Vec is never handed out. This is in
preparation of enforcing that the capacity of the inner vec never
shrinks, which is required for direct mapping.

* Adds the feature bpf_account_data_direct_mapping.

* Remaps EbpfError::AccessViolation into InstructionError::ReadonlyDataModified.

* WIP: Memory regions for each instruction account in create_vm().

* Fix serialization benches, run both copy and !copy variants

* rbpf-cli: fix build

* BorrowedAccount: ensure that account capacity is never reduced

Accounts can be directly mapped in address space. Their capacity can't
be reduced mid transaction as that would create holes in vm address
space that point to invalid host memory.

* bpf_load: run serialization tests for both copy and !copy account data

* bpf_loader: add Serializer::write_account

* fix lints

* BorrowedAccount: make_data_mut is host only

* Fix unused import warning

* Fix lints

* cpi: add explicit direct_mapping arg to update_(callee|caller)_account

* cpi: rename account_data_or_only_realloc_padding to serialized_data

* cpi: add CallerAccount::original_data_len comment

* cpi: add update_callee_account direct_mapping test

* cpi: add test_update_caller_account_data_direct_mapping and fix bug

We used to have a bug in zeroing data when shrinking account, where we zeroed
the spare account capacity but not the realloc padding.

* cpi: add tests for mutated readonly accounts

* cpi: update_caller_account doesn't need to change .serialized_data when direct_mapping is on

* cpi: update_caller_account: ensure that account capacity is always enough

Introduce a better way to ensure that account capacity never goes below what
might be mapped in memory regions.

* cpi: zero account capacity using the newly introduced BorrowedAccount::spare_data_capacity_mut()

Before we were using BorrowedAccount::get_data_mut() to get the base pointer to
the account data, then we were slicing the spare capacity from it. Calling
get_data_mut() doesn't work if an account has been closed tho, since the
current program doesn't own the account anymore and therefore get_data_mut()
errors out.

* bpf_loader: fix same lint for the umpteenth time

* bpf_loader: map AccessViolation to ReadonlyDataModified only for account region violations

* programs/sbf: realloc: add test for large write after realloc

Add a test that after a realloc does a large write that spans the
original account length and the realloc area. This ensures that memory
mapping works correctly across the boundary.

* programs/sbf: run test_program_sbf_realloc with both direct_mapping on and off

By default test banks test with all features on. This ensures we keep
testing the existing code until the new feature is enabled.

* bpf_loader: tweak memcmp syscall

Split the actual memcmp code in a separate function. Remove check
indexing the slices since the slices are guaranteed to have the correct
length by construction.

* bpf_loader: tweak the memset syscall

Use slice::fill, which is effectively memset.

* bpf_loader: syscalls: update mem syscalls to work with non contiguous memory

With direct mapping enabled, accounts can now span multiple memory
regions.

* fix lint, rebase mem_ops

* Implement CoW for writable accounts

* Fix CI

* Move CoW to the MemoryMapping level

* Update after rbpf API change

* Fix merge screwup

* Add create_vm macro. Fix benches.

* cpi: simplify update_caller_account

Simplify the logic to update a caller's memory region when a callee
causes an account data pointer to change (eg during CoW)

* benches/bpf_loader: move serialization out of  create_vm bench

* benches/bpf_loader: don't copy accounts when direct mapping is on

* Fix review nits

* bpf_loader: mem_ops: handle u64 overflow in MemoryChunkIterator::new

When starting at u64::MAX, the chunk iterator would always return the
empty sequence (None on the first next()) call, instead of returning a
memory access violation.

Use checked instead of saturating arithmetic to detect the condition and
error out.

This commit also adds more tests around boundary conditions.

* Fix loader-v3 tests: data_mut => data_as_mut_slice

* Fix CI

* bpf_loader: fix tuner bench: account must be writable

With direct mapping on, invalid writes are caught early meaning the
tuner would fail on the first store and not consume the whole budget
like the benchmark expects.

---------

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
2023-04-29 06:54:39 +10:00
Tyera 9af7009bb4
Add new CreateVoteAccount instruction-set builders (#31330)
* Add failing test

* Add config struct for vote-account creation

* Add create-vote-account ix builders that use CreateVoteAccountConfig

* Test now passes; add case to demonstrate failure after activation

* Deprecate existing ix builders

* Use new builders in solana-cli

* Query feature status to use correct VoteState size in solana-cli

* Fix tests and clippy warnings

* Improve ugly conditional block
2023-04-27 11:14:39 -06:00
Alexander Meißner c05d1d5c51
Refactor - Moves bpf_loader registration into the runtime (#31345)
* Moves the registration of bpf_loader built-ins from the ledger into the runtime.

* Removes bpf_loader built-ins registration in tests and benchmarks.

* Removes declare_builtin!() of bpf_loader built-ins.

* Removes built-ins from the SDK.

* Adjusts tests.
2023-04-26 14:44:19 +02:00
Alexander Meißner 7002c568fb
Cleanup - Removes the CLI option "no-bpf-jit" (#31329)
* Enables JIT everywhere by default.

* Removes the CLI argument "no-bpf-jit" and its plumbering through out the validator code base.

* Removes with_jit bpf_loader variants.

* Removes the to_builtin!() macro.
2023-04-25 19:04:11 +02:00
Alexander Meißner 4b0e16d06f
Refactor - `BuiltinPrograms` (#31324)
* Moves BuiltinProgram of the program runtime into its own file.

* Unifies the runtimes Builtin and program runtimes BuiltinProgram definitions.

* Moves BuiltinPrograms from bank.rs into the program runtime.
2023-04-24 19:01:40 +02:00
Alexander Meißner e5490b8d09
Refactor - Use builtin function interface from rbpf (#31221)
* Removes test_program_entry_debug().

* Uses declare_process_instruction!() in all tests and benchmarks.

* Replaces with ProcessInstructionWithContext with solana_rbpf::BuiltInFunction.
2023-04-21 18:08:32 +02:00
Alexander Meißner 24a87f33a8
Refactor - Cleanup error handling in program runtime (#30693)
* Moves stable_log::program_invoke(), stable_log::program_success() and stable_log::program_failure() calls from bpf_loader into InvokeContext::process_executable_chain().

* Turns result of ProcessInstructionWithContext from InstructionError into Box<dyn std::error::Error>.

* Bump to solana_rbpf v0.3.0

* Removes Result from return type of EbpfVm::new().

* Turns EbpfError into Box<dyn std::error::Error>.

* Removes BpfError.

* Removes SyscallError::InstructionError.

* Adds a type alias for Box<dyn std::error::Error> in syscalls.
2023-04-05 15:50:34 +02:00
Tyera 590593cd31
Remove flaky ProgramTest test (#30967)
Remove flaky test
2023-03-29 12:07:44 -06:00
Yihau Chen 2c842e9932
chore: workspace inheritance (#30939)
* client/Cargo.toml

* udp-client/Cargo.toml

* tpu-client/Cargo.toml

* thin-client/Cargo.toml

* storage-proto/Cargo.toml

* quic-client/Cargo.toml

* dos/Cargo.toml

* entry/Cargo.toml

* perf/Cargo.toml

* program-runtime/Cargo.toml

* program-test/Cargo.toml

* programs/address-lookup-table/Cargo.toml

* programs/loader-v3/Cargo.toml

* connection-cache/Cargo.toml

* programs/sbf/rust/big_mod_exp/Cargo.toml

* programs/zk-token-proof-tests/Cargo.toml
2023-03-29 03:28:56 +00:00
Kevin Heavey 6f73aafa09
Make BanksClient timeout after 10 seconds instead of 60 (#30904)
* don't increase the deadline by 50 seconds

* add test demonstrating a timeout panic

* add back missing Duration import for tests

* cargo fmt

* clarify test comments

* clarify comment

* make timeout test finish in 1 second

* sort dependencies
2023-03-28 17:55:44 -06:00
Tao Zhu 3e500d9e92
Feature gate builtin consumes static units during processing instruction (#30702)
* add feature gate
* builtins consume statically defined units at beginning of process_instruction()
* Add new instructionError; return error if builtin did not consume units to enforce builtin to consume units;
* updated related tests
* updated ProgramTest with deactivated native_programs_consume_cu feature to continue support existing mock/test programs that do not consume units
2023-03-24 11:31:01 -05:00