-
Notifications
You must be signed in to change notification settings - Fork 0
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
xdrill for operations #2
base: 5550/xdrill-transactions
Are you sure you want to change the base?
Conversation
Similar problems in stellar#5568 and #1 exist in this PR as well. TODO: fix it |
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.
High level, there are some quirks in stellar-etl. Now is the time for us to discuss whether it makes sense to incorporate back in to XDRill or not. Particularly:
- int vs real representation for asset amounts - should this stay in raw integer form? Should we convert to real? Offer both?
- Asset id - this is an optimization specific to Hubble. Does it make sense to create a more universal asset hash? If so, does
FarmHash
make the most sense? - buy vs sell side of offers. In Horizon, these are presented as
base
andcounter
assets, where base asset hash < counter asset hash so that the trade pairs are consistently on the same side. This may be an opportunity for us to reimagine how we want this schema to be defined
ingest/ledger_operation.go
Outdated
if ok { | ||
operationResultTr, ok := operationResults[o.OperationIndex].GetTr() | ||
if ok { | ||
operationTraceCode, err := operationResultTr.MapOperationResultTr() |
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: =
instead of :=
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 in c68cd9a
ingest/ledger_operation.go
Outdated
if err := o.addAccountAndMuxedAccountDetails(details, op.Destination, "to"); err != nil { | ||
return details, err | ||
} | ||
details["amount"] = o.ConvertStroopValueToReal(op.Amount) |
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.
do we want to bring over this logic from stellar-etl? I think both RPC and horizon keep the raw stroop values to avoid floating point errors. wdyt of keeping amounts in stroops?
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.
Hmm that's fair. Less railroading people into floating point if they don't want ot
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 in c68cd9a
ingest/ledger_operation.go
Outdated
if ledgerKey.TrustLine.Asset.Type == xdr.AssetTypeAssetTypePoolShare { | ||
result["trustline_liquidity_pool_id"] = o.PoolIDToString(*ledgerKey.TrustLine.Asset.LiquidityPoolId) | ||
} else { | ||
result["trustline_asset"] = ledgerKey.TrustLine.Asset.ToAsset().StringCanonical() |
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: Should we be parsing asset consistent via addAssetDetails...
?
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.
Let me take a look at this again. Might have just been stellar-etl never updated this or there was an actual reason for this
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 so this is a type TrustLineAsset
type TrustLineAsset struct {
Type AssetType
AlphaNum4 *AlphaNum4
AlphaNum12 *AlphaNum12
LiquidityPoolId *PoolId
}
Note the extra LiquidityPoolId *PoolId
Whereas addAssetDetails
only handles normal Asset types. I'll try to consolidate as I think they effectively want the same "asset" info
ingest/ledger_operation.go
Outdated
return details, fmt.Errorf("could not access CreateClaimableBalance info for this operation (index %d)", o.OperationIndex) | ||
} | ||
|
||
details["asset"] = op.Asset.StringCanonical() |
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: asset representation is different from manage buy/sell offer
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 in c68cd9a
ingest/ledger_operation.go
Outdated
details := map[string]interface{}{} | ||
_, ok := o.Operation.Body.GetRestoreFootprintOp() | ||
if !ok { | ||
return details, fmt.Errorf("could not access InvokeHostFunction info for this operation (index %d)", o.OperationIndex) |
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: copy/paste error. wrong operation 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.
🤦
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 in c68cd9a
Yeah I was debating this too. Thinking about it again I personally would lean towards addressing the quirks now. It means less refactoring in the future in favor of spending more time now. But I think it might be the right decision to defer for now. It's much easier to test and compare similar logic rather than slightly different logic. Like for refactor/testing of stellar-etl/processors/xdrill it'll be as easy as writing the new code and compare the output of old stellar-etl == new stellar-etl. I think the fewer value fixes we make will make the diffing much easier. Basically sticking with the status quo makes it easier for myself or anyone else to pick up later.
I agree with keeping this in the raw form instead of converted float
iirc the issue with the pure FarmHash is that it didn't fit nicely into the BigQuery integer size (64/128 bytes?) which is why some asset_ids can be negative because the BQ column for asset_id is int64 (?) instead of a long long type (128+). This is hacky. I'm not opposed to making this more standard and make more sense though
👍 Edit: So I went ahead and did make the int versus real amount change |
@@ -0,0 +1,47 @@ | |||
package ingest |
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.
Similarly to #3 (comment)
OperationDetails has been updated to structs to preserve strict typing for data instead of the the previous map[string]string/interface{}
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.
Oh also if anyone has better suggestions for organizing and what dir to put these files in I'm happy to update. One issue is that golang doesn't let you put these in a different directory and still have it as part of the same package (only files in the same dir can go in the same package) but if I separate these functions out to their own package I create a circular dependency with go/ingest
} | ||
|
||
// TODO: Parameters should be processed with xdr2json | ||
invokeHostFunctionDetail.Parameters, invokeHostFunctionDetail.ParametersDecoded = o.serializeParameters(args) |
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 do we feel about making Parameters a straight JSON from xdr2json instead of our current ScVal parameter mess?
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
CHANGELOG.md
within the component folder structure. For example, if I changed horizon, then I updated (services/horizon/CHANGELOG.md. I add a new line item describing the change and reference to this PR. If I don't update a CHANGELOG, I acknowledge this PR's change may not be mentioned in future release notes.semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
github issue
xdrill functions for LedgerOperations
Why
Create low level helper functions for operations parsing
Known limitations