-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boilerplate code #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::config::Config; | ||
use crate::jobs::types::{JobItem, JobStatus, JobType, JobVerificationStatus}; | ||
use crate::jobs::Job; | ||
use async_trait::async_trait; | ||
use color_eyre::Result; | ||
use std::collections::HashMap; | ||
use uuid::Uuid; | ||
|
||
pub struct RegisterProofJob; | ||
|
||
#[async_trait] | ||
impl Job for RegisterProofJob { | ||
async fn create_job( | ||
&self, | ||
_config: &Config, | ||
internal_id: String, | ||
metadata: HashMap<String, String>, | ||
) -> Result<JobItem> { | ||
Ok(JobItem { | ||
id: Uuid::new_v4(), | ||
internal_id, | ||
job_type: JobType::ProofRegistration, | ||
status: JobStatus::Created, | ||
external_id: String::new().into(), | ||
// metadata must contain the blocks that have been included inside this proof | ||
// this will allow state update jobs to be created for each block | ||
metadata, | ||
version: 0, | ||
}) | ||
} | ||
|
||
async fn process_job(&self, _config: &Config, _job: &JobItem) -> Result<String> { | ||
// Get proof from S3 and submit on chain for verification | ||
// We need to implement a generic trait for this to support multiple | ||
// base layers | ||
todo!() | ||
} | ||
|
||
async fn verify_job(&self, _config: &Config, _job: &JobItem) -> Result<JobVerificationStatus> { | ||
// verify that the proof transaction has been included on chain | ||
todo!() | ||
} | ||
|
||
fn max_process_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn max_verification_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn verification_polling_delay_seconds(&self) -> u64 { | ||
todo!() | ||
} | ||
} | ||
Comment on lines
+9
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::config::Config; | ||
use crate::jobs::types::{JobItem, JobStatus, JobType, JobVerificationStatus}; | ||
use crate::jobs::Job; | ||
use async_trait::async_trait; | ||
use color_eyre::Result; | ||
use std::collections::HashMap; | ||
use uuid::Uuid; | ||
|
||
pub struct SnosJob; | ||
|
||
#[async_trait] | ||
impl Job for SnosJob { | ||
async fn create_job( | ||
&self, | ||
_config: &Config, | ||
internal_id: String, | ||
metadata: HashMap<String, String>, | ||
) -> Result<JobItem> { | ||
Ok(JobItem { | ||
id: Uuid::new_v4(), | ||
internal_id, | ||
job_type: JobType::SnosRun, | ||
status: JobStatus::Created, | ||
external_id: String::new().into(), | ||
metadata, | ||
version: 0, | ||
}) | ||
} | ||
|
||
async fn process_job(&self, _config: &Config, _job: &JobItem) -> Result<String> { | ||
// 1. Fetch SNOS input data from Madara | ||
// 2. Import SNOS in Rust and execute it with the input data | ||
// 3. Store the received PIE in DB | ||
todo!() | ||
} | ||
|
||
async fn verify_job(&self, _config: &Config, _job: &JobItem) -> Result<JobVerificationStatus> { | ||
// No need for verification as of now. If we later on decide to outsource SNOS run | ||
// to another servicehow a, verify_job can be used to poll on the status of the job | ||
todo!() | ||
} | ||
|
||
fn max_process_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn max_verification_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn verification_polling_delay_seconds(&self) -> u64 { | ||
todo!() | ||
} | ||
} | ||
Comment on lines
+9
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::config::Config; | ||
use crate::jobs::types::{JobItem, JobStatus, JobType, JobVerificationStatus}; | ||
use crate::jobs::Job; | ||
use async_trait::async_trait; | ||
use color_eyre::Result; | ||
use std::collections::HashMap; | ||
use uuid::Uuid; | ||
|
||
pub struct StateUpdateJob; | ||
|
||
#[async_trait] | ||
impl Job for StateUpdateJob { | ||
async fn create_job( | ||
&self, | ||
_config: &Config, | ||
internal_id: String, | ||
metadata: HashMap<String, String>, | ||
) -> Result<JobItem> { | ||
Ok(JobItem { | ||
id: Uuid::new_v4(), | ||
internal_id, | ||
job_type: JobType::ProofRegistration, | ||
status: JobStatus::Created, | ||
external_id: String::new().into(), | ||
// metadata must contain the blocks for which state update will be performed | ||
// we don't do one job per state update as that makes nonce management complicated | ||
metadata, | ||
version: 0, | ||
}) | ||
} | ||
|
||
async fn process_job(&self, _config: &Config, _job: &JobItem) -> Result<String> { | ||
// Read the metadata to get the blocks for which state update will be performed. | ||
// For each block, get the program output (from the PIE?) and the | ||
todo!() | ||
} | ||
|
||
async fn verify_job(&self, _config: &Config, _job: &JobItem) -> Result<JobVerificationStatus> { | ||
// verify that the proof transaction has been included on chain | ||
todo!() | ||
} | ||
|
||
fn max_process_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn max_verification_attempts(&self) -> u64 { | ||
todo!() | ||
} | ||
|
||
fn verification_polling_delay_seconds(&self) -> u64 { | ||
todo!() | ||
} | ||
} | ||
Comment on lines
+9
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use async_trait::async_trait; | ||
|
||
pub mod proof_registration; | ||
pub mod proving; | ||
pub mod snos; | ||
pub mod update_state; | ||
|
||
#[async_trait] | ||
pub trait Worker: Send + Sync { | ||
async fn run_worker(&self); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::workers::Worker; | ||
use async_trait::async_trait; | ||
|
||
pub struct ProofRegistrationWorker; | ||
|
||
#[async_trait] | ||
impl Worker for ProofRegistrationWorker { | ||
/// 1. Fetch all blocks with a successful proving job run | ||
/// 2. Group blocks that have the same proof | ||
/// 3. For each group, create a proof registration job with from and to block in metadata | ||
async fn run_worker(&self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation pending in The |
||
todo!() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::workers::Worker; | ||
use async_trait::async_trait; | ||
|
||
pub struct ProvingWorker; | ||
|
||
#[async_trait] | ||
impl Worker for ProvingWorker { | ||
/// 1. Fetch all successful SNOS job runs that don't have a proving job | ||
/// 2. Create a proving job for each SNOS job run | ||
async fn run_worker(&self) { | ||
todo!() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation pending in The |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::workers::Worker; | ||
use async_trait::async_trait; | ||
|
||
pub struct SnosWorker; | ||
|
||
#[async_trait] | ||
impl Worker for SnosWorker { | ||
/// 1. Fetch the latest completed block from the Starknet chain | ||
/// 2. Fetch the last block that had a SNOS job run. | ||
/// 3. Create SNOS run jobs for all the remaining blocks | ||
async fn run_worker(&self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implementation pending in The |
||
todo!() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The results indicate that the
create_job
function is being called with the new metadata parameter in the relevant files. Specifically, the instances incrates/orchestrator/src/tests/jobs/da_job/mod.rs
andcrates/orchestrator/src/controllers/jobs_controller.rs
show the correct usage withHashMap::new()
.However, there are several instances where
create_job
is defined but not called with the new parameter, such as incrates/orchestrator/src/database/mongodb/mod.rs
,crates/orchestrator/src/jobs/state_update_job/mod.rs
,crates/orchestrator/src/jobs/snos_job/mod.rs
, andcrates/orchestrator/src/jobs/register_proof_job/mod.rs
. These instances need to be reviewed to ensure they are updated to use the new signature.Action Required:
Please update the following files to ensure that all calls to
create_job
include the new metadata parameter:crates/orchestrator/src/database/mongodb/mod.rs
crates/orchestrator/src/jobs/state_update_job/mod.rs
crates/orchestrator/src/jobs/snos_job/mod.rs
crates/orchestrator/src/jobs/register_proof_job/mod.rs
Analysis chain
Modification to
create_job
to include metadata.The addition of a metadata parameter in
create_job
is consistent with the expanded functionality. Please ensure that all calls to this function across the codebase have been updated to pass the necessary metadata.Modification to
create_job
to include metadata.The addition of a metadata parameter in
create_job
is consistent with the expanded functionality. Please ensure that all calls to this function across the codebase have been updated to pass the necessary metadata.The output from the script shows multiple occurrences of
create_job
across different files. To ensure all calls tocreate_job
have been updated to include the new metadata parameter, we need to inspect these occurrences more closely.Next Steps:
create_job
in the codebase are using the new signature with the metadata parameter.crates/orchestrator/src/tests/jobs/mod.rs
crates/orchestrator/src/tests/jobs/da_job/mod.rs
crates/orchestrator/src/routes.rs
crates/orchestrator/src/database/mongodb/mod.rs
crates/orchestrator/src/jobs/mod.rs
crates/orchestrator/src/jobs/state_update_job/mod.rs
crates/orchestrator/src/jobs/snos_job/mod.rs
crates/orchestrator/src/jobs/register_proof_job/mod.rs
crates/orchestrator/src/jobs/da_job/mod.rs
crates/orchestrator/src/database/mod.rs
crates/orchestrator/src/controllers/jobs_controller.rs
Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1756
Script:
Length of output: 1756
Script:
Length of output: 3664