Commit Graph

23531 Commits

Author SHA1 Message Date
Andrew Fitzgerald d36ded20fc
Make TimedTracedEvent accessible outside banking_trace.rs (#32985) 2023-09-05 08:54:32 -07:00
Proph3t 3dee9cb489
Fix a typo & phrasing of `bpf_loader_upgadeable` docs (#33141)
* Fix a typo & phrasing of `bpf_loader_upgradeable` docs

Originally, I was just going to fix the typo, replacing 'the' with
'that.' But I thought that the sentence was phrased awkwardly anyway, so
I tried to correct that as well.

* Fix second typo

Co-authored-by: ripatel-fd <ripatel+git@jumptrading.com>

---------

Co-authored-by: ripatel-fd <ripatel+git@jumptrading.com>
2023-09-05 08:05:34 -07:00
Callum McIntyre 19306bac74
Correct docs for getMultipleAccounts RPC (#32684) 2023-09-05 13:35:48 +00:00
Alexander Meißner e9542200e8
Fix - Superfluous `if` condition for overwriting `environments` in feature activation code (#33138)
Removes the `if` block around the overwriting of the `environments`.
2023-09-05 15:01:20 +02:00
dependabot[bot] 9ab5c34543
build(deps): bump thiserror from 1.0.47 to 1.0.48 (#33134)
* build(deps): bump thiserror from 1.0.47 to 1.0.48

Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.47 to 1.0.48.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.47...1.0.48)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [auto-commit] Update all Cargo lock files

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <dependabot-buildkite@noreply.solana.com>
2023-09-05 12:44:50 +00:00
dependabot[bot] bd61ff72aa
build(deps): bump ctrlc from 3.4.0 to 3.4.1 (#33131)
Bumps [ctrlc](https://github.com/Detegr/rust-ctrlc) from 3.4.0 to 3.4.1.
- [Release notes](https://github.com/Detegr/rust-ctrlc/releases)
- [Commits](https://github.com/Detegr/rust-ctrlc/compare/3.4.0...3.4.1)

---
updated-dependencies:
- dependency-name: ctrlc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-05 12:30:06 +00:00
dependabot[bot] 170ad08cc8
build(deps): bump regex from 1.9.4 to 1.9.5 (#33133)
* build(deps): bump regex from 1.9.4 to 1.9.5

Bumps [regex](https://github.com/rust-lang/regex) from 1.9.4 to 1.9.5.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.4...1.9.5)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [auto-commit] Update all Cargo lock files

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <dependabot-buildkite@noreply.solana.com>
2023-09-05 12:28:00 +00:00
dependabot[bot] 552dc83511
build(deps): bump syn from 2.0.29 to 2.0.31 (#33135)
* build(deps): bump syn from 2.0.29 to 2.0.31

Bumps [syn](https://github.com/dtolnay/syn) from 2.0.29 to 2.0.31.
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.29...2.0.31)

---
updated-dependencies:
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [auto-commit] Update all Cargo lock files

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <dependabot-buildkite@noreply.solana.com>
2023-09-05 12:25:39 +00:00
Alessandro Decina 6679153ca1
CPI: improve test coverage (#31986)
* programs/sbf: add TEST_[FORBID|ALLOW]_WRITE_AFTER_OWNERSHIP_CHANGE*

* programs/sbf: add tests for the AccessViolation -> InstructionError mapping

* cpi: add more tests

* programs/sbf: add tests for immutable AccountInfo pointers

* programs/sbf: add tests for verification of SolAccountInfo pointers too

* programs/sbf: add tests for ref_to_len_in_vm handling in CPI

Add TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE_MOVING_DATA_POINTER
and TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE that exercise the new
logic.

* cpi: tweak tests

Remove some copy pasta and rename two tests to better describe what they're doing

* cpi: add tests that check that CPI updates all accounts at once

* direct mapping: test that writes to executable accounts trigger ExecutableDataModified

* programs/sbf: add explicit tests for when an account's data allocation changes
2023-09-05 14:27:26 +07:00
Brooks adee97fe38
Ledger-tool CLI can specify accounts hash cache path (#33118) 2023-09-02 16:17:03 -04:00
Jeff Washington (jwash) fb1ba216f5
Revert "Add an RPC API that can query the list of Top N secondary index keys and their sizes (#28887)" (#33121)
* Revert "Add an RPC API that can query the list of Top N secondary index keys and their sizes (#28887)"

This reverts commit 1e3d6349aa.

* Revert "Add Admin RPC Front End for Top N Secondary Index Key Sizes Query. (#29352)"

This reverts commit aa353e4b83.

* fix test uses

* fmt
2023-09-01 14:36:06 -07:00
Brooks 330d6200e2
AccountsDb's base working dir should be within the ledger-tool dir (#33119) 2023-09-01 17:35:54 -04:00
Brooks 88d3c8ce90
Validator CLI can specify accounts hash cache path (#33117) 2023-09-01 17:11:52 -04:00
steviez ad33c68ce9
Update ShredFetchStage::modify_packets to drop root bank quicker (#33105)
This function used to contain feature gate activation checks that
required access to a bank. Those checks have been cleaned up, so we no
longer need access to a full Bank. Rather, we can momentarily get a Bank
from BankForks, calculate the necessary results and then drop the Bank
along with the BankForks read lock.
2023-09-01 23:08:49 +02:00
Brooks d1b849972f
Support a custom path for the accounts hash cache (#33115) 2023-09-01 15:29:56 -04:00
Jeff Washington (jwash) 255029f61a
add rate info to generate index log (#33108) 2023-09-01 11:40:00 -07:00
samkim-crypto a4ceea32d7
[zk-token-sdk] Allow all zero auditor pubkey in proofs (#33106)
* allow auditor ElGamal public key to be all zero

* remove test components on all zero auditor ElGamal pubkey
2023-09-01 10:26:15 -07:00
behzad nouri 931665551e
rolls out merkle shreds to 100% of mainnet slots (#32979) 2023-09-01 16:58:32 +00:00
Joe C 72706d6601
test validator write stake account to JSON (#33014) 2023-09-01 08:18:53 -06:00
Alessandro Decina 16ea141402
sdk: put AccountSharedData::set_data() behind feature="dev-context-only-utils" (#33086)
set_data() is deprecated in favor of set_data_from_slice().
2023-09-01 21:02:14 +07:00
Yihau Chen b4efbf07f7
ci: remove unstable options for stable tests (#33103) 2023-09-01 19:45:00 +08: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
Yihau Chen 114b5b95dd
ci: add a common script for installing dependencies (#33101)
ci: add a common place for install deps
2023-09-01 06:43:00 +00:00
Ryo Onodera 4fe0812f3c
Make should_panic tests compatible with 1.73+ panic format (#33099)
* Adjust should_panic tests for 1.73+ panic format

* Update more panic format change affected tests...
2023-09-01 02:04:22 +00:00
Trent Nelson 7e5cd11b34
fix memory corruption in geyser plugin manager tests with recent toolchains (#33097)
* geyser: genericize manager test dummy plugin generators

* geyser: dlopen self the safe way in test dummy plugin generator

fixes memory corruption
2023-08-31 17:45:46 -06:00
dependabot[bot] d14605666c
build(deps): bump chrono from 0.4.26 to 0.4.28 (#33094)
* build(deps): bump chrono from 0.4.26 to 0.4.28

Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.26 to 0.4.28.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.26...v0.4.28)

---
updated-dependencies:
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* [auto-commit] Update all Cargo lock files

* Switch from deprecated chrono api

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <dependabot-buildkite@noreply.solana.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
2023-08-31 16:58:06 -06:00
behzad nouri 39615bd075
removes manual let...else (#33089)
https://rust-lang.github.io/rust-clippy/master/index.html#/manual_let_else
2023-08-31 22:35:47 +00:00
HaoranYi c87f9cdfc9
use shift for pubkey to bin calculation (#33090)
Co-authored-by: HaoranYi <haoran.yi@solana.com>
2023-08-31 15:04:25 -05:00
behzad nouri 1431275328
removes outdated check for merkle shreds (#33088) 2023-08-31 20:01:54 +00:00
Jeff Washington (jwash) 9a7d503fe4
rework sorting during generate_index (#33076)
* drag data len around during generate_index

* fix tests

* update comments
2023-08-31 12:51:56 -07:00
behzad nouri 7275caf708
simplifies sigverify_shreds::get_slot_leaders (#33079) 2023-08-31 19:49:23 +00:00
Brooks 5e26b05597
Removes the "unpacked entries so far" log at startup (#33093) 2023-08-31 15:29:12 -04:00
Ashwin Sekar 6d2dae6ab0
send duplicate shred proofs for conflicting shred scenarios (#32965)
* send duplicate shred proofs for conflicting shred scenarios

The scenarios are multiple last_shred_in_slot shreds and
coding shreds with conflicting erasure metas.

* Pr feedback: deprecate shred_index for gossip duplicate shred proofs

* Pr feedback

* Remove extraneous dead code
2023-08-31 12:08:10 -07:00
Brooks f8789c79a2
Refactor bucket storage bad header size test (#33091) 2023-08-31 13:01:20 -04:00
Ryo Onodera 92a0b310c1
Add #[repr(C)] for more future-proof byte mangling (#33085)
* Add #[repr(C)] for more future-proof byte manglng

* Improve comments after code-review
2023-08-31 22:48:24 +09:00
Ashwin Sekar 025651e0d4
ff cleanup: allow_votes_to_directly_update_vote_state and compact_vot… (#32967)
ff cleanup: allow_votes_to_directly_update_vote_state and compact_vote_state_updates
2023-08-30 17:00:19 -07:00
Jeff Washington (jwash) 1b9c9a313c
reorder generate_index info (#33077)
reorder generateindex info
2023-08-30 16:16:40 -07:00
Yihau Chen f0f75aff59
ci: allocate more threads for gossip tests (#33074)
ci: allocate more threads for test_star_network_push_star_200 and test_star_network_push_ring_200 when test
2023-08-30 23:01:44 +00:00
Alexander Meißner ef16b5e27d
Refactor - Loader-v4 grows accounts with "truncate" not "write" (#33054)
* Moves initialization and growth of program accounts
from "write" to "truncate" instruction in loader-v4.

* Removes the parameter payer account from the truncate instruction.
2023-08-31 00:44:58 +02:00
Ashwin Sekar e88d6c6130
ff cleanup: vote_state_update_credit_per_deque (#32966) 2023-08-30 15:42:18 -07:00
Trent Nelson b13589b588
round two preliminaries for bumping nightly to 2023-08-25 (#33064)
* work around nightly ICE

seems to be something related to `const ref`s in generic contexts...

* allow lint false-positive on ignored trait bounds
2023-08-30 21:46:20 +02:00
samkim-crypto 79c02c8fd6
[zk-token-proof] Add CUs to close account instruction (#33042)
add compute units for close context state account
2023-08-30 11:16:09 -07:00
samkim-crypto 3458a7d210
Add feature ID for `enable_poseidon_syscall` (#33072)
add feature id for poseidon syscall
2023-08-30 10:57:02 -07:00
behzad nouri 4ec5ea6f7b
replaces assert!(matches!(...)) with assert_matches!(...) (#33068)
assert_matches!(...) provides more informative error message when it
fails and it is part of nightly rust:
https://doc.rust-lang.org/std/assert_matches/macro.assert_matches.html
2023-08-30 13:48:27 -04:00
vadorovsky e6dc3dac45
feat(sbf): Add Poseidon syscall (#32680)
Computing Poseidon[0] hashes is too expensive to be done in a Solana
program in one transaction. Poseidon is a zero-knowlege proof friendly
hash function, used by the majority of ZK-based projects, including the
ones built on top of Solana.

This change introduces the `sol_poseidon` syscall which takes 2D byte
slice as an input and then calculates a Poseidon hash using a BN254
curve and the following Poseidon parameters:

* x^5 S-boxes
* width - 2 ≤ t ≤ 13
* inputs - 1 ≤ n ≤ 12
* 8 full rounds and partial rounds depending on t: [56, 57, 56, 60, 60,
  63, 64, 63, 60, 66, 60, 65]

Computation of Poseidon hashes is done with the light-poseidon[1]
crate, which is audited[2] and compatible with Circom[3] (BN254 curve,
the same parameters and constants).

Proposed compute costs depend on number of inputs and are based on
light-poseidon benchmarks[4].

[0] https://www.poseidon-hash.info/
[1] https://crates.io/crates/light-poseidon
[2] https://github.com/Lightprotocol/light-poseidon/blob/main/assets/audit.pdf
[3] https://docs.circom.io/
[4] https://github.com/Lightprotocol/light-poseidon/tree/main#performance
2023-08-30 09:43:31 -07:00
samkim-crypto 01dbe4970c
[zk-token-proof] Enable proof program to be invoked as an inner call (#33045)
enable close context state account instruction to be invoked as an inner call
2023-08-30 08:18:22 -07:00
Jeff Washington (jwash) 48f27d5e73
add stats for generate_index (#33061) 2023-08-30 06:43:27 -07:00
steviez 611b7527e5
Cleanup BankForks access code in ShredFetchStage (#33066)
- BankForks is not an optional argument, so remove dated comment
- Given that BankForks is always present, no need for special values to
  initialize variables before the loop
- Root slot can be retrieved from root bank, no need to call
  BankForks::root() which will load the underlying atomic a second time
- Use BankForks::highest_slot() instead of .slot() on .working_bank() to
  avoid the extra clone that .working_bank() performs
- Move several operations outside of BankForks read lock scope to
  minimize lock time
2023-08-30 15:03:02 +02:00
Alessandro Decina 0f41719918
direct mapping: misc fixes (#32649)
* transaction_context: update make_data_mut comment

* bpf_loader: cpi: pass SerializeAccountMetadata to CallerAccount::from*

We now have a way to provide CallerAccount with trusted values coming
from our internal serialization code and not from untrusted vm space

* bpf_loader: direct_mapping: enforce account info pointers to be immutable

When direct mapping is enabled, we might need to update account data
memory regions across CPI calls. Since the only way we have to retrieve
the regions is based on their vm addresses, we enforce vm addresses to
be stable.  Accounts can still be mutated and resized of course, but it
must be done in place.

This also locks all other AccountInfo pointers, since there's no legitimate
reason to make them point to anything else.

* bpf_loader: cpi: access ref_to_len_in_vm through VmValue

Direct mapping needs to translate vm values at each access since
permissions of the underlying memory might have changed.

* direct mapping: improve memory permission tracking across CPI calls

Ensure that the data and realloc regions of an account always track the
account's permissions. In order to do this, we also need to split
realloc regions in their own self contained regions, where before we
had:

[account fields][account data][account realloc + more account fields + next account fields][next account data][...]

we now have:

[account fields][account data][account realloc][more account fields + next account fields][next account data][...]

Tested in TEST_[FORBID|ALLOW]_WRITE_AFTER_OWNERSHIP_CHANGE*

Additionally when direct mapping is on, we must update all perms at once before
doing account data updates. Otherwise, updating an account might write into
another account whose perms we haven't updated yet. Tested in
TEST_FORBID_LEN_UPDATE_AFTER_OWNERSHIP_CHANGE.

* bpf_loader: serialization: address review comment don't return vm_addr from push_account_region

* bpf_loader: rename push_account_region to push_account_data_region

* cpi: fix slow edge case zeroing extra account capacity after shrinking an account

When returning from CPI we need to zero all the account memory up to the
original length only if we know we're potentially dealing with uninitialized
memory.

When we know that the spare capacity has deterministic content, we only need to
zero new_len..prev_len.

This fixes a slow edge case that was triggerable by the following scenario:

- load a large account (say 10MB) into the vm
- shrink to 10 bytes - would memset 10..10MB
- shrink to 9 bytes - would memset 9..10MB
- shrink to 8 bytes - would memset 8..10MB
- ...

Now instead in the scenario above the following will happen:

- load a large account (say 10MB) into the vm
- shrink to 10 bytes - memsets 10..10MB
- shrink to 9 bytes - memsets 9..10
- shrink to 8 bytes - memset 8..9
- ...

* bpf_loader: add account_data_region_memory_state helper

Shared between serialization and CPI to figure out the MemoryState of an
account.

* cpi: direct_mapping: error out if ref_to_len_in_vm points to account memory

If ref_to_len_in_vm is allowed to be in account memory, calles could mutate it,
essentially letting callees directly mutate callers memory.

* bpf_loader: direct_mapping: map AccessViolation -> InstructionError

Return the proper ReadonlyDataModified / ExecutableDataModified /
ExternalAccountDataModified depending on where the violation occurs

* bpf_loader: cpi: remove unnecessary infallible slice::get call
2023-08-30 16:57:24 +07:00
Trent Nelson b8dc5daedb
preliminaries for bumping nightly to 2023-08-25 (#33047)
* remove unnecessary hashes around raw string literals

* remove unncessary literal `unwrap()`s

* remove panicking `unwrap()`

* remove unnecessary `unwrap()`

* use `[]` instead of `vec![]` where applicable

* remove (more) unnecessary explicit `into_iter()` calls

* remove redundant pattern matching

* don't cast to same type and constness

* do not `cfg(any(...` a single item

* remove needless pass by `&mut`

* prefer `or_default()` to `or_insert_with(T::default())`

* `filter_map()` better written as `filter()`

* incorrect `PartialOrd` impl on `Ord` type

* replace "slow zero-filled `Vec` initializations"

* remove redundant local bindings

* add required lifetime to associated constant
2023-08-29 23:05:35 +00:00