-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
engine: create a max procedure call stack depth #609
Conversation
values: make(map[string]any), | ||
DBID: p.DBID, | ||
Procedure: p.Procedure, | ||
StackDepth: p.StackDepth, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I had this with a +1
from the parent procedure's context, but (*baseDataset).Call
also does NewScope
so it can get incremented twice unintentionally.
// Call calls a procedure from the dataset. | ||
// If the procedure is not public, it will return an error. | ||
// It implements the Namespace interface. | ||
// It satisfies precompiles.Instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these interfaces have been renamed a few times. This seems to be the one it should mention.
// abusive recursive calls, but a hard upper limit will likely be necessary | ||
// unless the price of an action call is extremely expensive or rises | ||
// exponentially at each level of the call stack. | ||
const MaxStackDepth = 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do up to 10,000, but that sort of txn requires about 0.1sec to exec even with no actual queries and that is too much baseline IMO.
We sorta do need to spend each time an action is entered though, to make gas reflect DB utilization, but we can't just hard crash either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 1000 is certainly more than enough
This resolves a bug with the handling of deeply nested action calls. Ultimately the fix may be a gas cost for each action call, possibly exponentially increasing with depth, but I think a hard limit is still a good idea when user-defined recursion is a possibility. See code comments for more.
I don't think we want to scheme authors to write recursive algorithms, but if we change our mind I think we can life this restriction.