Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: fix read syscall and sdk method #584

Merged
merged 2 commits into from
May 24, 2022
Merged

fix: fix read syscall and sdk method #584

merged 2 commits into from
May 24, 2022

Conversation

Stebalien
Copy link
Member

  1. Return the correct offset (relative to the end of the logical buffer, not relative to the end of the bytes read).
  2. Don't cast "remaining" to a usize in read_block as it can be negative.
  3. Add an exhaustive test.

@Stebalien Stebalien requested a review from raulk May 19, 2022 23:29
@Stebalien Stebalien mentioned this pull request May 19, 2022
48 tasks
@Stebalien Stebalien force-pushed the fix/sdk-read-block branch from fc36827 to 4f06225 Compare May 19, 2022 23:31

#[no_mangle]
pub fn invoke(_: u32) -> u32 {
std::panic::set_hook(Box::new(|info| {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just makes debugging a lot easier.

@Stebalien Stebalien mentioned this pull request May 19, 2022
57 tasks
1. Return the correct offset (relative to the end of the logical buffer,
not relative to the end of the bytes read).
2. Don't cast "remaining" to a usize in read_block as it can be negative.
3. Add an exhaustive test.

Found by @wadealexc.
@Stebalien Stebalien force-pushed the fix/sdk-read-block branch from 4f06225 to 7a2671c Compare May 19, 2022 23:44
@raulk
Copy link
Member

raulk commented May 20, 2022

Will review this tomorrow, but just noting that @mriise is working on #577 separately.

@Stebalien
Copy link
Member Author

Yeah, that'll give us quite a bit of coverage. But we still need integration tests like this to get syscall (mostly concerning illegal arguments, etc.) and sdk coverage.

@Stebalien Stebalien requested a review from arajasek May 23, 2022 16:07
@wadealexc
Copy link

Looks good to me.

My one nit is that the unsafe blocks in ipld::get and get_block should be more defensive by default - i.e. using hard assertions in place of all the debug_assert currently being used.

I don't think that the cases being covered by these are currently possible, though.

@Stebalien Stebalien requested a review from vyzo May 24, 2022 17:28
This costs next to nothing, and is a good safety check.
@Stebalien Stebalien enabled auto-merge (squash) May 24, 2022 17:32
@Stebalien Stebalien merged commit 313ba0e into master May 24, 2022
@Stebalien Stebalien deleted the fix/sdk-read-block branch May 24, 2022 17:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants