Skip to content
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

Feature: Implement proving worker #22

Merged
merged 19 commits into from
Jun 24, 2024
Merged

Feature: Implement proving worker #22

merged 19 commits into from
Jun 24, 2024

Conversation

ocdbytes
Copy link
Member

  • Added proving worker
  • Added proving worker test cases

"$expr": {
"$and": [
{ "$eq": ["$job_type", "ProofCreation"] },
{ "$eq": ["$internal_id", "$$internal_id"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rename internal_id to block_id at last? :)
The relation between jobs (and the fact they can have the same ID) is non-obvious otherwise

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok cool will rename internal_id to block_id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @unstark

So I talked about this to apoorv and he told me that the interal_id field was just to make sure that for a particular job type there is a way to track the jobs internally so that's why a generic name internal_id was given to this field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @unstark my hypothesis was that the orchestrator can be designed in a way that we can also have jobs at the txn level later on. Maybe something like txn level proving or stream of txs to some XYZ place. So in that case, the internal_id will be the txn_hash. What are your thoughts on this? Does it feel like an overkill?

@@ -127,4 +129,53 @@ impl Database for MongoDb {
.await
.expect("Failed to fetch latest job by given job type"))
}

async fn get_successful_snos_jobs_without_proving(&self) -> Result<Vec<JobItem>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not an immediate issue, but we might need pagination here: imagine if there's a problem with the prover that lasts for quite some time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I will look into it and discuss and tell you. Can you explain a bit more on why we need pagination here in a db call ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case there is a really large amount of pending jobs :) Anyways, that's should not happen in practice, feel free to resolve

},
];

let mut cursor = self.get_job_collection().aggregate(filter, None).await?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming jobs are sorted by internal_id here? (just to confirm that we do not need to do explicit sorting)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we don't need sorting here as it will be already sorted result.

pub struct ProvingJob;

#[async_trait]
impl Job for ProvingJob {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to merge with the #6

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will do it.

"$expr": {
"$and": [
{ "$eq": ["$job_type", "ProofCreation"] },
{ "$eq": ["$internal_id", "$$internal_id"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @unstark my hypothesis was that the orchestrator can be designed in a way that we can also have jobs at the txn level later on. Maybe something like txn level proving or stream of txs to some XYZ place. So in that case, the internal_id will be the txn_hash. What are your thoughts on this? Does it feel like an overkill?

@@ -36,6 +36,8 @@ pub trait Database: Send + Sync {

async fn update_metadata(&self, job: &JobItem, metadata: HashMap<String, String>) -> Result<()>;
async fn get_latest_job_by_type_and_internal_id(&self, job_type: JobType) -> Result<Option<JobItem>>;

async fn get_successful_snos_jobs_without_proving(&self) -> Result<Vec<JobItem>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the database trait shouldn't have functions with the name snos or proving as that seems to leak the internal types. We should generalise the function over all types and take the type as an input. Function can look like

fn get_jobs_without_successor(job_a_type, job_a_status, job_b_type, job_b_status)

wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

}

// Queue function call simulations
queue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make this times 5 or 4?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in first case it is 5 in second case when one job is unsuccessful that's why we are using 4 here.

///
/// job_b_status : Status of Job B / None
///
/// **IMP** : For now Job B status implementation is pending so we can pass None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not take job as a param for now because it allows others to call this function by mistake. and we can make the IMP a TODO then

@ocdbytes ocdbytes merged commit 5c96c8e into main Jun 24, 2024
6 checks passed
@ocdbytes ocdbytes deleted the feat/proving-worker branch June 24, 2024 14:14
Tranduy1dol pushed a commit to sota-zk-labs/madara-orchestrator that referenced this pull request Jul 9, 2024
* feat : added snos worker implementation and unit tests

* feat : added review #1 changes : added error handling for snos workers

* feat : added review #1 changes : added error handling for snos workers

* fix : lint

* fix : lint errors

* feat : added proving worker

* feat : added proving worker

* fix : refactor : uncomment temp changes

* fix : ci fixes

* fix : lint

* fix : lint

* feat : added complete implementation of proving job

* fix : tests fix proving worker

* fix : lint

* feat : db generic fucntion

* feat : refactoring

---------

Co-authored-by: Arun Jangra <ocdbytes@Aruns-MacBook-Pro.local>
Tranduy1dol pushed a commit to sota-zk-labs/madara-orchestrator that referenced this pull request Jul 9, 2024
* feat : added snos worker implementation and unit tests

* feat : added review #1 changes : added error handling for snos workers

* feat : added review #1 changes : added error handling for snos workers

* fix : lint

* fix : lint errors

* feat : added proving worker

* feat : added proving worker

* fix : refactor : uncomment temp changes

* fix : ci fixes

* fix : lint

* fix : lint

* feat : added complete implementation of proving job

* fix : tests fix proving worker

* fix : lint

* feat : db generic fucntion

* feat : refactoring

---------

Co-authored-by: Arun Jangra <ocdbytes@Aruns-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants