From ba435bac761fa10e51001061c6b62d1624f0079c Mon Sep 17 00:00:00 2001 From: Reisen Date: Wed, 17 Apr 2024 13:16:41 +0000 Subject: [PATCH] refactor(fortuna): re-organize in monorepo --- .github/workflows/ci-fortuna.yml | 6 +++--- .github/workflows/push-fortuna-image.yml | 2 +- .pre-commit-config.yaml | 4 ++-- {fortuna => apps/fortuna}/.gitignore | 0 {fortuna => apps/fortuna}/Cargo.lock | 0 {fortuna => apps/fortuna}/Cargo.toml | 2 +- {fortuna => apps/fortuna}/Dockerfile | 6 +++--- {fortuna => apps/fortuna}/README.md | 0 {fortuna => apps/fortuna}/config.sample.yaml | 0 apps/fortuna/rust-toolchain | 1 + {fortuna => apps/fortuna}/src/api.rs | 0 {fortuna => apps/fortuna}/src/api/chain_ids.rs | 0 {fortuna => apps/fortuna}/src/api/index.rs | 0 {fortuna => apps/fortuna}/src/api/live.rs | 0 {fortuna => apps/fortuna}/src/api/metrics.rs | 0 {fortuna => apps/fortuna}/src/api/ready.rs | 0 {fortuna => apps/fortuna}/src/api/revelation.rs | 0 {fortuna => apps/fortuna}/src/chain.rs | 0 {fortuna => apps/fortuna}/src/chain/ethereum.rs | 2 +- {fortuna => apps/fortuna}/src/chain/reader.rs | 0 {fortuna => apps/fortuna}/src/command.rs | 0 {fortuna => apps/fortuna}/src/command/generate.rs | 0 {fortuna => apps/fortuna}/src/command/get_request.rs | 0 {fortuna => apps/fortuna}/src/command/register_provider.rs | 0 {fortuna => apps/fortuna}/src/command/request_randomness.rs | 0 {fortuna => apps/fortuna}/src/command/run.rs | 0 {fortuna => apps/fortuna}/src/command/setup_provider.rs | 0 {fortuna => apps/fortuna}/src/config.rs | 0 {fortuna => apps/fortuna}/src/config/generate.rs | 0 {fortuna => apps/fortuna}/src/config/get_request.rs | 0 {fortuna => apps/fortuna}/src/config/register_provider.rs | 0 {fortuna => apps/fortuna}/src/config/request_randomness.rs | 0 {fortuna => apps/fortuna}/src/config/run.rs | 0 {fortuna => apps/fortuna}/src/config/setup_provider.rs | 0 {fortuna => apps/fortuna}/src/keeper.rs | 0 {fortuna => apps/fortuna}/src/main.rs | 0 {fortuna => apps/fortuna}/src/state.rs | 0 37 files changed, 12 insertions(+), 11 deletions(-) rename {fortuna => apps/fortuna}/.gitignore (100%) rename {fortuna => apps/fortuna}/Cargo.lock (100%) rename {fortuna => apps/fortuna}/Cargo.toml (94%) rename {fortuna => apps/fortuna}/Dockerfile (75%) rename {fortuna => apps/fortuna}/README.md (100%) rename {fortuna => apps/fortuna}/config.sample.yaml (100%) create mode 100644 apps/fortuna/rust-toolchain rename {fortuna => apps/fortuna}/src/api.rs (100%) rename {fortuna => apps/fortuna}/src/api/chain_ids.rs (100%) rename {fortuna => apps/fortuna}/src/api/index.rs (100%) rename {fortuna => apps/fortuna}/src/api/live.rs (100%) rename {fortuna => apps/fortuna}/src/api/metrics.rs (100%) rename {fortuna => apps/fortuna}/src/api/ready.rs (100%) rename {fortuna => apps/fortuna}/src/api/revelation.rs (100%) rename {fortuna => apps/fortuna}/src/chain.rs (100%) rename {fortuna => apps/fortuna}/src/chain/ethereum.rs (99%) rename {fortuna => apps/fortuna}/src/chain/reader.rs (100%) rename {fortuna => apps/fortuna}/src/command.rs (100%) rename {fortuna => apps/fortuna}/src/command/generate.rs (100%) rename {fortuna => apps/fortuna}/src/command/get_request.rs (100%) rename {fortuna => apps/fortuna}/src/command/register_provider.rs (100%) rename {fortuna => apps/fortuna}/src/command/request_randomness.rs (100%) rename {fortuna => apps/fortuna}/src/command/run.rs (100%) rename {fortuna => apps/fortuna}/src/command/setup_provider.rs (100%) rename {fortuna => apps/fortuna}/src/config.rs (100%) rename {fortuna => apps/fortuna}/src/config/generate.rs (100%) rename {fortuna => apps/fortuna}/src/config/get_request.rs (100%) rename {fortuna => apps/fortuna}/src/config/register_provider.rs (100%) rename {fortuna => apps/fortuna}/src/config/request_randomness.rs (100%) rename {fortuna => apps/fortuna}/src/config/run.rs (100%) rename {fortuna => apps/fortuna}/src/config/setup_provider.rs (100%) rename {fortuna => apps/fortuna}/src/keeper.rs (100%) rename {fortuna => apps/fortuna}/src/main.rs (100%) rename {fortuna => apps/fortuna}/src/state.rs (100%) diff --git a/.github/workflows/ci-fortuna.yml b/.github/workflows/ci-fortuna.yml index c7e41022..bdff0b9d 100644 --- a/.github/workflows/ci-fortuna.yml +++ b/.github/workflows/ci-fortuna.yml @@ -2,10 +2,10 @@ name: Check Fortuna on: pull_request: - paths: [fortuna/**] + paths: [apps/fortuna/**] push: branches: [main] - paths: [fortuna/**] + paths: [apps/fortuna/**] jobs: test: runs-on: ubuntu-latest @@ -17,4 +17,4 @@ jobs: toolchain: nightly-2023-07-23 override: true - name: Run executor tests - run: cargo test --manifest-path ./fortuna/Cargo.toml + run: cargo test --manifest-path ./apps/fortuna/Cargo.toml diff --git a/.github/workflows/push-fortuna-image.yml b/.github/workflows/push-fortuna-image.yml index 1351f425..71645d1b 100644 --- a/.github/workflows/push-fortuna-image.yml +++ b/.github/workflows/push-fortuna-image.yml @@ -46,7 +46,7 @@ jobs: uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . - file: "./fortuna/Dockerfile" + file: "./apps/fortuna/Dockerfile" push: true tags: ${{ steps.metadata_fortuna.outputs.tags }} labels: ${{ steps.metadata_fortuna.outputs.labels }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba5fa8bc..bf55676a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,9 +60,9 @@ repos: - id: cargo-fmt-fortuna name: Cargo format for Fortuna language: "rust" - entry: cargo +nightly-2023-07-23 fmt --manifest-path ./fortuna/Cargo.toml --all -- --config-path rustfmt.toml + entry: cargo +nightly-2023-07-23 fmt --manifest-path ./apps/fortuna/Cargo.toml --all -- --config-path rustfmt.toml pass_filenames: false - files: fortuna + files: apps/fortuna # Hooks for message buffer contract - id: cargo-fmt-message-buffer name: Cargo format for message buffer contract diff --git a/fortuna/.gitignore b/apps/fortuna/.gitignore similarity index 100% rename from fortuna/.gitignore rename to apps/fortuna/.gitignore diff --git a/fortuna/Cargo.lock b/apps/fortuna/Cargo.lock similarity index 100% rename from fortuna/Cargo.lock rename to apps/fortuna/Cargo.lock diff --git a/fortuna/Cargo.toml b/apps/fortuna/Cargo.toml similarity index 94% rename from fortuna/Cargo.toml rename to apps/fortuna/Cargo.toml index deeba94d..1fa6a994 100644 --- a/fortuna/Cargo.toml +++ b/apps/fortuna/Cargo.toml @@ -16,7 +16,7 @@ ethers = { version = "2.0.14", features = ["ws"] } futures = { version = "0.3.28" } hex = "0.4.3" prometheus-client = { version = "0.21.2" } -pythnet-sdk = { path = "../pythnet/pythnet_sdk", features = ["strum"] } +pythnet-sdk = { path = "../../pythnet/pythnet_sdk", features = ["strum"] } rand = "0.8.5" reqwest = { version = "0.11.22", features = ["json", "blocking"] } serde = { version = "1.0.188", features = ["derive"] } diff --git a/fortuna/Dockerfile b/apps/fortuna/Dockerfile similarity index 75% rename from fortuna/Dockerfile rename to apps/fortuna/Dockerfile index d2e1f619..cc6fcfcf 100644 --- a/fortuna/Dockerfile +++ b/apps/fortuna/Dockerfile @@ -7,15 +7,15 @@ RUN rustup default nightly-2023-07-23 # Build WORKDIR /src -COPY fortuna fortuna +COPY apps/fortuna apps/fortuna COPY pythnet pythnet COPY target_chains/ethereum/entropy_sdk/solidity/abis target_chains/ethereum/entropy_sdk/solidity/abis -WORKDIR /src/fortuna +WORKDIR /src/apps/fortuna RUN --mount=type=cache,target=/root/.cargo/registry cargo build --release FROM rust:${RUST_VERSION} # Copy artifacts from other images -COPY --from=build /src/fortuna/target/release/fortuna /usr/local/bin/ +COPY --from=build /src/apps/fortuna/target/release/fortuna /usr/local/bin/ diff --git a/fortuna/README.md b/apps/fortuna/README.md similarity index 100% rename from fortuna/README.md rename to apps/fortuna/README.md diff --git a/fortuna/config.sample.yaml b/apps/fortuna/config.sample.yaml similarity index 100% rename from fortuna/config.sample.yaml rename to apps/fortuna/config.sample.yaml diff --git a/apps/fortuna/rust-toolchain b/apps/fortuna/rust-toolchain new file mode 100644 index 00000000..4c91121f --- /dev/null +++ b/apps/fortuna/rust-toolchain @@ -0,0 +1 @@ +nightly-2023-07-23-x86_64-unknown-linux-gnu diff --git a/fortuna/src/api.rs b/apps/fortuna/src/api.rs similarity index 100% rename from fortuna/src/api.rs rename to apps/fortuna/src/api.rs diff --git a/fortuna/src/api/chain_ids.rs b/apps/fortuna/src/api/chain_ids.rs similarity index 100% rename from fortuna/src/api/chain_ids.rs rename to apps/fortuna/src/api/chain_ids.rs diff --git a/fortuna/src/api/index.rs b/apps/fortuna/src/api/index.rs similarity index 100% rename from fortuna/src/api/index.rs rename to apps/fortuna/src/api/index.rs diff --git a/fortuna/src/api/live.rs b/apps/fortuna/src/api/live.rs similarity index 100% rename from fortuna/src/api/live.rs rename to apps/fortuna/src/api/live.rs diff --git a/fortuna/src/api/metrics.rs b/apps/fortuna/src/api/metrics.rs similarity index 100% rename from fortuna/src/api/metrics.rs rename to apps/fortuna/src/api/metrics.rs diff --git a/fortuna/src/api/ready.rs b/apps/fortuna/src/api/ready.rs similarity index 100% rename from fortuna/src/api/ready.rs rename to apps/fortuna/src/api/ready.rs diff --git a/fortuna/src/api/revelation.rs b/apps/fortuna/src/api/revelation.rs similarity index 100% rename from fortuna/src/api/revelation.rs rename to apps/fortuna/src/api/revelation.rs diff --git a/fortuna/src/chain.rs b/apps/fortuna/src/chain.rs similarity index 100% rename from fortuna/src/chain.rs rename to apps/fortuna/src/chain.rs diff --git a/fortuna/src/chain/ethereum.rs b/apps/fortuna/src/chain/ethereum.rs similarity index 99% rename from fortuna/src/chain/ethereum.rs rename to apps/fortuna/src/chain/ethereum.rs index 228770ef..5d543960 100644 --- a/fortuna/src/chain/ethereum.rs +++ b/apps/fortuna/src/chain/ethereum.rs @@ -59,7 +59,7 @@ use { // contract in the same repo. abigen!( PythRandom, - "../target_chains/ethereum/entropy_sdk/solidity/abis/IEntropy.json" + "../../target_chains/ethereum/entropy_sdk/solidity/abis/IEntropy.json" ); pub type SignablePythContract = PythRandom< diff --git a/fortuna/src/chain/reader.rs b/apps/fortuna/src/chain/reader.rs similarity index 100% rename from fortuna/src/chain/reader.rs rename to apps/fortuna/src/chain/reader.rs diff --git a/fortuna/src/command.rs b/apps/fortuna/src/command.rs similarity index 100% rename from fortuna/src/command.rs rename to apps/fortuna/src/command.rs diff --git a/fortuna/src/command/generate.rs b/apps/fortuna/src/command/generate.rs similarity index 100% rename from fortuna/src/command/generate.rs rename to apps/fortuna/src/command/generate.rs diff --git a/fortuna/src/command/get_request.rs b/apps/fortuna/src/command/get_request.rs similarity index 100% rename from fortuna/src/command/get_request.rs rename to apps/fortuna/src/command/get_request.rs diff --git a/fortuna/src/command/register_provider.rs b/apps/fortuna/src/command/register_provider.rs similarity index 100% rename from fortuna/src/command/register_provider.rs rename to apps/fortuna/src/command/register_provider.rs diff --git a/fortuna/src/command/request_randomness.rs b/apps/fortuna/src/command/request_randomness.rs similarity index 100% rename from fortuna/src/command/request_randomness.rs rename to apps/fortuna/src/command/request_randomness.rs diff --git a/fortuna/src/command/run.rs b/apps/fortuna/src/command/run.rs similarity index 100% rename from fortuna/src/command/run.rs rename to apps/fortuna/src/command/run.rs diff --git a/fortuna/src/command/setup_provider.rs b/apps/fortuna/src/command/setup_provider.rs similarity index 100% rename from fortuna/src/command/setup_provider.rs rename to apps/fortuna/src/command/setup_provider.rs diff --git a/fortuna/src/config.rs b/apps/fortuna/src/config.rs similarity index 100% rename from fortuna/src/config.rs rename to apps/fortuna/src/config.rs diff --git a/fortuna/src/config/generate.rs b/apps/fortuna/src/config/generate.rs similarity index 100% rename from fortuna/src/config/generate.rs rename to apps/fortuna/src/config/generate.rs diff --git a/fortuna/src/config/get_request.rs b/apps/fortuna/src/config/get_request.rs similarity index 100% rename from fortuna/src/config/get_request.rs rename to apps/fortuna/src/config/get_request.rs diff --git a/fortuna/src/config/register_provider.rs b/apps/fortuna/src/config/register_provider.rs similarity index 100% rename from fortuna/src/config/register_provider.rs rename to apps/fortuna/src/config/register_provider.rs diff --git a/fortuna/src/config/request_randomness.rs b/apps/fortuna/src/config/request_randomness.rs similarity index 100% rename from fortuna/src/config/request_randomness.rs rename to apps/fortuna/src/config/request_randomness.rs diff --git a/fortuna/src/config/run.rs b/apps/fortuna/src/config/run.rs similarity index 100% rename from fortuna/src/config/run.rs rename to apps/fortuna/src/config/run.rs diff --git a/fortuna/src/config/setup_provider.rs b/apps/fortuna/src/config/setup_provider.rs similarity index 100% rename from fortuna/src/config/setup_provider.rs rename to apps/fortuna/src/config/setup_provider.rs diff --git a/fortuna/src/keeper.rs b/apps/fortuna/src/keeper.rs similarity index 100% rename from fortuna/src/keeper.rs rename to apps/fortuna/src/keeper.rs diff --git a/fortuna/src/main.rs b/apps/fortuna/src/main.rs similarity index 100% rename from fortuna/src/main.rs rename to apps/fortuna/src/main.rs diff --git a/fortuna/src/state.rs b/apps/fortuna/src/state.rs similarity index 100% rename from fortuna/src/state.rs rename to apps/fortuna/src/state.rs