-
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
Conversation
WalkthroughThe updates introduce a new Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 9
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (18)
- Cargo.toml (1 hunks)
- crates/orchestrator/src/controllers/jobs_controller.rs (2 hunks)
- crates/orchestrator/src/jobs/da_job/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/mod.rs (4 hunks)
- crates/orchestrator/src/jobs/register_proof_job/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/snos_job/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/state_update_job/mod.rs (1 hunks)
- crates/orchestrator/src/jobs/types.rs (1 hunks)
- crates/orchestrator/src/lib.rs (1 hunks)
- crates/orchestrator/src/main.rs (2 hunks)
- crates/orchestrator/src/tests/jobs/da_job/mod.rs (1 hunks)
- crates/orchestrator/src/workers/mod.rs (1 hunks)
- crates/orchestrator/src/workers/proof_registration.rs (1 hunks)
- crates/orchestrator/src/workers/proving.rs (1 hunks)
- crates/orchestrator/src/workers/snos.rs (1 hunks)
- crates/orchestrator/src/workers/update_state.rs (1 hunks)
- crates/settlement_clients/settlement-client-interface/Cargo.toml (1 hunks)
- crates/settlement_clients/settlement-client-interface/src/lib.rs (1 hunks)
Files skipped from review due to trivial changes (3)
- Cargo.toml
- crates/orchestrator/src/workers/mod.rs
- crates/settlement_clients/settlement-client-interface/Cargo.toml
Additional comments not posted (11)
crates/orchestrator/src/lib.rs (1)
18-18
: Addition ofworkers
module.The addition of the
workers
module is well-placed and aligns with the architectural expansion to include worker functionalities.crates/settlement_clients/settlement-client-interface/src/lib.rs (2)
7-13
: TheSettlementVerificationStatus
enum is well-defined with appropriate variants. Ensure that the#[allow(dead_code)]
attribute is only temporary until these variants are used in the codebase.
19-37
: TheSettlementClient
trait is well-structured with clear async method definitions. Ensure that all implementations of this trait handle theResult
type correctly to manage errors effectively.crates/orchestrator/src/main.rs (2)
6-10
: The imports for the new worker types are correctly added. Ensure that these workers are properly integrated and tested within the system.
29-36
: Thestart_cron
function calls are correctly set up for the new workers. Ensure that the interval settings are appropriate for the system's performance and requirements.crates/orchestrator/src/tests/jobs/da_job/mod.rs (1)
25-25
: The test forcreate_job
in theDaJob
module is updated to include themetadata
parameter. Ensure that the test adequately covers all scenarios related to metadata handling.crates/orchestrator/src/jobs/types.rs (2)
78-78
: RenamingProofVerification
toProofRegistration
aligns with the updated functionality. Ensure all references to the old enum name are updated throughout the codebase.Verification successful
All references to
ProofVerification
have been successfully updated toProofRegistration
throughout the codebase.
crates/orchestrator/src/main.rs
crates/orchestrator/src/workers/proof_registration.rs
crates/orchestrator/src/jobs/types.rs
crates/orchestrator/src/jobs/state_update_job/mod.rs
crates/orchestrator/src/jobs/register_proof_job/mod.rs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all references to `ProofVerification` are updated to `ProofRegistration`. # Test: Search for the old enum name. Expect: No occurrences. rg --type rust 'ProofVerification'Length of output: 34
Script:
#!/bin/bash # Description: Verify all references to `ProofVerification` are updated to `ProofRegistration`. # Test: Search for the new enum name. Expect: Occurrences in relevant places. rg --type rust 'ProofRegistration'Length of output: 694
72-72
: Addition ofSnosRun
toJobType
enum. Ensure it is integrated properly in job creation and processing logic.Verification successful
The search results indicate that
SnosRun
is integrated into theJobType
enum and is used in the job creation logic withinsnos_job/mod.rs
. However, to ensure comprehensive integration, we should verify its usage in job processing functions as well.
The search results confirm that
SnosRun
is integrated into the job creation logic and is also referenced in the job processing function withinsnos_job/mod.rs
. This indicates thatSnosRun
is properly integrated into the job-related functionalities.
JobType::SnosRun
is used in the job creation function.- The job processing function mentions steps related to processing SNOS jobs.
This suggests that the integration of
SnosRun
is consistent and complete.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of `SnosRun` in job-related functionalities. # Test: Search for `SnosRun` usage in job creation and processing. Expect: Proper integration. rg --type rust 'SnosRun'Length of output: 160
Script:
#!/bin/bash # Description: Verify integration of `SnosRun` in job-related functionalities. # Test: Search for `SnosRun` usage in job creation and processing functions. rg --type rust 'SnosRun' -A 5 -B 5Length of output: 1586
Script:
#!/bin/bash # Description: Verify integration of `SnosRun` in job processing functions. # Test: Search for `SnosRun` usage in job processing functions. rg --type rust 'SnosRun' -A 10 -B 10Length of output: 3093
crates/orchestrator/src/jobs/da_job/mod.rs (1)
17-29
: The addition ofmetadata
parameter increate_job
method enhances job handling flexibility. Ensure it is properly utilized in job processing and related areas.Verification successful
The
metadata
parameter is well-integrated and utilized across various parts of the codebase, including job creation and processing functions.
crates/orchestrator/src/jobs/da_job/mod.rs
:metadata
is passed and used in job creation.crates/orchestrator/src/jobs/mod.rs
:metadata
is used in job creation and processing functions.crates/orchestrator/src/database/mod.rs
:metadata
is used in database update functions.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `metadata` parameter in job processing. # Test: Search for `metadata` usage in job processing. Expect: Proper utilization. rg --type rust 'metadata'Length of output: 6737
crates/orchestrator/src/jobs/mod.rs (2)
Line range hint
51-64
: Modification ofcreate_job
to includemetadata
parameter. Ensure this change is reflected in all job handling and processing logic.Verification successful
The
metadata
parameter has been integrated into various parts of the job handling and processing logic, as evidenced by the multiple instances found in therg
output.
- crates/orchestrator/src/jobs/mod.rs
- crates/orchestrator/src/database/mongodb/mod.rs
- crates/orchestrator/src/jobs/state_update_job/mod.rs
- crates/orchestrator/src/jobs/register_proof_job/mod.rs
These instances confirm that the
metadata
parameter is properly utilized across the relevant modules.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the integration of `metadata` parameter in job handling. # Test: Search for `metadata` usage in job handling. Expect: Proper integration. rg --type rust 'metadata'Length of output: 6737
15-17
: Addition of new job modules (register_proof_job
,snos_job
,state_update_job
). Ensure these modules are properly integrated and utilized within the orchestrator.
pub trait SettlementConfig { | ||
/// Should create a new instance of the DaConfig from the environment variables | ||
fn new_from_env() -> Self; | ||
} |
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.
The SettlementConfig
trait method new_from_env
is a good approach for environment-based configuration. Consider adding error handling or logging to capture issues during environment variable parsing.
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!() | ||
} | ||
} |
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.
The SnosJob
struct and its methods are well implemented. However, the todo!()
placeholders in methods like process_job
and verify_job
indicate incomplete implementation. Ensure these are addressed before merging.
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!() | ||
} | ||
} |
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.
The RegisterProofJob
struct and its methods are well implemented. However, the todo!()
placeholders in methods like process_job
and verify_job
indicate incomplete implementation. Ensure these are addressed before merging.
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!() | ||
} | ||
} |
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.
The StateUpdateJob
struct and its methods are well implemented. However, the todo!()
placeholders in methods like process_job
and verify_job
indicate incomplete implementation. Ensure these are addressed before merging.
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation pending in run_worker
.
The run_worker
method is currently not implemented and contains a todo!()
placeholder. Would you like me to help with the implementation or should we track this as an issue on GitHub?
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation pending in run_worker
.
The run_worker
method is currently not implemented and contains a todo!()
placeholder. Would you like me to help with the implementation or should we track this as an issue on GitHub?
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation pending in run_worker
.
The run_worker
method is currently not implemented and contains a todo!()
placeholder. Would you like me to help with the implementation or should we track this as an issue on GitHub?
/// 1. Fetch the last succesful state update job | ||
/// 2. Fetch all succesful proving jobs covering blocks after the last state update | ||
/// 3. Create state updates for all the blocks that don't have a state update job | ||
async fn run_worker(&self) { |
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.
Implementation pending in run_worker
.
The run_worker
method is currently not implemented and contains a todo!()
placeholder. Would you like me to help with the implementation or should we track this as an issue on GitHub?
@@ -16,6 +17,6 @@ pub struct CreateJobRequest { | |||
|
|||
/// Create a job | |||
pub async fn create_job(Json(payload): Json<CreateJobRequest>) -> Result<Json<()>, AppError> { | |||
crate::jobs::create_job(payload.job_type, payload.internal_id).await?; | |||
crate::jobs::create_job(payload.job_type, payload.internal_id, HashMap::new()).await?; |
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 in crates/orchestrator/src/tests/jobs/da_job/mod.rs
and crates/orchestrator/src/controllers/jobs_controller.rs
show the correct usage with HashMap::new()
.
However, there are several instances where create_job
is defined but not called with the new parameter, such as in crates/orchestrator/src/database/mongodb/mod.rs
, crates/orchestrator/src/jobs/state_update_job/mod.rs
, crates/orchestrator/src/jobs/snos_job/mod.rs
, and crates/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 to create_job
have been updated to include the new metadata parameter, we need to inspect these occurrences more closely.
Next Steps:
- Verify that all instances of
create_job
in the codebase are using the new signature with the metadata parameter. - Specifically check the following files for correct usage:
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:
#!/bin/bash
# Description: Verify all function calls to `create_job` include the new metadata parameter.
# Test: Search for the function usage. Expect: Only occurances with the new signature.
rg --type rust $'create_job'
Length of output: 1756
Script:
#!/bin/bash
# Description: Verify all function calls to `create_job` include the new metadata parameter.
# Test: Search for the function usage. Expect: Only occurances with the new signature.
rg --type rust $'create_job'
Length of output: 1756
Script:
#!/bin/bash
# Verify that all instances of `create_job` in the codebase are using the new signature with the metadata parameter.
# Check each file for the correct usage of `create_job`.
files=(
"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"
)
for file in "${files[@]}"; do
echo "Checking $file"
rg 'create_job\(' "$file"
done
Length of output: 3664
* boilerplate code * fix taplo * fmt fix
* boilerplate code * fix taplo * fmt fix
Summary by CodeRabbit
New Features
Enhancements
JobType
enum with new variants.Documentation