Skip to content

Commit

Permalink
de-mls with Waku (#29)
Browse files Browse the repository at this point in the history
* start building waku for group_chat

* replace test

* replace test

* fix building issue on m2

* continue waku integration

* add admin trait

* update cfg

* update code

* replace cli to ws

* add docker for each instance

* fully working process for joining to the group

* update readme

* Add Waku and WebSocket actors for message processing and group management

- Introduced `WakuActor` for handling message sending and group subscriptions using Waku protocol.
- Implemented `Group` actor for managing group creation, member addition/removal, and message processing.
- Added `WsActor` for WebSocket communication, enabling user connections and message handling.
- Defined message structures for processing and sending messages within the Waku and WebSocket contexts.
- Enhanced error handling and logging for message operations.

* Refactor Waku and WebSocket integration for improved message handling

- Updated `WakuActor` to return a vector of `WakuContentTopic` upon subscription, enhancing group topic management.
- Introduced `AppState` struct to centralize application state, including Waku actor reference and content topics.
- Refactored main loop to utilize `AppState`, improving message flow between Waku and WebSocket actors.
- Enhanced message handling in `WsActor` to support `MessageToPrint`, allowing for structured message sending.
- Improved error handling and logging throughout the message processing pipeline.

* Refactor Waku message handling and clean up unused code

* Refactor and remove unused components from the project

- Deleted the `sc_key_store` module and its associated files, streamlining the codebase.
- Removed unused Docker and Git configuration files, enhancing project clarity.
- Cleaned up `.gitignore` and `.dockerignore` to reflect current project structure.
- Updated `Cargo.toml` files to remove references to deleted modules and dependencies.
- Refactored Waku and WebSocket actors to improve message handling and group management.
- Enhanced error handling and logging throughout the message processing pipeline.
- Adjusted frontend input styling for better user experience.

* Update CI workflow to use 'main' branch and add support for manual triggers

* Enhance Waku integration and documentation

- Added instructions for running a test Waku node in the README.
- Refactored Waku message handling in `ds_waku.rs` to improve content topic management and error handling.
- Updated `Cargo.toml` dependencies for better compatibility and removed unused entries.
- Improved error handling in `DeliveryServiceError` for Waku node operations.
- Cleaned up CI workflow by commenting out unused test jobs.
- Enhanced logging in tests for better traceability of message flows.

* Update CI workflow to include Go setup for testing

- Added steps to the CI configuration to set up Go version 1.20.x for user tests.
- Ensured consistent environment setup across different jobs in the CI pipeline.

* Update package versions to 1.0.0 in Cargo.toml files for the main project and 'ds' module

* Update README to include note on frontend implementation based on Chatr
  • Loading branch information
seemenkina authored Dec 25, 2024
1 parent 49ab2b4 commit c99eadb
Show file tree
Hide file tree
Showing 91 changed files with 5,372 additions and 28,040 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[target.'cfg(target_os = "macos")']
# when using osx, we need to link against some golang libraries, it did just work with this missing flags
# from: https://github.com/golang/go/issues/42459
rustflags = ["-C", "link-args=-framework CoreFoundation -framework Security -framework CoreServices -lresolv"]
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env/
.idea/
target/
frontend/
162 changes: 48 additions & 114 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,131 +1,65 @@
name: "CI"

env:
FOUNDRY_PROFILE: "ci"

on:
workflow_dispatch:
pull_request:
push:
branches:
- "main"

concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref}}
name: "CI"

jobs:
lint:
runs-on: "ubuntu-latest"
# ds_test:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Install stable toolchain
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
# - uses: Swatinem/rust-cache@v2
# - name: cargo test
# run: |
# cargo test --release
# working-directory: ds
user_test:
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v4"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
- name: Setup Go
uses: actions/setup-go@v4
with:
node-version: "lts/*"

- name: "Install the Node.js dependencies"
run: "pnpm install"
working-directory: "contracts"

- name: "Lint the contracts"
run: "pnpm lint"
working-directory: "contracts"

- name: "Add lint summary"
go-version: '1.20.x'
- name: Checkout code
uses: actions/checkout@v3
- name: cargo test
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
build:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Build the contracts and print their size"
run: "forge build --sizes"
working-directory: "contracts"
cargo test --release
working-directory: tests

- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
test:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Show the Foundry config"
run: "forge config"
working-directory: "contracts"

- name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance"
run: >
echo "FOUNDRY_FUZZ_SEED=$(
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800))
)" >> $GITHUB_ENV
- name: "Run the tests"
run: "forge test"
working-directory: "contracts"

- name: "Add test summary"
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
coverage:
needs: ["lint", "build"]
runs-on: "ubuntu-latest"
lint:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
- name: Setup Go
uses: actions/setup-go@v4
with:
submodules: "recursive"

- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Generate the coverage report using the unit and the integration tests"
run: 'forge coverage --match-path "test/**/*.sol" --report lcov'
working-directory: "contracts"

