Commit Graph

1306 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
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
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
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
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
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
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
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
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
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
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
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
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
Tao Zhu 9ec5e9b866
refactor to remove additional is_simple_vote check (#30521) 2023-02-24 23:49:04 -06:00
Tao Zhu 66ea750182
add compute budget instruction to set loaded accounts data size limit (#30377)
* add compute budget instruction to set accounts data size limit

* changes names to explicitly for loaded accounts data size
2023-02-24 09:27:49 -06:00
steviez 2ba76e4235
chore: Use Self in Packet/PacketBatch impl blocks (#30417) 2023-02-22 10:02:50 -05:00
Brooks 0c36e4c82d
Adds stable layout types to pass to the runtime (#30192) 2023-02-16 08:16:25 -05:00
Tao Zhu 51bace2123
add cost tracking for each bank during replay (#30035)
* add cost tracking for each bank during replay
* add feature gate
2023-02-13 13:09:48 -06:00
Alexander Meißner 6558c8fdc9
Refactor - Delay visibility of program un-/re-/deployment (#29654)
* Use three separate HashMaps instead of the enum TxBankExecutorCacheDiff.

* Replaces all places which deploy programs by a macro.

* Adds a feature gate.

* Adjust tests.

* Makes undeployment visible immediately.
2023-02-11 11:18:25 +01:00
Tyera 45272147ad
Fill in feature issue number in feature_set (#30232)
Fill in feature issue number
2023-02-10 01:14:25 +00:00
Tyera a14473eb54
Prevent Rent-reward recipients from ending up RentPaying (#30130) 2023-02-06 12:16:36 -07:00
Tao Zhu 4293f11cf1
feature gate to enable compute_budget::request_heap_frame on mainnetBeta (#30077) 2023-02-03 09:21:57 -06:00
Tao Zhu 090b990e15
remove congestion multiplier from transaction fee calculation (#29828) 2023-02-01 16:26:50 -06:00
Tao Zhu a5af54669a
Limit loaded data per transaction to a fixed cap (#29743) 2023-01-31 22:51:35 -06:00
Alexander Meißner ac7d0ff633
Feature - Disable builtin loader ownership chains (#29959)
* Adds feature disable_builtin_loader_ownership_chains.

* Removes test_load_accounts_max_call_depth().
2023-01-29 19:27:49 +01:00
Illia Bobyr 8fafbb0a06
doc: Fix documentation warnings and add some links (#29887) 2023-01-25 23:15:58 -08:00
Ryo Onodera 40bbf99c74
Add fully-reproducible online tracer for banking (#29196)
* Add fully-reproducible online tracer for banking

* Don't use eprintln!()...

* Update programs/sbf/Cargo.lock...

* Remove meaningless assert_eq

* Group test-only code under aptly named mod

* Remove needless overflow handling in receive_until

* Delay stat aggregation as it's possible now

* Use Cow to avoid needless heap allocs

* Properly consume metrics action as soon as hold

* Trace UnprocessedTransactionStorage::len() instead

* Loosen joining api over type safety for replaystage

* Introce hash event to override these when simulating

* Use serde_with/serde_as instead of hacky workaround

* Update another Cargo.lock...

* Add detailed comment for Packet::buffer serialize

* Rename sender_overhead_minimized_receiver_loop()

* Use type interference for TraceError

* Another minor rename

* Retire now useless ForEach to simplify code

* Use type alias as much as possible

* Properly translate and propagate tracing errors

* Clarify --enable-banking-trace with better naming

* Consider unclean (signal-based) node restarts..

* Tweak logging and cli

* Remove Bank events as it's not needed anymore

* Make tpu own banking tracer thread

* Reduce diff a bit..

* Use latest serde_with

* Finally use the published rolling-file crate

* Make test code change more consistent

* Revive dead and non-terminating test code path...

* Dispose batches early now that possible

* Split off thread handle very early at ::new()

* Tweak message for TooSmallDirByteLimitl

* Remove too much of indirection

* Remove needless pub from ::channel()

* Clarify test comments

* Avoid needless event creation if tracer is disabled

* Write tests around file rotation and spill-over

* Remove unneeded PathBuf::clone()s...

* Introduce inner struct instead of tuple...

* Remove unused enum BankStatus...

* Avoid .unwrap() for the case of disabled tracer...
2023-01-25 21:54:38 +09:00
samkim-crypto a3c763c2a0
Add a feature ID for enable_big_mod_exp_syscall (#29851) 2023-01-25 04:57:38 +09:00
behzad nouri d75303f541
patches bug in sigverify-shreds when identity is hot-swapped (#29802)
Sigverify-shreds discards shreds from node's own leader slots:
https://github.com/solana-labs/solana/blob/6baab92ab/core/src/sigverify_shreds.rs#L153-L154

But if the identity is hot-swapped the pubkey would be wrong since it
is instantiated only once at startup:
https://github.com/solana-labs/solana/blob/6baab92ab/core/src/tvu.rs#L168
2023-01-21 20:07:41 +00:00
behzad nouri 272e667cb2
deprecates Pubkey::new in favor of Pubkey::{,try_}from (#29805)
The commit deprecates Pubkey::new which lacks type-safety and instead
implements TryFrom<&[u8]> and TryFrom<Vec<u8>> for Pubkey.
2023-01-21 18:06:27 +00:00
valiksinev 5f7fea100a
Big integer modular exponentiation (EIP-198) (#28503)
* big_mod_exp impl

* fix programs/sbf/Cargo.lock

* ComputeBudget impl

* update compute_budget

* compute_budget update

* fix build

* fix tests

* fix cargo clippy

* fix clippy

* fix bpf_loader dependency sorting

* fix sorting

* fix merge from master

* fix cargo fmt

* fix C-tests

* fix cargo fmt

* comments apply

* fix programs/sbf/Cargo.lock

* update compude_budget cost

* remove whitespaces

* fix cargo fmt

Co-authored-by: sinev-valentine <sinev-valentine@yandex.ru>
2023-01-20 18:42:37 +09:00