fix(contracts): reject unfulfillable output capture budgets
This commit is contained in:
@@ -109,7 +109,13 @@ class RunLimits(WireModel):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def consistent(self) -> Self:
|
||||
if self.stack_bytes > self.memory_bytes or self.file_bytes > self.workdir_bytes:
|
||||
if (
|
||||
self.stack_bytes > self.memory_bytes
|
||||
or self.file_bytes > self.workdir_bytes
|
||||
or self.stdout_bytes > self.file_bytes
|
||||
or self.stderr_bytes > self.file_bytes
|
||||
or self.stdout_bytes + self.stderr_bytes > self.workdir_bytes
|
||||
):
|
||||
raise ValueError("inconsistent resource limits")
|
||||
return self
|
||||
|
||||
|
||||
@@ -291,7 +291,12 @@ impl RunLimits {
|
||||
] {
|
||||
bounded(value, min, max)?;
|
||||
}
|
||||
if self.stack_bytes > self.memory_bytes || self.file_bytes > self.workdir_bytes {
|
||||
if self.stack_bytes > self.memory_bytes
|
||||
|| self.file_bytes > self.workdir_bytes
|
||||
|| self.stdout_bytes > self.file_bytes
|
||||
|| self.stderr_bytes > self.file_bytes
|
||||
|| self.stdout_bytes + self.stderr_bytes > self.workdir_bytes
|
||||
{
|
||||
return Err("inconsistent resource limits");
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"kind": "judge.manifest",
|
||||
"evaluation_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000001",
|
||||
"submission_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000002",
|
||||
"problem_version_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000003",
|
||||
"language": "cpp20",
|
||||
"toolchain": {
|
||||
"toolchain_id": "gnu-cxx-v1",
|
||||
"image_kind": "linux_gnu_cxx_x86_64_v1",
|
||||
"image_revision": 1
|
||||
},
|
||||
"source": {
|
||||
"digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bytes": 124
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000004",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 0
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000005",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 1
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000006",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 2
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"comparison": "exact_bytes",
|
||||
"compile_limits": {
|
||||
"cpu_time_us": 10000000,
|
||||
"wall_time_us": 30000000,
|
||||
"memory_bytes": 536870912,
|
||||
"stack_bytes": 16777216,
|
||||
"processes": 32,
|
||||
"open_files": 128,
|
||||
"stdout_bytes": 1048576,
|
||||
"stderr_bytes": 1048576,
|
||||
"file_bytes": 67108864,
|
||||
"workdir_bytes": 268435456
|
||||
},
|
||||
"run_limits": {
|
||||
"cpu_time_us": 1000000,
|
||||
"wall_time_us": 3000000,
|
||||
"memory_bytes": 67108864,
|
||||
"stack_bytes": 8388608,
|
||||
"processes": 8,
|
||||
"open_files": 64,
|
||||
"stdout_bytes": 1048576,
|
||||
"stderr_bytes": 1048576,
|
||||
"file_bytes": 524288,
|
||||
"workdir_bytes": 67108864
|
||||
},
|
||||
"job_wall_time_us": 60000000
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"kind": "judge.manifest",
|
||||
"evaluation_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000001",
|
||||
"submission_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000002",
|
||||
"problem_version_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000003",
|
||||
"language": "cpp20",
|
||||
"toolchain": {
|
||||
"toolchain_id": "gnu-cxx-v1",
|
||||
"image_kind": "linux_gnu_cxx_x86_64_v1",
|
||||
"image_revision": 1
|
||||
},
|
||||
"source": {
|
||||
"digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
"bytes": 124
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000004",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 0
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000005",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 1
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"case_id": "aaaaaaaa-aaaa-4aaa-8aaa-000000000006",
|
||||
"input": {
|
||||
"digest": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
"bytes": 2
|
||||
},
|
||||
"expected": {
|
||||
"digest": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
||||
"bytes": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"comparison": "exact_bytes",
|
||||
"compile_limits": {
|
||||
"cpu_time_us": 10000000,
|
||||
"wall_time_us": 30000000,
|
||||
"memory_bytes": 536870912,
|
||||
"stack_bytes": 16777216,
|
||||
"processes": 32,
|
||||
"open_files": 128,
|
||||
"stdout_bytes": 1048576,
|
||||
"stderr_bytes": 1048576,
|
||||
"file_bytes": 67108864,
|
||||
"workdir_bytes": 268435456
|
||||
},
|
||||
"run_limits": {
|
||||
"cpu_time_us": 1000000,
|
||||
"wall_time_us": 3000000,
|
||||
"memory_bytes": 67108864,
|
||||
"stack_bytes": 8388608,
|
||||
"processes": 8,
|
||||
"open_files": 64,
|
||||
"stdout_bytes": 1048576,
|
||||
"stderr_bytes": 1048576,
|
||||
"file_bytes": 1048576,
|
||||
"workdir_bytes": 1048576
|
||||
},
|
||||
"job_wall_time_us": 60000000
|
||||
}
|
||||
Reference in New Issue
Block a user