Skip to content

Commit

Permalink
fix idempotency bug in execute_job
Browse files Browse the repository at this point in the history
  • Loading branch information
simke9445 committed Mar 14, 2024
1 parent 868c3f2 commit 73b4bcb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions contracts/warp-controller/src/execute/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ pub fn execute_job(
let mut msgs = vec![];
let mut submsgs = vec![];

let mut execution_matched = false;

for Execution { condition, msgs } in job.executions {
let resolution: StdResult<bool> = deps.querier.query_wasm_smart(
config.resolver_address.clone(),
Expand Down Expand Up @@ -509,6 +511,9 @@ pub fn execute_job(
gas_limit: None,
reply_on: ReplyOn::Always,
});

execution_matched = true;

break;
}
Ok(false) => {
Expand All @@ -524,6 +529,15 @@ pub fn execute_job(
}
}

if !execution_matched {
return Ok(Response::new()
.add_attribute("action", "execute_job")
.add_attribute("executor", info.sender)
.add_attribute("job_id", job.id)
.add_attribute("job_condition", "inactive")
.add_attributes(attrs));
}

// Controller sends reward to executor
msgs.push(build_transfer_native_funds_msg(
info.sender.to_string(),
Expand Down

0 comments on commit 73b4bcb

Please sign in to comment.