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

tracer: Default to ledger tracer when starting new evaluator #5521

Merged
merged 2 commits into from Jul 5, 2023

Conversation

Eric-Warehime
Copy link
Contributor

Summary

Addresses #5483 by assigning the Block Evaluator's tracer to be the tracer associated with the ledger on creation if there is no tracer passed in.

This lets devmode and private networks accumulate txn group deltas when the tracer is enabled on the ledger.

Test Plan

Added e2e test which retrieves txn group deltas while in dev mode.

@Eric-Warehime Eric-Warehime added the bug Something isn't working label Jun 30, 2023
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #5521 (859238a) into master (22e0e09) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #5521      +/-   ##
==========================================
- Coverage   55.81%   55.77%   -0.05%     
==========================================
  Files         446      446              
  Lines       63228    63231       +3     
==========================================
- Hits        35290    35266      -24     
- Misses      25572    25590      +18     
- Partials     2366     2375       +9     
Impacted Files Coverage Δ
ledger/ledger.go 70.55% <100.00%> (+0.22%) ⬆️

... and 15 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Eric-Warehime Eric-Warehime added Bug-Fix and removed bug Something isn't working labels Jul 3, 2023
tzaffi
tzaffi previously approved these changes Jul 3, 2023
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Leaving some questions and nits.

daemon/algod/api/client/restClient.go Outdated Show resolved Hide resolved
test/e2e-go/features/devmode/devmode_test.go Show resolved Hide resolved
test/e2e-go/features/devmode/devmode_test.go Show resolved Hide resolved
test/e2e-go/features/devmode/devmode_test.go Show resolved Hide resolved
func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint, maxTxnBytesPerBlock int, tracer logic.EvalTracer) (*eval.BlockEvaluator, error) {
tracerForEval := tracer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistic and ignoreable nit: introducing a new variable isn't necessary. You can either rename the param tracerForEval or even without renaming simply overwrite it with l.tracer when it's nil.

Copy link
Contributor

@tzaffi tzaffi Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another point to consider. Currently, and in the pre-existing code the tracer param overrides l.tracer even when it's non-nil. This feels like an error to me and perhaps deserves an error (though it may very well break some tests and even live uses). Something like:

if tracer != nil && l.tracer != nil {
    return nil, fmt.Errorf("ledger StartEvaluator(): ambiguous non-nil EvalTracers provided both in Ledger and as tracer param")
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure this doesn't break the simulate endpoint, which attaches its own tracer with this function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasonpaulos are there regression tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe there are any tests of simulate with the config option EnableTxnEvalTracer=true yet. This would be a good test to ensure simulate isn't affected by this PR.

Probably the simplest way to achieve this would be to either augment or copy TestSimulateTransaction to also test with the new DevModeTxnTracerNetwork.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the intention right now is to allow StartEvaluator to have the final say in which tracer is attached to the newly created evaluator. The ledger's tracer is provided as the default in case nothing is passed in.

This lets simulate/txn eval tracer work for their respective use cases currently, but maybe we would want to revisit this decision in the future if/when we have more tracers competing for access to the evaluator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test which is a copy of the TestSimulateTransaction test w/ a couple of assertions changed because devmode lets us be confident that the round increases deterministically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- Works nicely in sandbox and group deltas endpoints can be retrieved in dev mode 👍

Copy link
Member

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as simulate is unaffected, I see no issues with this

@algochoi
Copy link
Contributor

algochoi commented Jul 3, 2023

FWIW I ran a simple payment and app call (https://github.com/algorand/py-algorand-sdk/blob/develop/examples/apps.py) on the simulate endpoint using this branch and it looks ok as well

func (l *Ledger) StartEvaluator(hdr bookkeeping.BlockHeader, paysetHint, maxTxnBytesPerBlock int, tracer logic.EvalTracer) (*eval.BlockEvaluator, error) {
tracerForEval := tracer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@winder winder merged commit ec9e662 into algorand:master Jul 5, 2023
17 checks passed
@Eric-Warehime Eric-Warehime deleted the add-tracer-txnpool branch July 6, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants