-
Notifications
You must be signed in to change notification settings - Fork 493
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 Deltas: AccountDelta retrieval through ledger/catchup service #4658
Merged
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
0e234dc
Add AccountDeltas to ledger interface
Eric-Warehime 2a4677c
Add EnableSyncMode config variable
Eric-Warehime f9d9ab9
Add NodeInterface/LedgerForAPI changes
Eric-Warehime 2eb0d40
Stop synching blocks in catchup service when sync round is set
Eric-Warehime d1206f2
Add comments, fix interface naming
Eric-Warehime ab0ded3
Fix handler tests
Eric-Warehime 5331665
Fix catchup service syncRound, add test
Eric-Warehime 023626f
Fix race condition
Eric-Warehime bae0275
Fix sanity
Eric-Warehime 539db38
Fix mock interface
Eric-Warehime 745fddb
Add /v2/accountdelta/{round} API
Eric-Warehime a36b6e2
Merge upstream
Eric-Warehime 229d2f8
Add tests for handler
Eric-Warehime c25e4b8
Fix race condition
Eric-Warehime 853714e
Add RoundDeltas API
Eric-Warehime 14158ea
Add mutex to catchup service
Eric-Warehime 00c8558
Add SyncRound APIs
Eric-Warehime 56b54e1
Fix code gen
Eric-Warehime e17e6ff
Add node unset sync round implementation
Eric-Warehime e00355e
Add comments to exports
Eric-Warehime d3b3a15
Add descriptions to API changes
Eric-Warehime 9e91dab
Fix race condition in catchup service_test
Eric-Warehime 01d6135
Fix error msg, lint imports
Eric-Warehime 24cc272
PR comments
Eric-Warehime c5dbed5
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime db39ddb
Update merged fields
Eric-Warehime cd03056
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime 0cc41e0
Add KV Deltas to RoundDeltas response
Eric-Warehime 67b722d
Remove EnableSyncMode
Eric-Warehime 0f2dfb9
Fix index bug, add tests
Eric-Warehime 9821bde
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime 93ef0b9
Update algod spec to return StateDelta
Eric-Warehime a9185e6
Consolidate acctupdates deltas into single cache
Eric-Warehime 13508ff
Fix handlers interfaces
Eric-Warehime 4c9c4e5
Update required fields, fix acctupdates totals
Eric-Warehime 59199e3
Mark acctupdates test non parallel
Eric-Warehime 7cedca2
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime ab97557
Add PR comments
Eric-Warehime 0460b1a
Fix mock node
Eric-Warehime 98e9f43
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime 4fd5d8f
Update catchup/service_test.go
Eric-Warehime a15da3c
Fix model imports
Eric-Warehime 7e29b90
Update catchup service test
Eric-Warehime 9ca4d60
Refactor account conversion to use factory method
michaeldiamant e45e409
Merge pull request #2 from michaeldiamant/statedelta_factory_method
Eric-Warehime 233cef2
Prototype approval test for GetRoundStateDelta
michaeldiamant 534066d
Fix lint error
michaeldiamant 6b669a3
Merge pull request #3 from michaeldiamant/approval_test_example
Eric-Warehime ba7c1ce
Revert "Prototype approval test for GetRoundStateDelta"
michaeldiamant 15372b4
Merge pull request #4 from michaeldiamant/revert_approvals_test
Eric-Warehime 456f377
PR feedback
Eric-Warehime b811356
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime a819ed7
Merge remote-tracking branch 'upstream/master' into statedelta-ledger…
Eric-Warehime 1cd6f82
PR feedback
Eric-Warehime 62fffea
Fix tests
Eric-Warehime d114060
Move Delta creation, add test
Eric-Warehime 4273a07
Lint import order
Eric-Warehime c425f4f
Update catchup/service.go
Eric-Warehime 3fd1d1a
gofmt
Eric-Warehime 2c40cca
Reuse ApplicationParams and AssetParameters converters
michaeldiamant 18d3664
Expose AppLocalState converter
michaeldiamant 6d8b516
Expose AssetHolding converter
michaeldiamant da723a5
Merge pull request #5 from michaeldiamant/reuse_converters
Eric-Warehime 4114c3b
Remove error returns
Eric-Warehime 2d91a96
Update ledger/acctupdates.go
Eric-Warehime ce09bf8
Update daemon/algod/api/server/v2/handlers.go
Eric-Warehime 01349d8
PR feedback
Eric-Warehime a377e3f
Fix new API code gen
Eric-Warehime 844ffd6
Change mutex to atomic uint64
Eric-Warehime 41cdeee
cleanup
Eric-Warehime 59563ba
Move MaxAcctLookback access out of catchup service
Eric-Warehime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -181,6 +181,96 @@ func (cl *periodicSyncLogger) Warnf(s string, args ...interface{}) { | |||||
cl.Logger.Warnf(s, args...) | ||||||
} | ||||||
|
||||||
func TestSyncRound(t *testing.T) { | ||||||
partitiontest.PartitionTest(t) | ||||||
|
||||||
// Make Ledger | ||||||
local := new(mockedLedger) | ||||||
local.blocks = append(local.blocks, bookkeeping.Block{}) | ||||||
|
||||||
remote, _, blk, err := buildTestLedger(t, bookkeeping.Block{}) | ||||||
if err != nil { | ||||||
t.Fatal(err) | ||||||
return | ||||||
} | ||||||
addBlocks(t, remote, blk, 10) | ||||||
|
||||||
// Create a network and block service | ||||||
blockServiceConfig := config.GetDefaultLocal() | ||||||
net := &httpTestPeerSource{} | ||||||
ls := rpcs.MakeBlockService(logging.Base(), blockServiceConfig, remote, net, "test genesisID") | ||||||
|
||||||
nodeA := basicRPCNode{} | ||||||
nodeA.RegisterHTTPHandler(rpcs.BlockServiceBlockPath, ls) | ||||||
nodeA.start() | ||||||
defer nodeA.stop() | ||||||
rootURL := nodeA.rootURL() | ||||||
net.addPeer(rootURL) | ||||||
|
||||||
auth := &mockedAuthenticator{fail: true} | ||||||
initialLocalRound := local.LastRound() | ||||||
require.True(t, 0 == initialLocalRound) | ||||||
|
||||||
// Make Service | ||||||
localCfg := config.GetDefaultLocal() | ||||||
s := MakeService(logging.Base(), localCfg, net, local, auth, nil, nil) | ||||||
s.log = &periodicSyncLogger{Logger: logging.Base()} | ||||||
s.deadlineTimeout = 2 * time.Second | ||||||
|
||||||
// Set disable round success | ||||||
err = s.SetDisableSyncRound(3) | ||||||
require.NoError(t, err) | ||||||
|
||||||
s.Start() | ||||||
defer s.Stop() | ||||||
// wait past the initial sync - which is known to fail due to the above "auth" | ||||||
time.Sleep(s.deadlineTimeout*2 - 200*time.Millisecond) | ||||||
require.Equal(t, initialLocalRound, local.LastRound()) | ||||||
auth.alter(-1, false) | ||||||
|
||||||
// wait until the catchup is done. Since we've might have missed the sleep window, we need to wait | ||||||
// until the synchronization is complete. | ||||||
waitStart := time.Now() | ||||||
for time.Since(waitStart) < 2*s.deadlineTimeout { | ||||||
if remote.LastRound() == local.LastRound() { | ||||||
break | ||||||
} | ||||||
time.Sleep(20 * time.Millisecond) | ||||||
} | ||||||
// Assert that the last block is the one we expect--i.e. disableSyncRound - 1 | ||||||
rnd := s.GetDisableSyncRound() | ||||||
rr, lr := basics.Round(rnd-1), local.LastRound() | ||||||
require.Equal(t, rr, lr) | ||||||
|
||||||
for r := basics.Round(1); r < rr; r++ { | ||||||
localBlock, err := local.Block(r) | ||||||
require.NoError(t, err) | ||||||
remoteBlock, err := remote.Block(r) | ||||||
require.NoError(t, err) | ||||||
require.Equal(t, remoteBlock.Hash(), localBlock.Hash()) | ||||||
} | ||||||
|
||||||
// unset syncRound and make sure we finish catching up | ||||||
s.UnsetDisableSyncRound() | ||||||
// wait until the catchup is done | ||||||
waitStart = time.Now() | ||||||
for time.Now().Sub(waitStart) < 8*s.deadlineTimeout { | ||||||
if remote.LastRound() == local.LastRound() { | ||||||
break | ||||||
} | ||||||
time.Sleep(20 * time.Millisecond) | ||||||
} | ||||||
rr, lr = remote.LastRound(), local.LastRound() | ||||||
require.Equal(t, rr, lr) | ||||||
for r := basics.Round(1); r < remote.LastRound(); r++ { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
and should it be r<=rr? |
||||||
localBlock, err := local.Block(r) | ||||||
require.NoError(t, err) | ||||||
remoteBlock, err := remote.Block(r) | ||||||
require.NoError(t, err) | ||||||
require.Equal(t, remoteBlock.Hash(), localBlock.Hash()) | ||||||
} | ||||||
} | ||||||
|
||||||
func TestPeriodicSync(t *testing.T) { | ||||||
partitiontest.PartitionTest(t) | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: not sure if our version has it, I think this is what
require.Eventually
is for: