Skip to content

Commit

Permalink
Merge branch 'main' into test/settlement-client
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv authored Aug 23, 2024
2 parents ef5a562 + 7926588 commit 6b7a656
Show file tree
Hide file tree
Showing 30 changed files with 536 additions and 254 deletions.
11 changes: 10 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ SQS_JOB_VERIFICATION_QUEUE_URL=
AWS_S3_BUCKET_NAME=
AWS_S3_BUCKET_REGION=


# Ethereum Settlement
DEFAULT_SETTLEMENT_CLIENT_RPC=
DEFAULT_L1_CORE_CONTRACT_ADDRESS=
DEFAULT_L1_CORE_CONTRACT_ADDRESS=

# Sharp Services
SHARP_CUSTOMER_ID=
SHARP_USER_CRT=
SHARP_USER_KEY=
SHARP_SERVER_CRT=
SHARP_PROOF_LAYOUT=

11 changes: 10 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,13 @@ DEFAULT_SETTLEMENT_CLIENT_RPC="http://localhost:3000"
# Ethereum Settlement
DEFAULT_L1_CORE_CONTRACT_ADDRESS="0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"
SHOULD_IMPERSONATE_ACCOUNT="true"
TEST_DUMMY_CONTRACT_ADDRESS="0xE5b6F5e695BA6E4aeD92B68c4CC8Df1160D69A81"
TEST_DUMMY_CONTRACT_ADDRESS="0xE5b6F5e695BA6E4aeD92B68c4CC8Df1160D69A81"

# Sharp Services
SHARP_CUSTOMER_ID="sharp_consumer_id"
SHARP_URL="http://127.0.0.1:5000"
# [IMP!!!] These are test certificates (they don't work)
SHARP_USER_CRT="LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR4ekNDQXErZ0F3SUJBZ0lVTjBSK0xpb1MzL2ZadUZsK291RjZNNFk2RnRZd0RRWUpLb1pJaHZjTkFRRUwKQlFBd2N6RUxNQWtHQTFVRUJoTUNTVTR4RXpBUkJnTlZCQWdNQ2xOdmJXVX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RGR6alRLRXN1CjRFUTVadnEwMnJvTEZ0ZjEvL3dRVG0xNkNKdFpGWnhNZ1phYnNxc2JRc3M2dWdMUGtTTmdBWjI1L2VhcWhnQ20KTjFUV2FxL0xJMVBLSkxPK085NFlMa2FsNVpyOTJCOXk4Q0VKVUVuSTA1R1N1MmJUOFM2a0ZBMEpadEszTW9SbwpqRWZWV1lQVHR5TFR4amNvRndCcDlHaXZYSDdSdHBxMDlmSmFhU1pNekxmNGlyNHpBdXprbExBNWZvampPNXlKCllnYlVaQUU2aS81N1NFWjR3VmxTCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
SHARP_PROOF_LAYOUT="small"
33 changes: 20 additions & 13 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
name: Task - Rust Tests & Coverage
name: Rust Test & Coverage

on:
pull_request_target:
Expand All @@ -14,7 +13,6 @@ on:

jobs:
coverage:
# sadly, for now we have to "rebuild" for the coverage
runs-on: ubuntu-latest

services:
Expand All @@ -39,8 +37,15 @@ jobs:
# before the plugin, as the cache uses the current rustc version as its cache key
- run: rustup show

- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -56,21 +61,23 @@ jobs:
exit 1
fi
- name: Clean workspace
- name: Install cargo-llvm-cov & nextest
uses: taiki-e/install-action@cargo-llvm-cov

- name: Install nextest
uses: taiki-e/install-action@nextest

- name: Getting neccesary files for testing
run: |
cargo llvm-cov clean --workspace
wget -P ./crates/prover-services/sharp-service/tests/artifacts https://madara-orchestrator-sharp-pie.s3.amazonaws.com/238996-SN.zip
- name: Run llvm-cov
- name: Run llvm-cov tests
env:
ETHEREUM_BLAST_RPC_URL: ${{ secrets.ETHEREUM_BLAST_RPC_URL }}
run: |
cargo llvm-cov nextest --release --lcov --output-path lcov.info --test-threads=1
run: cargo llvm-cov nextest --release --lcov --output-path lcov.info --test-threads=1

- name: Coveralls
uses: coverallsapp/github-action@v2
with:
files: lcov.info
debug: true

- uses: colpal/actions-clean@v1
if: ${{ always() }} # To ensure this step runs even when earlier steps fail
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
*.code-workspace
.vscode

lcov.info
lcov.info

**/*-SN.zip
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## Added

- Tests for Settlement client.
- Tests for prover client.
- Added Rust Cache for Coverage Test CI.
- support for fetching PIE file from storage client in proving job.
- added coveralls support
- moved mongodb serde behind feature flag
- implemented DA worker.
Expand All @@ -33,8 +36,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Removed

- `init_config` from all the tests.
- `fetch_from_test` argument

## Fixed

- Get Fact Info logic.
- Fixed state update worker logic as per the new implementation.
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dotenvy = "0.15.7"
futures = "0.3.30"
mongodb = { version = "2.8.1" }
omniqueue = { version = "0.2.0" }
reqwest = { version = "0.11.24" }
reqwest = { version = "0.11.24", features = ["rustls-tls", "native-tls"] }
rstest = "0.18.2"
serde = { version = "1.0.197" }
serde_json = "1.0.114"
Expand All @@ -48,7 +48,7 @@ tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18" }
url = { version = "2.5.0", features = ["serde"] }
uuid = { version = "1.7.0", features = ["v4", "serde"] }
httpmock = { version = "0.7.0" }
httpmock = { version = "0.7.0", features = ["remote"] }
num-bigint = { version = "0.4.4" }
arc-swap = { version = "1.7.1" }
num-traits = "0.2"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,17 @@ The tentative flow of the orchestrator looks like this but this is subject to
change as we learn more about external systems and the constraints involved.

![orchestrator_da_sequencer_diagram](./docs/orchestrator_da_sequencer_diagram.png)

## Testing

- Files needed for tests can be fetched through s3 :

```shell
wget -P ./crates/prover-services/sharp-service/tests/artifacts https://madara-orchestrator-sharp-pie.s3.amazonaws.com/238996-SN.zip
```

- To run all the tests :

```shell
cargo llvm-cov nextest --release --lcov --output-path lcov.info --test-threads=1
```
4 changes: 0 additions & 4 deletions crates/orchestrator/src/jobs/constants.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
pub const JOB_PROCESS_ATTEMPT_METADATA_KEY: &str = "process_attempt_no";

pub const JOB_VERIFICATION_ATTEMPT_METADATA_KEY: &str = "verification_attempt_no";

pub const JOB_METADATA_CAIRO_PIE_PATH_KEY: &str = "cairo_pie_path";

pub const JOB_METADATA_STATE_UPDATE_BLOCKS_TO_SETTLE_KEY: &str = "blocks_number_to_settle";
pub const JOB_METADATA_STATE_UPDATE_FETCH_FROM_TESTS: &str = "fetch_from_test_data";
pub const JOB_METADATA_STATE_UPDATE_ATTEMPT_PREFIX: &str = "attempt_tx_hashes_";
Expand Down
31 changes: 19 additions & 12 deletions crates/orchestrator/src/jobs/da_job/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,11 @@ pub mod test {
use std::fs;
use std::fs::File;
use std::io::Read;
use std::sync::Arc;

use crate::config::config;
use crate::data_storage::MockDataStorage;
use crate::tests::config::TestConfigBuilder;
use ::serde::{Deserialize, Serialize};
use color_eyre::Result;
use da_client_interface::MockDaClient;
Expand All @@ -385,9 +388,10 @@ pub mod test {
use majin_blob_types::state_diffs::UnorderedEq;
use rstest::rstest;
use serde_json::json;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::JsonRpcClient;
use starknet_core::types::{FieldElement, StateUpdate};

use crate::tests::common::init_config;
use url::Url;

/// Tests `da_word` function with various inputs for class flag, new nonce, and number of changes.
/// Verifies that `da_word` produces the correct FieldElement based on the provided parameters.
Expand Down Expand Up @@ -453,16 +457,19 @@ pub mod test {
// Mocking storage client
storage_client.expect_put_data().returning(|_, _| Result::Ok(())).times(1);

let config = init_config(
Some(format!("http://localhost:{}", server.port())),
None,
None,
Some(da_client),
None,
None,
Some(storage_client),
)
.await;
let provider = JsonRpcClient::new(HttpTransport::new(
Url::parse(format!("http://localhost:{}", server.port()).as_str()).expect("Failed to parse URL"),
));

// mock block number (madara) : 5
TestConfigBuilder::new()
.mock_starknet_client(Arc::new(provider))
.mock_da_client(Box::new(da_client))
.mock_storage_client(Box::new(storage_client))
.build()
.await;

let config = config().await;

get_nonce_attached(&server, nonce_file_path);

Expand Down
30 changes: 13 additions & 17 deletions crates/orchestrator/src/jobs/proving_job/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;

use async_trait::async_trait;
use cairo_vm::vm::runners::cairo_pie::CairoPie;
Expand All @@ -11,7 +9,6 @@ use tracing::log::log;
use tracing::log::Level::Error;
use uuid::Uuid;

use super::constants::JOB_METADATA_CAIRO_PIE_PATH_KEY;
use super::types::{JobItem, JobStatus, JobType, JobVerificationStatus};
use super::{Job, JobError, OtherError};
use crate::config::Config;
Expand All @@ -22,7 +19,10 @@ pub enum ProvingError {
CairoPIEWrongPath { internal_id: String },

#[error("Not able to read the cairo PIE file from the zip file provided.")]
CairoPIENotReadable,
CairoPIENotReadable(String),

#[error("Not able to get the PIE file from AWS S3 bucket.")]
CairoPIEFileFetchFailed(String),

#[error("Other error: {0}")]
Other(#[from] OtherError),
Expand All @@ -38,10 +38,6 @@ impl Job for ProvingJob {
internal_id: String,
metadata: HashMap<String, String>,
) -> Result<JobItem, JobError> {
if !metadata.contains_key(JOB_METADATA_CAIRO_PIE_PATH_KEY) {
// TODO: validate the usage of `.clone()` here, ensure lightweight borrowing of variables
Err(ProvingError::CairoPIEWrongPath { internal_id: internal_id.clone() })?
}
Ok(JobItem {
id: Uuid::new_v4(),
internal_id,
Expand All @@ -54,15 +50,15 @@ impl Job for ProvingJob {
}

async fn process_job(&self, config: &Config, job: &mut JobItem) -> Result<String, JobError> {
// TODO: allow to download PIE from storage
let cairo_pie_path = job
.metadata
.get(JOB_METADATA_CAIRO_PIE_PATH_KEY)
.map(|s| PathBuf::from_str(s))
.ok_or_else(|| ProvingError::CairoPIEWrongPath { internal_id: job.internal_id.clone() })?
.map_err(|_| ProvingError::CairoPIENotReadable)?;

let cairo_pie = CairoPie::read_zip_file(&cairo_pie_path).map_err(|_| ProvingError::CairoPIENotReadable)?;
// Cairo Pie path in s3 storage client
let cairo_pie_path = job.internal_id.to_string() + "/pie.zip";
let cairo_pie_file = config
.storage()
.get_data(&cairo_pie_path)
.await
.map_err(|e| ProvingError::CairoPIEFileFetchFailed(e.to_string()))?;
let cairo_pie = CairoPie::from_bytes(cairo_pie_file.to_vec().as_slice())
.map_err(|e| ProvingError::CairoPIENotReadable(e.to_string()))?;

let external_id = config
.prover_client()
Expand Down
47 changes: 2 additions & 45 deletions crates/orchestrator/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,66 +1,23 @@
pub mod constants;

use std::collections::HashMap;
use std::sync::Arc;

use ::uuid::Uuid;
use aws_config::Region;
use constants::*;
use da_client_interface::MockDaClient;
use mongodb::Client;
use prover_client_interface::MockProverClient;
use rstest::*;
use serde::Deserialize;
use settlement_client_interface::MockSettlementClient;
use starknet::providers::jsonrpc::HttpTransport;
use starknet::providers::JsonRpcClient;
use url::Url;

use crate::config::Config;
use crate::data_storage::aws_s3::config::{AWSS3ConfigType, S3LocalStackConfig};
use crate::data_storage::aws_s3::AWSS3;
use crate::data_storage::{DataStorage, DataStorageConfig, MockDataStorage};
use crate::data_storage::{DataStorage, DataStorageConfig};
use crate::database::mongodb::config::MongoDbConfig;
use crate::database::mongodb::MongoDb;
use crate::database::{DatabaseConfig, MockDatabase};
use crate::database::DatabaseConfig;
use crate::jobs::types::JobStatus::Created;
use crate::jobs::types::JobType::DataSubmission;
use crate::jobs::types::{ExternalId, JobItem};
use crate::queue::job_queue::{JOB_PROCESSING_QUEUE, JOB_VERIFICATION_QUEUE};
use crate::queue::MockQueueProvider;

pub async fn init_config(
rpc_url: Option<String>,
database: Option<MockDatabase>,
queue: Option<MockQueueProvider>,
da_client: Option<MockDaClient>,
prover_client: Option<MockProverClient>,
settlement_client: Option<MockSettlementClient>,
storage_client: Option<MockDataStorage>,
) -> Config {
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::INFO).with_target(false).try_init();

let rpc_url = rpc_url.unwrap_or(MADARA_RPC_URL.to_string());
let database = database.unwrap_or_default();
let queue = queue.unwrap_or_default();
let da_client = da_client.unwrap_or_default();
let prover_client = prover_client.unwrap_or_default();
let settlement_client = settlement_client.unwrap_or_default();
let storage_client = storage_client.unwrap_or_default();

// init starknet client
let provider = JsonRpcClient::new(HttpTransport::new(Url::parse(rpc_url.as_str()).expect("Failed to parse URL")));

Config::new(
Arc::new(provider),
Box::new(da_client),
Box::new(prover_client),
Box::new(settlement_client),
Box::new(database),
Box::new(queue),
Box::new(storage_client),
)
}

#[fixture]
pub fn default_job_item() -> JobItem {
Expand Down
Loading

0 comments on commit 6b7a656

Please sign in to comment.