- name: "Upload coverage report to Codecov"
uses: "codecov/codecov-action@v3"
go-version: '1.20.x'
- name: Checkout sources
uses: actions/checkout@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
files: "./contracts/lcov.info"

- name: "Add coverage summary"
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
if: success() || failure()
run: cargo fmt -- --check
- name: cargo clippy
if: success() || failure()
run: |
echo "## Coverage result" >> $GITHUB_STEP_SUMMARY
echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY
strategy:
fail-fast: false
max-parallel: 16
cargo clippy --release -- -D warnings
12 changes: 1 addition & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ Cargo.lock

.DS_Store
src/.DS_Store

## contracts
# directories
contracts/cache/**
contracts/node_modules/**
contracts/out/**
.idea

# files
*.env
Expand All @@ -30,9 +25,4 @@ contracts/out/**
lcov.info
yarn.lock

# broadcasts
contracts/!broadcast
contracts/broadcast/*
contracts/broadcast/*/31337/

.certora_internal
7 changes: 0 additions & 7 deletions .gitmodules

This file was deleted.

52 changes: 32 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,70 @@
[workspace]
members = ["sc_key_store", "ds", "crates/bindings", "mls_crypto"]
[workspace.dependencies]
foundry-contracts = { path = "crates/bindings" }
members = ["ds", "mls_crypto"]
# [workspace.dependencies]
# foundry-contracts = { path = "crates/bindings" }

[package]
name = "de-mls"
version = "0.1.0"
version = "1.0.0"
edition = "2021"

[[bin]]
name = "de-mls"
path = "src/main.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
foundry-contracts.workspace = true
# foundry-contracts.workspace = true
openmls = { version = "=0.5.0", features = ["test-utils"] }
openmls_basic_credential = "=0.2.0"
openmls_rust_crypto = "=0.2.0"
openmls_traits = "=0.2.0"

# waku-bindings = "0.6.0"
axum = { version = "0.6.10", features = ["ws"] }
futures = "0.3.26"
tower-http = { version = "0.4.0", features = ["cors"] }
tokio = { version = "=1.38.0", features = [
"macros",
"rt-multi-thread",
"full",
] }
tokio-util = "=0.7.11"
tokio-tungstenite = "0.15"
tungstenite = "0.14"
tokio-util = "0.7.13"
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
"providers",
"node-bindings",
"network",
"transports",
"k256",
"signer-local",
] }
fred = { version = "=9.0.3", features = ["subscriber-client"] }
console-subscriber = "0.1.5"
kameo = "0.13.0"

waku-bindings = { git = "https://github.com/waku-org/waku-rust-bindings.git", branch = "force-cluster-15", subdir = "waku-bindings" }
waku-sys = { git = "https://github.com/waku-org/waku-rust-bindings.git", branch = "force-cluster-15", subdir = "waku-sys" }

rand = "=0.8.5"
serde_json = "=1.0"
serde = "=1.0.204"
url = "=2.5.2"
serde = { version = "=1.0.204", features = ["derive"] }
tls_codec = "=0.3.0"
hex = "=0.4.3"
chrono = "=0.4.38"

shlex = "=1.3.0"
clap = { version = "=4.5.8", features = ["derive"] }
secp256k1 = { version = "0.30.0", features = [
"rand",
"std",
"hashes",
"global-context",
] }
ecies = "0.2.7"
libsecp256k1 = "0.7.1"

anyhow = "=1.0.81"
thiserror = "=1.0.61"
uuid = "1.11.0"
bounded-vec-deque = "0.1.1"

crossterm = "=0.27.0"
ratatui = "=0.27.0"
textwrap = "=0.16.1"
env_logger = "0.11.5"
log = "0.4.22"

ds = { path = "ds" }
sc_key_store = { path = "sc_key_store" }
mls_crypto = { path = "mls_crypto" }
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
####################################################################################################
## Build image
####################################################################################################
FROM rust:latest as builder

WORKDIR /app
RUN apt-get update && apt-get install -y libssl-dev pkg-config gcc clang

ENV PATH="/usr/local/go/bin:${PATH}"
COPY --from=golang:1.20 /usr/local/go/ /usr/local/go/

# Cache build dependencies
RUN echo "fn main() {}" > dummy.rs
COPY ["Cargo.toml", "./Cargo.toml"]
COPY ["ds/", "./ds/"]
COPY ["mls_crypto/", "./mls_crypto/"]
RUN sed -i 's#src/main.rs#dummy.rs#' Cargo.toml
RUN cargo build --release
RUN sed -i 's#dummy.rs#src/main.rs#' Cargo.toml

# Build the actual app
COPY ["src/", "./src/"]
RUN cargo build --release

CMD ["/app/target/release/de-mls"]
28 changes: 0 additions & 28 deletions Makefile

This file was deleted.

Loading

0 comments on commit c99eadb

Please sign in to comment.