-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: refactor bounded vec to zero copy #1444
Merged
ananas-block
merged 4 commits into
main
from
jorrit/feat-refactor-bounded-vec-to-zero-copy
Jan 5, 2025
Merged
feat: refactor bounded vec to zero copy #1444
ananas-block
merged 4 commits into
main
from
jorrit/feat-refactor-bounded-vec-to-zero-copy
Jan 5, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ananas-block
requested review from
sergeytimoshin and
SwenSchaeferjohann
as code owners
January 2, 2025 18:48
ananas-block
force-pushed
the
jorrit/feat-refactor-bounded-vec-to-zero-copy
branch
4 times, most recently
from
January 2, 2025 23:02
1ffbafb
to
f0153d8
Compare
ananas-block
commented
Jan 2, 2025
Comment on lines
+285
to
+290
// TODO: remove | ||
pub fn get_metadata(&self) -> &BatchedMerkleTreeMetadata { | ||
unsafe { self.metadata.as_ref() }.unwrap() | ||
self.metadata.get() | ||
} | ||
// TODO: remove |
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.
in different pr
ananas-block
commented
Jan 2, 2025
Comment on lines
+173
to
+179
// TODO: remove | ||
pub fn get_metadata(&self) -> &BatchedQueueMetadata { | ||
unsafe { &*self.metadata } | ||
self.metadata.get() | ||
} | ||
|
||
// TODO: remove | ||
pub fn get_metadata_mut(&mut self) -> &mut BatchedQueueMetadata { | ||
unsafe { &mut *self.metadata } | ||
self.metadata.get_mut() |
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.
remove in different pr
ananas-block
force-pushed
the
jorrit/feat-refactor-bounded-vec-to-zero-copy
branch
2 times, most recently
from
January 3, 2025 16:16
39463dc
to
668ddcd
Compare
ananas-block
force-pushed
the
jorrit/feat-refactor-bounded-vec-to-zero-copy
branch
from
January 4, 2025 21:14
10d88fc
to
95e9bf0
Compare
sergeytimoshin
approved these changes
Jan 4, 2025
ananas-block
force-pushed
the
jorrit/feat-refactor-bounded-vec-to-zero-copy
branch
from
January 4, 2025 23:44
0ed92f0
to
ef0c4c5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
Solution:
light-bounded-vec
so that unsafe operations are unified and wrappedlight-bounded-vec
and rename refactored crate tolight-zero-copy
light-batched-merkle-tree
replace all instances of bound vec with zero copy vec, zero copy slice or zero copy cyclic veclight-batched-merkle-tree
Changes:
ManuallyDrop
*mut BatchedQueueMetadata
->WrappedPointerMut<BatchedQueueMetadata>
ManuallyDrop<BoundedVec<Batch>>
->ZeroCopySliceMutUsize<Batch>
Vec<ManuallyDrop<BoundedVec<[u8; 32]>>>
->Vec<ZeroCopyVecUsize<[u8; 32]>>
Vec<ManuallyDrop<BoundedVec<u8>>>
->Vec<ZeroCopySliceMutUsize<u8>>
Vec<ManuallyDrop<BoundedVec<[u8; 32]>>>
->Vec<ZeroCopyVecUsize<[u8; 32]>>
deref
&deref_mut
metadata -> can removeget_metadata
andget_metadata_mut
in a different pr*mut BatchedMerkleTreeMetadata
->WrappedPointerMut<BatchedMerkleTreeMetadata>
ManuallyDrop<CyclicBoundedVec<[u8; 32]>>
->ZeroCopyCyclicVecUsize<[u8; 32]>
ManuallyDrop<BoundedVec<Batch>>
->ZeroCopySliceMutUsize<Batch>
Vec<ManuallyDrop<BoundedVec<[u8; 32]>>>
->Vec<ZeroCopyVecUsize<[u8; 32]>>
Vec<ManuallyDrop<BoundedVec<u8>>>
->Vec<ZeroCopySliceMutUsize<u8>>
Vec<ManuallyDrop<BoundedVec<[u8; 32]>>>
->Vec<ZeroCopyVecUsize<[u8; 32]>>
deref
&deref_mut
metadata -> can removeget_metadata
andget_metadata_mut
in a different prWrappedPointer
: wrapper around immutable raw pointerWrappedPointerMut
: wrapper around mutable raw pointerZeroCopySliceMut
:WrappedPointer
and dataMaybeUninit<*mut T>
ZeroCopyVec
ZeroCopySliceMut
, treats slice length as capacity and adds dynamic length asWrappedPointerMut
ZeroCopyCyclicVec
ZeroCopyVec
, addscurrent_index
asWrappedPointerMut
and adds cyclic functionality