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

Everest: duplicated txs #36

Closed
menxit opened this issue Aug 24, 2020 · 1 comment · Fixed by #55
Closed

Everest: duplicated txs #36

menxit opened this issue Aug 24, 2020 · 1 comment · Fixed by #55
Assignees
Labels
bug Something isn't working

Comments

@menxit
Copy link
Member

menxit commented Aug 24, 2020

Ortelius returns duplicated txs on asset detail:

@menxit menxit changed the title Duplicated txs Everest: duplicated txs Aug 24, 2020
@menxit menxit closed this as completed Sep 4, 2020
@menxit menxit reopened this Sep 4, 2020
@tyler-smith tyler-smith added the bug Something isn't working label Sep 8, 2020
@tyler-smith tyler-smith self-assigned this Sep 8, 2020
@tyler-smith
Copy link
Contributor

tyler-smith commented Sep 9, 2020

The cause of this issue is a faulty JOIN when filtering transactions by asset and/or address.

Relevant schema:

Transactions has many Outputs
Outputs has many OutputAddresses.

Outputs has asset_id property
OutputAddresses has address property 

SQL: https://github.com/ava-labs/ortelius/blob/40ca1f3237a5914f1417c0bf8a342aab66e77113/services/db/migrations/001_create_avm_schemas.up.sql

Bug analysis:

We JOIN Outputs and OutputAddresses to Transactions to enable a WHERE clause restricting asset_id and/or address, so transactions with multiple outputs or multiple addresses on an output become duplicated.

Code:

needOutputsJoin := len(p.Addresses) > 0 || p.AssetID != nil
if needOutputsJoin {
b = b.LeftJoin("avm_outputs", "avm_outputs.transaction_id = avm_transactions.id")
}
if len(p.Addresses) > 0 {
addrs := make([]string, len(p.Addresses))
for i, id := range p.Addresses {
addrs[i] = id.String()
}
b = b.LeftJoin("avm_output_addresses", "avm_outputs.id = avm_output_addresses.output_id").
Where("avm_output_addresses.address IN ?", addrs)
}

@tasinco tasinco linked a pull request Sep 9, 2020 that will close this issue
@tasinco tasinco self-assigned this Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants