-
Notifications
You must be signed in to change notification settings - Fork 545
Direct Mapping Supercharged #5871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The Firedancer team maintains a line-for-line reimplementation of the |
9d85e3a
to
1cf4e9c
Compare
1179878
to
03bf5f3
Compare
b4cbde8
to
48c65cd
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5871 +/- ##
=========================================
Coverage 82.8% 82.8%
=========================================
Files 847 847
Lines 379509 378425 -1084
=========================================
- Hits 314372 313572 -800
+ Misses 65137 64853 -284 🚀 New features to boost your workflow:
|
3aa050a
to
720953f
Compare
f53af04
to
4d52477
Compare
Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis. |
b37984e
to
1b3e4bb
Compare
…irect_mapping as well.
1b3e4bb
to
f7302df
Compare
We could remove |
// No other translated references can be live when calling this. | ||
// Meaning it should generally be at the beginning or end of a syscall and | ||
// it should only be called once with all translations passed in one call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to explicitly say that when using translate_mut
all previous translations will be invalidated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The borrow checker now enforces this via lifetimes, so you can not get to the situation where a previous translation would be invalidated.
f7302df
to
f73a122
Compare
new_region.cow_callback_payload = account.get_index_in_transaction() as u32; | ||
} | ||
self.vaddr += new_region.len; | ||
let address_space_reserved_for_account = if self.aligned { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Not necessary for this PR, but renaming aligned
would clear a source of confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep aligned
here does not refer to the MemoryMapping
but the unaligned ABIv0 of loader-v1.
That name has already been in place before this PR, so I would change it separately later.
…de of `if prev_len != post_len`.
…ller_account_region()`.
Problem
Direct mapping is very complex and still buggy. So far, we have been trying to match the existing behavior exactly, including things which are undefined behavior from the programs (not the runtimes) perspective. E.g. the runtime allows reads (in the realloc padding) beyond the current length of an account. From a programs perspective this is uninitialized memory and no sane program should be reading from it before writing to it first. If we were to stop supporting this and instead throw
InstructionError::AccountDataTooSmall
we could significantly simplify the direct mapping feature.Summary of Changes
Removes:
memcpy
,memmov
,memset
,memcmp
)MemoryRegion::host_addr
andMemoryRegion::writable
in SBPFMemoryRegion
(Cell<>
aroundhost_addr
andwritable
) in SBPF, which prevented declaring proper lifetimes on the results of map / translate calls in this repoVec::spare_capacity_mut
MemoryRegion
as writable and then reverted that usingscopeguard::defer
serialize_parameters_aligned
)update_caller_account
)update_caller_account
) when the underlyingVec
was reallocatedupdate_callee_account
)update_caller_account
)deserialize_parameters_aligned
)MemoryRegion
Adds:
AccessType::Store
) in syscalls which enables use of the borrow checker to ensure that theAccessViolationHandler
can not invalidate translated references during the syscallTransactionContext::access_violation_handler()
when resize padding is written to (AccessType::Store
)EbpfError::AccessViolation
error translation toInstructionError::AccountDataTooSmall
andInstructionError::InvalidRealloc
test_deny_access_beyond_current_length()
forInstructionError::AccountDataTooSmall
andInstructionError::InvalidRealloc
test_access_violation_handler()
for the interaction ofTransactionContext::access_violation_handler()
andcreate_memory_region_of_account()
Feature Gate Issue: https://github.com/anza-xyz/feature-gate-tracker/issues/16