Skip to content

Commit

Permalink
services/horizon/internal/db2/history: Fix fee source muxed account i…
Browse files Browse the repository at this point in the history
…ngestion bug (#3948)
  • Loading branch information
tamirms authored and bartekn committed Sep 22, 2021
1 parent 337f2ac commit b070b2c
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
1 change: 1 addition & 0 deletions services/horizon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

* Fix ingestion of fee bump transactions which have muxed source accounts ([3948](https://github.com/stellar/go/pull/3948)).
* Add an index on trade aggregations, to improve ingestion performance ([3947](https://github.com/stellar/go/pull/3947)).

## v2.8.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func transactionToRow(transaction ingest.LedgerTransaction, sequence uint32) (Tr
feeBumpAccount := transaction.Envelope.FeeBumpAccount()
feeAccount := feeBumpAccount.ToAccountId()
var feeAccountMuxed null.String
if source.Type == xdr.CryptoKeyTypeKeyTypeMuxedEd25519 {
if feeBumpAccount.Type == xdr.CryptoKeyTypeKeyTypeMuxedEd25519 {
feeAccountMuxed = null.StringFrom(feeBumpAccount.Address())
}
t.FeeAccount = null.StringFrom(feeAccount.Address())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,84 @@ func TestTransactionToMap_muxed(t *testing.T) {

assert.Equal(t, feeSource.Address(), row.FeeAccountMuxed.String)
}

func TestTransactionToMap_SourceMuxedAndFeeSourceUnmuxed(t *testing.T) {
innerSource := xdr.MuxedAccount{
Type: xdr.CryptoKeyTypeKeyTypeMuxedEd25519,
Med25519: &xdr.MuxedAccountMed25519{
Id: 1,
Ed25519: xdr.Uint256{3, 2, 1},
},
}
innerAccountID := innerSource.ToAccountId()
feeSource := xdr.MuxedAccount{
Type: xdr.CryptoKeyTypeKeyTypeEd25519,
Ed25519: &xdr.Uint256{0, 1, 2},
}
tx := ingest.LedgerTransaction{
Index: 1,
Envelope: xdr.TransactionEnvelope{
Type: xdr.EnvelopeTypeEnvelopeTypeTxFeeBump,
FeeBump: &xdr.FeeBumpTransactionEnvelope{
Tx: xdr.FeeBumpTransaction{
FeeSource: feeSource,
Fee: 200,
InnerTx: xdr.FeeBumpTransactionInnerTx{
Type: xdr.EnvelopeTypeEnvelopeTypeTx,
V1: &xdr.TransactionV1Envelope{
Tx: xdr.Transaction{
SourceAccount: innerSource,
Operations: []xdr.Operation{
{
SourceAccount: &innerSource,
Body: xdr.OperationBody{
Type: xdr.OperationTypePayment,
PaymentOp: &xdr.PaymentOp{
Destination: innerSource,
Asset: xdr.Asset{Type: xdr.AssetTypeAssetTypeNative},
Amount: 100,
},
},
},
},
},
},
},
},
},
},
Result: xdr.TransactionResultPair{
TransactionHash: xdr.Hash{1, 2, 3},
Result: xdr.TransactionResult{
Result: xdr.TransactionResultResult{
Code: xdr.TransactionResultCodeTxFeeBumpInnerSuccess,
InnerResultPair: &xdr.InnerTransactionResultPair{
TransactionHash: xdr.Hash{3, 2, 1},
Result: xdr.InnerTransactionResult{
Result: xdr.InnerTransactionResultResult{
Results: &[]xdr.OperationResult{},
},
},
},
Results: &[]xdr.OperationResult{},
},
},
},
UnsafeMeta: xdr.TransactionMeta{
V: 1,
Operations: &[]xdr.OperationMeta{},
V1: &xdr.TransactionMetaV1{
TxChanges: []xdr.LedgerEntryChange{},
Operations: []xdr.OperationMeta{},
},
},
}
row, err := transactionToRow(tx, 20)
assert.NoError(t, err)

assert.Equal(t, innerAccountID.Address(), row.Account)

assert.Equal(t, feeSource.Address(), row.FeeAccount.String)

assert.False(t, row.FeeAccountMuxed.Valid)
}
23 changes: 23 additions & 0 deletions services/horizon/internal/db2/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- +migrate Up

UPDATE history_transactions SET fee_account_muxed = NULL WHERE fee_account IS NOT NULL AND fee_account_muxed LIKE 'G%';

-- +migrate Down

0 comments on commit b070b2c

Please sign in to comment.