Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Various cleanups and niceties #150

Merged

Conversation

arnauorriols
Copy link
Contributor

@arnauorriols arnauorriols commented Sep 18, 2021

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:

This PR depends on #146

Type of change

  • Enhancement (a non-breaking change which cleans up code)

How the change has been tested

Change checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Arnau Orriols added 17 commits September 9, 2021 11:48
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()`
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`
@arnauorriols arnauorriols mentioned this pull request Sep 18, 2021
21 tasks
@arnauorriols arnauorriols marked this pull request as ready for review October 11, 2021 14:55
iota-streams-app/src/identifier.rs Show resolved Hide resolved
iota-streams-app/src/message/binary.rs Outdated Show resolved Hide resolved
iota-streams-app/src/message/binary.rs Outdated Show resolved Hide resolved
iota-streams-app/src/transport/tangle/mod.rs Show resolved Hide resolved
@arnauorriols arnauorriols changed the base branch from support-selecting-transport-in-examples-with-env to develop October 29, 2021 09:15
Arnau Orriols added 3 commits October 30, 2021 00:45
…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.
Copy link
Contributor

@DyrellC DyrellC left a 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.

bindings/c/main.c Show resolved Hide resolved
bindings/wasm/examples/node.js Show resolved Hide resolved
iota-streams-app-channels/src/api/user.rs Outdated Show resolved Hide resolved
iota-streams-app/src/identifier.rs Show resolved Hide resolved
iota-streams-app/src/message/binary.rs Outdated Show resolved Hide resolved
iota-streams-app/src/message/binary.rs Outdated Show resolved Hide resolved
iota-streams-core/src/errors/error_handler.rs Show resolved Hide resolved
@arnauorriols arnauorriols force-pushed the remove-phantomdata-from-binarybody-et-al branch from 74f5ed1 to 3384221 Compare November 3, 2021 01:00
Copy link
Contributor

@kwek20 kwek20 left a 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?)

@arnauorriols
Copy link
Contributor Author

arnauorriols commented Jan 25, 2022

@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.

@DyrellC
Copy link
Contributor

DyrellC commented Jan 25, 2022

@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.

Arnau Orriols added 4 commits January 27, 2022 13:09
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).
@arnauorriols arnauorriols force-pushed the remove-phantomdata-from-binarybody-et-al branch 2 times, most recently from 70e49d5 to 7fcb6eb Compare January 27, 2022 23:05
Copy link
Contributor

@kwek20 kwek20 left a comment

Choose a reason for hiding this comment

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

LGTM!

@DyrellC
Copy link
Contributor

DyrellC commented Jan 28, 2022

Beautiful looking green checkmark right there. Let's get the ball rolling!

@DyrellC DyrellC merged commit eb1ca1d into iotaledger:develop Jan 28, 2022
@arnauorriols arnauorriols deleted the remove-phantomdata-from-binarybody-et-al branch July 1, 2022 08:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants