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

Fix: make entity field presence an error #297

Merged
merged 1 commit into from
Jan 8, 2025
Merged

Conversation

jmcardon
Copy link
Member

@jmcardon jmcardon commented Jan 7, 2025

In pact 4, defpact steps have a "private entity" optional expression parameter which currently we do not support in pact 5.

Regular defpact steps take 1 argument, if they have a rollback they take 2 args.
There's an "optional" entity argument which, if present, basically causes the defpact to fail 100% of the time.

pact> (module m g (defcap g () true) (defpact f () (step 1 2) (step 1 2)))
"Loaded module m, hash P4sRCOphLqh1gv6h2Vw_WBVDCfRg6iDQJXLvgn0W0QY"
pact> (f)
<interactive>:0:51:Error: applyPact: step entity must be String value
 at <interactive>:0:0: (f)
pact> (module m g (defcap g () true) (defpact f () (step "bob" 2) (step "bob" 2)))
"Loaded module m, hash AJ6muDjYGH0s3GOcfEso3_2wgVM45MIXknuSi9OKqpo"
pact> (f)
<interactive>:0:45:Error: applyPact: private step executed against non-private environment
 at <interactive>:0:0: (f)

Pact 5 was basically simply ignoring the private entity parameter, but parity replay makes it clear that since people made the mistake of deploying contracts where this field is present, it should be a static error. This PR turns this field's presence into an error in two ways:

  • If it is found at deploy time (in pact 5), we fail with EntityNotAllowedInDefPact and we do not allow the module to be deployed.
  • If It is found at runtime (as will be generally the case with legacy deployed modules), we fail with EntityNotAllowedInDefPact when attempting to execute a step with an entity.

PR checklist:

  • Test coverage for the proposed changes
  • PR description contains example output from repl interaction or a snippet from unit test output
  • (If Relevant) Documentation has been (manually) updated at https://docs.kadena.io/pact

Additionally, please justify why you should or should not do the following:

  • Benchmark regressions
  • N/A
  • Confirm replay/back compat (Ignore until core release)
  • (For Kadena engineers) Run integration-tests against a Chainweb built with this version of Pact (Ignore until core release)

@@ -222,6 +222,8 @@ data Step name ty builtin info
| StepWithRollback
(Term name ty builtin info)
(Term name ty builtin info)
| LegacyStepWithEntity (Term name ty builtin info) (Term name ty builtin info)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: These are separate cases for a few reasons:

  • We don't want to change hashes this close to release, and having new ADT cases ensures our CBOR repr doesn't have to.
  • It makes it more explicit to handle cases in functions like hasRollback and ordinaryDefPactStepExec

@jmcardon jmcardon force-pushed the jose/entity-fields branch from 708e71d to 1f9392d Compare January 7, 2025 22:03
Copy link
Member

@emilypi emilypi left a comment

Choose a reason for hiding this comment

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

This was a vestigial feature of the private blockchain we no longer support. +1 from me.

@jmcardon jmcardon merged commit fa68835 into master Jan 8, 2025
10 checks passed
@jmcardon jmcardon deleted the jose/entity-fields branch January 8, 2025 16:38
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.

3 participants