From e950f78f6c7099318345519c231bfdc7edd05cf3 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 16:20:08 -0500 Subject: [PATCH 1/8] create lib-xps crate, remove gateway terminology --- Cargo.toml | 2 +- {xps-gateway => lib-xps}/Cargo.toml | 0 {xps-gateway => lib-xps}/src/lib.rs | 0 {xps-gateway => lib-xps}/src/main.rs | 0 {xps-gateway => lib-xps}/src/rpc.rs | 0 {xps-gateway => lib-xps}/src/rpc/api.rs | 0 {xps-gateway => lib-xps}/src/rpc/methods.rs | 0 {xps-gateway => lib-xps}/src/types.rs | 0 {xps-gateway => lib-xps}/src/util.rs | 0 {xps-gateway => lib-xps}/tests/integration_test.rs | 0 {xps-gateway => lib-xps}/tests/integration_util/mod.rs | 0 {gateway-types => xps-types}/Cargo.toml | 0 {gateway-types => xps-types}/src/lib.rs | 0 xps/Cargo.toml | 8 ++++++++ xps/src/main.rs | 3 +++ 15 files changed, 12 insertions(+), 1 deletion(-) rename {xps-gateway => lib-xps}/Cargo.toml (100%) rename {xps-gateway => lib-xps}/src/lib.rs (100%) rename {xps-gateway => lib-xps}/src/main.rs (100%) rename {xps-gateway => lib-xps}/src/rpc.rs (100%) rename {xps-gateway => lib-xps}/src/rpc/api.rs (100%) rename {xps-gateway => lib-xps}/src/rpc/methods.rs (100%) rename {xps-gateway => lib-xps}/src/types.rs (100%) rename {xps-gateway => lib-xps}/src/util.rs (100%) rename {xps-gateway => lib-xps}/tests/integration_test.rs (100%) rename {xps-gateway => lib-xps}/tests/integration_util/mod.rs (100%) rename {gateway-types => xps-types}/Cargo.toml (100%) rename {gateway-types => xps-types}/src/lib.rs (100%) create mode 100644 xps/Cargo.toml create mode 100644 xps/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 3fc3be0..983ad42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ "messaging", "inbox", "registry", - "gateway-types", + "gateway-types", "lib-xps", "xps", ] exclude = [ ] diff --git a/xps-gateway/Cargo.toml b/lib-xps/Cargo.toml similarity index 100% rename from xps-gateway/Cargo.toml rename to lib-xps/Cargo.toml diff --git a/xps-gateway/src/lib.rs b/lib-xps/src/lib.rs similarity index 100% rename from xps-gateway/src/lib.rs rename to lib-xps/src/lib.rs diff --git a/xps-gateway/src/main.rs b/lib-xps/src/main.rs similarity index 100% rename from xps-gateway/src/main.rs rename to lib-xps/src/main.rs diff --git a/xps-gateway/src/rpc.rs b/lib-xps/src/rpc.rs similarity index 100% rename from xps-gateway/src/rpc.rs rename to lib-xps/src/rpc.rs diff --git a/xps-gateway/src/rpc/api.rs b/lib-xps/src/rpc/api.rs similarity index 100% rename from xps-gateway/src/rpc/api.rs rename to lib-xps/src/rpc/api.rs diff --git a/xps-gateway/src/rpc/methods.rs b/lib-xps/src/rpc/methods.rs similarity index 100% rename from xps-gateway/src/rpc/methods.rs rename to lib-xps/src/rpc/methods.rs diff --git a/xps-gateway/src/types.rs b/lib-xps/src/types.rs similarity index 100% rename from xps-gateway/src/types.rs rename to lib-xps/src/types.rs diff --git a/xps-gateway/src/util.rs b/lib-xps/src/util.rs similarity index 100% rename from xps-gateway/src/util.rs rename to lib-xps/src/util.rs diff --git a/xps-gateway/tests/integration_test.rs b/lib-xps/tests/integration_test.rs similarity index 100% rename from xps-gateway/tests/integration_test.rs rename to lib-xps/tests/integration_test.rs diff --git a/xps-gateway/tests/integration_util/mod.rs b/lib-xps/tests/integration_util/mod.rs similarity index 100% rename from xps-gateway/tests/integration_util/mod.rs rename to lib-xps/tests/integration_util/mod.rs diff --git a/gateway-types/Cargo.toml b/xps-types/Cargo.toml similarity index 100% rename from gateway-types/Cargo.toml rename to xps-types/Cargo.toml diff --git a/gateway-types/src/lib.rs b/xps-types/src/lib.rs similarity index 100% rename from gateway-types/src/lib.rs rename to xps-types/src/lib.rs diff --git a/xps/Cargo.toml b/xps/Cargo.toml new file mode 100644 index 0000000..9881468 --- /dev/null +++ b/xps/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "xps" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/xps/src/main.rs b/xps/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/xps/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} From 4e9ee4de920a113c42702b5ae48bfcb315685b66 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 16:48:35 -0500 Subject: [PATCH 2/8] remove references to `gateway` --- .github/workflows/ghcr-image.yml | 26 +++-------- .github/workflows/prod-ci-image.yml | 14 ++---- Cargo.toml | 5 ++- Dockerfile | 10 ++--- lib-xps/Cargo.toml | 3 +- lib-xps/src/lib.rs | 2 +- lib-xps/src/main.rs | 69 ---------------------------- lib-xps/src/rpc/api.rs | 4 +- lib-xps/src/rpc/methods.rs | 4 +- lib-xps/tests/integration_test.rs | 2 +- prod/Dockerfile | 10 ++--- registry/Cargo.toml | 2 +- registry/src/lib.rs | 2 +- xps/Cargo.toml | 3 ++ xps/src/main.rs | 70 ++++++++++++++++++++++++++++- 15 files changed, 104 insertions(+), 122 deletions(-) delete mode 100644 lib-xps/src/main.rs diff --git a/.github/workflows/ghcr-image.yml b/.github/workflows/ghcr-image.yml index 92d05d3..a5e8322 100644 --- a/.github/workflows/ghcr-image.yml +++ b/.github/workflows/ghcr-image.yml @@ -1,56 +1,44 @@ name: Docker Image Build Push - on: push: tags: - "*" - concurrency: group: "docker-image" cancel-in-progress: true - jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Generate repository name run: | echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV} echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-8 )" >> ${GITHUB_ENV} - - - name: Login to GitHub Container Registry + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and Push + - name: Build and Push uses: docker/build-push-action@v3 with: context: . file: ./prod/Dockerfile platforms: linux/amd64,linux/arm64 push: true - build-args: | - VERSION=${{ github.ref_name }} - CARGO_INCREMENTAL=0 + build-args: "VERSION=${{ github.ref_name }}\nCARGO_INCREMENTAL=0 \n" tags: | ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }} ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }} ghcr.io/${{ env.REPOSITORY_PATH }}:latest - - - name: GitHub Release + - name: GitHub Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prod-ci-image.yml b/.github/workflows/prod-ci-image.yml index 16027cb..d3b2d4a 100644 --- a/.github/workflows/prod-ci-image.yml +++ b/.github/workflows/prod-ci-image.yml @@ -1,5 +1,4 @@ name: Build Prod Image CI - on: workflow_dispatch: pull_request: @@ -8,28 +7,23 @@ on: push: branches: - "*" - jobs: build: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build Prod Image CI uses: docker/build-push-action@v3 with: context: . - file: prod/Dockerfile + file: prod/Dockerfile platforms: linux/amd64 push: false build-args: | VERSION=latest CARGO_INCREMENTAL=0 - diff --git a/Cargo.toml b/Cargo.toml index 983ad42..cdbca06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,12 @@ [workspace] members = [ - "xps-gateway", + "xps", + "lib-xps", "messaging", "inbox", "registry", - "gateway-types", "lib-xps", "xps", + "xps-types", ] exclude = [ ] diff --git a/Dockerfile b/Dockerfile index dcc012b..90af36a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN sudo apt update && sudo apt install -y pkg-config openssl libssl-dev COPY --from=ghcr.io/xmtp/foundry:latest /usr/local/bin/anvil /usr/local/bin/anvil -ARG PROJECT=xps-gateway +ARG PROJECT=xps WORKDIR /workspaces/${PROJECT} COPY --chown=xmtp:xmtp . . @@ -20,17 +20,17 @@ RUN cargo check RUN cargo fmt --check RUN cargo clippy --all-features --no-deps -- -D warnings RUN cargo test --workspace --all-features -RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path xps-gateway --bin=xps_gateway --root=~${USER}/.cargo/ -RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/xps_gateway --help +RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path xps --bin=xps --root=~${USER}/.cargo/ +RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/xps --help CMD RUST_LOG=info cargo run -- --host 0.0.0.0 --port 8080 LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="rustdev" \ org.label-schema.description="Rust Development Container" \ - org.label-schema.url="https://github.com/xmtp/xps-gateway" \ + org.label-schema.url="https://github.com/xmtp/xps" \ org.label-schema.vcs-ref=$VCS_REF \ - org.label-schema.vcs-url="git@github.com:xmtp/xps-gateway.git" \ + org.label-schema.vcs-url="git@github.com:xmtp/xps.git" \ org.label-schema.vendor="xmtp" \ org.label-schema.version=$VERSION \ org.label-schema.schema-version="1.0" \ diff --git a/lib-xps/Cargo.toml b/lib-xps/Cargo.toml index 7f777b8..d0220ec 100644 --- a/lib-xps/Cargo.toml +++ b/lib-xps/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "xps_gateway" +name = "lib-xps" version = "0.1.0" edition = "2021" resolver = "2" @@ -21,7 +21,6 @@ ctor.workspace = true lib-didethresolver.workspace = true gateway-types.workspace = true hex.workspace = true -clap = { version = "4.4.18", features = ["derive"] } rand = "0.8.5" tokio-stream = { version = "0.1", features = ["net"] } registry = { path = "../registry" } diff --git a/lib-xps/src/lib.rs b/lib-xps/src/lib.rs index c6b3e8a..fbca33e 100644 --- a/lib-xps/src/lib.rs +++ b/lib-xps/src/lib.rs @@ -7,7 +7,7 @@ use ethers::{ abi::Address, providers::{Provider, Ws}, }; -use gateway_types::DID_ETH_REGISTRY; +use xps_types::DID_ETH_REGISTRY; use jsonrpsee::server::Server; use std::str::FromStr; diff --git a/lib-xps/src/main.rs b/lib-xps/src/main.rs deleted file mode 100644 index 127d370..0000000 --- a/lib-xps/src/main.rs +++ /dev/null @@ -1,69 +0,0 @@ -use anyhow::Result; -use clap::Parser; -use xps_gateway::run; - -#[derive(Parser, Debug)] -#[command( - name = "xps-gateway", - version = "0.1.0", - about = "XMTP Postal Service Gateway" -)] -struct Args { - #[arg(short = 'p', long = "port", default_value_t = 0)] - port: u16, - #[arg(short = 's', long = "host", default_value = "127.0.0.1")] - host: String, -} - -#[tokio::main] -async fn main() -> Result<()> { - let args = Args::parse(); - crate::run(args.host, args.port).await?; - Ok(()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_port_0() -> Result<()> { - let arg_list = vec!["xps-gateway", "-p", "0"]; - let args = Args::parse_from(arg_list); - assert_eq!(args.port, 0); - Ok(()) - } - - #[test] - fn test_port_25() -> Result<()> { - let arg_list = vec!["xps-gateway", "--port", "25"]; - let args = Args::parse_from(arg_list); - assert_eq!(args.port, 25); - Ok(()) - } - - #[test] - fn test_host_test_net() -> Result<()> { - let arg_list = vec!["xps-gateway", "-s", "test.net"]; - let args = Args::parse_from(arg_list); - assert_eq!(args.host, "test.net"); - Ok(()) - } - - #[test] - fn test_host_test_0000() -> Result<()> { - let arg_list = vec!["xps-gateway", "--host", "0.0.0.0"]; - let args = Args::parse_from(arg_list); - assert_eq!(args.host, "0.0.0.0"); - Ok(()) - } - - #[test] - fn test_default() -> Result<()> { - let arg_list = vec!["xps-gateway"]; - let args = Args::parse_from(arg_list); - assert_eq!(args.port, 0); - assert_eq!(args.host, "127.0.0.1"); - Ok(()) - } -} diff --git a/lib-xps/src/rpc/api.rs b/lib-xps/src/rpc/api.rs index 85abf69..b7124b5 100644 --- a/lib-xps/src/rpc/api.rs +++ b/lib-xps/src/rpc/api.rs @@ -4,8 +4,8 @@ use ethers::core::types::Signature; use ethers::prelude::*; use jsonrpsee::{proc_macros::rpc, types::ErrorObjectOwned}; -use gateway_types::Message; -use gateway_types::{GrantInstallationResult, KeyPackageResult}; +use xps_types::Message; +use xps_types::{GrantInstallationResult, KeyPackageResult}; use lib_didethresolver::types::XmtpAttribute; /// XPS JSON-RPC Interface Methods diff --git a/lib-xps/src/rpc/methods.rs b/lib-xps/src/rpc/methods.rs index 25f3ce6..f18df6a 100644 --- a/lib-xps/src/rpc/methods.rs +++ b/lib-xps/src/rpc/methods.rs @@ -8,14 +8,14 @@ use jsonrpsee::types::error::ErrorCode; use async_trait::async_trait; use ethers::prelude::*; use ethers::{core::types::Signature, providers::Middleware}; -use gateway_types::{GrantInstallationResult, KeyPackageResult}; +use xps_types::{GrantInstallationResult, KeyPackageResult}; use jsonrpsee::types::ErrorObjectOwned; use lib_didethresolver::types::XmtpAttribute; use rand::{rngs::StdRng, SeedableRng}; use std::sync::Arc; use thiserror::Error; -use gateway_types::Message; +use xps_types::Message; use registry::{error::ContactOperationError, ContactOperations}; // DEFAULT_ATTRIBUTE_VALIDITY is the hard-coded value we use for the validity of the attributes we set. diff --git a/lib-xps/tests/integration_test.rs b/lib-xps/tests/integration_test.rs index 9abab96..5c4de6e 100644 --- a/lib-xps/tests/integration_test.rs +++ b/lib-xps/tests/integration_test.rs @@ -13,7 +13,7 @@ use lib_didethresolver::{ use xps_gateway::rpc::*; use ethers::types::{Address, U256}; -use gateway_types::{Message, Status}; +use xps_types::{Message, Status}; use integration_util::*; diff --git a/prod/Dockerfile b/prod/Dockerfile index ff83592..eef1d40 100644 --- a/prod/Dockerfile +++ b/prod/Dockerfile @@ -19,8 +19,8 @@ RUN cargo clippy --all-features --no-deps -- -D warnings RUN cargo test --lib RUN cargo test --doc RUN cargo build --release -RUN CARGO_TARGET_DIR=/build/target cargo install --root /xmtp --path xps-gateway --bin=xps_gateway -RUN strip /xmtp/bin/xps_gateway +RUN CARGO_TARGET_DIR=/build/target cargo install --root /xmtp --path xps --bin=xps +RUN strip /xmtp/bin/xps RUN cp CHANGELOG.md /xmtp/ RUN cp LICENSE /xmtp/ @@ -44,11 +44,11 @@ EXPOSE 8080 ENV USER=none USER none -CMD ["/xmtp/bin/xps_gateway", "--host", "0.0.0.0", "--port", "8080"] +CMD ["/xmtp/bin/xps", "--host", "0.0.0.0", "--port", "8080"] LABEL org.label-schema.build-date=$BUILD_DATE \ - org.label-schema.name="xps-gateway" \ - org.label-schema.description="xps-gateway" \ + org.label-schema.name="xps" \ + org.label-schema.description="xps" \ org.label-schema.url="https://github.com/xmtp/xps-gateway" \ org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="git@github.com:xmtp/xps-gateway.git" \ diff --git a/registry/Cargo.toml b/registry/Cargo.toml index 0fe1573..74feccb 100644 --- a/registry/Cargo.toml +++ b/registry/Cargo.toml @@ -11,7 +11,7 @@ tracing.workspace = true tokio.workspace = true async-trait.workspace = true ethers = { workspace = true, features = ["ws"] } -gateway-types.workspace = true +xps-types.workspace = true lib-didethresolver.workspace = true rustc-hex.workspace = true thiserror.workspace = true diff --git a/registry/src/lib.rs b/registry/src/lib.rs index e54d422..7eeb47a 100644 --- a/registry/src/lib.rs +++ b/registry/src/lib.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use error::ContactOperationError; use ethers::types::{H160, U256}; use ethers::{core::types::Signature, providers::Middleware, types::Address}; -use gateway_types::{GrantInstallationResult, KeyPackageResult, Status}; +use xps_types::{GrantInstallationResult, KeyPackageResult, Status}; use lib_didethresolver::types::VerificationMethodProperties; use lib_didethresolver::Resolver; use lib_didethresolver::{did_registry::DIDRegistry, types::XmtpAttribute}; diff --git a/xps/Cargo.toml b/xps/Cargo.toml index 9881468..a690904 100644 --- a/xps/Cargo.toml +++ b/xps/Cargo.toml @@ -6,3 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +lib-xps = { path = "../lib-xps" } +anyhow.workspace = true +clap = { version = "4.4.18", features = ["derive"] } diff --git a/xps/src/main.rs b/xps/src/main.rs index e7a11a9..9f55207 100644 --- a/xps/src/main.rs +++ b/xps/src/main.rs @@ -1,3 +1,69 @@ -fn main() { - println!("Hello, world!"); +use anyhow::Result; +use clap::Parser; +use lib_xps::run; + +#[derive(Parser, Debug)] +#[command( + name = "xps", + version = "0.1.0", + about = "XMTP Postal Service" +)] +struct Args { + #[arg(short = 'p', long = "port", default_value_t = 0)] + port: u16, + #[arg(short = 's', long = "host", default_value = "127.0.0.1")] + host: String, +} + +#[tokio::main] +async fn main() -> Result<()> { + let args = Args::parse(); + crate::run(args.host, args.port).await?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_port_0() -> Result<()> { + let arg_list = vec!["xps", "-p", "0"]; + let args = Args::parse_from(arg_list); + assert_eq!(args.port, 0); + Ok(()) + } + + #[test] + fn test_port_25() -> Result<()> { + let arg_list = vec!["xps", "--port", "25"]; + let args = Args::parse_from(arg_list); + assert_eq!(args.port, 25); + Ok(()) + } + + #[test] + fn test_host_test_net() -> Result<()> { + let arg_list = vec!["xps", "-s", "test.net"]; + let args = Args::parse_from(arg_list); + assert_eq!(args.host, "test.net"); + Ok(()) + } + + #[test] + fn test_host_test_0000() -> Result<()> { + let arg_list = vec!["xps", "--host", "0.0.0.0"]; + let args = Args::parse_from(arg_list); + assert_eq!(args.host, "0.0.0.0"); + Ok(()) + } + + #[test] + fn test_default() -> Result<()> { + let arg_list = vec!["xps"]; + let args = Args::parse_from(arg_list); + assert_eq!(args.port, 0); + assert_eq!(args.host, "127.0.0.1"); + Ok(()) + } } From 073ee34beda49003870bf7eab50b24f87541a403 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 16:51:47 -0500 Subject: [PATCH 3/8] last fixes --- Cargo.lock | 61 +++++++++++++++------------ Cargo.toml | 2 +- lib-xps/Cargo.toml | 2 +- lib-xps/tests/integration_test.rs | 2 +- lib-xps/tests/integration_util/mod.rs | 2 +- xps-types/Cargo.toml | 2 +- xps/Cargo.toml | 3 +- 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 498c87f..ee49a85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1405,14 +1405,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "gateway-types" -version = "0.1.0" -dependencies = [ - "lib-didethresolver", - "serde", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2162,6 +2154,31 @@ dependencies = [ "url", ] +[[package]] +name = "lib-xps" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "ctor", + "ethers", + "futures", + "hex", + "jsonrpsee 0.22.0", + "lib-didethresolver", + "log", + "rand", + "registry", + "serde", + "serde_json", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "tracing-subscriber", + "xps-types", +] + [[package]] name = "libc" version = "0.2.152" @@ -2904,13 +2921,13 @@ version = "0.1.0" dependencies = [ "async-trait", "ethers", - "gateway-types", "lib-didethresolver", "log", "rustc-hex", "thiserror", "tokio", "tracing", + "xps-types", ] [[package]] @@ -4483,29 +4500,21 @@ dependencies = [ ] [[package]] -name = "xps_gateway" +name = "xps" version = "0.1.0" dependencies = [ "anyhow", - "async-trait", "clap", - "ctor", - "ethers", - "futures", - "gateway-types", - "hex", - "jsonrpsee 0.22.0", + "lib-xps", + "tokio", +] + +[[package]] +name = "xps-types" +version = "0.1.0" +dependencies = [ "lib-didethresolver", - "log", - "rand", - "registry", "serde", - "serde_json", - "thiserror", - "tokio", - "tokio-stream", - "tracing", - "tracing-subscriber", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index cdbca06..18f2f86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,6 @@ thiserror = "1.0" ethers = { version = "2.0.11", features = ["abigen"] } ctor = "0.2" lib-didethresolver = { git = "https://github.com/xmtp/didethresolver", branch = "main" } -gateway-types = { path = "./gateway-types" } +xps-types = { path = "./xps-types" } rustc-hex = "2.1" hex = "0.4" diff --git a/lib-xps/Cargo.toml b/lib-xps/Cargo.toml index d0220ec..d3dde6b 100644 --- a/lib-xps/Cargo.toml +++ b/lib-xps/Cargo.toml @@ -19,7 +19,7 @@ thiserror.workspace = true ethers = { workspace = true, features = ["ws"] } ctor.workspace = true lib-didethresolver.workspace = true -gateway-types.workspace = true +xps-types.workspace = true hex.workspace = true rand = "0.8.5" tokio-stream = { version = "0.1", features = ["net"] } diff --git a/lib-xps/tests/integration_test.rs b/lib-xps/tests/integration_test.rs index 5c4de6e..4d35281 100644 --- a/lib-xps/tests/integration_test.rs +++ b/lib-xps/tests/integration_test.rs @@ -10,7 +10,7 @@ use lib_didethresolver::{ did_registry::RegistrySignerExt, types::{DidUrl, KeyEncoding, XmtpAttribute, XmtpKeyPurpose, NULL_ADDRESS}, }; -use xps_gateway::rpc::*; +use lib_xps::rpc::*; use ethers::types::{Address, U256}; use xps_types::{Message, Status}; diff --git a/lib-xps/tests/integration_util/mod.rs b/lib-xps/tests/integration_util/mod.rs index 25a6232..307f5d3 100644 --- a/lib-xps/tests/integration_util/mod.rs +++ b/lib-xps/tests/integration_util/mod.rs @@ -27,7 +27,7 @@ use std::{ use tokio::time::timeout as timeout_tokio; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Registry}; -use xps_gateway::{ +use lib_xps::{ types::{GatewayContext, GatewaySigner}, XpsMethods, XpsServer, }; diff --git a/xps-types/Cargo.toml b/xps-types/Cargo.toml index 5aea0be..431b609 100644 --- a/xps-types/Cargo.toml +++ b/xps-types/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "gateway-types" +name = "xps-types" version = "0.1.0" edition = "2021" diff --git a/xps/Cargo.toml b/xps/Cargo.toml index a690904..5d3a1d9 100644 --- a/xps/Cargo.toml +++ b/xps/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lib-xps = { path = "../lib-xps" } anyhow.workspace = true +tokio.workspace = true +lib-xps = { path = "../lib-xps" } clap = { version = "4.4.18", features = ["derive"] } From 6c87f934411453e8a2d2c40e214084102a056c24 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 16:54:03 -0500 Subject: [PATCH 4/8] fix link to github --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 90af36a..078b255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,9 +28,9 @@ CMD RUST_LOG=info cargo run -- --host 0.0.0.0 --port 8080 LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="rustdev" \ org.label-schema.description="Rust Development Container" \ - org.label-schema.url="https://github.com/xmtp/xps" \ + org.label-schema.url="https://github.com/xmtp/xps-gateway" \ org.label-schema.vcs-ref=$VCS_REF \ - org.label-schema.vcs-url="git@github.com:xmtp/xps.git" \ + org.label-schema.vcs-url="git@github.com:xmtp/xps-gateway.git" \ org.label-schema.vendor="xmtp" \ org.label-schema.version=$VERSION \ org.label-schema.schema-version="1.0" \ From 2943655c2f09ca7223f6c4385e64f71a3c45cf1f Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 17:04:21 -0500 Subject: [PATCH 5/8] fmt --- lib-xps/src/lib.rs | 2 +- lib-xps/src/rpc/api.rs | 2 +- lib-xps/src/rpc/methods.rs | 4 ++-- registry/src/lib.rs | 2 +- xps/src/main.rs | 6 +----- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib-xps/src/lib.rs b/lib-xps/src/lib.rs index fbca33e..a467507 100644 --- a/lib-xps/src/lib.rs +++ b/lib-xps/src/lib.rs @@ -7,9 +7,9 @@ use ethers::{ abi::Address, providers::{Provider, Ws}, }; -use xps_types::DID_ETH_REGISTRY; use jsonrpsee::server::Server; use std::str::FromStr; +use xps_types::DID_ETH_REGISTRY; pub use crate::rpc::{XpsMethods, XpsServer}; use crate::types::GatewayContext; diff --git a/lib-xps/src/rpc/api.rs b/lib-xps/src/rpc/api.rs index b7124b5..c0d496b 100644 --- a/lib-xps/src/rpc/api.rs +++ b/lib-xps/src/rpc/api.rs @@ -4,9 +4,9 @@ use ethers::core::types::Signature; use ethers::prelude::*; use jsonrpsee::{proc_macros::rpc, types::ErrorObjectOwned}; +use lib_didethresolver::types::XmtpAttribute; use xps_types::Message; use xps_types::{GrantInstallationResult, KeyPackageResult}; -use lib_didethresolver::types::XmtpAttribute; /// XPS JSON-RPC Interface Methods #[rpc(server, client, namespace = "xps")] diff --git a/lib-xps/src/rpc/methods.rs b/lib-xps/src/rpc/methods.rs index f18df6a..ff756ee 100644 --- a/lib-xps/src/rpc/methods.rs +++ b/lib-xps/src/rpc/methods.rs @@ -8,15 +8,15 @@ use jsonrpsee::types::error::ErrorCode; use async_trait::async_trait; use ethers::prelude::*; use ethers::{core::types::Signature, providers::Middleware}; -use xps_types::{GrantInstallationResult, KeyPackageResult}; use jsonrpsee::types::ErrorObjectOwned; use lib_didethresolver::types::XmtpAttribute; use rand::{rngs::StdRng, SeedableRng}; use std::sync::Arc; use thiserror::Error; +use xps_types::{GrantInstallationResult, KeyPackageResult}; -use xps_types::Message; use registry::{error::ContactOperationError, ContactOperations}; +use xps_types::Message; // DEFAULT_ATTRIBUTE_VALIDITY is the hard-coded value we use for the validity of the attributes we set. // This value is interpeted as number of seconds starting from the block where the attribute is being set. diff --git a/registry/src/lib.rs b/registry/src/lib.rs index 7eeb47a..2744b0e 100644 --- a/registry/src/lib.rs +++ b/registry/src/lib.rs @@ -5,10 +5,10 @@ use std::str::FromStr; use error::ContactOperationError; use ethers::types::{H160, U256}; use ethers::{core::types::Signature, providers::Middleware, types::Address}; -use xps_types::{GrantInstallationResult, KeyPackageResult, Status}; use lib_didethresolver::types::VerificationMethodProperties; use lib_didethresolver::Resolver; use lib_didethresolver::{did_registry::DIDRegistry, types::XmtpAttribute}; +use xps_types::{GrantInstallationResult, KeyPackageResult, Status}; pub struct ContactOperations { registry: DIDRegistry, diff --git a/xps/src/main.rs b/xps/src/main.rs index 9f55207..ebde1bc 100644 --- a/xps/src/main.rs +++ b/xps/src/main.rs @@ -3,11 +3,7 @@ use clap::Parser; use lib_xps::run; #[derive(Parser, Debug)] -#[command( - name = "xps", - version = "0.1.0", - about = "XMTP Postal Service" -)] +#[command(name = "xps", version = "0.1.0", about = "XMTP Postal Service")] struct Args { #[arg(short = 'p', long = "port", default_value_t = 0)] port: u16, From 60f2a96194dd857dc623f6865b1a687bf00bc3b5 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Thu, 8 Feb 2024 20:12:42 -0500 Subject: [PATCH 6/8] revert changes to yaml --- .github/workflows/ghcr-image.yml | 26 +++++++++++++++++++------- .github/workflows/prod-ci-image.yml | 14 ++++++++++---- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ghcr-image.yml b/.github/workflows/ghcr-image.yml index a5e8322..92d05d3 100644 --- a/.github/workflows/ghcr-image.yml +++ b/.github/workflows/ghcr-image.yml @@ -1,44 +1,56 @@ name: Docker Image Build Push + on: push: tags: - "*" + concurrency: group: "docker-image" cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout + - + name: Checkout uses: actions/checkout@v3 - - name: Set up QEMU + - + name: Set up QEMU uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Generate repository name run: | echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV} echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-8 )" >> ${GITHUB_ENV} - - name: Login to GitHub Container Registry + - + name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and Push + - + name: Build and Push uses: docker/build-push-action@v3 with: context: . file: ./prod/Dockerfile platforms: linux/amd64,linux/arm64 push: true - build-args: "VERSION=${{ github.ref_name }}\nCARGO_INCREMENTAL=0 \n" + build-args: | + VERSION=${{ github.ref_name }} + CARGO_INCREMENTAL=0 tags: | ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }} ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }} ghcr.io/${{ env.REPOSITORY_PATH }}:latest - - name: GitHub Release + - + name: GitHub Release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prod-ci-image.yml b/.github/workflows/prod-ci-image.yml index d3b2d4a..16027cb 100644 --- a/.github/workflows/prod-ci-image.yml +++ b/.github/workflows/prod-ci-image.yml @@ -1,4 +1,5 @@ name: Build Prod Image CI + on: workflow_dispatch: pull_request: @@ -7,23 +8,28 @@ on: push: branches: - "*" + jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout + - + name: Checkout uses: actions/checkout@v3 - - name: Set up QEMU + - + name: Set up QEMU uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build Prod Image CI uses: docker/build-push-action@v3 with: context: . - file: prod/Dockerfile + file: prod/Dockerfile platforms: linux/amd64 push: false build-args: | VERSION=latest CARGO_INCREMENTAL=0 + From c9a273e563a6ef9e8c23d74bde5c2c0022a7033d Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Fri, 9 Feb 2024 14:21:31 -0500 Subject: [PATCH 7/8] add export of XpsClient in root --- lib-xps/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib-xps/src/lib.rs b/lib-xps/src/lib.rs index a467507..d8afe74 100644 --- a/lib-xps/src/lib.rs +++ b/lib-xps/src/lib.rs @@ -11,7 +11,7 @@ use jsonrpsee::server::Server; use std::str::FromStr; use xps_types::DID_ETH_REGISTRY; -pub use crate::rpc::{XpsMethods, XpsServer}; +pub use crate::rpc::{XpsClient, XpsMethods, XpsServer}; use crate::types::GatewayContext; /// Entrypoint for the xps Gateway From 9e8627f35a9b335676b1256fa4ced8cfa79b7cf4 Mon Sep 17 00:00:00 2001 From: Andrew Plaza Date: Mon, 12 Feb 2024 13:36:43 -0500 Subject: [PATCH 8/8] fix after merge --- lib-xps/src/lib.rs | 3 +-- lib-xps/src/rpc/api.rs | 7 +++---- lib-xps/src/rpc/methods.rs | 9 +++------ lib-xps/tests/integration_test.rs | 4 ++-- messaging/src/lib.rs | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib-xps/src/lib.rs b/lib-xps/src/lib.rs index 6a8e483..3fd478e 100644 --- a/lib-xps/src/lib.rs +++ b/lib-xps/src/lib.rs @@ -7,10 +7,9 @@ use ethers::{ abi::Address, providers::{Provider, Ws}, }; -use gateway_types::{CONVERSATION, DID_ETH_REGISTRY}; use jsonrpsee::server::Server; use std::str::FromStr; -use xps_types::DID_ETH_REGISTRY; +use xps_types::{CONVERSATION, DID_ETH_REGISTRY}; pub use crate::rpc::{XpsClient, XpsMethods, XpsServer}; use crate::types::GatewayContext; diff --git a/lib-xps/src/rpc/api.rs b/lib-xps/src/rpc/api.rs index b09d9b7..d099955 100644 --- a/lib-xps/src/rpc/api.rs +++ b/lib-xps/src/rpc/api.rs @@ -4,11 +4,10 @@ use ethers::core::types::Signature; use ethers::prelude::*; use jsonrpsee::{proc_macros::rpc, types::ErrorObjectOwned}; -use gateway_types::{GrantInstallationResult, KeyPackageResult, WalletBalance}; -use gateway_types::{Message, SendMessageResult}; use lib_didethresolver::types::XmtpAttribute; -use xps_types::Message; -use xps_types::{GrantInstallationResult, KeyPackageResult}; +use xps_types::{ + GrantInstallationResult, KeyPackageResult, Message, SendMessageResult, WalletBalance, +}; /// XPS JSON-RPC Interface Methods #[rpc(server, client, namespace = "xps")] diff --git a/lib-xps/src/rpc/methods.rs b/lib-xps/src/rpc/methods.rs index 91f110a..89aa19e 100644 --- a/lib-xps/src/rpc/methods.rs +++ b/lib-xps/src/rpc/methods.rs @@ -10,21 +10,18 @@ use ethers::{ core::types::Signature, providers::{Middleware, ProviderError}, }; -use gateway_types::{ - GrantInstallationResult, KeyPackageResult, SendMessageResult, Unit, WalletBalance, -}; use jsonrpsee::types::ErrorObjectOwned; use lib_didethresolver::types::XmtpAttribute; use messaging::MessagingOperations; use rand::{rngs::StdRng, SeedableRng}; use std::sync::Arc; use thiserror::Error; -use xps_types::{GrantInstallationResult, KeyPackageResult}; +use xps_types::{ + GrantInstallationResult, KeyPackageResult, Message, SendMessageResult, Unit, WalletBalance, +}; -use gateway_types::Message; use messaging::error::MessagingOperationError; use registry::{error::ContactOperationError, ContactOperations}; -use xps_types::Message; // DEFAULT_ATTRIBUTE_VALIDITY is the hard-coded value we use for the validity of the attributes we set. // This value is interpeted as number of seconds starting from the block where the attribute is being set. diff --git a/lib-xps/tests/integration_test.rs b/lib-xps/tests/integration_test.rs index 8788674..79f1d56 100644 --- a/lib-xps/tests/integration_test.rs +++ b/lib-xps/tests/integration_test.rs @@ -8,15 +8,15 @@ use ethers::providers::Middleware; use ethers::types::{Address, Bytes, TransactionRequest, U256}; use ethers::utils::keccak256; use ethers::{signers::LocalWallet, signers::Signer}; -use gateway_types::{Message, Status, Unit}; use integration_util::*; use jsonrpsee::core::ClientError; use lib_didethresolver::{ did_registry::RegistrySignerExt, types::{DidUrl, KeyEncoding, XmtpAttribute, XmtpKeyPurpose, NULL_ADDRESS}, }; +use lib_xps::rpc::{XpsClient, DEFAULT_ATTRIBUTE_VALIDITY}; use messaging::ConversationSignerExt; -use xps_gateway::rpc::{XpsClient, DEFAULT_ATTRIBUTE_VALIDITY}; +use xps_types::{Message, Status, Unit}; #[tokio::test] async fn test_say_hello() -> Result<(), Error> { diff --git a/messaging/src/lib.rs b/messaging/src/lib.rs index e9d6e44..88a3174 100644 --- a/messaging/src/lib.rs +++ b/messaging/src/lib.rs @@ -11,7 +11,7 @@ use ethers::{ types::H256, utils::keccak256, }; -use gateway_types::{error::ExtSignerError, Message, SendMessageResult, Status}; +use xps_types::{error::ExtSignerError, Message, SendMessageResult, Status}; abigen!( Conversation,