Skip to content

Commit

Permalink
Merge branch 'main' into chore-replact-if-cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft authored Nov 22, 2024
2 parents 9bb4159 + 6e98484 commit edcbb58
Show file tree
Hide file tree
Showing 22 changed files with 317 additions and 194 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:
- "lib/**"
- "script/**"
- "!docs/**"
merge_group:

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: CI - Lint
on:
pull_request:
types: [opened, reopened, edited, synchronize]
merge_group:
paths:
- "!docs/**"

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-provers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ on:
paths:
- "pipelines/**"
- "harness/**"
- "!docs/**"
pull_request:
paths:
- "pipelines/**"
- "harness/**"
merge_group:
- "!docs/**"

env:
CARGO_TERM_COLOR: always
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-risc0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
branches: ["main"]
paths:
- "provers/risc0/**"
- "!docs/**"
pull_request:
paths:
- "provers/risc0/**"
merge_group:
- "!docs/**"

jobs:
build-test-risc0:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-sgx-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
branches: ["main"]
paths:
- "provers/sgx/**"
- "!docs/**"
pull_request:
paths:
- "provers/sgx/**"
merge_group:
- "!docs/**"

jobs:
build-test-sgx:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-sgx-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
branches: ["main"]
paths:
- "docker/**"
- "!docs/**"
pull_request:
paths:
- "docker/**"
merge_group:
- "!docs/**"

jobs:
build-test-sgx-with-docker:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-sp1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:
branches: ["main"]
paths:
- "provers/sp1/**"
- "!docs/**"
pull_request:
paths:
- "provers/sp1/**"
merge_group:
- "!docs/**"

jobs:
build-test-sp1:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/openapi-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name: OpenAPI
on:
push:
branches: ["main"]
paths-ignore:
- "docs/**"
paths:
- "!docs/**"
pull_request:
merge_group:
paths:
- "!docs/**"

permissions:
contents: read
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/repo--merge-gatekeeper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Merge Gatekeeper

on:
pull_request:
branches:
- main
merge_group: # Trigger in merge queue to pass the required status check

