MinaProtocol / mina

Mina is a cryptocurrency protocol with a constant size blockchain, improving scaling while maintaining decentralization and security.
https://minaprotocol.com
Apache License 2.0
1.99k stars 529 forks source link

Postgres schema for Archive Node is broken with Encore #7908

Closed nerdvibe closed 3 years ago

nerdvibe commented 3 years ago

The Postgres schema for the Archive Node seems to be broken (https://raw.githubusercontent.com/MinaProtocol/mina/master/src/app/archive/create_schema.sql) with encore (minaprotocol/mina-daemon-baked:0.3.3-3ef8663-encore-3b5824a).

If anyone else stumbles into this issue, as a temporary fix, I've created a schema that "works" https://gist.github.com/nerdvibe/2ebd5598c736552008f6df58753198f2

(carbonara from Discord)

nerdvibe commented 3 years ago

This then creates the following issue:

[Warn] Failed to archive block: $block, see $error
    block: "3NL33t6WEDcpZkABYXCPSdmH9KpvjQyEUyLPkWix6wsHhMkBZ8BP"
    error: "Request to <postgres://someuser:_@somewhere:5432/archive> failed: ERROR:  insert or update on table \"user_commands\" violates foreign key constraint \"user_commands_receiver_account_creation_fee_paid_fkey\"\nDETAIL:  Key (receiver_account_creation_fee_paid)=(1000000) is not present in table \"public_keys\".\n 
Query: \" 

UPDATE user_commands
                   SET status = $1
                    failure_reason = $2,
                    fee_payer_account_creation_fee_paid = $3,
                    receiver_account_creation_fee_paid = $4,
                    created_token = $5
                   WHERE id = $6
             \"."
deepthiskumar commented 3 years ago

@nerdvibe Could you share the version/commit id of the archive process you're running? It seems to be different than what's on master (3ef8663 latest release). The field receiver_account_creation_fee_paid was moved from user_commands table to blocks_user_commands. Also, the schema you've created (which is causing the error shown above) is not correct- receiver_account_creation_fee_paid is not a public key id and therefore cannot have the foreign key constraint. Could you share the issue you are seeing with the schema for encore https://raw.githubusercontent.com/MinaProtocol/mina/master/src/app/archive/create_schema.sql ?

aneesharaines commented 3 years ago

https://github.com/MinaProtocol/website/pull/151 has been merged. Going to close this, @nerdvibe please re-open if you are still having issues! thanks!