Spaces:
Running
Running
ajaxwin commited on
Commit ·
c27e659
1
Parent(s): 45bd962
html file path and api corrected
Browse files- README.md +1 -7
- pyproject.toml +1 -1
- server/app.py +17 -16
README.md
CHANGED
|
@@ -300,12 +300,6 @@ pip install -r requirements.txt
|
|
| 300 |
uvicorn server.app:app --host 0.0.0.0 --port 7860 --reload
|
| 301 |
```
|
| 302 |
|
| 303 |
-
### Validate OpenEnv Compliance
|
| 304 |
-
|
| 305 |
-
```bash
|
| 306 |
-
openenv validate openenv.yaml
|
| 307 |
-
```
|
| 308 |
-
|
| 309 |
---
|
| 310 |
|
| 311 |
## Baseline Inference Script
|
|
@@ -355,7 +349,7 @@ Do not include any other text outside the JSON object.
|
|
| 355 |
|
| 356 |
```yaml
|
| 357 |
name: smart-contract-audit-env
|
| 358 |
-
version: "1.
|
| 359 |
description: >
|
| 360 |
OpenEnv RL environment for Solidity smart contract security auditing.
|
| 361 |
Agents explore real-world DeFi contracts using a structured action API
|
|
|
|
| 300 |
uvicorn server.app:app --host 0.0.0.0 --port 7860 --reload
|
| 301 |
```
|
| 302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
---
|
| 304 |
|
| 305 |
## Baseline Inference Script
|
|
|
|
| 349 |
|
| 350 |
```yaml
|
| 351 |
name: smart-contract-audit-env
|
| 352 |
+
version: "1.2.0"
|
| 353 |
description: >
|
| 354 |
OpenEnv RL environment for Solidity smart contract security auditing.
|
| 355 |
Agents explore real-world DeFi contracts using a structured action API
|
pyproject.toml
CHANGED
|
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
|
|
| 10 |
|
| 11 |
[project]
|
| 12 |
name = "openenv-smartcontractenv"
|
| 13 |
-
version = "1.
|
| 14 |
description = "Smartcontractenv environment for OpenEnv"
|
| 15 |
requires-python = ">=3.12"
|
| 16 |
dependencies = [
|
|
|
|
| 10 |
|
| 11 |
[project]
|
| 12 |
name = "openenv-smartcontractenv"
|
| 13 |
+
version = "1.2.0"
|
| 14 |
description = "Smartcontractenv environment for OpenEnv"
|
| 15 |
requires-python = ">=3.12"
|
| 16 |
dependencies = [
|
server/app.py
CHANGED
|
@@ -112,19 +112,20 @@ _ROOT_JSON = {
|
|
| 112 |
@app.get("/")
|
| 113 |
def root(request: Request):
|
| 114 |
"""
|
| 115 |
-
Landing page.
|
| 116 |
-
- Browsers (Accept: text/html) → polished HTML UI
|
| 117 |
-
- API clients (Accept: */*) → JSON summary
|
| 118 |
"""
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
return JSONResponse(content=_ROOT_JSON, status_code=200)
|
| 123 |
|
| 124 |
@app.get("/health")
|
| 125 |
def health():
|
| 126 |
"""Liveness probe."""
|
| 127 |
-
return {"status": "ok", "version": "1.
|
| 128 |
|
| 129 |
|
| 130 |
@app.get("/tasks")
|
|
@@ -231,22 +232,22 @@ def action_space(task_id: str = "task1_vuln_detection"):
|
|
| 231 |
{"type": "get_function_natspec", "params": {}, "reward": -0.08, "description": "Read NatSpec + expected behaviour"},
|
| 232 |
{"type": "get_file_natspec", "params": {}, "reward": -0.03, "description": "Read contract-level NatSpec"},
|
| 233 |
{"type": "get_related_functions", "params": {}, "reward": -0.06, "description": "List caller/callee functions with summaries"},
|
| 234 |
-
{"type": "get_signature",
|
| 235 |
{"type": "get_similar_rule", "params": {}, "reward": -0.20, "description": "Get a similar property from another contract"},
|
| 236 |
-
{"type": "submit_property", "params": {"property": "string"}, "reward": "0.0–5.0
|
| 237 |
],
|
| 238 |
}
|
| 239 |
if task_id == "task3_rule_checker":
|
| 240 |
return {
|
| 241 |
"task_id": task_id,
|
| 242 |
"actions": [
|
| 243 |
-
{"type": "list_functions", "params": {},
|
| 244 |
-
{"type": "get_function_metadata", "params": {"function_name": "string"},
|
| 245 |
-
{"type": "get_function_code", "params": {"function_name": "string"},
|
| 246 |
-
{"type": "get_state_variable", "params": {"variable_name": "string (opt)"},
|
| 247 |
-
{"type": "get_call_graph", "params": {},
|
| 248 |
-
{"type": "get_property_specification", "params": {},
|
| 249 |
-
{"type": "submit_function", "params": {"function_name": "string"},
|
| 250 |
],
|
| 251 |
}
|
| 252 |
return {"error": f"No action space defined for task '{task_id}'"}
|
|
|
|
| 112 |
@app.get("/")
|
| 113 |
def root(request: Request):
|
| 114 |
"""
|
| 115 |
+
Landing page with human-readable description and API summary. Also serves as a health check.
|
|
|
|
|
|
|
| 116 |
"""
|
| 117 |
+
BASE_DIR = Path(__file__).resolve().parent
|
| 118 |
+
return FileResponse(BASE_DIR / "server/index.html", media_type="text/html", status_code=200)
|
| 119 |
+
|
| 120 |
+
@app.get("/api")
|
| 121 |
+
def api_root():
|
| 122 |
+
"""Machine-readable API summary."""
|
| 123 |
return JSONResponse(content=_ROOT_JSON, status_code=200)
|
| 124 |
|
| 125 |
@app.get("/health")
|
| 126 |
def health():
|
| 127 |
"""Liveness probe."""
|
| 128 |
+
return {"status": "ok", "version": "1.2.0"}
|
| 129 |
|
| 130 |
|
| 131 |
@app.get("/tasks")
|
|
|
|
| 232 |
{"type": "get_function_natspec", "params": {}, "reward": -0.08, "description": "Read NatSpec + expected behaviour"},
|
| 233 |
{"type": "get_file_natspec", "params": {}, "reward": -0.03, "description": "Read contract-level NatSpec"},
|
| 234 |
{"type": "get_related_functions", "params": {}, "reward": -0.06, "description": "List caller/callee functions with summaries"},
|
| 235 |
+
{"type": "get_signature", "params": {}, "reward": -0.04, "description": "Get structured I/O + expected behaviour"},
|
| 236 |
{"type": "get_similar_rule", "params": {}, "reward": -0.20, "description": "Get a similar property from another contract"},
|
| 237 |
+
{"type": "submit_property", "params": {"property": "string"}, "reward": "0.0–5.0", "description": "Submit property. ONE attempt. Ends episode."},
|
| 238 |
],
|
| 239 |
}
|
| 240 |
if task_id == "task3_rule_checker":
|
| 241 |
return {
|
| 242 |
"task_id": task_id,
|
| 243 |
"actions": [
|
| 244 |
+
{"type": "list_functions", "params": {}, "reward": -0.05, "description": "List all function names"},
|
| 245 |
+
{"type": "get_function_metadata", "params": {"function_name": "string"}, "reward": -0.05, "description": "Get signature, visibility, params of a function"},
|
| 246 |
+
{"type": "get_function_code", "params": {"function_name": "string"}, "reward": -0.10, "description": "Read full Solidity source of a function"},
|
| 247 |
+
{"type": "get_state_variable", "params": {"variable_name": "string (opt)"},"reward": -0.05, "description": "Get a state variable or list all"},
|
| 248 |
+
{"type": "get_call_graph", "params": {}, "reward": -0.08, "description": "Get function call graph"},
|
| 249 |
+
{"type": "get_property_specification", "params": {}, "reward": -0.03, "description": "Get formal pre/post-condition for the property"},
|
| 250 |
+
{"type": "submit_function", "params": {"function_name": "string"}, "reward": "+5.0 / +1.5 / -1.5", "description": "Submit answer. ONE attempt. Ends episode."},
|
| 251 |
],
|
| 252 |
}
|
| 253 |
return {"error": f"No action space defined for task '{task_id}'"}
|