Reconcile byte-identical historical offers without allowing another execution

This commit is contained in:
2026-11-18 12:10:27 +01:00
parent cd80bfc704
commit 0f70d8d8f5
3 changed files with 39 additions and 2 deletions
+3 -1
View File
@@ -24,7 +24,6 @@ pub fn accept(
&& hex_hash(&offer.plan_hash),
"OFFER_BINDING"
);
ensure!(supported(&job), "UNSUPPORTED_CAPABILITY");
let bytes = offer.encode_to_vec();
let existing: Option<Vec<u8>> = db
.query_row(
@@ -37,6 +36,9 @@ pub fn accept(
ensure!(old == bytes, "OFFER_CONFLICT");
return Ok(false);
}
// An identical journal receipt is evidence of a previous delivery. Current
// executable capabilities apply to newly accepted offers.
ensure!(supported(&job), "UNSUPPORTED_CAPABILITY");
let count: i64 = db.query_row("SELECT count(*) FROM job_attempts", [], |r| r.get(0))?;
ensure!(count < 10000, "JOURNAL_CAPACITY_NEW_EFFECTS_BLOCKED");
db.execute(