-
Notifications
You must be signed in to change notification settings - Fork 205
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
LF: Factorize the logic for Ast lookup #9871
Conversation
7dac774
to
e66cb43
Compare
e66cb43
to
9ff0a27
Compare
CHANGELOG_BEGIN CHANGELOG_END
9ff0a27
to
e3e21f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thank you!
daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala
Outdated
Show resolved
Hide resolved
daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala
Outdated
Show resolved
Hide resolved
daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala
Outdated
Show resolved
Hide resolved
daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala
Outdated
Show resolved
Hide resolved
daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala
Outdated
Show resolved
Hide resolved
@@ -162,7 +162,7 @@ object Converter { | |||
} | |||
|
|||
private def fromAnyChoice( | |||
lookupChoice: (Identifier, Name) => Either[String, TemplateChoiceSignature], | |||
lookupChoice: (Identifier, Name) => Either[String, GenTemplateChoice[_]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What’s up with this? Why do we need more than the signature now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually cannot do more with GenTemplateChoice[_]
that you can do with TemplateChoiceSignature = TemplateChoice[Unit]
.
It is a bit annoying here, but the change is due to Interface
returning GenXxxx[_]
and not XxxSignature
.
There is basically two reason for that:
- Interface does not have to work with Signature it is just a wrapper around
GenPackage[_]
, so we can use it with package where value are substituted with Unit or not. (It is more flexible like). - The only place where PackageSignature is very usefull is inside CompiledPackageto be sure we do not store the values.
- Even if we change the type of Interface to take PackageSignature instead of GenPackage[_] we still have some issue with pattern matching and type erasure in to return GenXxxx[Unit] in some of the lookup (e.g.
lookupValue
).
I am considering one of the two changes (for an upcomming PR)
- remove all The
XxxSignature
type aliases (exceptionPackageSignature
) which are now a pretty useless - redefined all the
XxxSignature
to be alias ofGenXxx[_]
and defined a use directlyGenPackage[Unit]
inCompiledPackage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not really worried about being able to do more. What I’m a bit worried about is that we end up leaking memory. Part of the reason for the signature changes was that things like triggers and daml script really should not keep the AST in memory and relying on signatures made that pretty explicit. Now, it’s very unclear to me if that is still working correctly and that it will keep working.
If we need Interface
in both cases, maybe it’s worth adding a type parameter to it so we can enforce that we use Unit
in some places and don’t leak and _
where we don’t care or Value
where we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, I don’t think this is merge-blocking but at least something to think about and potentially address later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making Interface
generic is quite a pain.
So I try again to make it use PackageSignature
and everything went smooth this time, i.e. I did not have problem of type erasure in this case.
7b6818e
This definitively prevent the usage of lookup in the ScenarioLoader
as explained below but I think it not worthwhile to generalize Interface
for only one use case.
daml-script/runner/src/main/scala/com/digitalasset/daml/lf/engine/script/ScriptF.scala
Show resolved
Hide resolved
case Right(x) => | ||
List((Ref.Identifier(packageId, scenarioQualName) -> x)) | ||
case Left(_) => List() | ||
pkg.modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we no longer using one of the lookup functions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we need the value attached to the definition, Interface returns GenDValue[_]
while here we need GenDValue[Expr]
.
It is actually the only place where we do this kind of lookup, so I am not sure it worthwhile to generalize Interface
for this use case, specially because we do not use the error.
daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala
Show resolved
Hide resolved
daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Speedy.scala
Show resolved
Hide resolved
@@ -82,6 +82,7 @@ conformance_test( | |||
",ParticipantPruningIT" + # see "conformance-test-participant-pruning" below | |||
",ConfigManagementServiceIT,LedgerConfigurationServiceIT" + # dynamic config management not supported by Canton | |||
",ClosedWorldIT" + # Canton currently fails this test with a different error (missing namespace in "unallocated" party id) | |||
",CommandServiceIT,CommandSubmissionCompletionI" + # FIXME: canton should be updated with last SDK to produce proper output message for those tests to pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
",CommandServiceIT,CommandSubmissionCompletionI" + # FIXME: canton should be updated with last SDK to produce proper output message for those tests to pass | |
",CommandServiceIT,CommandSubmissionCompletionIT" + # FIXME: canton should be updated with last SDK to produce proper output message for those tests to pass |
you will also need to fix the compat tests
023182f
to
a81eab3
Compare
{ | ||
"start": "1.0.0", | ||
"platform_ranges": [ | ||
{ | ||
"end": "0.0.0", | ||
"exclusions": [ | ||
"CommandServiceIT:CSCreateAndBadExerciseChoice", | ||
"CommandSubmissionCompletionIT:CSCRefuseBadChoice", | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
"end": "1.14.0-snapshot.20210602.7086.0.f36f556b", | ||
"platform_ranges": [ | ||
{ | ||
"start": "0.0.0", | ||
"exclusions": [ | ||
"CommandServiceIT:CSCreateAndBadExerciseChoice", | ||
"CommandSubmissionCompletionIT:CSCRefuseBadChoice", | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
"start": "0.0.0", | ||
"platform_ranges": [ | ||
{ | ||
"end": "1.14.0-snapshot.20210602.7086.0.f36f556b", | ||
"exclusions": [ | ||
"CommandServiceIT:CSCreateAndBadExerciseChoice", | ||
"CommandSubmissionCompletionIT:CSCRefuseBadChoice", | ||
], | ||
}, | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cocreature Does this make sens ?
@@ -82,6 +82,7 @@ conformance_test( | |||
",ParticipantPruningIT" + # see "conformance-test-participant-pruning" below | |||
",ConfigManagementServiceIT,LedgerConfigurationServiceIT" + # dynamic config management not supported by Canton | |||
",ClosedWorldIT" + # Canton currently fails this test with a different error (missing namespace in "unallocated" party id) | |||
",CommandServiceIT:CSCreateAndBadExerciseChoice,CommandSubmissionCompletionIT:CSCRefuseBadChoice" + # FIXME: canton should be updated with last SDK to produce proper output message for those tests to pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliverse-da Fyi, I inactivated 2 tests. This is due to a mismatch of the error messages because an change in the engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should reactivate once you have updated canton with the next SDK.
{ | ||
"start": "1.0.0", | ||
"platform_ranges": [ | ||
{ | ||
"end": "0.0.0", | ||
"exclusions": [ | ||
"CommandServiceIT:CSCreateAndBadExerciseChoice", | ||
"CommandSubmissionCompletionIT:CSCRefuseBadChoice", | ||
], | ||
}, | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What’s up with this? This is excluding literally all versions.
Co-authored-by: Moritz Kiefer <[email protected]>
CHANGELOG_BEGIN CHANGELOG_END
This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging. @garyverhaegen-da is in charge of this release. Commit log: ``` 3cb8d5c Deprecate use of divulged contracts (#9930) e9a2e2e Allow two different time formats as input for the metrics reporting interval (#9926) 1dc8472 Fix variable name (#9927) 4037b1c Add metrics to the http json service (#9923) bd26c43 LF: fix TransactionCoderSpec (#9922) 69ef624 Fix flaky InstrumentedSourceSpec test (#9921) cbcec32 LF: clean up the remaining Exception TODOs (#9913) 5374209 Add dependency proto3-suite for Setup.hs (#9917) c77324d skip fix_bazel_cache on forks (#9920) ddf93fc Address TODOs in JdbcIndexer (#9911) a0d3e80 Add missing telemetryContext instances in the ledger-api-client's Ctx (#9916) 1e009b4 Upgrade canton to 0.25.0-snapshot supporting lf-1.13 and enable/fix tests (#9915) db14536 LF: Freeze archive proto for LF 1.14 (#9912) 15f9dfb update compat versions for 1.14.0-snapshot.20210602.7086.0.f36f556b (#9900) b4247c1 [In-memory fan-out] BuffersUpdater implementation (#9858) 7e733c3 DPP-390 remove appendonly todos (#9910) 512f1fd LF: Preview version of LF 1.14 (#9906) 2da94c3 Add warning about using divulged contracts in pruning doc (#9883) 3dee3d0 LF: Fix encoder for Exception (#9904) b22c046 ledger-api-test-tool: Only wait for parties on participants under test. (#9903) b8c02d6 Bump perf test for for #9871 (#9902) 4660e57 Fix typoed participant name in ExceptionsIT (#9901) 316069d Postgres batching refinements (#9898) 7bc925e LF: Factorize the logic for AST lookup (#9871) 2fa250f DPP-387 Remove migration todos (#9896) 65f9395 Try to fix windows skipping again (#9893) 850c731 Include PackageMetadata in LF interface (#9892) 41266c3 Fix the formatting on the LF spec. (#9889) dc79830 DPP-393 Enable sandbox tests for the append-only schema (#9876) 3c83b77 Parallel Ingestion renames (#9894) 6e48034 Dpp 392 todo cleanup postgre batch (#9875) 08ed7b6 rotate release duty after 1.14.0-snapshot.20210601.7081.0.7d716e6d (#9878) 081c54b Revert "Try to unflake JSON API failure tests (#9855)" (#9887) df0f3ff maybe fix deleted release tags (#9891) 4b020dd Release ledger-api-bench-tool (#9890) d801914 Release new snapshot (#9885) 4a4dde0 Implemented JdbcLedgerDaoTransactionLogUpdatesSpec (#9813) ``` Changelog: ``` - [Ledger API] Use of divulged contracts in later transactions is deprecated. Divulged contracts were already incompatible with pruning. We are working on features to handle the cases currently covered by divulgence. - for applications which support the --metrics-reporter-interval cli option, these now support both the java and scala duration string format (e.g. PT1M30S and 1.5min) Small fixes to the doc [HTTP/JSON API] - metrics reporting can now be chosen via the command line option --metrics-reporter (currently hidden), valid options are console, csv://, graphite:// and prometheus:// - metrics reporting interval can also now be chosen via a command line option --metrics-reporting-interval (currently hidden) [ledger api] Add warning about incompatibility between pruning and divulged contracts to pruning docs. ``` CHANGELOG_BEGIN CHANGELOG_END
This PR has been created by a script, which is not very smart and does not have all the context. Please do double-check that the version prefix is correct before merging. @garyverhaegen-da is in charge of this release. Commit log: ``` 3cb8d5c Deprecate use of divulged contracts (#9930) e9a2e2e Allow two different time formats as input for the metrics reporting interval (#9926) 1dc8472 Fix variable name (#9927) 4037b1c Add metrics to the http json service (#9923) bd26c43 LF: fix TransactionCoderSpec (#9922) 69ef624 Fix flaky InstrumentedSourceSpec test (#9921) cbcec32 LF: clean up the remaining Exception TODOs (#9913) 5374209 Add dependency proto3-suite for Setup.hs (#9917) c77324d skip fix_bazel_cache on forks (#9920) ddf93fc Address TODOs in JdbcIndexer (#9911) a0d3e80 Add missing telemetryContext instances in the ledger-api-client's Ctx (#9916) 1e009b4 Upgrade canton to 0.25.0-snapshot supporting lf-1.13 and enable/fix tests (#9915) db14536 LF: Freeze archive proto for LF 1.14 (#9912) 15f9dfb update compat versions for 1.14.0-snapshot.20210602.7086.0.f36f556b (#9900) b4247c1 [In-memory fan-out] BuffersUpdater implementation (#9858) 7e733c3 DPP-390 remove appendonly todos (#9910) 512f1fd LF: Preview version of LF 1.14 (#9906) 2da94c3 Add warning about using divulged contracts in pruning doc (#9883) 3dee3d0 LF: Fix encoder for Exception (#9904) b22c046 ledger-api-test-tool: Only wait for parties on participants under test. (#9903) b8c02d6 Bump perf test for for #9871 (#9902) 4660e57 Fix typoed participant name in ExceptionsIT (#9901) 316069d Postgres batching refinements (#9898) 7bc925e LF: Factorize the logic for AST lookup (#9871) 2fa250f DPP-387 Remove migration todos (#9896) 65f9395 Try to fix windows skipping again (#9893) 850c731 Include PackageMetadata in LF interface (#9892) 41266c3 Fix the formatting on the LF spec. (#9889) dc79830 DPP-393 Enable sandbox tests for the append-only schema (#9876) 3c83b77 Parallel Ingestion renames (#9894) 6e48034 Dpp 392 todo cleanup postgre batch (#9875) 08ed7b6 rotate release duty after 1.14.0-snapshot.20210601.7081.0.7d716e6d (#9878) 081c54b Revert "Try to unflake JSON API failure tests (#9855)" (#9887) df0f3ff maybe fix deleted release tags (#9891) 4b020dd Release ledger-api-bench-tool (#9890) d801914 Release new snapshot (#9885) 4a4dde0 Implemented JdbcLedgerDaoTransactionLogUpdatesSpec (#9813) ``` Changelog: ``` - [Ledger API] Use of divulged contracts in later transactions is deprecated. Divulged contracts were already incompatible with pruning. We are working on features to handle the cases currently covered by divulgence. - for applications which support the --metrics-reporter-interval cli option, these now support both the java and scala duration string format (e.g. PT1M30S and 1.5min) Small fixes to the doc [HTTP/JSON API] - metrics reporting can now be chosen via the command line option --metrics-reporter (currently hidden), valid options are console, csv://, graphite:// and prometheus:// - metrics reporting interval can also now be chosen via a command line option --metrics-reporting-interval (currently hidden) [ledger api] Add warning about incompatibility between pruning and divulged contracts to pruning docs. ``` CHANGELOG_BEGIN CHANGELOG_END Co-authored-by: Azure Pipelines DAML Build <[email protected]>
I strongly advice to review in the following order:
language
packageCompiledPackages
,PureCompiledPackages
,ConcurrentCompiledPackages
part of #9974
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.