From 628b66a58504773031fac6e51a46e1ac87dda937 Mon Sep 17 00:00:00 2001 From: Kasper Ziemianek Date: Tue, 22 Oct 2024 23:16:24 +0200 Subject: [PATCH] `omni-executor` basic CI checks (#3137) * omni-executor rust version bump * check omni-executor in CI * cargo fmt * specify working dirs * remove verbose * fixes * fix lints --------- Co-authored-by: Kai <7630809+Kailai-Wang@users.noreply.github.com> --- .github/file-filter.yml | 7 ++++ .github/workflows/ci.yml | 37 +++++++++++++++++++ tee-worker/omni-executor/Cargo.toml | 3 ++ .../ethereum/intention-executor/Cargo.toml | 3 ++ .../omni-executor/executor-core/Cargo.toml | 3 ++ .../executor-core/src/listener.rs | 2 +- .../omni-executor/executor-worker/Cargo.toml | 3 ++ .../omni-executor/executor-worker/src/cli.rs | 6 +-- .../omni-executor/executor-worker/src/main.rs | 20 ++++++---- .../parentchain/listener/Cargo.toml | 3 ++ .../parentchain/listener/src/event_handler.rs | 4 +- 11 files changed, 78 insertions(+), 13 deletions(-) diff --git a/.github/file-filter.yml b/.github/file-filter.yml index db877faf2d..0756c63e3e 100644 --- a/.github/file-filter.yml +++ b/.github/file-filter.yml @@ -45,3 +45,10 @@ bitacross_test: &bitacross_test - 'tee-worker/bitacross/cli/*.sh' - 'parachain/docker/**' - 'tee-worker/bitacross/docker/*.yml' + +omni_executor_src: &omni_executor_src + - 'tee-worker/omni-executor/Cargo.toml' + - 'tee-worker/omni-executor/Cargo.lock' + - 'tee-worker/omni-executor/**/*.rs' + - 'tee-worker/omni-executor/rust-toolchain.toml' + - 'tee-worker/omni-executor/**/*.scale' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7087e328f..86b2fe5e2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,6 +60,11 @@ on: description: rebuild-bitacross required: true default: true + check-omni-executor: + type: boolean + description: check-omni-executor + required: true + default: true run-multi-worker-test: type: boolean description: run-multi-worker-test @@ -95,6 +100,7 @@ jobs: rebuild_parachain: ${{ steps.env.outputs.rebuild_parachain }} rebuild_identity: ${{ steps.env.outputs.rebuild_identity }} rebuild_bitacross: ${{ steps.env.outputs.rebuild_bitacross }} + check_omni_executor: ${{ steps.env.outputs.check_omni_executor }} push_docker: ${{ steps.env.outputs.push_docker }} run_parachain_test: ${{ steps.env.outputs.run_parachain_test }} run_identity_test: ${{ steps.env.outputs.run_identity_test }} @@ -118,6 +124,7 @@ jobs: rebuild_parachain=false rebuild_identity=false rebuild_bitacross=false + check_omni_executor=false push_docker=false run_parachain_test=false run_identity_test=false @@ -130,6 +137,9 @@ jobs: if [ "${{ github.event.inputs.rebuild-bitacross }}" = "true" ] || [ "${{ steps.filter.outputs.bitacross_src }}" = "true" ]; then rebuild_bitacross=true fi + if [ "${{ github.event.inputs.check-omni-executor }}" = "true" ] || [ "${{ steps.filter.outputs.omni_executor_src }}" = "true" ]; then + check_omni_executor=true + fi if [ "${{ github.event.inputs.push-docker }}" = "true" ]; then push_docker=true elif [ "${{ github.event_name }}" = 'push' ] && [ "${{ github.ref }}" = 'refs/heads/dev' ]; then @@ -147,6 +157,7 @@ jobs: echo "rebuild_parachain=$rebuild_parachain" | tee -a $GITHUB_OUTPUT echo "rebuild_identity=$rebuild_identity" | tee -a $GITHUB_OUTPUT echo "rebuild_bitacross=$rebuild_bitacross" | tee -a $GITHUB_OUTPUT + echo "check_omni_executor=$check_omni_executor" | tee -a $GITHUB_OUTPUT echo "push_docker=$push_docker" | tee -a $GITHUB_OUTPUT echo "run_parachain_test=$run_parachain_test" | tee -a $GITHUB_OUTPUT echo "run_identity_test=$run_identity_test" | tee -a $GITHUB_OUTPUT @@ -191,6 +202,11 @@ jobs: run: | cargo fmt --all -- --check + - name: omni-executor fmt check + working-directory: ./tee-worker/omni-executor + run: | + cargo fmt --all -- --check + - name: Enable corepack and pnpm run: corepack enable && corepack enable pnpm @@ -570,6 +586,27 @@ jobs: if: failure() uses: andymckay/cancel-action@0.5 + omni-executor-check: + runs-on: ubuntu-latest + needs: + - fmt + - set-condition + - sequentialise + steps: + - uses: actions/checkout@v4 + - name: Clippy + if: needs.set-condition.outputs.check_omni_executor == 'true' + working-directory: ./tee-worker/omni-executor + run: cargo clippy --release -- -D warnings + - name: Build + if: needs.set-condition.outputs.check_omni_executor == 'true' + working-directory: ./tee-worker/omni-executor + run: cargo build + - name: Tests + if: needs.set-condition.outputs.check_omni_executor == 'true' + working-directory: ./tee-worker/omni-executor + run: cargo test + parachain-ts-test: runs-on: ubuntu-latest needs: diff --git a/tee-worker/omni-executor/Cargo.toml b/tee-worker/omni-executor/Cargo.toml index 1672f89225..a3135cf7c7 100644 --- a/tee-worker/omni-executor/Cargo.toml +++ b/tee-worker/omni-executor/Cargo.toml @@ -20,3 +20,6 @@ scale-encode = "0.7.1" parity-scale-codec = "3.6.12" alloy = "0.3.6" clap = "4.5.17" + +[workspace.lints.clippy] +result_unit_err = "allow" diff --git a/tee-worker/omni-executor/ethereum/intention-executor/Cargo.toml b/tee-worker/omni-executor/ethereum/intention-executor/Cargo.toml index 2c62fda636..97ecd9bc87 100644 --- a/tee-worker/omni-executor/ethereum/intention-executor/Cargo.toml +++ b/tee-worker/omni-executor/ethereum/intention-executor/Cargo.toml @@ -9,3 +9,6 @@ alloy = { workspace = true, features = ["contract", "signer-local", "rpc", "rpc- async-trait = { workspace = true } executor-core = { path = "../../executor-core" } log = { workspace = true } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/executor-core/Cargo.toml b/tee-worker/omni-executor/executor-core/Cargo.toml index 2139accc31..c214c2230c 100644 --- a/tee-worker/omni-executor/executor-core/Cargo.toml +++ b/tee-worker/omni-executor/executor-core/Cargo.toml @@ -9,3 +9,6 @@ async-trait = { workspace = true } log = { workspace = true } parity-scale-codec = { workspace = true, features = ["derive"] } tokio = { workspace = true } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/executor-core/src/listener.rs b/tee-worker/omni-executor/executor-core/src/listener.rs index f3293f8096..76fc11d7c8 100644 --- a/tee-worker/omni-executor/executor-core/src/listener.rs +++ b/tee-worker/omni-executor/executor-core/src/listener.rs @@ -42,7 +42,7 @@ impl IntentionEvent { /// `Fetcher` - used to fetch data from chain /// `IntentionExecutor` - used to execute intentions on target chain /// `CheckpointRepository` - used to store listener's progress -/// `EventId` - represents chain event id +/// `EventId` - represents chain event id /// `BlockEvent` - represents chain event pub struct Listener< Fetcher, diff --git a/tee-worker/omni-executor/executor-worker/Cargo.toml b/tee-worker/omni-executor/executor-worker/Cargo.toml index f0b8afd215..e4641b65e5 100644 --- a/tee-worker/omni-executor/executor-worker/Cargo.toml +++ b/tee-worker/omni-executor/executor-worker/Cargo.toml @@ -15,3 +15,6 @@ parentchain-listener = { path = "../parentchain/listener" } scale-encode = { workspace = true } serde_json = "1.0.127" tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/executor-worker/src/cli.rs b/tee-worker/omni-executor/executor-worker/src/cli.rs index 1bb4112442..3ee590d34b 100644 --- a/tee-worker/omni-executor/executor-worker/src/cli.rs +++ b/tee-worker/omni-executor/executor-worker/src/cli.rs @@ -3,6 +3,6 @@ use clap::Parser; #[derive(Parser)] #[command(version, about, long_about = None)] pub struct Cli { - pub parentchain_url: String, - pub ethereum_url: String, -} \ No newline at end of file + pub parentchain_url: String, + pub ethereum_url: String, +} diff --git a/tee-worker/omni-executor/executor-worker/src/main.rs b/tee-worker/omni-executor/executor-worker/src/main.rs index 19b1b64df3..5dfd1137d7 100644 --- a/tee-worker/omni-executor/executor-worker/src/main.rs +++ b/tee-worker/omni-executor/executor-worker/src/main.rs @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with Litentry. If not, see . +use crate::cli::Cli; +use clap::Parser; use intention_executor::EthereumIntentionExecutor; use log::error; use parentchain_listener::CustomConfig; use std::io::Write; use std::thread::JoinHandle; use std::{fs, thread}; -use clap::Parser; use tokio::runtime::Handle; use tokio::sync::oneshot; -use crate::cli::Cli; mod cli; @@ -43,21 +43,27 @@ async fn main() -> Result<(), ()> { }) .init(); - let cli = Cli::parse(); fs::create_dir_all("data/").map_err(|e| { error!("Could not create data dir: {:?}", e); })?; - listen_to_parentchain(cli.parentchain_url, cli.ethereum_url).await.unwrap().join().unwrap(); + listen_to_parentchain(cli.parentchain_url, cli.ethereum_url) + .await + .unwrap() + .join() + .unwrap(); Ok(()) } -async fn listen_to_parentchain(parentchain_url: String, ethereum_url: String) -> Result, ()> { +async fn listen_to_parentchain( + parentchain_url: String, + ethereum_url: String, +) -> Result, ()> { let (_sub_stop_sender, sub_stop_receiver) = oneshot::channel(); - let ethereum_intention_executor = EthereumIntentionExecutor::new(ðereum_url) - .map_err(|e| log::error!("{:?}", e))?; + let ethereum_intention_executor = + EthereumIntentionExecutor::new(ðereum_url).map_err(|e| log::error!("{:?}", e))?; let mut parentchain_listener = parentchain_listener::create_listener::( diff --git a/tee-worker/omni-executor/parentchain/listener/Cargo.toml b/tee-worker/omni-executor/parentchain/listener/Cargo.toml index 7c1fc8ce71..a33c0578a7 100644 --- a/tee-worker/omni-executor/parentchain/listener/Cargo.toml +++ b/tee-worker/omni-executor/parentchain/listener/Cargo.toml @@ -15,3 +15,6 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } [dev-dependencies] env_logger = { workspace = true } + +[lints] +workspace = true diff --git a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs index 6ac81c4e60..937452564c 100644 --- a/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs +++ b/tee-worker/omni-executor/parentchain/listener/src/event_handler.rs @@ -103,14 +103,14 @@ impl { - self.ethereum_intention_executor.execute(intention).await.map_err(|e| { + self.ethereum_intention_executor.execute(intention).await.map_err(|_| { // assume for now we can easily recover log::error!("Error executing intention"); Error::RecoverableError })?; }, Intention::TransferEthereum(_, _) => { - self.ethereum_intention_executor.execute(intention).await.map_err(|e| { + self.ethereum_intention_executor.execute(intention).await.map_err(|_| { // assume for now we can easily recover log::error!("Error executing intention"); Error::RecoverableError