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

Add fee fields; formatting for warnings #240

Merged
merged 7 commits into from
Apr 30, 2024
Merged

Add fee fields; formatting for warnings #240

merged 7 commits into from
Apr 30, 2024

Conversation

chowbao
Copy link
Contributor

@chowbao chowbao commented Apr 29, 2024

  • Add new soroban fee fields
  • input/ledgers needed to add LCM to extract a fee field
    • The fee field will be blank if running in captive-core mode because HistoryArchives does not contain the value
    • Potentially can add to the captive-core mode but doesn't seem worth the effort as everything runs with txmeta files now
  • Fixed all existing warnings
    • Warnings were mostly from fmt.errors should not start with a capitalized string
    • or unused functions/variables

Note: The EMIT_SOROBAN_TRANSACTION_META_EXT_V1 EMIT_LEDGER_CLOSE_META_EXT_V1 flags for core are set to true for ledgerexporter testnet txmeta files

@chowbao chowbao requested a review from a team as a code owner April 29, 2024 18:29
@chowbao chowbao changed the title Add p21 fee fields; formatting for warnings Add fee fields; formatting for warnings Apr 29, 2024
@@ -68,7 +68,12 @@ func GetLedgers(start, end uint32, limit int64, env utils.EnvironmentDetails, us
},
}

ledgerSlice = append(ledgerSlice, ledger)
ledgerLCM := utils.HistoryArchiveLedgerAndLCM{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the new LCM fee field we need to pass in the historyarchive.Ledger as well as the LedgerCloseMeta. This should be eventually refactored in the future to where input/ledger and input/assets don't use historyarchive.Ledger and just use LCM

Comment on lines +170 to +175
extV1, ok := meta.SorobanMeta.Ext.GetV1()
if ok {
outputTotalNonRefundableResourceFeeCharged = int64(extV1.TotalNonRefundableResourceFeeCharged)
outputTotalRefundableResourceFeeCharged = int64(extV1.TotalRefundableResourceFeeCharged)
outputRentFeeCharged = int64(extV1.RentFeeCharged)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New fee fields

var outputSorobanFeeWrite1Kb int64
lcmV1, ok := lcm.GetV1()
if ok {
outputSorobanFeeWrite1Kb = int64(lcmV1.Ext.V1.SorobanFeeWrite1Kb)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New fee change

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be worthwhile to use the safety getter method of LedgerCloseMetaExt.GetV1() rather than direct reference to nested V1 struct, to avoid potential nil pointer, i.e. check ok from lcmv1.Ext.GetV1()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Done in d43e728

Copy link
Contributor

@sydneynotthecity sydneynotthecity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HistoryArchiveLedgerAndLCM is definitely a hack that I want to address and refactor sometime this quarter. Probably a good opportunity to pair program with a new team member and refactor that code. Like you noted, if someone runs the codebase using Captive Core, they will run into errors getting the write fee since LCM will be empty.

Also, do you think there is any merit in keeping the code you commented out, or should that just be deleted entirely? A lot of those functions predate me and were original attempts to maintain parity between Horizon/Hubble.

internal/transform/contract_data.go Outdated Show resolved Hide resolved
internal/transform/effects_test.go Outdated Show resolved Hide resolved
internal/transform/ledger_test.go Outdated Show resolved Hide resolved
Comment on lines +72 to +73
TotalNonRefundableResourceFeeCharged int64 `json:"non_refundable_resource_fee_charged"`
TotalRefundableResourceFeeCharged int64 `json:"refundable_resource_fee_charged"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these differ from resource_fee_refund and resource_fee?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the xdr itself they are different fields. Functionally equivalent I'm not sure. We can probably compare them when there is data emitted and then determine if we only need to keep one or the other

@sydneynotthecity
Copy link
Contributor

Note: The EMIT_SOROBAN_TRANSACTION_META_EXT_V1 EMIT_LEDGER_CLOSE_META_EXT_V1 flags for core are set to true for ledgerexporter testnet txmeta files

Nit: Should we also update the Captive core configs to use those flags within stellar-etl too?

@chowbao
Copy link
Contributor Author

chowbao commented Apr 30, 2024

Also, do you think there is any merit in keeping the code you commented out, or should that just be deleted entirely?

Yeah we can delete them. Worse case we can find them again in the commit history

Copy link
Contributor

@sydneynotthecity sydneynotthecity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chowbao chowbao merged commit d39b487 into master Apr 30, 2024
4 checks passed
@sydneynotthecity sydneynotthecity deleted the p21-fee-updates branch July 15, 2024 13:00
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.

3 participants