Skip to content
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

Enable setting a Debugger from public code #5037

Closed
fergalwalsh opened this issue Jan 20, 2023 · 3 comments
Closed

Enable setting a Debugger from public code #5037

fergalwalsh opened this issue Jan 20, 2023 · 3 comments
Labels
new-feature-request Feature request that needs triage Team Scytale

Comments

@fergalwalsh
Copy link

Problem

I'd like to be able to set a Debugger on the EvalContext from public code.
Currently the only way to do this is to modify the code within eval.go somewhere around here: https://github.com/algorand/go-algorand/blob/master/data/transactions/logic/eval.go#L836
I'd like to be able to set the debugger somewhere through a public interface, probably at the Ledger level.

Why?
In AlgoJig I am creating a Ledger and evaluating txns against a predetermined ledger state. I have a nice feature that captures traces of all contract evaluations and stores them so that additional analysis can be performed. This allows the developer to step through the contracts line by line post execution (whether execution failed or not) and it also allows for producing code coverage reports for contracts by aggregating the outputs of all tests.
I have a POC of this feature but it relies on a manually edited version of go-algorand (i.e. a fork). This is not really practical for a public project.

The current DebuggerHook interface works perfectly well btw so far. I have been able to write a custom debugger for collecting all the necessary information that adheres to the existing interface. (But just to be clear, I am not talking about the WebDebuggerHook)

Solution

I suggest having a public setter for a debugger somewhere on the Ledger object or possibly an argument to StartEvaluator.

BTW AlgoJig does a bunch of things that neither Dryrun nor Simulate do so switching to those to get traces is not an option.

Dependencies

No.

Urgency

What can I say? It's not blocking anyone but it could dramatically improve the contract development & testing experience if this was available.

@fergalwalsh fergalwalsh added the new-feature-request Feature request that needs triage label Jan 20, 2023
@fergalwalsh
Copy link
Author

I just came across #4438
It looks like BlockEvaluator.Tracer might actually be exactly what I am looking for! I'll try to play with this a bit and see if it meets my needs.

@fergalwalsh
Copy link
Author

I finally had a chance to look into this. The EvalTracer interface does look useful but unfortunately at the moment it is of very limited use in external code because most of the EvalContext fields are private.

For example I'd like to use this AfterOpcode(cx *EvalContext, evalError error) to access and record the stack and scratch space usage after each opcode. But I can't do this because EvalContext.stack, . scratch etc are all private without accessors.

Is there any plans to make these public (and their dependents like stackValue)? I'd like to see pretty much every field of EvalContext made public so external developers can go crazy creating useful tracing tools.

@bbroder-algo
Copy link
Contributor

We will be working on simulate-enabled stack tracing soon and we can revisit this request then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature-request Feature request that needs triage Team Scytale
Projects
None yet
Development

No branches or pull requests

3 participants