-
Notifications
You must be signed in to change notification settings - Fork 523
ledger: refactor evaluator into an internal package #2983
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
ledger: refactor evaluator into an internal package #2983
Conversation
|
fyi: @algorandskiy |
|
|
||
| // newTestLedger creates a in memory Ledger that is as realistic as | ||
| // possible. It has Rewards and FeeSink properly configured. | ||
| func newTestLedger(t testing.TB, balances bookkeeping.GenesisBalances) *Ledger { |
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.
looks like this also need to go into testing since these functions are generic and not app-specific
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't do that due to circular dependencies between the "testing" and the "ledger".
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.
looks like the only problem is `Ledger at
type testingEvaluator struct {
*internal.BlockEvaluator
ledger *Ledger
}and ledger. genesisProto, ledger.lookup usages. The former is implemented as GenesisProto() in #2984, the latter most likely is Lookup* function. So defining a new LedgerForTesting (well, I know) interface might make the trick.
|
btw, maybe move block eval into |
I think that doing so would be much easier after this PR is done. |
Codecov Report
@@ Coverage Diff @@
## master #2983 +/- ##
==========================================
- Coverage 43.83% 43.62% -0.21%
==========================================
Files 385 390 +5
Lines 86754 86750 -4
==========================================
- Hits 38026 37849 -177
- Misses 42716 42875 +159
- Partials 6012 6026 +14
Continue to review full report at Codecov.
|
algorandskiy
left a comment
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.
Looks good to me but I have some opinionated remarks.
| "github.com/algorand/go-algorand/data/transactions" | ||
| "github.com/algorand/go-algorand/data/txntest" | ||
| "github.com/algorand/go-algorand/ledger/ledgercore" | ||
| ledgertesting "github.com/algorand/go-algorand/ledger/testing" |
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.
nit: ledgertesting looks way too long, maybe ltesting or something?
|
|
||
| // newTestLedger creates a in memory Ledger that is as realistic as | ||
| // possible. It has Rewards and FeeSink properly configured. | ||
| func newTestLedger(t testing.TB, balances bookkeeping.GenesisBalances) *Ledger { |
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.
looks like the only problem is `Ledger at
type testingEvaluator struct {
*internal.BlockEvaluator
ledger *Ledger
}and ledger. genesisProto, ledger.lookup usages. The former is implemented as GenesisProto() in #2984, the latter most likely is Lookup* function. So defining a new LedgerForTesting (well, I know) interface might make the trick.
ledger/ledger.go
Outdated
| } | ||
|
|
||
| // MakeDebugBalances creates a ledger suitable for dryrun and debugger | ||
| func MakeDebugBalances(l ledgercore.LedgerForCowBase, round basics.Round, proto protocol.ConsensusVersion, prevTimestamp int64) apply.Balances { |
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.
thoughts/comments?
( not all the unit tests are ready yet )
## Summary This PR addresses a regression introduced in #2983. The culprit is that an interface might contain a nil pointer, which makes it insufficient to test the interface pointer itself. Fail cases: https://app.circleci.com/pipelines/github/algorand/go-algorand/2451/workflows/8807ced7-89ae-4b6b-96b0-1bc5bdf9d84c/jobs/27259/tests#failed-test-0 ## Test Plan Use existing unit testing. In particular TestCatchupOverGossip.
This PR reorganize the files inside the ledger package by move the evaluator related files into its own `internal` package. The files in the internal package cannot access the root ledger files, and therefore using the shared `ledgercore` as a place to share interfaces. ``` ledger/ ├── apply/ ├── internal/ ├── ledgercore/ └── testing/ ``` use existing test, and update existing tests.
## Summary This PR addresses a regression introduced in algorand#2983. The culprit is that an interface might contain a nil pointer, which makes it insufficient to test the interface pointer itself. Fail cases: https://app.circleci.com/pipelines/github/algorand/go-algorand/2451/workflows/8807ced7-89ae-4b6b-96b0-1bc5bdf9d84c/jobs/27259/tests#failed-test-0 ## Test Plan Use existing unit testing. In particular TestCatchupOverGossip.
## Summary This PR reorganize the files inside the ledger package by move the evaluator related files into its own `internal` package. The files in the internal package cannot access the root ledger files, and therefore using the shared `ledgercore` as a place to share interfaces. ``` ledger/ ├── apply/ ├── internal/ ├── ledgercore/ └── testing/ ``` ## Test Plan use existing test, and update existing tests.
Summary
This PR reorganize the files inside the ledger package by move the evaluator related files into its own
internalpackage.The files in the internal package cannot access the root ledger files, and therefore using the shared
ledgercoreas a place to share interfaces.Test Plan
use existing test, and update existing tests.