Skip to content

Commit

Permalink
Fix soroban inclusion fee computation
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed May 16, 2024
1 parent 57ecad1 commit 965a13f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/soroban-rpc/internal/feewindow/feewindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ func (fw *FeeWindows) IngestFees(meta xdr.LedgerCloseMeta) error {
continue
}
sorobanFees := tx.UnsafeMeta.V3.SorobanMeta.Ext.V1
// TODO: this seems incorrect, since in integration tests it's larger than feeCharged
sorobanFeeCharged := sorobanFees.RentFeeCharged + sorobanFees.TotalNonRefundableResourceFeeCharged + sorobanFees.TotalRefundableResourceFeeCharged
inclusionFee := feeCharged - uint64(sorobanFeeCharged)
resourceFeeCharged := sorobanFees.TotalNonRefundableResourceFeeCharged + sorobanFees.TotalRefundableResourceFeeCharged
inclusionFee := feeCharged - uint64(resourceFeeCharged)
sorobanInclusionFees = append(sorobanInclusionFees, inclusionFee)
continue
}
}
classicFees = append(classicFees, feeCharged)
feePerOp := feeCharged / uint64(len(ops))
classicFees = append(classicFees, feePerOp)

}
bucket := ledgerbucketwindow.LedgerBucket[[]uint64]{
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-rpc/internal/test/get_fee_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestGetFeeStats(t *testing.T) {
var sorobanTxMeta xdr.TransactionMeta
require.NoError(t, xdr.SafeUnmarshalBase64(sorobanTxResponse.ResultMetaXdr, &sorobanTxMeta))
sorobanFees := sorobanTxMeta.MustV3().SorobanMeta.Ext.MustV1()
sorobanNonInclusionFee := sorobanFees.RentFeeCharged + sorobanFees.TotalRefundableResourceFeeCharged + sorobanFees.TotalNonRefundableResourceFeeCharged
sorobanInclusionFee := uint64(sorobanTotalFee - sorobanNonInclusionFee)
sorobanResourceFeeCharged := sorobanFees.TotalRefundableResourceFeeCharged + sorobanFees.TotalNonRefundableResourceFeeCharged
sorobanInclusionFee := uint64(sorobanTotalFee - sorobanResourceFeeCharged)

// Submit classic transaction
params = txnbuild.TransactionParams{
Expand Down

0 comments on commit 965a13f

Please sign in to comment.