jobs:
merge-gatekeeper:
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
runs-on: [arc-runner-set]
permissions:
checks: read
statuses: read
steps:
- name: Run Merge Gatekeeper
uses: upsidr/merge-gatekeeper@v1
with:
timeout: 1200
token: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 18 additions & 18 deletions host/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ impl From<HostError> for TaskStatus {
| HostError::JoinHandle(_)
| HostError::InvalidAddress(_)
| HostError::InvalidRequestConfig(_) => unreachable!(),
HostError::Conversion(e) => TaskStatus::NonDbFailure(e),
HostError::Serde(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Core(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Anyhow(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::FeatureNotSupportedError(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Io(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::RPC(_) => TaskStatus::NetworkFailure,
HostError::Guest(_) => TaskStatus::ProofFailure_Generic,
HostError::TaskManager(_) => TaskStatus::SqlDbCorruption,
HostError::Conversion(e) => TaskStatus::IoFailure(e),
HostError::Serde(e) => TaskStatus::IoFailure(e.to_string()),
HostError::Core(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::Anyhow(e) => TaskStatus::AnyhowError(e.to_string()),
HostError::FeatureNotSupportedError(_) => TaskStatus::InvalidOrUnsupportedBlock,
HostError::Io(e) => TaskStatus::IoFailure(e.to_string()),
HostError::RPC(e) => TaskStatus::NetworkFailure(e.to_string()),
HostError::Guest(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::TaskManager(e) => TaskStatus::TaskDbCorruption(e.to_string()),
}
}
}
Expand All @@ -142,15 +142,15 @@ impl From<&HostError> for TaskStatus {
| HostError::JoinHandle(_)
| HostError::InvalidAddress(_)
| HostError::InvalidRequestConfig(_) => unreachable!(),
HostError::Conversion(e) => TaskStatus::NonDbFailure(e.to_owned()),
HostError::Serde(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Core(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Anyhow(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::FeatureNotSupportedError(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::Io(e) => TaskStatus::NonDbFailure(e.to_string()),
HostError::RPC(_) => TaskStatus::NetworkFailure,
HostError::Guest(_) => TaskStatus::ProofFailure_Generic,
HostError::TaskManager(_) => TaskStatus::SqlDbCorruption,
HostError::Conversion(e) => TaskStatus::GuestProverFailure(e.to_owned()),
HostError::Serde(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::Core(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::Anyhow(e) => TaskStatus::AnyhowError(e.to_string()),
HostError::FeatureNotSupportedError(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::Io(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::RPC(e) => TaskStatus::NetworkFailure(e.to_string()),
HostError::Guest(e) => TaskStatus::GuestProverFailure(e.to_string()),
HostError::TaskManager(e) => TaskStatus::TaskDbCorruption(e.to_string()),
}
}
}
21 changes: 14 additions & 7 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ impl ProofActor {
}

pub async fn cancel_task(&mut self, key: ProofTaskDescriptor) -> HostResult<()> {
let tasks_map = self.running_tasks.lock().await;
let Some(task) = tasks_map.get(&key) else {
warn!("No task with those keys to cancel");
return Ok(());
let task = {
let tasks_map = self.running_tasks.lock().await;
match tasks_map.get(&key) {
Some(task) => task.to_owned(),
None => {
warn!("No task with those keys to cancel");
return Ok(());
}
}
};

let mut manager = get_task_manager(&self.opts.clone().into());
Expand Down Expand Up @@ -134,10 +139,12 @@ impl ProofActor {
proof_request.prover.clone().to_string(),
));

let mut tasks = self.running_tasks.lock().await;
tasks.insert(key.clone(), cancel_token.clone());
let sender = self.sender.clone();
{
let mut tasks = self.running_tasks.lock().await;
tasks.insert(key.clone(), cancel_token.clone());
}

let sender = self.sender.clone();
let tasks = self.running_tasks.clone();
let opts = self.opts.clone();
let chain_specs = self.chain_specs.clone();
Expand Down
62 changes: 33 additions & 29 deletions host/src/server/api/v2/proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,42 +64,46 @@ async fn proof_handler(

let mut manager = prover_state.task_manager();
let status = manager.get_task_proving_status(&key).await?;

let Some((latest_status, ..)) = status.0.last() else {
// If there are no tasks with provided config, create a new one.
manager.enqueue_task(&key).await?;

prover_state
.task_channel
.try_send(Message::from(&proof_request))?;

return Ok(TaskStatus::Registered.into());
};

match latest_status {
// If task has been cancelled add it to the queue again
TaskStatus::Cancelled
| TaskStatus::Cancelled_Aborted
| TaskStatus::Cancelled_NeverStarted
| TaskStatus::CancellationInProgress => {
manager
.update_task_progress(key, TaskStatus::Registered, None)
.await?;
match status.0.last() {
Some((latest_status, ..)) => {
match latest_status {
// If task has been cancelled
TaskStatus::Cancelled
| TaskStatus::Cancelled_Aborted
| TaskStatus::Cancelled_NeverStarted
| TaskStatus::CancellationInProgress
// or if the task is failed, add it to the queue again
| TaskStatus::GuestProverFailure(_)
| TaskStatus::UnspecifiedFailureReason => {
manager
.update_task_progress(key, TaskStatus::Registered, None)
.await?;

prover_state
.task_channel
.try_send(Message::from(&proof_request))?;

Ok(TaskStatus::Registered.into())
}
// If the task has succeeded, return the proof.
TaskStatus::Success => {
let proof = manager.get_task_proof(&key).await?;

Ok(proof.into())
}
// For all other statuses just return the status.
status => Ok(status.clone().into()),
}
}
None => {
manager.enqueue_task(&key).await?;

prover_state
.task_channel
.try_send(Message::from(&proof_request))?;

Ok(TaskStatus::Registered.into())
}
// If the task has succeeded, return the proof.
TaskStatus::Success => {
let proof = manager.get_task_proof(&key).await?;

Ok(proof.into())
}
// For all other statuses just return the status.
status => Ok(status.clone().into()),
}
}

Expand Down
Loading

0 comments on commit edcbb58

Please sign in to comment.