Giter VIP home page Giter VIP logo

Comments (1)

tyler-smith avatar tyler-smith commented on July 3, 2024

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)
}

from ortelius.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.