Daml 2.10 introduced support for Daml LF 1.17 along with the support for Smart Contract Upgrades (SCU).
Daml LF is the core, low-level representation of Daml code that results from compilation into a .dar file (similar to JVM bytecode for Java). It is primarily used internally for executing smart contracts on various ledgers, for communication via the Ledger API, and as an intermediate format for generating language-specific bindings that allow external applications to interact with Daml models. While you most likely won’t directly interact with Daml LF, understanding its type system becomes important when directly using the Ledger API to construct and interpret data exchanged with the Daml ledger. For example, with Daml 2.10, packages built with LF 1.17 now need to meet certain constraints.
If you have a package containing both templates and interfaces, and attempt to build it using LF 1.17 in Daml 2.10, you may encounter the following error:
This package defines both interfaces and templates. This may make this package and its dependents not upgradeable.
It is recommended that interfaces are defined in their own package separate from their implementations.
Downgrade this error to a warning with -Wupgrade-interfaces
Disable this error entirely with -Wno-upgrade-interfaces
There are a few ways to resolve this error or bypass it. Here are your options:
1) Suppress the error and continue building the package using the -Wno-upgrade-interfaces flag. However there are some disadvantages of continuing to use LF 1.17+ while disabling the error.
The main concern is that co-locating interfaces and templates in a single package blocks you from performing smart contract upgrades (SCU) in future releases. Thus, you risk having “packages and their dependents being not upgradeable,” and you may encounter errors later if you bypass this restriction. (See SCU documentation) Attempting to upgrade a package that has interfaces and templates together can lead to type checking problems. (See Daml 2.10 Release Notes)
2) Downgrade to the lower version of Daml LF LF 1.15 in Daml 2.10. However this will forgo the ability to upgrade using SCU.
If you need the newer “smart contract upgrades (SCU)” feature, you must use LF 1.17 or greater. The documentation states “Smart contract upgrades were only enabled in LF 1.17. This means that packages of previous LF versions, namely <= LF 1.15, are not upgradeable.” . Therefore, using LF 1.15 implies foregoing the ability to upgrade using SCU. Keep in mind, you can still upgrade your contracts using traditional upgrade methods. The upside
3) Make your package compatible with LF 1.17+. This is the recommended long term solution.
The best practice is to separate interface definitions (and exceptions) from your template package. This allows smooth upgrading of templates in new package versions under LF 1.17. By splitting interfaces (and exceptions) into a dedicated helper package, you enable each new package version of the templates to continue referencing those interfaces without encountering upgrade conflicts. See SCU documentation on how to make these changes.
This will put you in a position to more easily migrate to Daml 3 when it becomes available.