Commit Graph

170 Commits

Author SHA1 Message Date
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
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
Ryo Onodera d80745cfaf
dcou: BorrowedAccount::set_data() (#32424)
* dcou: BorrowedAccount::set_data()

* Properly depend on dev-context-only-utils
2023-07-13 22:44:08 +09:00
Yihau Chen e587df1285
ci: update cargo.toml (#31934)
* ci: add missing description and documentation to zk-token-sdk/Cargo.toml

* ci: add missing description back to programs/bpf_loader/Cargo.toml

* ci: add missing description back to banks-client/Cargo.toml
2023-06-02 15:08:07 +00:00
dependabot[bot] f85cf889f4
Bump memoffset from 0.8.0 to 0.9.0 (#31724)
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 <tyera@solana.com>
2023-05-19 13:47:14 -07:00
Yihau Chen df3ef111f7
chore: workspace inheritance (#29893)
* introduce workspace.package

* introduce workspace.dependencies

* read version from root cargo.toml

* pass check when version = { workspace = true }

* don't bump version when version = { workspace = true }

* including workspace Cargo.toml when bump version

* programs/sbf use workspace inheritance

* fix increasing cargo version ignore program/sbf/Cargo.toml
2023-02-23 22:01:54 +08:00
Michael Vines 5136ed3448
Update homepage value for all crates (#30444) 2023-02-23 02:20:18 +00:00
Alexander Meißner 4bfcbf75eb
Bump solana_rbpf to v0.2.39 (#30398)
* Bump solana_rbpf to v0.2.39

* Adds MemoryRegion::vm_addr_end.
2023-02-21 18:43:34 +01:00
Brooks 0c36e4c82d
Adds stable layout types to pass to the runtime (#30192) 2023-02-16 08:16:25 -05:00
Will Hickey 04a6a631bc
Bump version to v1.16 (#30028) 2023-01-31 17:48:33 -06:00
joeaba a12bf8c003
Update maintainers references (#29997)
* update maintainers references

* chore: update maintainers reference
2023-01-31 08:07:13 -05:00
Yihau Chen 9193b4221d
Revert "chore: workspace inheritance (#29509)" (#29892)
This reverts commit a67d239dde.
2023-01-25 15:50:41 +08:00
Yihau Chen a67d239dde
chore: workspace inheritance (#29509)
* introduce workspace.package

* introduce workspace.dependencies

* read version from root cargo.toml

* pass check when version = { workspace = true }

* don't bump version when version = { workspace = true }

* including workspace Cargo.toml when bump version

* programs/sbf use workspace inheritance

* fix increasing cargo version ignore program/sbf/Cargo.toml
2023-01-25 13:59:59 +08:00
Alexander Meißner 013f784e92
Bump solana_rbpf to v0.2.38 (#29137)
* Refactor register_syscalls() => create_loader().

* Bumps solana_rbpf to v0.2.38

* Replaces Config::encrypt_environment_registers by Config::runtime_environment_key.

* Adds pc parameter to MemoryMapping::map()

* Removes debugger from rbpf CLI.

* Adds debugger to rbpf CLI again.

* Renames vm.context_object => vm.env.context_object_pointer.

* Renames SyscallRegistry => BuiltInProgram.
Renames SyscallFunction => BuiltInFunction.
Renames register_syscall_by_name() => register_function_by_name().

* Removes ContextObject from Analysis.

* Renames Config::error_on_syscall_bpf_function_hash_collisions => Config::external_internal_function_hash_collision.
2022-12-12 08:47:09 +01:00
Yihau Chen eaea3ec5bc
bump solana_rbpf to v0.2.37 (#28857) 2022-11-19 11:30:36 +08:00
Alexander Meißner ff1ff587d1
Bump solana_rbpf to 0.2.36 (#28794)
* Bumps solana_rbpf to v0.2.36

* Removes ThisInstructionMeter.

* Removes one "unsafe" expression.

* Removes redundant call to solana_rbpf:🧝:register_bpf_function().

* Adjusts SyscallFunction and SyscallRegistry.

* Inlines ProgramEnvironment into EbpfVm.

* Refactors trait SyscallConsume into fn consume_compute_meter().

* Inlines ComputeMeter into InvokeContext.

* Removes solana-metrics dependency from bpf_loader.

* Replaces RBPF tracer functionality by the debugger.

* Take compute_units_consumed from execute_program().

* Merges execute_program_interpreted() and execute_program_jit().
2022-11-15 15:21:11 +01:00
Dmitri Makarov f48ed1f331 Bump solana_rbpf to 0.2.35
- recognize new SBF machine code in ELF header
2022-10-25 15:28:02 +00:00
Alexander Meißner 5aca7df232
Bank::create_executor() (#28474)
* Moves the integration test test_bpf_loader_upgradeable_deploy_with_max_len() from the bpf_loader into the runtime.

* Adds Bank::create_executor().

* Adds a test for Bank::create_executor().
2022-10-19 22:28:57 +02:00
Alexander Meißner 30b0a13ba9
Bump solana_rbpf to 0.2.34 (#28198)
* Bumps solana_rbpf to 0.2.34

* Removes generic UserError from EbpfError.

* Uses ProgramResult for syscalls.
Removes use sites of the question_mark! macro by wrapping the call method of SyscallObjects.

* Uses InvokeContext as syscall context object directly.

* Replaces bind_syscall_context_object() by a parameter in the constructor.

* Inlines bind_syscall_context_objects() at its only call site.
2022-10-06 20:31:58 +02:00
Alessandro Decina 7469ce7ba1
Bump solana_rbpf to 0.2.33 (#28121) 2022-09-28 19:52:19 +01:00
Will Hickey c0e4379f43
Whickey/version v1.15 (#27739)
* Bump version to v1.13.0
* Bump version to v1.14.0
* Bump version to v1.15.0
2022-09-13 09:06:15 -05:00
Alexander Meißner f76f8d5d41
Bumps solana_rbpf to v0.2.32 (#27059) 2022-08-15 16:04:48 +02:00
Will Hickey ed8c224374
Bump version to v1.12 (#26967) 2022-08-06 13:20:30 -05:00
github-actions[bot] fbf1bf6d86
Bump Version to 1.11.6 (#26906)
Co-authored-by: willhickey <willhickey@users.noreply.github.com>
2022-08-03 12:48:43 -05:00
github-actions[bot] 5d038b9d2a
Bump Version to 1.11.5 (#26758)
Co-authored-by: willhickey <willhickey@users.noreply.github.com>
2022-07-25 13:05:14 -06:00
github-actions[bot] fd5df1cf25
Bump Version to 1.11.4 (#26578)
Co-authored-by: willhickey <willhickey@users.noreply.github.com>
2022-07-11 23:30:38 -05:00
github-actions[bot] 9d937fb8a0
Bump Version to 1.11.3 (#26481)
Co-authored-by: willhickey <willhickey@users.noreply.github.com>
2022-07-07 14:39:46 -05:00
github-actions[bot] 5c2f819f99
Bump Version to 1.11.2 (#26159) 2022-06-22 21:16:18 -05:00
Will Hickey 51f26dc96e
Bump version to 1.11.1 (#26104) 2022-06-21 12:07:46 -05:00
Jack May 363d8d1539
Bump rBPF (#25593) 2022-06-07 04:45:07 -07:00
Alexander Meißner b4a32f2e8d
Bumps solana_rbpf to v0.2.30 (#25755) 2022-06-03 16:22:23 +02:00
Alexander Meißner d38752e1e7
Bumps solana_rbpf to v0.2.29 (#25333) 2022-05-19 09:19:05 +02:00
dependabot[bot] bece7f32c8
chore: bump log from 0.4.16 to 0.4.17 (#24987)
* chore: bump log from 0.4.16 to 0.4.17

Bumps [log](https://github.com/rust-lang/log) from 0.4.16 to 0.4.17.
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/commits/0.4.17)

---
updated-dependencies:
- dependency-name: log
  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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <dependabot-buildkite@noreply.solana.com>
2022-05-05 01:49:18 +00:00
Alexander Meißner 7f987722bf
Bump solana_rbpf to v0.2.28 (#24800) 2022-04-30 10:58:12 +02:00
Jack May 224e0b27a1
Simplify register and bind (#24724)
* Revert "Bumps solana_rbpf to v0.2.27 (#24694)"

This reverts commit f3d27cc400.

* Simplify syscall register and bind (#24546)

* declare syscalls with macro (#24564)
2022-04-28 10:24:42 +02:00
Alexander Meißner f3d27cc400
Bumps solana_rbpf to v0.2.27 (#24694) 2022-04-26 17:58:55 +02:00
Jeff Washington (jwash) 6ff16b1728
revert #24546 (#24647)
* Revert "declare syscalls with macro (#24564)"

38bdb401a3

* Revert "Simplify syscall register and bind (#24546)"

28ed2a9df4

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
2022-04-25 15:37:43 -05:00
Jack May 28ed2a9df4
Simplify syscall register and bind (#24546) 2022-04-21 09:09:07 -07:00
Jack May 85e5b1e902
Bump solana-rbpf to v0.2.25 (#24213) 2022-04-11 10:38:47 -07:00
Will Hickey c4ecfa5716
Bump version to v1.11 (#23807)
* Revert crossbeam_epoch to stable. 0.9.8 only works with nightly
* Remove unneeded unit expression
2022-03-21 17:40:50 -05:00
Will Hickey 2f58c9e501
Bump version to 1.10.4 (#23743) 2022-03-17 14:02:13 -05:00
Will Hickey 63bf0f66af
Bump version to 1.10.3 (#23648) 2022-03-14 11:18:45 -05:00
Brooks Prumo d20dd21600
Sort tables in Cargo.toml files (#23602) 2022-03-11 11:05:57 -06:00
Will Hickey b444836a97
Bump version to 1.10.2 (#23597) 2022-03-10 16:41:06 -06:00
Will Hickey 1a99251498
Bump version to 1.10.1 (#23453) 2022-03-02 13:47:01 -06:00
Alexander Meißner d0d256ee9a
Bump rbpf to v0.2.24 (#23263) 2022-02-21 23:38:12 +01:00
Alexander Meißner e05cf4bf97
Bumps solana_rbpf to version v0.2.23 (#22954) 2022-02-05 08:51:52 +01:00
Alexander Meißner 96c88d1a5e
Bumps solana_rbpf to version v0.2.22 (#22923)
* Bumps solana_rbpf to v0.2.22

* Adjusts vm::Config and feature gates.
2022-02-04 21:17:49 +01:00
Trent Nelson 2f29ff1a3f add excutor creation trace timings 2022-01-08 11:18:37 +00:00
Michael Vines bb3a1b6b31 Add zk_token_sdk_enabled feature to gate Zk Token proof program and `sol_zk_token_elgamal_op` syscalls 2022-01-05 11:57:37 -08:00