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

audit our examples #1929

Closed
3 of 7 tasks
b5 opened this issue Jan 5, 2024 · 11 comments · Fixed by #1981
Closed
3 of 7 tasks

audit our examples #1929

b5 opened this issue Jan 5, 2024 · 11 comments · Fixed by #1981
Assignees
Labels
c-iroh c-iroh-bytes c-iroh-net docs Improvements or additions to documentation
Milestone

Comments

@b5
Copy link
Member

b5 commented Jan 5, 2024

a user on our discord has pointed out that our examples need a cleanup to match recent changes. We should do an audit of examples & make sure they're up to date by confirming each example works as described.

  • /iroh/examples/client.rs
  • /iroh/examples/collection.rs
  • /iroh/examples/dump-blob-fsm.rs
  • /iroh/examples/hello-world.rs
  • /iroh/examples/stream.rs
  • /iroh-net/examples/magic.rs
  • /iroh-gossip/examples/chat.rs
@s2dd
Copy link

s2dd commented Jan 5, 2024

/iroh/iroh/examples/collection has hardcoded

    // print the ticket, containing all the above information
    println!("in another terminal, run:");
    println!("\t$ cargo run -- get --ticket {}", ticket);
    // wait for the node to finish, this will block indefinitely
    // stop with SIGINT (ctrl+c)
    node.await?;

where i today need use console and there issue blob get <ticket> produced from example.

@s2dd
Copy link

s2dd commented Jan 5, 2024

Stated in the README.md
"At the top of each example file is a comment describing how to run the example."
more then often outdated ...

@ramfox
Copy link
Contributor

ramfox commented Jan 5, 2024

for /iroh-net/examples/magic.rs specifically:
I believe when a user looks at an example called "magic" they believe that it's meant to magically connect via just node_id, but I'm pretty sure the intention here is to just show how to use MagicEndpoint

we should:

  • write docs that talk about the intention of the example
  • mention that if you supply a direct addr only on connect, you may not be able to connect if you require any hole-punching

for the listen command:

  • print out all of our known addrs
  • print out all of our derp urls
  • print out what command should be run in another terminal to connect correctly
  • allow overrides for bind-port and derp-url are "global", but should really be moved to listen (since the connect command has a derp-url parameter that isn't global as well)

for the connect command:

  • don't allow the command to run if you don't have one of addr or derp_url

However, if we are supposed to show that we can magically connect via just node id, we need to add default derp_urls to the connect command.

edit:
we decided that we are better off showing an example that is simpler & does not allow for much configuration. mentioned below: #1929 (comment)

@s2dd
Copy link

s2dd commented Jan 5, 2024

if no derp_url use default_derp_url

besides node-id , addr , maybe a ticket with derp_urlembeded = calling-card

@ramfox
Copy link
Contributor

ramfox commented Jan 5, 2024

if no derp_url use default_derp_url

besides node-id , addr , maybe a ticket with derp_urlembeded = calling-card

if the examples are there to educate someone about what MagicEndpoint does and how to start understanding/coding with it, then adding a default_derp_url and wrapping everything in a ticket is depriving the dev of learning how to use MagicEndpoint

so I'm not sure I would want to hide these here. For any example in the github.com/n0-computer/iroh-examples repo, I think we should definitely use tickets and defaults.

just an opinion ¯_(ツ)_/¯ not married to it

@s2dd
Copy link

s2dd commented Jan 5, 2024

i am in favor of dynamic derps in calling-cards and tickets
find for my use-cases need own derp in open but closed for the wild p2p's
having default hardcoded derps is fine but if --derp-url is provided should take precedence ?

so its like if You don't need it You have it ...

@s2dd
Copy link

s2dd commented Jan 8, 2024

@b5 i can not find /iroh/examples/stream.rs mentioned above

@s2dd
Copy link

s2dd commented Jan 8, 2024

@b5 but there is a `/iroh/examples/rpc.rs

that i can not get to work ...

"
//! An example that runs an iroh node that can be controlled via RPC.
//!
//! Run this example with
//! $ cargo run --example rpc
//! Then in another terminal, run any of the normal iroh CLI commands, which you can run from
//! cargo as well:
//! $ cargo run node stats
//! The node stats command will reach out over RPC to the node constructed in the example
"
after run --example rpc
and then issue run node stats i get

Error: rpc connect

Caused by:
    iroh is not running, please start it

@s2dd
Copy link

s2dd commented Jan 8, 2024

https://iroh.computer/docs/quickstart

when try start node B per documentation
$ export IROH_DATA_DIR=./
$ iroh start --rpc-port 1111

no joy

configuration option flag --rpc-port do not exist in
[package]
name = "iroh"
version = "0.12.0"

maybe reference version in documentation´s

i see there is auto for 0.12.0
$ iroh start

RPC port 4919 already in use, switching to random port

but how to start console for node B port ?

need run node B on other ip for example

@s2dd
Copy link

s2dd commented Jan 8, 2024

my comment so far is code is very clean but documentation for version examples ++ is lagging.

@ramfox ramfox added this to the v0.13.0 milestone Jan 11, 2024
@ramfox
Copy link
Contributor

ramfox commented Jan 20, 2024

TODO:

  • add "fetch" side of the simple examples for hello_world & collection @ramfox
  • /iroh/examples/dump-blob-fsm.rs should remove references to iroh-net (& use direct quic connections instead), and be moved to iroh-bytes @flub
  • /iroh/examples/dump-blob-stream.rs should do the same @flub
  • /iroh-net/examples/magic.rs should be largely simplified, taking out any CLI / clap, and expecting the direct addrs and derp URL as arguments (not supplied by flags)

@ramfox ramfox added docs Improvements or additions to documentation c-iroh-net c-iroh-bytes c-iroh labels Jan 22, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 29, 2024
## Description

Fixes incorrect information in our `iroh/examples`

Also adds an example that shows the most basic way to use iroh to fetch
content.

related to #1929 

## Notes & open questions

Unfortunately, we don't seem to have very simple APIs for fetching (that
isn't just exporting the content to an external path). Working through
this.

Also adds:
- `BlobDownloadProgress` - this takes a stream of `DownloadProgress` and
puts it into a form that will poll the stream by calling `finish`
- adjusts the `blob_download0` function to not eat certain errors

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
github-merge-queue bot pushed a commit that referenced this issue Feb 1, 2024
## Description

closes #1929 

### `provide-bytes`
This example adds either a single blob or collection to the database and
provides it. It gives instructions on how to run the fetch side of the
example for `fetch-fsm` and `fetch-stream`.

We could make this example more "advanced" by having the user provide a
path & serve the blob or collection of that content, but I wanted to
keep its simple at first.

### `fetch-fsm`
This example fetches a blob or collection using the `get` finite state
machine directly, printing the contents to the terminal.

### `fetch-stream`
This example fetches a blob or collection using a helper function to
turn the `get` finite state machine into a stream. It prints the
contents to the terminal.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [ ] Tests if relevant.
fubuloubu pushed a commit to ApeWorX/iroh that referenced this issue Feb 21, 2024
## Description

Fixes incorrect information in our `iroh/examples`

Also adds an example that shows the most basic way to use iroh to fetch
content.

related to n0-computer#1929 

## Notes & open questions

Unfortunately, we don't seem to have very simple APIs for fetching (that
isn't just exporting the content to an external path). Working through
this.

Also adds:
- `BlobDownloadProgress` - this takes a stream of `DownloadProgress` and
puts it into a form that will poll the stream by calling `finish`
- adjusts the `blob_download0` function to not eat certain errors

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
fubuloubu pushed a commit to ApeWorX/iroh that referenced this issue Feb 21, 2024
## Description

closes n0-computer#1929 

### `provide-bytes`
This example adds either a single blob or collection to the database and
provides it. It gives instructions on how to run the fetch side of the
example for `fetch-fsm` and `fetch-stream`.

We could make this example more "advanced" by having the user provide a
path & serve the blob or collection of that content, but I wanted to
keep its simple at first.

### `fetch-fsm`
This example fetches a blob or collection using the `get` finite state
machine directly, printing the contents to the terminal.

### `fetch-stream`
This example fetches a blob or collection using a helper function to
turn the `get` finite state machine into a stream. It prints the
contents to the terminal.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [ ] Tests if relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-iroh c-iroh-bytes c-iroh-net docs Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants