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

tools/stellar-archivist: Fix stellar-archivist dumpxdr command #1331

Closed
wants to merge 2 commits into from

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented May 24, 2019

DumpXdrAsJson function is creating shared objects for various XDR types:

var lhe xdr.LedgerHeaderHistoryEntry
var the xdr.TransactionHistoryEntry
var thre xdr.TransactionHistoryResultEntry
var bke xdr.BucketEntry
var scp xdr.ScpHistoryEntry

These objects are later reused inside for loop. It seems that previous values are persisted in the shared objects when unmarshaling unions. For example:

stellar-archivist dumpxdr bucket-4100ad3b1085bd14d1c808ece3b38db97171532d0d11ed5edd57aff0e416e06a.xdr.gz
56052390-}{
56052391-    "Type": 1,
56052392-    "LiveEntry": {
56052393-        "LastModifiedLedgerSeq": 23608331,
56052394-        "Data": {
56052395-            "Type": 0,
56052396-            "Account": {
56052397:                "AccountId": "GDZZYKUL3B5R2CNZF6GWZGQB6W4DAYMUBU4H7YHSTY5K4VJYEO7N2X73",
56052398-                "Balance": 15998000,
56052399-                "SeqNum": 92133538194784276,
56052400-                "NumSubEntries": 1,
56052401-                "InflationDest": null,
56052402-                "Flags": 0,
56052403-                "HomeDomain": "",
56052404-                "Thresholds": [
56052405-                    1,
56052406-                    0,
56052407-                    0,
56052408-                    0
56052409-                ],
56052410-                "Signers": null,
56052411-                "Ext": {
56052412-                    "V": 0,
56052413-                    "V1": null
56052414-                }
56052415-            },
56052416-            "TrustLine": null,
56052417-            "Offer": null,
56052418-            "Data": null
56052419-        },
56052420-        "Ext": {
56052421-            "V": 0
56052422-        }
56052423-    },
56052424-    "DeadEntry": {
56052425-        "Type": 0,
56052426-        "Account": {
56052427-            "AccountId": "GDZZYMG4436ILOHHRZKWFJV3SRRRLH55ZRXCD5CXYL2XSAW3TYHKJU4I"
56052428-        },
56052429-        "TrustLine": null,
56052430-        "Offer": null,
56052431-        "Data": null
56052432-    },
56052433-    "MetaEntry": null
56052434-}{

Note: AccountId fields are strkey-encoded for readability. In example above LiveEntry should be null because bucket entry type is equal 1.

This PR recreates empty objects on each iteration.


Should a long term fix be actually added to go-xdr (xdr.Unmarshal)?

@bartekn
Copy link
Contributor Author

bartekn commented Jul 1, 2019

It looks like I accidentally included a fix for this in cca9f0a#diff-a180e1f12313289bc086aad14e4310c5 (PR: #1264). Closing this but the question remains:

Should a long term fix be actually added to go-xdr (xdr.Unmarshal)?

@bartekn bartekn closed this Jul 1, 2019
@bartekn bartekn deleted the fix-archivist-dumpxdr branch July 1, 2019 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant