Skip to content

Commit

Permalink
Merge pull request #852 from freenet/develop
Browse files Browse the repository at this point in the history
Fix more documentation naming
  • Loading branch information
iduartgomez authored Sep 27, 2023
2 parents d8170ea + 3ae9755 commit b6fdaca
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 69 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<a href="https://github.com/freenet/freenet-core/actions/workflows/ci.yml">
<img src="https://img.shields.io/github/actions/workflow/status/freenet/locutus/ci.yml?branch=main&label=tests&style=flat-square" alt="continuous integration status" />
</a>
<a href="https://crates.io/crates/locutus">
<img src="https://img.shields.io/crates/v/locutus.svg?style=flat-square"
<a href="https://crates.io/crates/freenet">
<img src="https://img.shields.io/crates/v/freenet.svg?style=flat-square"
alt="Crates.io version" />
</a>
<a href="https://matrix.to/#/#freenet-locutus:matrix.org">
Expand Down
30 changes: 1 addition & 29 deletions crates/core/src/runtime/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use wasmer::{Instance, TypedFunction};

use super::error::RuntimeInnerError;
use super::{util, ContractError, Runtime, RuntimeResult};
use super::{ContractError, Runtime, RuntimeResult};

#[derive(Debug, Serialize, Deserialize)]
pub enum Response {
Expand Down Expand Up @@ -216,16 +216,6 @@ impl Runtime {
context.user_response.insert(req_id, response);
last_context = DelegateContext::new(bincode::serialize(&context).unwrap());
}
OutboundDelegateMsg::RandomBytesRequest(bytes) => {
let mut bytes = vec![0; bytes];
util::generate_random_bytes(&mut bytes);
let inbound = InboundDelegateMsg::RandomBytes(bytes);
let new_outbound_msgs =
self.exec_inbound(params, attested, &inbound, process_func, instance)?;
for msg in new_outbound_msgs.into_iter() {
outbound_msgs.push_back(msg);
}
}
OutboundDelegateMsg::ContextUpdated(context) => {
last_context = context;
}
Expand Down Expand Up @@ -337,24 +327,6 @@ impl DelegateRuntimeInterface for Runtime {
&mut results,
)?;
}
InboundDelegateMsg::RandomBytes(bytes) => {
let mut outbound = VecDeque::from(self.exec_inbound(
params,
attested,
&InboundDelegateMsg::RandomBytes(bytes),
&process_func,
&running.instance,
)?);
self.get_outbound(
delegate_key,
&running.instance,
&process_func,
params,
attested,
&mut outbound,
&mut results,
)?;
}
InboundDelegateMsg::GetSecretRequest(GetSecretRequest {
key: secret_key, ..
}) => {
Expand Down
8 changes: 0 additions & 8 deletions crates/core/src/runtime/util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
use rand::{rngs::ThreadRng, Rng};

#[inline]
pub fn generate_random_bytes(output: &mut [u8]) {
let mut rng = ThreadRng::default();
for element in output {
*element = rng.gen();
}
}
22 changes: 11 additions & 11 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

# Introduction

## What is Locutus?
## What is Freenet?

Locutus is a global, [observable](https://en.wikipedia.org/wiki/Small-world_network), decentralized key-value store. Values are arbitrary blocks of data, called the contract's "state." Keys are cryptographic contracts that specify:
Freenet is a global, [observable](https://en.wikipedia.org/wiki/Small-world_network), decentralized key-value store. Values are arbitrary blocks of data, called the contract's "state." Keys are cryptographic contracts that specify:

- Whether a given state is permitted under this contract
- How the state can be modified over time
- How two valid states can be merged
- How to efficiently synchronize a contract's state between peers

Locutus is a true decentralized peer-to-peer network, and is robust and scalable, through its use of a [small-world network](https://en.wikipedia.org/wiki/Small-world_network).
Freenet is a true decentralized peer-to-peer network, and is robust and scalable, through its use of a [small-world network](https://en.wikipedia.org/wiki/Small-world_network).

Applications on Locutus can be built in any language that is supported by web browsers, including JavaScript and WebAssembly. These applications are distributed over Locutus and can create, retrieve, and update contracts through a WebSocket connection to the local Locutus peer.
Applications on Freenet can be built in any language that is supported by web browsers, including JavaScript and WebAssembly. These applications are distributed over Freenet and can create, retrieve, and update contracts through a WebSocket connection to the local Freenet peer.

## Writing a Contract

Locutus contracts can be written in any language that compiles to WebAssembly.
Freenet contracts can be written in any language that compiles to WebAssembly.
This includes [Rust](https://www.rust-lang.org/), and
[AssemblyScript](https://www.assemblyscript.org/), among many others.

Expand All @@ -27,17 +27,17 @@ A contract can be retrieved using a key, which is a cryptographic hash derived f

## Small world routing

Locutus peers self-organize into a [small-world network](https://en.wikipedia.org/wiki/Small-world_routing) to allow contracts to be found in a fast, scalable, and decentralized way.
Freenet peers self-organize into a [small-world network](https://en.wikipedia.org/wiki/Small-world_routing) to allow contracts to be found in a fast, scalable, and decentralized way.

Every peer in Locutus is assigned a number between 0 and 1 when it first joins the network, this is the peer's "location". The small world network topology ensures that peers with similar locations are more likely to be connected.
Every peer in Freenet is assigned a number between 0 and 1 when it first joins the network, this is the peer's "location". The small world network topology ensures that peers with similar locations are more likely to be connected.

Contracts also have a location, which is derived from the contract's key. Peers cache contracts close to their locations.

## Writing an Application

Creating a decentralized application on Locutus is very similar to creating a normal web application. You can use familiar frameworks like React, Bootstrap, Angular, Vue.js, and so on.
Creating a decentralized application on Freenet is very similar to creating a normal web application. You can use familiar frameworks like React, Bootstrap, Angular, Vue.js, and so on.

The main difference is that instead of connecting to a REST API running on a server, the web application connects to the Locutus peer running on the local computer through a [WebSocket](https://en.wikipedia.org/wiki/WebSocket) connection.
The main difference is that instead of connecting to a REST API running on a server, the web application connects to the Freenet peer running on the local computer through a [WebSocket](https://en.wikipedia.org/wiki/WebSocket) connection.

Through this the application can:

Expand All @@ -51,11 +51,11 @@ Contracts are extremely flexible. they can be used to create decentralized data

## Delegate Ecosystem

Applications in Locutus don't need to be built from scratch, they can be built on top of components provided by us or others.
Applications in Freenet don't need to be built from scratch, they can be built on top of components provided by us or others.

### Reputation system

Allows users to build up reputation over time based on feedback from those they interact with. Think of the feedback system in services like Uber, but with Locutus it will be entirely decentralized and cryptographically secure. It can be used for things like spam prevention (with IM and email), or fraud prevention (with an online store).
Allows users to build up reputation over time based on feedback from those they interact with. Think of the feedback system in services like Uber, but with Freenet it will be entirely decentralized and cryptographically secure. It can be used for things like spam prevention (with IM and email), or fraud prevention (with an online store).

This is conceptually similar to Freenet's [Web of Trust](http://www.draketo.de/english/freenet/friendly-communication-with-anonymity) plugin.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/contract-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Interface

Locutus contracts must implement the contract interface from [stdlib/rust/src/contract_interface.rs](https://github.com/freenet/freenet-core/blob/main/stdlib/rust/src/contract_interface.rs):
Freenet contracts must implement the contract interface from [stdlib/rust/src/contract_interface.rs](https://github.com/freenet/freenet-core/blob/main/stdlib/rust/src/contract_interface.rs):

```rust,no_run,noplayground
{{#include ../../stdlib/rust/src/contract_interface.rs:contractifce}}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cd docker
docker compose build
```

## Running Locutus Node from the docker image
## Running Freenet from the docker image

Note: Currently the node will not pick up new contracts when they are published.
Make sure the node is stopped and re-started after new contracts are added.
Expand Down
12 changes: 6 additions & 6 deletions docs/src/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Application

Software that uses Locutus as a back-end. This includes native software
distributed independenly of Locutus but which uses Locutus as a back-end
(perhaps bundling Locutus), and [web applications](glossary#web-application)
that are distributed over Locutus and run in a web browser.
Software that uses Freenet as a back-end. This includes native software
distributed independenly of Freenet but which uses Freenet as a back-end
(perhaps bundling Freenet), and [web applications](glossary#web-application)
that are distributed over Freenet and run in a web browser.

## Contract

Expand All @@ -24,7 +24,7 @@ the web proxy.
For example, if the contract id is
`6C2KyVMtqw8D5wWa8Y7e14VmDNXXXv9CQ3m44PC9YbD2` then visiting
`http://localhost:PORT/contract/web/6C2KyVMtqw8D5wWa8Y7e14VmDNXXXv9CQ3m44PC9YbD2`
will cause the application/component to be retrieved from Locutus, decompressed,
will cause the application/component to be retrieved from Freenet, decompressed,
and sent to the browser where it can execute.

## Contract State
Expand Down Expand Up @@ -78,7 +78,7 @@ consistency](https://en.wikipedia.org/wiki/Eventual_consistency).

## Web Application

Software built on Locutus and distributed through Locutus.
Software built on Freenet and distributed through Freenet.

Applications run in the browser and can be built with tools like React,
TypeScript, and Vue.js. An application may use multiple components and
Expand Down
20 changes: 10 additions & 10 deletions docs/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Mac (for Windows see [here](https://rustup.rs)):
curl https://sh.rustup.rs -sSf | sh
```

### Locutus Dev Tool (LDT)
### Freenet Dev Tool (LDT)

Once you have a working installation of Cargo you can install the Locutus dev
Once you have a working installation of Cargo you can install the Freenet dev
tools:

```bash
cargo install freenet
```

This command will install `fdev` (Locutus Dev Tool) and a working Freenet kernel that can
This command will install `fdev` (Freenet development tool) and a working Freenet kernel that can
be used for local development.

### Node.js and TypeScript
Expand Down Expand Up @@ -83,13 +83,13 @@ fdev new web-app
```

will create the skeleton for a web application and its container contract for
Locutus ready for development at the `my-app/web` directory.
Freenet ready for development at the `my-app/web` directory.

## Making a container contract

The first thing that we need is to write the code for our container contract.
This contract's role is to contain the web application code itself, allowing it
to be distributed over Locutus.
to be distributed over Freenet.

The `new` command has created the source ready to be modified for us, in your
favorite editor open the following file:
Expand Down Expand Up @@ -122,7 +122,7 @@ That's a lot of information, let's unpack it:
use freenet_stdlib::prelude::*;
```

Here we are importing the necessary types and traits to write a Locutus contract
Here we are importing the necessary types and traits to write a Freenet contract
successfully using Rust.

```rust,noplayground
Expand Down Expand Up @@ -167,7 +167,7 @@ which does not do anything yet. To change this, we will start developing our web
application.

To do that, we can go and modify the code of the contract state, which in this
case is the web application. Locutus offers a standard library (stdlib) that can
case is the web application. Freenet offers a standard library (stdlib) that can
be used with Typescript/JavaScript to facilitate the development of web
applications and interfacing with your local node, so we will make our
`package.json` contains the dependency:
Expand Down Expand Up @@ -378,7 +378,7 @@ HTTP gateway access and then we can re-use it for publishing additional
contracts.

<!--
TODO: Publishing to the real functioning Locutus network is not yet supported.
TODO: Publishing to the real functioning Freenet network is not yet supported.
-->

Currently, wep applications follow a standarized build procedure in case you use
Expand Down Expand Up @@ -470,7 +470,7 @@ You should see some logs printed via the stdout of the process indicating that
the node HTTP gateway is running.

Once the HTTP gateway is running, we are ready to publish the contracts to our
local Locutus node:
local Freenet node:

```bash
cd ../backend && fdev publish --code="./build/freenet/backend.wasm" --state="./build/freenet/contract-state"
Expand All @@ -497,7 +497,7 @@ to new contracts, and evolving it over time.

## Limitations

- Publishing to the Locutus network is not yet supported.
- Publishing to the Freenet network is not yet supported.
- Only Rust is currently supported for contract development, but we'll support
more languages like [AssemblyScript](https://www.assemblyscript.org/) in the
future.
Expand Down

0 comments on commit b6fdaca

Please sign in to comment.