algod: Refactor AccountData conversion#5098
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5098 +/- ##
==========================================
+ Coverage 53.40% 53.42% +0.01%
==========================================
Files 431 431
Lines 54381 54420 +39
==========================================
+ Hits 29042 29072 +30
- Misses 23079 23085 +6
- Partials 2260 2263 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
winder
left a comment
There was a problem hiding this comment.
I updated the indexer validatedblock objects with these changes: algorand/indexer#1455
It looks good, but you can see that the slices are no longer sorted, which is one difference between accountDataToAccount and AccountDataToAccount. This isn't necessarily a problem, just something I noticed.
Do you think it makes sense to keep using AccountDataToAccount but replace ledgercore.AssignAccountData with an AccountDataToAccountData function? I'm fine with either approach.
| if !ad.AuthAddr.IsZero() { | ||
| authAddr = strOrNil(ad.AuthAddr.String()) | ||
| } | ||
| return model.Account{ |
There was a problem hiding this comment.
Might be worth putting a comment cross linking the model.Account init in AccountDataToAccount so that the next person in this code knows to update both.
There was a problem hiding this comment.
Ended up moving it to account.go since it sort of just belongs there.
17652f1
I'd like to just get rid of the intermediate type and directly convert from one to the other. |
Summary
Because of the way AccountData conversion was initially implemented--
ledgercore.AccountData=>basics.AccountData=>model.Account--we were losing data on App and Asset created/opted into.The combination of AssignAccountData which throws away
AppParams, AppLocalState, AssetHolding, and AssetParams, and AccountDataToAccount which uses those parameters to calculate asset/app numbers, caused that data to be lost.I've refactored into a separate conversion function directly from
ledgercore.AccountDatatomodel.Account. I've also updated the test to cover exactly the data that indexer requires to be correct.