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

p2p checkpoint #141

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a70a51f
impl a basic NetworkBehaviour and config objects
chunningham Nov 3, 2022
463aac6
move relay out of config
chunningham Nov 3, 2022
344be69
make generic over kad store and kad store config
chunningham Nov 3, 2022
c4fd4ea
extra config stuff, add swarm type
chunningham Nov 3, 2022
ccf7c71
IdentifyConfig conveniance changes
chunningham Nov 4, 2022
1fac014
renames and streamline the builder process
chunningham Nov 4, 2022
623889b
move behaviour to p2p mod and split into sub-mods
chunningham Nov 4, 2022
e4db46f
unused warns and stuff
chunningham Nov 4, 2022
6a58a9b
add autonat to behaviour
chunningham Nov 4, 2022
df98195
add an incomplete relay impl
chunningham Nov 4, 2022
8f40fb4
impl partially stubbed relay node with task
chunningham Nov 10, 2022
ff46d56
minor builder refactors
chunningham Nov 10, 2022
4110ff2
wip
chunningham Nov 10, 2022
2c1c348
make transport configs actually convenient
chunningham Nov 10, 2022
1892692
fix errors
chunningham Nov 10, 2022
969e2c1
use IntoTransport in relay::launch
chunningham Nov 10, 2022
d1a896e
clean up some unused builder stuff
chunningham Nov 10, 2022
6d686a9
get addrs and listen with relay via the event channels
chunningham Nov 10, 2022
d505122
comments, add vanilla dns to kepler relay peer
chunningham Nov 23, 2022
60914e1
remove currently unnecessary modules
chunningham Nov 23, 2022
f3cfcb9
remove janky builder derive workaround
chunningham Nov 23, 2022
4434944
warnings
chunningham Nov 23, 2022
1fc7ee5
minor cleanup, update to libp2p 0.50
chunningham Nov 30, 2022
ea1b72d
copy request-response protocol crate to kepler
chunningham Nov 30, 2022
b1b2b75
allow AsyncRead responses for stream req-res protocol
chunningham Nov 30, 2022
b817823
basic behaviour and builder for it
chunningham Nov 30, 2022
520a9bb
add write_keyed to immutablestorage trait
chunningham Nov 30, 2022
1e2a0d5
initial stubbed data swap behaviour
chunningham Nov 30, 2022
c9ddba5
exchange fixes
chunningham Dec 6, 2022
cb6a54b
wip
chunningham Dec 6, 2022
c8e950b
fix import deprecation warnings and relay instantiation in app()
chunningham Mar 21, 2023
bb21e20
updates for libp2p 0.51
chunningham Mar 29, 2023
73f7f59
use KeyPair instead of Ed25519 everywhere
chunningham Apr 5, 2023
5b80515
clean up a bunch of unused stuff and imports
chunningham Apr 5, 2023
92427eb
fix relay and fully-specify errors
chunningham Apr 5, 2023
12cd9e9
fix orbit behaviour builder and use specific errors
chunningham Apr 5, 2023
67bba63
warnings + relay connected_peers fn
chunningham Apr 5, 2023
7acd79e
remove exchange-protocol subcrate
chunningham Apr 5, 2023
6e55927
satisfy clippy
chunningham Apr 6, 2023
6f4e0b5
cargo-update
chunningham Apr 6, 2023
622e92f
satisfy clippy again
chunningham Apr 6, 2023
4fd7cba
relay test
chunningham Apr 6, 2023
9faea0f
config relay with any multiaddr
chunningham Apr 26, 2023
5253b89
fix rocket config, add .toml relay config comments
chunningham Apr 27, 2023
c3cc2a6
fix readme example
chunningham Apr 27, 2023
4645b00
update docker relay config
chunningham Apr 27, 2023
d3e55c8
fix readme log config example
chunningham Apr 27, 2023
9985cc6
unfix log readme example
chunningham Apr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ Kepler instances are configured by the [kepler.toml](kepler.toml) configuration

The following common options are available:

