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

Introduce a separate Address table #1396

Closed
wants to merge 1 commit into from
Closed

Conversation

kderme
Copy link
Contributor

@kderme kderme commented Apr 25, 2023

Description

Fixes #1333

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with fourmolu (which can be run with scripts/fourmolize.sh
  • Self-reviewed the diff

Migrations

  • The pr causes a breaking change of type a,b or c
  • If there is a breaking change, the pr includes a database migration and/or a fix process for old values, so that upgrade is possible
  • Resyncing and running the migrations provided will result in the same database semantically

If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.

EXECUTE 'ALTER TABLE "tx_out" DROP COLUMN "address_raw"' ;
EXECUTE 'ALTER TABLE "tx_out" DROP COLUMN "address_has_script"' ;
EXECUTE 'ALTER TABLE "tx_out" DROP COLUMN "payment_cred"' ;
EXECUTE 'CREATe TABLE "address"("id" SERIAL8 PRIMARY KEY UNIQUE,"address" VARCHAR NOT NULL,"address_raw" BYTEA NOT NULL,"has_script" BOOLEAN NOT NULL,"payment_cred" hash28type NULL)' ;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this table have an additional field inserted (stake_address_id)? Useful to filter used addresses contributing towards a stake.
Absence of this field would require querying tx_out table and then doing a [distinct] fetch on address_id together

@infnada
Copy link

infnada commented Jun 22, 2023

Is this and/or should this MR also take into account collateral_tx_out?

Also, i don't know if it's possible to have an address inside collateral_tx_out without having it in tx_out.

Not really familiar with collaterals, i would say it is possible since a collateral output can be sent to any account (assumption), and at the same time a collateral must have a tx_out where to use and reference it for "a future tx_in" in the chain, so i'm a little confused :). If that's the case and we don't handle collateral_tx_out we will end up with an address table not really containing all the addresses.

@rdlrt rdlrt mentioned this pull request Feb 2, 2024
@rdlrt
Copy link

rdlrt commented Apr 16, 2024

@kderme - are there plans for this PR to progress to an upcoming release? would be nice to get an insight around any blockers for this one

*The updated size difference with tx_out on mainnet is 89GB vs [37GB for tx_out + 14GB for new address table]GB respectively for structure below (where address_id is against an index for seperate table where address, address_has_script, payment_cred were moved in DB leaving leftover indexes as-is):

id,tx_id,index,address,address_has_script,payment_cred,stake_address_id,value,data_hash,inline_datum_id,reference_script_id,consumed_by_tx_id

vs

id,tx_id,index,address_id,stake_address_id,value,data_hash,inline_datum_id,reference_script_id,consumed_by_tx_id

@kderme
Copy link
Contributor Author

kderme commented Oct 2, 2024

Done here #1820

@kderme kderme closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split out addresses table from tx_out
3 participants