-
Notifications
You must be signed in to change notification settings - Fork 57
Various cleanups and niceties #150
Various cleanups and niceties #150
Conversation
These modules are deprecated and they introduce noise with outdated benches and tests
`assert!()` is the idiomatic way to do conditional panics in Rust. Aliasing it is actually confusing.
The `core::panic_if_not!()` macro is a transparent proxy to `std::assert!()` with some optional debugging log. Therefore, it's not unreasonable to shadow the `std::assert!()` macro instead of introducing a new name.
Some of the `PhantomData<F>` used throughtout the project are debatable. They feel like necessary because type arguments and bounds are placed too early in `impl` blocks instead of the very same methods that need them. However, type arguments in data types produce a cascade effect that infects everything the type passes by, introducing a significant amount of complexity, unreadability and, in some cases, actual contention to achieve certain things. One of the more evident cases is `BinaryBody`, which from a conceptual point of view shouldn't ever concern with the `PRP` except for when being wrapped or unwrapped, as we already have `WrappedMessage` and `UnwrappedMessage` that act as bundles of a message and a spongos state.
…entifier` Also add `Identifier::as_bytes()` to get a borrowed view of the Byte array, besides the owned `Identifier::to_bytes()`
…assert!()` (prev `panic_if_not!()`
These include: - `as_str(&self) -> Option<&str>` - `into_string(self) -> Option<String>` - `From<Vec<u8>> for Bytes` - `From<Bytes> for Vec<u8>` - `From<&[u8]> for Bytes` - `From<[u8; N]> for Bytes` - `From<&[u8; N]> for Bytes` - `AsRef<[u8]> for Bytes`
…ak` benches `core-keccak` benches don't compile, and it is being migrated to crypto.rs, so there's no point in trying to make them work. `app-channels-example` is an example binary that should have its own environment much like `/examples`, specially since it needs nightly and `no-std` to compile.
Commit 655d28c fixed `User::reset_state()` by resetting also the link-store of the user. This is considered the proper behaviour of `User::reset_state()`, as a the common expectancy of a reseted user is for it to be as blank as possible, keeping only its identity data. This change, makes resetted users lose any data of the channel whatsoever, including subscription messages that cannot be recovered by fetching from the Tangle. This makes it a method only to be used in specific scenarios where for security reasons a user needs to trully be reseted; it also renders it not suitable as a means to _just_ replay the channel messages from the announcement message. The examples fixed in this commit were exemplifying the unsubscribe feature after `User::reset_state()` was called, and broke after the explained change for the aforementioned reason.
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.
Overall i'm on board with the cleanup of everything, just a couple questions/comments specifically regarding the stuff in iota-streams-core-edsig
but we'll be addressing those in later PR's i'm sure.
74f5ed1
to
3384221
Compare
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.
About the members array in cargo.toml; I believe we need to rename iota-streams-app-channels-example into a sub folder called "examples/no-std" (and move original example to an std folder?)
@DyrellC @kwek20 What do we want to do with chrono? General consensus is to migrate to time-rs, but I still think we should just remove the timestamp and get rid of the dependency altogether. And if we need/want to properly introduce a timestamp in the Streams messages, we'll deal with the issue then, which whichever crate is best then If you agree, I can remove just the timestamp and the dependency in this PR so that we fix the builds and remove the vulnerability warning, and finish the cleanup in #138 In any case, we need to merge this PR ASAP, to fix the build of the library. |
@arnauorriols I'm of the same opinion, we don't use the timestamp right now for anything and if it's determined that that will be valid to use going forward we can deal with it then. For now we should just remove the dependency and get this bad boy merged. |
Bug was actually in the `try_or` macro of the error_handler module. Macros work strictly at syntactic level. Therefore, expressions passed to a macro are passed literally, before they are evaluated. It's necessary, if one wants to mimic the function-like semantics for the macro invocation, to take extra care not to expand the $expr variable more than once, to avoid triggering its side-effects more than once (unless that's explicitly intended).
70e49d5
to
7fcb6eb
Compare
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.
LGTM!
Beautiful looking green checkmark right there. Let's get the ball rolling! |
Description of change
This PR is a miscellanea of small changes, cleanups and simplifications in preparation for the next PR. The most important changes included are:
PhantomData<F>
from BinaryBodypanic_if_not!()
toassert!()
Bytes
Identifier
Cursor<Link>
This PR depends on #146
Type of change
How the change has been tested
Change checklist