-
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
Feature: Implement proving worker #22
Conversation
ocdbytes
commented
Jun 19, 2024
- Added proving worker
- Added proving worker test cases
"$expr": { | ||
"$and": [ | ||
{ "$eq": ["$job_type", "ProofCreation"] }, | ||
{ "$eq": ["$internal_id", "$$internal_id"] } |
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.
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
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.
ok cool will rename internal_id
to block_id
.
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.
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.
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.
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>> { |
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.
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.
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.
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 ?
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.
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?; |
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.
Assuming jobs are sorted by internal_id here? (just to confirm that we do not need to do explicit sorting)
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.
no we don't need sorting here as it will be already sorted result.
pub struct ProvingJob; | ||
|
||
#[async_trait] | ||
impl Job for ProvingJob { |
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.
Will need to merge with the #6
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.
sure will do it.
"$expr": { | ||
"$and": [ | ||
{ "$eq": ["$job_type", "ProofCreation"] }, | ||
{ "$eq": ["$internal_id", "$$internal_id"] } |
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.
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>>; |
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.
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?
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.
makes sense
} | ||
|
||
// Queue function call simulations | ||
queue |
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.
should we make this times 5 or 4?
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.
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 |
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.
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
* 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 <[email protected]>
* 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 <[email protected]>
* 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 <[email protected]>