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

MA Policies Whitelist #1610

Closed
wants to merge 4 commits into from
Closed

MA Policies Whitelist #1610

wants to merge 4 commits into from

Conversation

Cmdv
Copy link
Contributor

@Cmdv Cmdv commented Jan 22, 2024

Description

This is the first part of #1600 adding a whitelist for MA Policies and renaming:
KeepMetadataNames -> WhitelistMetadataNames

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 on version 0.10.1.0 (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.

@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch from e7c17e7 to 33f2272 Compare January 24, 2024 08:45
sgillespie
sgillespie previously approved these changes Jan 24, 2024
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch 3 times, most recently from 66a50cf to f5c2028 Compare February 1, 2024 16:02
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch 3 times, most recently from 85527d3 to 44b6d0b Compare February 12, 2024 11:54
cardano-db-sync/src/Cardano/DbSync/Config.hs Outdated Show resolved Hide resolved
cardano-db-sync/src/Cardano/DbSync/Config.hs Outdated Show resolved Hide resolved
cardano-db-sync/src/Cardano/DbSync/Config.hs Outdated Show resolved Hide resolved
cardano-db-sync/src/Cardano/DbSync/Config.hs Outdated Show resolved Hide resolved
cardano-db-sync/src/Cardano/DbSync/Config.hs Outdated Show resolved Hide resolved
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch from 21d0f5c to af8c468 Compare February 14, 2024 15:29
plutusMultiAssetWhitelistCheck :: SyncEnv -> [Generic.TxOut] -> Bool
plutusMultiAssetWhitelistCheck syncEnv txOuts =
plutusMaybeCheck txOuts && (plutusWhitelistCheck syncEnv txOuts || multiAssetWhitelistCheck syncEnv txOuts)
plutusMaybeCheck txOuts || (plutusWhitelistCheck syncEnv txOuts || multiAssetWhitelistCheck syncEnv txOuts)
Copy link
Contributor

Choose a reason for hiding this comment

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

plutusWhitelistCheck is called in plutusMaybeCheck, so why is it also called here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't see plutusWhitelistCheck inside plutusMaybeCheck, am I understanding you right?

Copy link
Contributor

@kderme kderme Feb 15, 2024

Choose a reason for hiding this comment

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

Oh sorry I got confused by indentation.

Actually I don't see what's the purpose of plutusMaybeCheck. It may return False even with PlutusEnable, which should never happen. plutusWhitelistCheck already does the necessary work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The was my original comment

-- TODO: cmdv: unsure if this is correct because if plutusMaybeCheck fails then no multiasset whitelist is not checked

I was trying to make what we spoke about and push the checks as far up the chain and I may have miss understood what you meant and that's why I left this comment there about the plutusMaybeCheck. It's there as a check so you don't do any whitelist checks if there isn't any txOutScript or txOutAddress and that's what it was an && not an || so this is:

if plutusMaybeCheck txOuts
    then (plutusWhitelistCheck syncEnv txOuts || multiAssetWhitelistCheck syncEnv txOuts)
    else False

which is essentially bellow as it will return false straight away if plutusMaybeCheck txOuts if false:

plutusMaybeCheck txOuts && (plutusWhitelistCheck syncEnv txOuts || multiAssetWhitelistCheck syncEnv txOuts)

Copy link
Contributor

Choose a reason for hiding this comment

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

I still can't fully understand what does plutusMaybeCheck check, since all necessary checks are done in plutusWhitelistCheck. Using or instead of and here will simply give True in more cases than we want to.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove plutusMaybeCheck, unless I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was just to save doing big elem checks if they're not needed. But it's all good we can just do it inside the whitelist checks.

@Cmdv Cmdv requested a review from kderme February 15, 2024 10:34
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch from af8c468 to 6a1a323 Compare February 15, 2024 12:55
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch 2 times, most recently from 6dc9215 to 65c2fe2 Compare February 20, 2024 11:42
@Cmdv Cmdv force-pushed the 1600-1-whitelist-MA-policies branch from 65c2fe2 to 41a1fce Compare February 22, 2024 09:50
@Cmdv
Copy link
Contributor Author

Cmdv commented Mar 6, 2024

closing this PR as it's been superseded by #1644

@Cmdv Cmdv closed this Mar 6, 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.

None yet

3 participants