Skip to content

Commit

Permalink
Extend reinterpret to take inputContract as input
Browse files Browse the repository at this point in the history
  • Loading branch information
remyhaemmerle-da committed Sep 25, 2024
1 parent a3d29dd commit 90e6e25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Engine(val config: EngineConfig) {
for {
pkgResolution <- preprocessor.buildPackageResolution(packageMap, packagePreference)
processedCmds <- preprocessor.preprocessApiCommands(pkgResolution, cmds.commands)
processedDiscs <- preprocessor.preprocessDisclosedContracts(disclosures)
processedDiscs <- preprocessor.preprocessInputContracts(disclosures)
result <-
interpretCommands(
validating = false,
Expand Down Expand Up @@ -189,6 +189,7 @@ class Engine(val config: EngineConfig) {
def reinterpret(
submitters: Set[Party],
command: ReplayCommand,
inputContracts: ImmArray[FatContractInstance] = ImmArray.empty,
nodeSeed: Option[crypto.Hash],
submissionTime: Time.Timestamp,
ledgerEffectiveTime: Time.Timestamp,
Expand All @@ -197,12 +198,15 @@ class Engine(val config: EngineConfig) {
)(implicit loggingContext: LoggingContext): Result[(SubmittedTransaction, Tx.Metadata)] =
for {
speedyCommand <- preprocessor.preprocessReplayCommand(command)
processedContracts <- preprocessor.preprocessInputContracts(inputContracts)
sexpr <- runCompilerSafely(
NameOf.qualifiedNameOfCurrentFunc,
compiledPackages.compiler.unsafeCompileForReinterpretation(speedyCommand),
compiledPackages.compiler.unsafeCompile(ImmArray(speedyCommand), processedContracts),
)
// reinterpret is never used for submission, only for validation.
result <- interpretExpression(
// TODO https://github.com/digital-asset/daml/issues/19539
// Once canton uses the input contracts prevent the machine to query contract/key when validation is on
validating = true,
submitters = submitters,
readAs = Set.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private[engine] final class Preprocessor(
commandPreprocessor.unsafePreprocessApiCommands(pkgResolution, cmds)
}

def preprocessDisclosedContracts(
def preprocessInputContracts(
discs: data.ImmArray[FatContractInstance]
): Result[ImmArray[speedy.DisclosedContract]] =
safelyRun(pullPackage(discs.toSeq.view.map(_.templateId))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class PreprocessorSpec(majorLanguageVersion: LanguageMajorVersion)
val contract2 =
buildDisclosedContract(contractId, templateId = withKeyTmplId, keyHash = Some(keyHash))
val finalResult = preprocessor
.preprocessDisclosedContracts(ImmArray(contract1, contract2))
.preprocessInputContracts(ImmArray(contract1, contract2))
.consume(pkgs = pkgs)

inside(finalResult) {
Expand Down

0 comments on commit 90e6e25

Please sign in to comment.