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

Change a representation of witnesses in transaction's certificates to an ordered map where a certificate is the key #734

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Jan 22, 2025

Changelog

- description: |
    Change a representation of witnesses in transaction's certificates to an ordered map where a certificate is the key.
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
   - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
   - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

This PR changes representation of transaction certificates' witnesses from a list of with stake credentials to a map.

The issue is that there's a relationship Certificate *--1 StakeCredential which makes the assigning of witnesses impossible in the cases where we have more than one certificate with the same stake credential. This then breaks witnesses indexing.

See related PRs:

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@carbolymer carbolymer changed the title Use correct representation of witnesses in transaction's certificates Change a representation of witnesses in transaction's certificates to an ordered map where a certificate is the key Jan 24, 2025
@carbolymer carbolymer force-pushed the mgalazyn/fix/correct-certificates-representation branch 2 times, most recently from 090aa57 to 53c3b35 Compare January 24, 2025 14:24
@carbolymer carbolymer marked this pull request as ready for review January 24, 2025 14:26
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Confirm we aren't reintroducing a bug and I'll be happy to approve.

, Either
(TxBodyErrorAutoBalance era)
( BuildTxWith
BuildTx
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes my eyes bleed (I know it's not your fault).

(Certificate era)
( BuildTxWith
build
(Maybe (StakeCredential, Witness WitCtxStake era))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would seek confirmation that #456 is not an issue with this change. I suspect this needs to be a list still.

Copy link
Contributor Author

@carbolymer carbolymer Jan 27, 2025

Choose a reason for hiding this comment

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

I suspect this needs to be a list still.

I don't see a reason for that.

I've ran regression tests here: https://github.com/IntersectMBO/cardano-node-tests/actions/runs/12928366127
cardano-testnet tests pass: IntersectMBO/cardano-node#6082

Is that enough?

@carbolymer carbolymer requested a review from Jimbo4350 January 27, 2025 17:58
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Nice work. Takes a little while to page the context back into my head. One minor comment.

mWit
( cert
, pure $
(,wit) <$> selectStakeCredentialWitness cert
Copy link
Contributor

Choose a reason for hiding this comment

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

To be aware of.

In the ledger repo


-- For both of the functions `getScriptWitnessConwayTxCert` and
-- `getVKeyWitnessConwayTxCert` we preserve the old behavior of not requiring a witness
-- for staking credential registration, but only during the transitional period of Conway
-- era and only for staking credential registration certificates without a deposit. Future
-- eras will require a witness for registration certificates, because the one without a
-- deposit will be removed.

Eventually we should be able to remove the Maybe in:

OMap
        (Certificate era)
        ( BuildTxWith
            build
            (Maybe (StakeCredential, Witness WitCtxStake era))

Can you add a comment to the type definition pointing this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@carbolymer carbolymer force-pushed the mgalazyn/fix/correct-certificates-representation branch from 3f2a381 to 4b1fc5e Compare January 29, 2025 14:32
@carbolymer carbolymer merged commit dd23475 into master Jan 29, 2025
14 of 18 checks passed
@carbolymer carbolymer deleted the mgalazyn/fix/correct-certificates-representation branch January 29, 2025 14:32
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.

2 participants