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

Next hard fork support #1081

Closed
14 tasks done
kderme opened this issue Mar 14, 2022 · 3 comments
Closed
14 tasks done

Next hard fork support #1081

kderme opened this issue Mar 14, 2022 · 3 comments

Comments

@kderme
Copy link
Contributor

kderme commented Mar 14, 2022

HF integration progress

  • Extract fields from Praos block header that are already extracted for Tpraos.
  • Fix epoch params and proposals values for Babbage.
  • Split Cardano.DbSync.Era.Shelley.Generic.Tx module into module per era. Make getters top level so that they can be reused for next epochs and resuce duplication.
  • Rewrite Alonzo.resolveRedeemers logic so that it can be reused for Babbage.
  • Support Babbage ignoring its new fields
  • Existing tests pass
  • Extend Generic.Tx fields for Babbage TxBody
  • Extract Babbage specific fields from TxBody/TxOut.
  • Extend schema to accomodate new fields
  • Translate tests from Alonzo to Babbage, leaving the new fields empty
  • Add tests which hard fork from one era to the other
  • Add tests for the new Babbage fields.
  • Sync Babbage testnet
  • Review

Expected changes (for qa, downstream components)

  • Schema changes:

Changes documented in schema table (search for New in v13 to see changes). Not all changes for version 13.0.0 are annotated, only the ones related to Babbage :
https://gist.github.com/kderme/cfd1f3f4d5147687ab8d2078cba5a69a

Schema changes from postgres raw commands:
vasil-hf.txt

  • Inline datums (CIP-32)

Outputs with an inline datum will have its hash in the tx_out.data_hash field and the datum will be included in the datum table. A new field is added tx_out.inline_datum_id which references inline datum.

  • Reference Scripts (CIP-33)

Reference scripts found in outputs will be inserted in the script table. Their hash will be used by redeemers or script outputs normally as any other script. A new field is added tx_out.reference_script_id which references script.

  • Collateral return (CIP-40)

A new table collateral_output will be introduced, with the same schema as tx_out. In case of a phase 2 failure of the tx, the tx_out table will contain the collateral_output instead of the normal outputs.

  • datum table split in 2 tables (fix of existing issue/misnomer)

A new table redeemer_data will be created with exactly the same schema as datum. It will contain the redeemer data and each entry will be referenced by at least one redeemer.redeemer_data_id (field will also be renamed from redeemer.datum). This is a fix of an existing problematic situation, since the current table datum contains 2 different things.

  • Reference inputs (CIP-31)

A new table tx_in_reference which has the same schema as tx_in. The table just shows that a tx has some reference inputs.

  • Fees

When there is a phase 2 failure, tx.fee needs to equal the difference of outputs and inputs, which will be the collateral.

  • Praos header

It seems the block table will not change, since it's not affected by the header blcock changes. We never extracted the block nonce for TPraos block anyway.

  • Params

  • epoch_param.entropy is renamed to epoch_param.extra_entropy (which is a more proper name anyway). For Babbage era it will always be Null.
  • epoch_param.decentralisation will be fixed to 0.
  • param_proposal.entropy and param_proposal.decentralisation are fixed to null.

How to details (for developers)

  • Inline datums (CIP-32)

Inline datums need to be extracted from such outputs, inserted in a new field in Generic.TxOut and insertDatum needs to be called for them.

  • Reference Scripts (CIP-33)

Reference scripts need to be extracted from such outputs, inserted in a new field in Generic.TxOut and insertScript needs to be called for them.

  • Reference inputs

  • findScriptHash needs to be extended to resolve reference inputs. It's not still clear in specs how this will work. We don't need to resolve reference inputs, because the scripts it references has already been inserted in the script table from a previous tx. Also the script hash is resolved with the already used way (through the redeemers ptrs) and not through the reference input

  • Collateral return (CIP-40)

Collateral outputs come from _collateralReturn field.

  • Fees

Fees can be taken from the txcoll field.

  • Praos header

We need to extract from praos block header the same data as we do from the tpraos header.

@kderme
Copy link
Contributor Author

kderme commented Mar 14, 2022

For unit tests db-sync can have similar tests to this IntersectMBO/cardano-ledger#2471
Existing tests focus on Alonzo era and will need to be migrated.
We will also need some tests that migrate from one era to another.

@erikd
Copy link
Contributor

erikd commented Mar 16, 2022

Is there not some way to make tests as era independent as possible?

@kderme
Copy link
Contributor Author

kderme commented Mar 16, 2022

Most things don't depend on the era. However the tx constructors in Cardano.Mock.Forging.Tx.Alonzo are coupled to a specific era.

One idea is to have a function Tx Alonzo -> Tx Babbage which tranlsates all txs to the new era in a default way, so we can pretty fast test it. Then we can add a new module Cardano.Mock.Forging.Tx.Babbage with similar constructors to add more era specific tests. After the hard fork we can slowly remove the Alonzo related tests.

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

No branches or pull requests

2 participants