AntTP - Serving Autonomi data over HTTP

So, the main thing to consider is that AntTP treats archives (public or tarchives) as file containers. These make up the base part of a URL. This of them a bit like a ‘host’ in the traditional web.

You can reference files within the archives, which then loads them, much like a file on a regular web server. There is also an app-conf.json, which instructs AntTP to do special routing for SPAs (single page apps), etc.

IMIM is a bit unusual, as it uses routing to link two archives together. The first archive address is the IMIM app code. The second archive address is the blog you’re viewing. The app-conf.json in IMIM essentially allows the IMIM app code to pull the blogs from the blog archive.

Under the hood, IMIM loads from the first archive, then does a REST request for the second archive address. IMIM then converts the markdown to HTML and sends it to the user.

So, if you want to index the resulting blog pages in HTML form, the IMIM app needs to run and build the pages. Alternatively, you can read the blog markdown files directly.

There are easier, simpler, ways to build web pages that would run on AntTP (nextjs, react, etc), but I wanted to go ‘all in’ to see how far I could take the SPA concept with IMIM.

I’m not sure if the above helps or hinders, but maybe the explanation at least guides next steps?

Yeah, they (i.e. gimim, gindex, traktion-blog, etc) are AntTP bookmarks. They are just short names that link to an autonomi address (mutable or immutable). I usually assign them to pointers and then just change the pointer when I update data. The bookmarks are a prequel to a proper name resolution system. They’re handy in the interim though!

EDIT: Just to add, if a file is uploaded without an archive, the address in the URL will point directly to it. A filename suffix can still be appended, but it is largely for convenience, e.g. ‘http://<xor_address>/music.mp3’ will give the browser a hint that it is an MP3 file and attempting to ‘save’ it will populate the save dialogue (in the browser) with this name too. Any filename can be used - the same data will be downloaded in this case.

FWIW, I hope the above is intuitive, as storing files and archives is essentially what ant CLI does with immutables. For mutables, pointers and registers behave as expected too, if used in URLs (i.e. they resolve to the data they point at). You can do more fancy things with web apps using the REST API, but at its core, AntTP serves files from URLs.

7 Likes

Thanks for letting me know. I’ve no idea why Windows takes a notion on stuff like this. Maybe building from source locally would help? Or, using the docker container instead?

2 Likes

Pushed another version with a change to help with failing builds and some minor fixes:

  • Adds cargo.lock for more consistent builds.
  • Improves REST resolving for pointers to accept bookmarks.
  • Improves utoipa/swagger configuration for public_archive_controller.rs

Github: Release v0.15.1 · traktion/AntTP · GitHub
Dockerhub: https://hub.docker.com/r/traktion/anttp
Cargo: cargo install anttp

Edit: @riddim used cargo install --locked anttp with success, if the above fails.

6 Likes

Apologies, I forgot to publish on crates.io. The latest has now been pushed for those cargo install anttp folks!

2 Likes

Just in, been busy all day - now Mrs S wants to go out to eat.
Sometime before the next dawn I will bring this all up to date and see if we have solved the CloudFlare/SSL issue that was no issue for months…

same error again now –
kicked off with

worker@noderunner01:~/safebox-server$ cargo install anttp
    Updating crates.io index
  Downloaded anttp v0.15.1
  Downloaded 1 crate (541.8KiB) in 0.46s
  Installing anttp v0.15.1
    Updating crates.io index
     Locking 756 packages to latest compatible versions
      Adding brotli v3.3.4 (available: v3.5.0)
      Adding brotli-decompressor v2.3.5 (available: v2.5.1)
  Downloaded ant-evm v0.1.17
  Downloaded alloy-chains v0.2.12

snippage

  Compiling alloy-consensus v0.15.11
error[E0433]: failed to resolve: could not find `__private` in `serde`
   --> /home/worker/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alloy-consensus-0.15.11/src/transaction/envelope.rs:916:34
    |
916 |             let content = serde::__private::de::Content::deserialize(deserializer)?;
    |                                  ^^^^^^^^^ could not find `__private` in `serde`

error[E0433]: failed to resolve: could not find `__private` in `serde`
   --> /home/worker/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/alloy-consensus-0.15.11/src/transaction/envelope.rs:918:24
    |
918 |                 serde::__private::de::ContentRefDeserializer::<D::Error>::new(&content);
    |                        ^^^^^^^^^ could not find `__private` in `serde`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `alloy-consensus` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `anttp v0.15.1`, intermediate artifacts can be found at `/tmp/cargo-installrU7VJw`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
1 Like

Try cargo install anttp --locked

2 Likes

Thank you - that worked :slight_smile:

Compiling chunk-streamer v0.4.3
   Compiling anttp v0.15.1
    Finished `release` profile [optimized] target(s) in 9m 29s
   Replacing /home/worker/.cargo/bin/anttp
    Replaced package `anttp v0.13.0` with `anttp v0.15.1` (executable `anttp`)

Need to go out now, so I have not tried anntp.antsnest.site/gindex yet.

Prob be a CF/SSL fail though - later…

EDT : just seen msgs from @Traktion and @safemedia - I’ll look at it later tonight.

1 Like

anttp.antsnest.site is back up now

2 Likes

New AntTP v0.15.2 released:

  • Improves type conversion safety.
  • Fixes the new GET /anttp-0/binary/public_data/{address} endpoint to return public data correctly.
  • Reduces caching duplication for archives (where chunks are already cached).
  • Adds path filters to JSON directory listings to mirror HTML listings.

Github: Release v0.15.2 · traktion/AntTP · GitHub
Dockerhub: https://hub.docker.com/r/traktion/anttp
Cargo: cargo install anttp

Edit: You may still need to cargo install anttp --locked if it fails to build.

13 Likes

AntTP v0.15.4 has been released:

  • Bumped chunk-streamer version, which includes AARM64/android fixes.
  • Builds bookmarks map at init to avoid having to iterate through vector to resolve.
  • Adds pointer_existence_check to pointer_caching_client for rapid checks.
  • Adds bookmark resolving to register service, to allow bookmarks to be used for gets and updates (same as pointers).
  • Experimental improvements to analyze_simple performance (disabled).
  • Minor refactors/improvements.

The big news is the AARM64 (Android) fixes!

Termux can now be used to launch anttp in the background again, but this time power saving features are present. In short, unless you are using AntTP, it barely touches the battery now.

When browsing sites with AntTP, cached data is also very battery efficient. When it has to connect to the network, it will use a bit more juice, but it’s pretty good.

Github: Release v0.15.4 · traktion/AntTP · GitHub
Dockerhub: https://hub.docker.com/r/traktion/anttp
Cargo: cargo install anttp

Edit: You may still need to cargo install anttp --locked if it fails to build.

15 Likes

New AntTP release time and this one is a bit of a whopper!

  • Migrates from adhoc async command execution (for uploads) to an async command queue. Implementation uses tokio channels.
  • Allows more control over command sequencing and better monitoring of progress. The command sequence is serialised to ensure order is maintained (retries and optional parallelism can be added later).
  • Enables each command to be encapsulated via the command pattern, reducing complexity in the caching client.
  • Further decouples caching from uploads, allowing immediate cache updates for all uploads (mutable and immutable data). Allows low latency HTTP client experience, while slow commands are executed, in sequence, in the background.
  • Simplifies REST API for Scratchpads.
  • Improvements to API for Scratchpads, Registers Swagger docs
  • Refactors to move command module to within client module.
  • Adds GetPointerCommand and CheckPointerCommand, GetGraphEntryCommand, GetPointerCommand, GetRegisterCommand, GetScratchpadCommand, to get latest version and cache it (with TTL). Allows background refreshing of cache.
  • Client logic moved to above commands to simplify.
  • Reduced lock time for autonomi client, as doesn’t need exclusive access. This reduces latency, improving response times.
  • Removes locks from client retrieval in CreateChunkCommand and ChunkGetter to improve performance.
  • Adds command endpoint to return the status of background commands. These include updating the cache for mutables, as well as mutable and immutable uploads.
  • Updates supporting command and models for commands.
  • Reduced logging noise

The big news are the changes to the way background tasks are handled. They used to be fired off as adhoc async jobs, but that made them isolated and harder to control or monitor. These are now moved to a channels based queue, allowing them to be executed in order, with possibilities to retry on error, etc.

There is a new /anttp-0/command swagger endpoint to go with this too. If you are running a local instance, you can see this in the usual Swagger interface: http://localhost:18888/swagger-ui/

They say pictures are worth a thousand words, so here are some:

