Skip to content
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

refactor: replace std::io::Error with custom OerError #723

Merged
merged 24 commits into from
Jun 15, 2021

Conversation

whalelephant
Copy link
Contributor

@whalelephant whalelephant commented May 19, 2021

Remove requirement to keep mapping std::io::Error into different crates` error type.

@whalelephant whalelephant force-pushed the io-errors branch 4 times, most recently from 0af1137 to 6aaf4be Compare May 19, 2021 15:18
@whalelephant whalelephant changed the title Io errors Remove io errors May 19, 2021
@whalelephant whalelephant marked this pull request as ready for review May 19, 2021 15:20
Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

I think this is looking great! The major question is to go with the added read_{u{8,16,32},exact} or just with bytes::Buf methods and have an oblig length check before deserialization.

I think the single big length check would be preferable, because afterwards the LLVM can probably see that the bytes::Buf methods cannot panic.

Regarding the failed exchange_rates.rs test... We might need to disable it, unless there was just some temporary issue.

crates/interledger-packet/src/oer.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/oer.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
crates/ilp-node/Cargo.toml Show resolved Hide resolved
crates/interledger-btp/src/errors.rs Outdated Show resolved Hide resolved
whalelephant and others added 6 commits May 20, 2021 19:10
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
- Introduce `try_read_u8` in `BufOerExt` trait
- Remove ByteOrder dep in packet, stream, service-util and ildcp
- Add OerError to stream, btp and ccp
- stream remove useless error var

Signed-off-by: bwty <whalelephant@users.noreply.github.com>

Signed-off-by: bwty <whalelephant@users.noreply.github.com>
- added methods in BufOerExt for check and read data into buf
- remove bytesorder dependencies
- rename previous try_read_u8 to read_u8

Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Co-authored-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

With the suggestions (resolved and made them into a PR) I think this is looking good!

koivunej and others added 6 commits May 20, 2021 18:43
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: bwty <whalelephant@users.noreply.github.com>
@koivunej koivunej changed the title Remove io errors refactor: replace std::io::Error with custom OerError May 21, 2021
@koivunej
Copy link
Collaborator

koivunej commented May 21, 2021

Oki I understand that the PR is now ready to be merged but since it's already friday lets give this some more time.

@koivunej koivunej mentioned this pull request May 21, 2021
@koivunej koivunej linked an issue May 21, 2021 that may be closed by this pull request
Copy link
Collaborator

@pradovic pradovic left a comment

Choose a reason for hiding this comment

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

Great job!
I added a couple of subjective comments, so if you don't agree with them you can skip, it is still good to go from me!

crates/interledger-btp/src/errors.rs Outdated Show resolved Hide resolved
crates/interledger-btp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-btp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-btp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-ccp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-ccp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-ccp/src/packet.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
crates/interledger-packet/src/errors.rs Outdated Show resolved Hide resolved
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
the comments on the test case bothered me after reading through them
over and over again. Made the cases exhaustive by checking every
other short buffer as well.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
this will allow defining easily constants for more fields.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
naming: most of the constants seem LEN not LENGTH

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
smaller than the Address::MIN_LEN constant.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
I hope this doesn't duplicate some existing test ... I did try to look
around for it.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
the string contained a stringified version of chrono::Error, which
wasn't much use, see the two cases of changed strings.

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
- more "Invalid Packet" -- these used to be mostly I/O Errors
- use display instead of debug formatting

Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
Signed-off-by: Joonas Koivunen <joonas.koivunen@gmail.com>
@koivunej koivunej requested a review from pradovic June 11, 2021 14:06
Copy link
Collaborator

@pradovic pradovic left a comment

Choose a reason for hiding this comment

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

LGTM! 👏 nice job!

@koivunej
Copy link
Collaborator

Cannot get any reliable perf changes, but at least there's no more IO error, so this is a big win for readability.

@koivunej koivunej merged commit 9ef5a16 into interledger:master Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overuse of interledger_packet::errors::ParseError
3 participants