| Option | env var | description |
|:---------------------|:----------------------------|:---------------------------------------------------------------|
| log_level | KEPLER_LOG_LEVEL | Set the level of logging output, options are "normal", "debug" |
| address | KEPLER_ADDRESS | Set the listening address of the kepler instance |
| port | KEPLER_PORT | Set the listening TCP port for the kepler instance |
| storage.blocks.type | KEPLER_STORAGE_BLOCKS_TYPE | Set the mode of block storage, options are "Local" and "S3" |
| storage.indexes.type | KEPLER_STORAGE_INDEXES_TYPE | Set the type of the index store, options are "Local" and "DynamoDB" |
| orbits.allowlist | KEPLER_ORBITS_ALLOWLIST | Set the URL of an allowlist service for gating the creation of Orbit Peers |
| Option | env var | description |
|:---------------------|:----------------------------|:---------------------------------------------------------------------------|
| log_level | KEPLER_LOG_LEVEL | Set the level of logging output, options are "normal", "debug" |
| address | KEPLER_ADDRESS | Set the listening multi-address of the kepler instance |
sbihel marked this conversation as resolved.
Show resolved Hide resolved
| storage.blocks.type | KEPLER_STORAGE_BLOCKS_TYPE | Set the mode of block storage, options are "Local" and "S3" |
| storage.indexes.type | KEPLER_STORAGE_INDEXES_TYPE | Set the type of the index store, options are "Local" and "DynamoDB" |
| orbits.allowlist | KEPLER_ORBITS_ALLOWLIST | Set the URL of an allowlist service for gating the creation of Orbit Peers |

### Storage Config

Expand Down Expand Up @@ -82,7 +81,7 @@ Additionally, the following environment variables must be present: `AWS_ACCESS_K
Kepler instances can be started via command line, e.g.:

``` sh
KEPLER_PORT=8001 kepler
KEPLER_ADDRESS=/ip4/127.0.0.1/tcp/8001 kepler
```

If the Kepler instance is not able to find or establish a connection to the configured storage, the instance will terminate.
Expand Down
3 changes: 1 addition & 2 deletions kepler.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[global]
# log_level = "normal"
# address = "127.0.0.1"
# port = 8000
# address = "/ip4/127.0.0.1/tcp/8081"
# cors = true

## Example of nest config variable: KEPLER_DATABASE_PATH
Expand Down
3 changes: 1 addition & 2 deletions src/auth_guards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ fn get_state(req: &Request<'_>) -> Result<(config::Config, (PeerId, Multiaddr))>
.state::<config::Config>()
.cloned()
.ok_or_else(|| anyhow!("Could not retrieve config"))?;
let port = config.relay.port;
Ok((
config,
req.rocket()
.state::<RelayNode>()
.map(|r| (*r.id(), multiaddr!(Memory(port))))
.map(|r| (*r.id(), multiaddr!(Memory(1u8))))
.ok_or_else(|| anyhow!("Could not retrieve relay node information"))?,
))
}
Expand Down
7 changes: 3 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
storage::{file_system::FileSystemConfig, s3::S3BlockConfig},
BlockConfig,
};
use libp2p::{build_multiaddr, Multiaddr};
use rocket::http::hyper::Uri;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr, FromInto};
Expand Down Expand Up @@ -81,8 +82,7 @@ pub struct DynamoStorage {

#[derive(Serialize, Deserialize, Debug, Clone, Hash, PartialEq, Eq)]
pub struct Relay {
pub address: String,
pub port: u16,
pub address: Multiaddr,
}

#[derive(Serialize, Deserialize, Debug, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -122,8 +122,7 @@ impl Default for LocalIndexStorage {
impl Default for Relay {
fn default() -> Self {
Self {
address: "127.0.0.1".into(),
port: 8081,
address: build_multiaddr!(Ip4([127, 0, 0, 1]), Tcp(8081u16)),
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ pub async fn app(config: &Figment) -> Result<Rocket<Build>> {
)?;

relay_node
.listen_on([
build_multiaddr!(Memory(kepler_config.relay.port)),
build_multiaddr!(Ip4([127, 0, 0, 1]), Tcp(kepler_config.relay.port)),
])
.listen_on([build_multiaddr!(Memory(1u64)), kepler_config.relay.address])
.await?;

let routes = routes![
Expand Down
14 changes: 7 additions & 7 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use kepler_lib::{
authorization::{EncodingError, HeaderEncode},
libipld::Cid,
};
use libp2p::{identity::Keypair, multiaddr::multiaddr, PeerId};
use libp2p::{identity::Keypair, multiaddr::Protocol, PeerId};
use rocket::{
data::{Data, ToByteUnit},
http::{Header, Status},
Expand Down Expand Up @@ -90,12 +90,12 @@ pub mod util_routes {

#[get("/peer/relay")]
pub fn relay_addr(relay: &State<RelayNode>, config: &State<Config>) -> String {
multiaddr!(
Ip4([127, 0, 0, 1]),
Tcp(config.relay.port),
P2p(*relay.id())
)
.to_string()
config
.relay
.address
.clone()
.with(Protocol::P2p(*relay.id().as_ref()))
.to_string()
}

#[get("/peer/generate")]
Expand Down