Commit Graph

2166 Commits

Author SHA1 Message Date
Trent Nelson 5572d23efa
ci: deflake `Measurement` tests (#31812)
* measure: test timer and conversion separately

* measure: test `timing::duration_as_*()` directly...
2023-05-25 12:46:46 -06:00
Andrew Fitzgerald 75954dc061
Banking worker (#30970) 2023-05-25 10:16:04 -07:00
Alexander Meißner 691b12c693
Cleanup - merge_nonce_error_into_system_error (#31773)
* merge_nonce_error_into_system_error

* more cleanup

---------

Co-authored-by: Trent Nelson <trent@solana.com>
2023-05-24 18:05:07 +02:00
vadorovsky bea062b1e6
Add alt_bn128 syscall tests (and fix related issues) (#31436)
* Fix C headers (the name of the syscall was incorrect).
* Add C SBF tests using the alt_bn128 syscall.
* Fix the Rust SBF program:
  * Do not use serde and array-bytes, provide test cases as byte arrays
    directly.
  * Use the `custom_heap_default` macro.
  * Replace `bpf` with `sbf` in the crate name.
* Execute both previously existing Rust tests and new C tests in
  `programs/sbf/tests`, so they are actually tested on CI.
2023-05-22 14:05:10 -07:00
samkim-crypto 6de581ac08
[clap-v3-utils, sdk, zk-token-sdk] Split `EncodableKey` into `EncodableKey` + `SeedDerivable` (#31668)
* add `SeedDerivable` trait

* implement `SeedDerivable` for `Keypair`

* implement `SeedDerivable` for `ElGamalKeypair`

* update clap-v3-utils to use `EncodableKey + SeedDerivable`

* implement `SeedDerivable` trait for `AeKey`

* implement `EncodableKey` and `SeedDerivable` for `ElGamalSecretKey`

* implement `SeedDerivable` trait for `ElGamalPubkey`
2023-05-17 17:42:35 +09:00
samkim-crypto e14384d8ff
[clap-v3-utils] Add `EncodableKeypair` trait and make `confirm_keypair_pubkey` generic (#31642)
* add `EncodableKeypair` trait

* implement `EncodableKeypair` for `Keypair`

* implement `EncodableKeypair` for `ElGamalKeypair

* make confirm pubkey functions generic

* fix a typo

* Update sdk/src/signer/keypair.rs

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>

* Update clap-v3-utils/src/keypair.rs

Co-authored-by: Tyera <teulberg@gmail.com>

* fix a typo

---------

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
Co-authored-by: Tyera <teulberg@gmail.com>
2023-05-17 05:37:59 +09: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
Tao Zhu 49f44f5ded
Refactor pass feature status to deserialized packet via packet meta (#31549)
Add a flag to packet, set its value by packet_deserializer when received by banking_stage with working_bank
2023-05-11 09:31:05 -05:00
Alexander Meißner bbd8be6cbe
Refactor - Renames loader-v3 to loader-v4. (#31570)
Renames loader-v3 to loader-v4.
2023-05-11 08:29:06 +02:00
Brooks b3d5c0d94d
Replace the feature ID for stake_raise_minimum_delegation_to_1_sol (#31463) 2023-05-03 13:51:15 -04: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
Ryo Onodera a30830d7a9
ci: treewide: deny used_underscore_binding (#31319)
* Enforce used_underscore_binding

* Fix all

* Work around for cfg()-ed code...

* ci....

* Make clipply fixes more pleasant

* Clone exit signal while intentionally shadowing

* Use more verbose code to avoid any #[allow(...)]s
2023-04-27 10:10:16 +09: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
Illia Bobyr cc6c454076
Bump syn from 1.0.109 to 2.0.5 (#31263)
Update users based on the new syn ABI.

Short API update summary can be found here:

  https://github.com/dtolnay/syn/releases/tag/2.0.0
2023-04-24 22:18:51 -07:00
Tao Zhu b4331ae955
use checked arithmetic (#31259)
* use checked arithmetic
* add feature gate; updated tests
* allow collapsible-else-if

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
Co-authored-by: mvines <mvines@gmail.com>
2023-04-20 22:56:08 -05:00
Ashwin Sekar 37ab00d361
Link issue for vote state latency feature gate (#31266) 2023-04-19 15:44:56 -06:00
bji a45710838d
Add new vote state version that replaces Lockout with LandedVote to a… (#30831)
Add new vote state version that replaces Lockout with LandedVote to allow vote latency to be tracked in a future change.

Includes a feature to be enabled which will when enabled cause the vote state to be written in the new form.
2023-04-18 20:27:38 -07:00
hana 07e038bceb
clean up delegation errors (#31202)
* Make delegation errors more descriptive

* Fix tests for StakeError::InsufficientDelegation
2023-04-14 15:30:59 -07:00
Dmitri Makarov d12501056d
Eliminate dependency on Open SSL in cargo-build-sbf (#31205) 2023-04-14 13:42:35 -04:00
behzad nouri 4d0abebe0e
removes Packet Meta.sender_stake and find_packet_sender_stake_stage (#31077)
Packet Meta.sender_stake is unused since
https://github.com/solana-labs/solana/pull/26512
removed sender_stake from banking-stage buffer prioritization.
2023-04-06 21:33:43 +00:00
samkim-crypto d67fa6c470
[clap-v3-utils] Define `EncodableKey` and make `keypair_from_path` and `keypair_from_seed` generic functions (#30947)
* generalize `Keypair` to using `EncodableKey` trait in clap-v3-utils

* add associated `Pubkey` type to `EncodableKey`

* remove associated type `Pubkey` from `EncodableKey`

* rename `EncodableKey` associated function names

* remove default overrides for `{read,write}_file`

* resolve dependencies for test

* remove `pubkey_string` from `EncodableKey` trait
2023-04-06 07:42:11 +09:00
ananas-block c4648f5a26
bump arkworks deps to version 0.4.0 (#30536)
* bump ark-works 0.4.0

* removed obsolete commented code

* bumped deps again after rebase

* paring: merged two vectors into one

* added zero serialization test

* reverted formatting change

* updated Cargo.lock after rebase

* fixed Cargo.lock
2023-04-04 20:16:47 -06:00
Alexander Meißner 911489d373
Feature - Stop truncating strings in syscalls (#31030)
* Adds the feature gate stop_truncating_strings_in_syscalls.

* Removes the truncation of everything after the first NULL byte in translate_string_and_do().
2023-04-04 19:33:53 +02:00
Proph3t ab8d3066a5
Improve poh.rs readability (#30298)
* chore: factor out variable hashes per tick to a constant

* chore: add units to `elapsed` in `compute_hashes_per_tick`
2023-04-03 12:12:41 -07:00
Dmitri Makarov 8c860e9894
Bump platform-tools version to v1.37 (#31017) 2023-04-01 12:08:03 -04:00
behzad nouri ff9a42a354
uses Duration type instead of untyped ..._ms: u64 (#30971) 2023-03-31 15:42:49 +00:00
blackghost1987 9f9d6f8a89
Relax `Sized` bound for `Signers` in `Transaction` and `Client` (#30568)
* relax Sized bound for Signers in Transaction and Client

* also relax Sized bounds in client, runtime, thin-client and tpu-client

* add tests for using non-sized transaction signers

* fix macro for thin_client vs ?Sized

* move tests to transactions, add Sized relaxation to mut macro

* fix clippy warning

* get rid of unnecessary imports
2023-03-30 13:12:48 +00:00
Brennan 000b912fc6
Update discord invite links (#30909)
* Update discord invite links

* Point to Stack Exchange for support
2023-03-29 09:14:22 -07:00
Pankaj Garg bf488eb384
Update documentation of instruction error and add a unit test (#30915)
* Update documentation of instruction error and add a unit test

* update test name
2023-03-28 11:54:49 -07:00
Pankaj Garg 035c974a8c
Remove redundant check during loading upgradeable program for writing (#30561)
* Remove redundant check during loading upgradeable program

* Apply clippy suggestion
2023-03-28 11:50:49 -07:00
samkim-crypto 742c56ae28
[cargo-test-sbf] Rename sbf-tools to platform-tools and use sbfv1 (#30927)
rename sbf-tools to platform-tools and use sbfv1
2023-03-28 20:30:14 +09: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
Alexander Meißner c10f337f85
Feature - Loader built-in program v3 (#30464)
* Adds loader-v3 in SDK.

* Adds loader-v3 built-in program.

* Adds tests.
2023-03-23 18:13:47 +01:00
Dmitri Makarov db9623db06
Fix cargo-build-bpf removing a wrong command line option (#30848) 2023-03-22 09:37:33 -07:00
Dmitri Makarov 81ef2a0d75
Update references to platform-tools (#30764) 2023-03-22 07:41:40 -07:00
Tao Zhu 21c287a64f
include loaded accounts data size limit in transaction fee calculation (#30659)
* include loaded accounts data size limit in transaction base fee calculation
* citing compute_budget for heap cost;
* update sbf tests

Co-authored-by: Trent Nelson <trent.a.b.nelson@gmail.com>
2023-03-21 18:41:41 -05:00
steviez 5344a789d7
Revert "Add new vote state version that replaces Lockout with LandedV… (#30817)
Revert "Add new vote state version that replaces Lockout with LandedVote to a… (#29524)"

This reverts commit d77f0a22c7.
2023-03-21 22:54:13 +08:00
Alexander Meißner 66da71fa7a
Fix - Revert and feature gate incorrect error message in BPF loader (#30748)
* Revert to old behavior.

* Adds feature gate.
2023-03-21 11:08:41 +01:00
bji d77f0a22c7
Add new vote state version that replaces Lockout with LandedVote to a… (#29524)
* Add new vote state version that replaces Lockout with LandedVote to allow vote latency to be tracked in a future change. Includes a feature to be enabled which will when enabled cause the vote state to be written in the new form.

* Update feature set key to one owned by ashwin

---------

Co-authored-by: Ashwin Sekar <ashwin@solana.com>
2023-03-20 08:31:46 -06:00
Tao Zhu 17ba051e1f
Revert "add default_cost as mandatory field for Builtin (#30639)" (#30749)
This reverts commit 7b95c8e698.
2023-03-16 11:21:06 -05:00
ryleung-solana 0ed9f62602
Quic server batching (#30330) 2023-03-16 21:50:57 +08:00
Ryo Onodera aaaee556d8
ci: silence ci test output while recording in full (#30654)
* ci: silence ci test output while recording in full

* shellcheck

* Adjust --color handling place

* Dump to stderr...

* Reduce too spammy solana_metrics logs

* Clean up

* Tweak

* Stash actual command's exit_code, not echo's
2023-03-16 22:17:29 +09:00
Tao Zhu a4ad0c75fc
fix heap cost calculation rounding error (#30673)
* add test for refaction heap size, fix size truncating by div op
* add feature gate
* checked result of consume_checked() if feature is activated
2023-03-15 12:03:04 -05:00
Tao Zhu 7b95c8e698
add default_cost as mandatory field for Builtin (#30639)
* add default_cost as mandatory field for Builtin

* updated tests

* set zkp program default to VerifyTransfer CUs

---------

Co-authored-by: Jon Cinque <joncinque@pm.me>
2023-03-10 14:02:24 -06:00
Tao Zhu 3b9438fd49
Replace hardcoded loaded accounts size limit with compute budget instruction (#30506)
1. replace hardcoded loaded accounts data size limit with compute budget instruction;
2. new transaction error for invalid account data size limit
3. test requested limit with combination of features and transactions
2023-03-08 19:41:45 -06:00
Dmitri Makarov b915b47315
Bump sbf-tools version to v1.35 (#30628)
- this release includes fixes in relocation handling necessary for
  source-level debugging of on-chain programs
2023-03-07 07:23:59 -08:00
Dmitri Makarov 7361fe27f9
Disable cwd remapping if debug build is requested in build-sbf (#30601)
CWD remapping removes absolute path prefixes from the path strings in
generated binary files. The paths are needed for source level
debugging.
2023-03-06 21:36:44 -05:00
Oliver Tušla ec7b1c8bda
Fix typo: where -> were (#30599) 2023-03-05 16:46:00 -05:00
Alexander Meißner 31bd695b83
Feature - `switch_to_new_elf_parser` (#30498)
Adds feature gate "switch_to_new_elf_parser".
2023-03-01 09:13:00 +01:00