Skip to content

Commit

Permalink
omni-executor basic CI checks (#3137)
Browse files Browse the repository at this point in the history
* omni-executor rust version bump

* check omni-executor in CI

* cargo fmt

* specify working dirs

* remove verbose

* fixes

* fix lints

---------

Co-authored-by: Kai <[email protected]>
  • Loading branch information
kziemianek and Kailai-Wang authored Oct 22, 2024
1 parent 5b3aebd commit 628b66a
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/file-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -570,6 +586,27 @@ jobs:
if: failure()
uses: andymckay/[email protected]

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:
Expand Down
3 changes: 3 additions & 0 deletions tee-worker/omni-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tee-worker/omni-executor/executor-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ async-trait = { workspace = true }
log = { workspace = true }
parity-scale-codec = { workspace = true, features = ["derive"] }
tokio = { workspace = true }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion tee-worker/omni-executor/executor-core/src/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<Id: Clone> IntentionEvent<Id> {
/// `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,
Expand Down
3 changes: 3 additions & 0 deletions tee-worker/omni-executor/executor-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tee-worker/omni-executor/executor-worker/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
pub parentchain_url: String,
pub ethereum_url: String,
}
20 changes: 13 additions & 7 deletions tee-worker/omni-executor/executor-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

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;

Expand All @@ -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<JoinHandle<()>, ()> {
async fn listen_to_parentchain(
parentchain_url: String,
ethereum_url: String,
) -> Result<JoinHandle<()>, ()> {
let (_sub_stop_sender, sub_stop_receiver) = oneshot::channel();
let ethereum_intention_executor = EthereumIntentionExecutor::new(&ethereum_url)
.map_err(|e| log::error!("{:?}", e))?;
let ethereum_intention_executor =
EthereumIntentionExecutor::new(&ethereum_url).map_err(|e| log::error!("{:?}", e))?;

let mut parentchain_listener =
parentchain_listener::create_listener::<CustomConfig, EthereumIntentionExecutor>(
Expand Down
3 changes: 3 additions & 0 deletions tee-worker/omni-executor/parentchain/listener/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }

[dev-dependencies]
env_logger = { workspace = true }

[lints]
workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ impl<ChainConfig: Config, EthereumIntentionExecutorT: IntentionExecutor + Send +
//to explicitly handle all intention variants
match intention {
Intention::CallEthereum(_, _) => {
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
Expand Down

0 comments on commit 628b66a

Please sign in to comment.