Skip to content

Commit

Permalink
addded stamp cost for exceeding max_frames
Browse files Browse the repository at this point in the history
  • Loading branch information
duelingbenjos committed Sep 30, 2024
1 parent 345fad8 commit 9c3c783
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/contracting/execution/metering/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Tracer_trace(Tracer * self, PyFrameObject * frame, int what, PyObject * arg) {
self->call_count++;

if (self->call_count > 800000) {
self->cost += 100000; // Add a stamp cost
PyErr_SetString(PyExc_AssertionError, "Call count exceeded threshold! Infinite Loop?");
PyEval_SetTrace(NULL, NULL); // Stop tracing
self->started = 0; // Mark tracer as stopped
Expand All @@ -164,6 +165,7 @@ Tracer_trace(Tracer * self, PyFrameObject * frame, int what, PyObject * arg) {
const char *current_function_name = PyUnicode_AsUTF8(code->co_name);
if (current_function_name == NULL) {
Py_DECREF(code);
Py_DECREF(globals);
return RET_OK;
}
PyObject *globals = PyFrame_GetGlobals(frame);
Expand Down

0 comments on commit 9c3c783

Please sign in to comment.