Skip to content

Commit

Permalink
Merge branch 'master' into bump-spell
Browse files Browse the repository at this point in the history
  • Loading branch information
nahsi committed Feb 24, 2023
2 parents ac5b109 + 2c11e35 commit 7cd1cc7
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 67 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ on:
description: "whether to update node-distro"
required: true

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"

jobs:
rust-peer:
runs-on: builder
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Contribute Code

You are welcome to contribute to Fluence.
You are welcome to contribute to Fluence!

Things you need to know:

1. You need to **agree to the Contributors License Agreement**. This is a common practice in all major Open Source projects. At the current moment we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.
2. **Not all proposed contributions can be accepted**. Some features may e.g. just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.
1. You need to **agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7) (CLA)**. This is a common practice in all major Open Source projects. At the current moment, we are unable to accept contributions made on behalf of a company. Only individual contributions will be accepted.

2. **Not all proposed contributions can be accepted**. Some features may, e.g., just fit a third-party add-on better. The contribution must fit the overall direction of Fluence and really improve it. The more effort you invest, the better you should clarify in advance whether the contribution fits: the best way would be to just open an issue to discuss the contribution you plan to make.

### Contributor License Agreement

When you contribute, you have to be aware that your contribution is covered by **Apache License 2.0**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**.
In particular you need to agree to the [Contributor License Agreement](https://gist.github.com/fluencelabs-org/3f4cbb3cc14c1c0fb9ad99d8f7316ed7). If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.
When you contribute, you have to be aware that your contribution is covered by **[Apache License 2.0](./LICENSE)**, but might relicensed under few other software licenses mentioned in the **Contributor License Agreement**. In particular, you need to agree to the Contributor License Agreement. If you agree to its content, you simply have to click on the link posted by the CLA assistant as a comment to the pull request. Click it to check the CLA, then accept it on the following screen if you agree to it. The CLA assistant will save this decision for upcoming contributions and will notify you if there is any change to the CLA in the meantime.
70 changes: 23 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,43 @@
# Fluence Project
# Rust Peer

**Fluence is a peer-to-peer computing protocol and a software licensing
system.**
Rust Peer is the reference implementation of the [Fluence](https://fluence.network) peer. It is used as a Relay for all Clients and as a Host for all Workers.

_The project is a work in progress!_

[fluence.network](https://fluence.network)
## Installation and Usage

See the [Vision manifesto](http://fluence.one/manifesto.html), follow updates on
[Twitter](https://twitter.com/fluence_project) or subscribe to the
[newsletter](https://fluence.network/).
Rust peer is distributed in [rust-peer-distro repo](https://github.com/fluencelabs/rust-peer-distro) as a [docker image](https://github.com/fluencelabs/rust-peer-distro/releases). To start a local instance of Rust peer, run:

For documentation, go [here](https://fluence.dev/)
```bash
docker pull fluencelabs/rust-peer:latest
docker run -d --name fluence -e RUST_LOG="info" -p 7777:7777 -p 9999:9999 fluencelabs/rust-peer:latest --local --keypair-value=gKdiCSUr1TFGFEgu2t8Ch1XEUsrN5A2UfBLjSZvfci9SPR3NvZpACfcpPGC3eY4zma1pk7UvYv5zb1VjvPHwCjj
```

# Fluence stack
This will setup a network of one Rust peer and an IPFS sidecar, not connected to any other network. Next, run some [Aqua](https://github.com/fluencelabs/aqua) against it:

| Layer | Tech | Scale | State | Based on |
| :-------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------: | :-------------------------------: | :----------------------------------------------------------------------------------------------------------: |
| Execution | [Marine](https://github.com/fluencelabs/marine) | Single peer | Disk, network, external processes | Wasm, [IT](https://github.com/fluencelabs/interface-types), [Wasmer*](https://github.com/fluencelabs/wasmer) |
| Composition | [Aqua](https://github.com/fluencelabs/aqua) | Involved peers | Results and signatures | ⇅, π-calculus |
| Topology | [TrustGraph](https://github.com/fluencelabs/fluence/tree/master/trust-graph), [DHT*](https://github.com/fluencelabs/rust-libp2p) | Distributed with Kademlia* algo | Actual state of the network | [libp2p](https://github.com/libp2p/rust-libp2p) |
| Security & Accounting | Blockchain | Whole network | Licenses & payments | substrate? |
```bash
npm i -g @fluencelabs/aqua@unstable
aqua remote list_modules --addr /ip4/127.0.0.1/tcp/9999/ws/p2p/12D3KooWKEprYXUXqoV5xSBeyqrWLpQLLH4PXfvVkDJtmcqmh5V3
```

<br/>
For more info about the docker image (image version flavours, environment variables, deployment examples) and documentation for Rust peer operators, see the [rust-peer-distro](https://github.com/fluencelabs/rust-peer-distro) repository.

<p width="100%">
<img alt="aquamarine scheme" align="center" src="images/aqua_marine_stack.png"/>
</p>

## Quick summary
## Documentation

Fluence protocol aims to empower internet applications with interoperability,
resilience, and security. Fluence makes it possible to publish, run, compose,
and monetize applications without intermediaries or central servers.
Comprehensive documentation on everything related to Fluence can be found [here](https://fluence.dev/). Check also our [YouTube channel](https://www.youtube.com/@fluencelabs).

- **Fluence** is an open runtime for internet applications. A purely
peer-to-peer architecture allows to build distributed applications without
reliance on centralized platforms. Fluence incorporates concepts of Web of
Trust, DPKI, S/Kademlia, and is built with libp2p and WebAssembly.
- **Fluence** is a business model for the open source. Fluence enables the
blockchain-based software licensing system, allowing authors to earn income
from their applications usage over the protocol. The infrastructure
maintenance is outsourced to the open market of compute providers via the Open
Source as a Service (OSaaS) model.

## Run
## Support

### Prebuilt docker image
Please, file an [issue](https://github.com/fluencelabs/rust-peer/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.

```bash
docker run -d --name fluence -e RUST_LOG="info" -p 7777 -p 9999 fluencelabs/fluence
```

Ports will be assigned randomly by your OS.
## Contributing

Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic [rules](./CONTRIBUTING.md). The Contributor License Agreement can be found [here](./FluenceCLA).

## **Contributing**

While the project is a still in the early stage of development, you are welcome
to track progress and contribute. At the current moment we don't have detailed
instructions on how to join development or which code guidelines to follow.
However, you can expect more info to appear soon enough. In the meanwhile, check
out the [basic contributing rules](CONTRIBUTING.md).
## License

## **License**
All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](./LICENSE) license.

[Apache 2.0](LICENSE)
2 changes: 1 addition & 1 deletion crates/builtins-deployer/src/builtins_deployer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl BuiltinsDeployer {

let result = self
.send_particle(script, hashmap! {"name".to_string() => json!(name)})
.wrap_err(format!("remove_service call failed, service {}", name))?;
.wrap_err(format!("remove_service call failed, service {name}"))?;

assert_ok(result, "remove_service call failed")
}
Expand Down
9 changes: 8 additions & 1 deletion crates/key-manager/src/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::error::KeyManagerError::{
CannotExtractRSASecretKey, CreateKeypairsDir, DeserializePersistedKeypair,
ReadPersistedKeypair, SerializePersistedKeypair, WriteErrorPersistedKeypair,
};
use crate::KeyManager;
use fluence_keypair::KeyPair;
use fluence_libp2p::peerid_serializer;
use libp2p::PeerId;
Expand All @@ -30,9 +31,11 @@ use std::path::Path;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PersistedKeypair {
#[serde(with = "peerid_serializer")]
#[serde(alias = "remote_peer_id")]
pub deal_creator: PeerId,
pub private_key_bytes: Vec<u8>,
pub key_format: String,
#[serde(default)]
pub deal_id: String,
}

Expand Down Expand Up @@ -100,12 +103,16 @@ pub fn load_persisted_keypairs(
err,
path: file.to_path_buf(),
})?;
let keypair =
let mut keypair: PersistedKeypair =
toml::from_slice(bytes.as_slice()).map_err(|err| DeserializePersistedKeypair {
err,
path: file.to_path_buf(),
})?;

if keypair.deal_id.is_empty() {
keypair.deal_id = KeyManager::generate_deal_id(keypair.deal_creator);
}

Ok(keypair)
})
.collect()
Expand Down
136 changes: 136 additions & 0 deletions crates/particle-node-tests/tests/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,3 +1758,139 @@ fn exec_script_as_admin(

client.receive_args().wrap_err("receive args")
}

#[test]
fn add_alias_list() {
let swarms = make_swarms(1);
let mut client = ConnectedClient::connect_with_keypair(
swarms[0].multiaddr.clone(),
Some(swarms[0].management_keypair.clone()),
)
.wrap_err("connect client")
.unwrap();

let tetraplets_service = create_service(
&mut client,
"tetraplets",
load_module("tests/tetraplets/artifacts", "tetraplets").expect("load module"),
);

let alias = "tetraplets".to_string();
client.send_particle(
r#"
(seq
(seq
(call relay ("srv" "add_alias") [alias service])
(call relay ("srv" "list") [] list)
)
(call %init_peer_id% ("op" "return") [list])
)
"#,
hashmap! {
"relay" => json!(client.node.to_string()),
"service" => json!(tetraplets_service.id),
"alias" => json!(alias.clone())
},
);

use serde_json::Value::Array;

if let [Array(list)] = client.receive_args().unwrap().as_slice() {
assert_eq!(list.len(), 1);

let service_info = &list[0];
let aliases = service_info
.as_object()
.unwrap()
.get("aliases")
.unwrap()
.as_array()
.unwrap();
assert_eq!(aliases.len(), 1);
assert_eq!(aliases[0].as_str().unwrap(), alias)
} else {
panic!("incorrect args: expected an array")
}
}

#[test]
fn aliases_restart() {
let kp = KeyPair::generate_ed25519();
let swarms = make_swarms_with_keypair(1, kp.clone(), None);

let mut client = ConnectedClient::connect_with_keypair(
swarms[0].multiaddr.clone(),
Some(swarms[0].management_keypair.clone()),
)
.wrap_err("connect client")
.unwrap();

let tetraplets_service = create_service(
&mut client,
"tetraplets",
load_module("tests/tetraplets/artifacts", "tetraplets").expect("load module"),
);

let alias = "tetraplets".to_string();
client.send_particle(
r#"
(xor
(seq
(call relay ("srv" "add_alias") [alias service])
(call %init_peer_id% ("op" "return") ["ok"])
)
(call %init_peer_id% ("op" "return") [%last_error%.$.instruction])
)
"#,
hashmap! {
"relay" => json!(client.node.to_string()),
"service" => json!(tetraplets_service.id),
"alias" => json!(alias.clone())
},
);

if let [JValue::String(result)] = client.receive_args().unwrap().as_slice() {
assert_eq!(*result, "ok");
}

use serde_json::Value::Array;

// stop swarm
swarms.into_iter().map(|s| s.outlet.send(())).for_each(drop);
let swarms = make_swarms_with_keypair(1, kp, None);
let mut client = ConnectedClient::connect_with_keypair(
swarms[0].multiaddr.clone(),
Some(swarms[0].management_keypair.clone()),
)
.wrap_err("connect client")
.unwrap();

client.send_particle(
r#"
(seq
(call relay ("srv" "list") [] list_after)
(call %init_peer_id% ("op" "return") [list_after])
)
"#,
hashmap! {
"relay" => json!(client.node.to_string()),
"service" => json!(tetraplets_service.id),
},
);

if let [Array(after)] = client.receive_args().unwrap().as_slice() {
assert_eq!(after.len(), 1);
let service_info = &after[0];
let aliases = service_info
.as_object()
.unwrap()
.get("aliases")
.unwrap()
.as_array()
.unwrap();
assert_eq!(aliases.len(), 1);
assert_eq!(aliases[0].as_str().unwrap(), alias)
} else {
panic!("incorrect args: expected array")
}
}
Loading

0 comments on commit 7cd1cc7

Please sign in to comment.