-
Notifications
You must be signed in to change notification settings - Fork 92
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
Local Ledger #1011
Local Ledger #1011
Conversation
Codecov Report
@@ Coverage Diff @@
## localledger/integration #1011 +/- ##
===========================================================
- Coverage 59.58% 59.21% -0.37%
===========================================================
Files 45 46 +1
Lines 8353 8523 +170
===========================================================
+ Hits 4977 5047 +70
- Misses 2918 3012 +94
- Partials 458 464 +6
Continue to review full report at Codecov.
|
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.
Made it about halfway through. Left some questions. Overall it's quite a large PR.
// validated block | ||
var vb ledgercore.ValidatedBlock | ||
vb = ledgercore.MakeValidatedBlock(blockCert.Block, delta) | ||
if protoChanged { |
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 see https://github.com/algorand/go-algorand/blob/master/ledger/evalindexer.go which seems to be the reason we need to modify the consensus properties. Is there a reason we need this block just to reconstruct the vb with the updated consensus property?
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.
|
||
// LookupResources is part of go-algorand's indexerLedgerForEval interface. | ||
func (l LedgerForEvaluator) LookupResources(input map[basics.Address]map[ledger.Creatable]struct{}) (map[basics.Address]map[ledger.Creatable]ledgercore.AccountResource, error) { | ||
// Initialize the result `res` with the same structure as `input`. |
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.
Why do we need to create a copy instead of mutating the input?
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.
input
type doesn't match the return type.
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.
Some initial feedback. I still need to take a closer look at AddBlock
api/handlers_e2e_test.go
Outdated
l := test.MakeTestLedger("ledger") | ||
defer l.Close() | ||
proc, err := blockprocessor.MakeProcessor(l, db.AddBlock) | ||
require.NoError(t, err, "failed to open ledger") | ||
blockCert := rpcs.EncodedBlockCert{Block: block} | ||
err = proc.Process(&blockCert) |
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.
Could this go in setupIdb
instead? Returning a new addBlock
callback would be one way to get the tests to behave similar to before, and avoid the duplicate code block. Another way would be to return the processor along with the IndexerDb implementation.
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 don't think an addBlock callback would work in this case since addBlock takes a validated block. I'll go with the second option.
@@ -263,115 +263,96 @@ func (db *IndexerDb) AddBlock(block *bookkeeping.Block) error { | |||
if err != nil { | |||
return fmt.Errorf("AddBlock() err: %w", err) | |||
} | |||
if block.Round() != basics.Round(importstate.NextRoundToAccount) { | |||
if block.Round() > basics.Round(importstate.NextRoundToAccount) { |
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.
Why aren't these equal anymore? We're ignoring the case where old blocks are submitted more than once?
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.
yeah. I'm making it ignore blocks with older rounds. this change was partly because this test was failing with local ledger, https://github.com/algorand/indexer/blob/develop/idb/postgres/postgres_integration_test.go#L2109. setupIdb
calls AddBlock to add genesisBlock but it was already added when calling Makeprocessor()
.
l := test.MakeTestLedger("ledger") | ||
defer l.Close() | ||
proc, err := blockprocessor.MakeProcessor(l, db.AddBlock) | ||
require.NoError(t, err, "failed to open ledger") | ||
blockCert := rpcs.EncodedBlockCert{Block: block} | ||
err = proc.Process(&blockCert) |
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.
Same as before, can we figure out how to streamline this?
cmd/algorand-indexer/daemon.go
Outdated
|
||
imp := importer.NewImporter(db) | ||
handler := blockHandler(imp, 1*time.Second) | ||
proc, err := blockprocessor.MakeProcessor(initState, indexerDataDir, imp.ImportBlock) |
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.
Could this constructor work with MakeProcessor(&genesis, indexerDataDir, imp.ImportBlock)
? It seems like we would want to start fetcher from round 0, so AddBlock could create the initial state when that occurs.
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.
how about pass an algod client to MakeProcessor
and skip passing block 0 to handler in MakeProcessor
?
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.
updated the method to accept a genesis and a genesis block.
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.
Just left a little more feedback
} | ||
|
||
// MakeLedgerForEvaluator creates a LedgerForEvaluator object. | ||
func MakeLedgerForEvaluator(ld *ledger.Ledger) (LedgerForEvaluator, error) { |
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.
Since error
is always nil
, consider not returning error
at all
"github.com/algorand/indexer/processor" | ||
iledger "github.com/algorand/indexer/processor/eval" |
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: consider renaming iledger
→ indexerLedger
or something a bit more verbose. Through my own misjudgment, I kept on thinking that iledger.xyz
are interfaces of some sort.
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'll include these changes in another related pr.
* Local Ledger (#1011) * integrate block processor * Local Ledger Deployment (#1013) * add simple local ledger migration * add deleted opts * fast catchup (#1023) * add fast catchup * Localledger merge (#1036) * return empty lists from fetchApplications and fetchAppLocalStates (#1010) * Update model to converge with algod (#1005) * New Feature: Adds Data Directory Support (#1012) - Updates the go-algorand submodule hash to point to rel/beta - Moves the cpu profiling file, pid file and indexer configuration file to be options of only the daemon sub-command - Changes os.Exit() to be a panic with a special handler. This is so that defer's are handled instead of being ignored. - Detects auto-loading configuration files in the data directory and issues errors if equivalent command line arguments are supplied. - Updates the README with instructions on how to use the auto-loading configuration files and the data directory. * Update mockery version Co-authored-by: erer1243 <[email protected]> Co-authored-by: AlgoStephenAkiki <[email protected]> * recovery scenario (#1024) * handle ledger recovery scenario * refactor create genesis block (#1026) * refactor create genesis block * Adds Local Ledger Readme (#1035) * Adds Local Ledger Readme Resolves #4109 Starts Readme docs * Update docs/LocalLedger.md Co-authored-by: Will Winder <[email protected]> * Update docs/LocalLedger.md Co-authored-by: Will Winder <[email protected]> * Update docs/LocalLedger.md Co-authored-by: Will Winder <[email protected]> * Removed troubleshooting section Co-authored-by: Will Winder <[email protected]> * update ledger file path and migration (#1042) * LocalLedger Refactoring + Catchpoint Service (#1049) Part 1 cleanup genesis file access. put node catchup into a function that can be swapped out with the catchup service. pass the indexer logger into the block processor. move open ledger into a util function, and move the initial state util function into a new ledger util file. add initial catchupservice implementation. move ledger init from daemon.go to constructor. Merge multiple read genesis functions. Part 2 Merge local_ledger migration package into blockprocessor. Rename Migration to Initialize Use logger in catchup service catchup Part 3 Update submodule and use NewWrappedLogger. Make util.CreateInitState private * build: merge develop into localledger/integration (#1062) * Ledger init status (#1058) * Generate an error if the catchpoint is not valid for initialization. (#1075) * Use main logger in handler and fetcher. (#1077) * Switch from fullNode catchup to catchpoint catchup service. (#1076) * Refactor daemon, add more tests (#1039) Refactors daemon cmd into separate, testable pieces. * Merge develop into localledger/integration (#1083) * Misc Local Ledger cleanup (#1086) * Update processor/blockprocessor/initialize.go Co-authored-by: Zeph Grunschlag <[email protected]> * commit * fix function call args * RFC-0001: Rfc 0001 impl (#1069) Adds an Exporter interface and a noop exporter implementation with factory methods for construction * Fix test errors * Add/fix tests * Add postgresql_exporter tests * Update config loading * Change BlockExportData to pointers * Move and rename ExportData * Add Empty func to BlockData * Add comment Co-authored-by: shiqizng <[email protected]> Co-authored-by: [email protected] <[email protected]> Co-authored-by: erer1243 <[email protected]> Co-authored-by: AlgoStephenAkiki <[email protected]> Co-authored-by: Will Winder <[email protected]> Co-authored-by: Zeph Grunschlag <[email protected]>
Summary
This PR integrates BlockProcessor to daemon and and AddBlock. And AddBlock is refactored to take a validated block.
Test Plan
Regression tests passing.