The command log of background refreshes of the pointer cache, when hitting pages which resolve pointers to data:

Uploading a tar file with Swagger:

Then seeing the associated background command, along with when it was waiting in the queue, when it started running and when it completed.

The time figures are in milliseconds and took about 17s to upload the 2.5 MB test file (for those interested!). However, the upload page returned instantly, with the sync to the network happening in the background. EDIT: Actually, the tar file had already been uploaded, so that 17s was validating all the chunks were present - it usually takes a bit longer, which is why background tasks are nice!

To complete the picture, the AntTP log during the upload:

So, what does this all mean? Why is it important?

The goal is a slick user experience. When using AntTP web apps on Autonomi (like IMIM), two things are important:

  1. The user isn’t sitting waiting for something to happen on the UI. They want to do the action, it happen immediately, then do something else.
  2. The UI dev complexity should be as low as possible. Having a mechanism to easily post data, then easily check the status of it later is useful for this. The new command endpoint can be searched for associated tasks, then surfaced to the UI as appropriate.

Autonomi is a distributed network that thrives on being ‘eventually consistent’. This new logic embraces that behaviour, allowing the AntTP to sync with the Autonomi network without interrupting or slowing down the user flow - instead of the user waiting 17s to upload a file, it feels immediate to the user.

But isn’t the data unavailable until it is uploaded? To other people, this is true. For the user interacting with AntTP, the data is all persisted to the cache prior to the background upload. This means everything feels like it has been uploaded! Pointers, registers, scratchpads, chunks, etc… all of them are immediately accessible, creating a silky smooth user experience.

IMIM already takes advantage of these features and I’ll be adding some logic to surface the command endpoint results too. The plan is to have a status icon on the page, that will notify if there is a network sync issue. The rest of the time, it will just be out of the way of annoying the user.

Moreover, IMIM uses pointers for blogs and the app itself. These are refreshed in the background command queue now. You always get the last value, then it retrieves the latest in the background for the next request. Given there can be many duplicate pointer lookups, the new queue will discard duplicate requests (TODO: there is a bit of work to include the time-to-live again here, but that’s trivial and I’ll add it to the next release).

Anyway, probably a bit of a technical one, but I hope to do some demos with IMIM to show it all working soon!

Github: Release v0.16.2 · traktion/AntTP · GitHub
Dockerhub: https://hub.docker.com/r/traktion/anttp
Cargo: cargo install anttp

Edit: You may still need to cargo install anttp --locked if it fails to build.

19 Likes

amazing stuff :building_construction:

5 Likes

@safemedia

I’m updating anttp both locally and on antsnest.site.
Anything else I should do?

3 Likes

Not really, should just work I think. You would have to edit the code a little if you want to add some custom configs for the cache etc.

4 Likes

Friday night as well I’ll need to sober up to even have a chance of comprehending this !!

5 Likes

New AntTP v0.16.4 released

  • Bumps version of autonomi and chunk-streamer libraries
  • Bumps of supporting libraries
  • Improves command error handling
  • Adds retryable errors with 5 attempts and an exponential backoff.
  • Removes stale command details from the executor_map to prevent unbounded growth

This improves on the command executor from the last big release.

It also adds support for cheaper uploads and bootstrap caching improvements that came with the latest autonomi libraries.

Github: Release v0.16.4 · traktion/AntTP · GitHub
Dockerhub: https://hub.docker.com/r/traktion/anttp
Cargo: cargo install anttp

Edit: You may still need to cargo install anttp --locked if it fails to build.

10 Likes

I would like to understand more about how the autonomi proxy works. I don’t fully understand what it does or how to use it, I know what a proxy is but there are things I am missing.

Would it be possible with some form of youtube tutorial on how it mainly works and how to set it up. :folded_hands:

3 Likes

I’m planning on doing a series of youtube videos on what it is, how it works and what it can be used for over the coming weeks. Hopefully, that will help to answer a lot of questions.

The readme at the repo gives some further commentary for now, but as a summary, just think of it as a HTTP wrapper for the Autonomi library. HTTP being the primary protocol for web browsers.

AntTP pretty much echos how the ant CLI works too. However, it treats pointers and registers as symbolic links / shortcuts to other data when use in URLs.

The is also a REST API for manipulating mutable types, archives, etc. These can be used to build dynamic web apps, etc.

8 Likes