Skip to content

feat(external-call): Add Canton protocol support for external calls#441

Draft
trusch wants to merge 7 commits intodigital-asset:mainfrom
zenith-network:external-call/04-canton-protocol
Draft

feat(external-call): Add Canton protocol support for external calls#441
trusch wants to merge 7 commits intodigital-asset:mainfrom
zenith-network:external-call/04-canton-protocol

Conversation

@trusch
Copy link
Copy Markdown

@trusch trusch commented Feb 6, 2026

Summary

This PR adds Canton-specific protocol support for external calls, including ActionDescription extensions, view participant data, and transaction hashing.

Requires #440

Changes

Proto Definition (participant_transaction.proto)

message ActionDescription {
  message ExerciseActionDescription {
    // ... existing fields ...
    repeated ExternalCallResult external_call_results = 12;
  }
}

ActionDescription (ActionDescription.scala)

Extended ExerciseActionDescription to include external call results:

final case class ExerciseActionDescription(
    inputContractId: LfContractId,
    templateId: LfTemplateId,
    choice: LfChoiceName,
    interfaceId: Option[LfInterfaceId],
    packagePreference: Set[LfPackageId],
    chosenValue: LfVersioned[Value],
    actors: Set[LfPartyId],
    byKey: Boolean,
    seed: LfHash,
    failed: Boolean,
    externalCallResults: Seq[ExternalCallResult]  // NEW
) extends ActionDescription

ViewParticipantData (ViewParticipantData.scala)

  • Updated to propagate external call results through view construction

NodeHashBuilder (NodeHashBuilder.scala)

Added external call results to exercise node hash:

private def addExerciseNode(node: Node.Exercise): this.type = {
  // ... existing fields ...
  withContext("External Call Results") {
    _.addIterator(node.externalCallResults.iterator, node.externalCallResults.size) {
      (builder, result) =>
        builder
          .addString(result.extensionId)
          .addString(result.functionId)
          .addBytes(result.config)
          .addBytes(result.input)
          .addBytes(result.output)
    }
  }
}

View Decomposition

External call results are aggregated at the view level:

  1. Each Exercise node in a view may have external calls
  2. Results from all Exercise nodes in the view core are collected
  3. ActionDescription stores the aggregated results
  4. ModelConformanceChecker validates during reinterpretation

Hashing

External call results are included in the transaction hash to ensure:

  • All participants compute the same hash
  • Tampering with results is detectable
  • Consensus requires matching results

Testing

  • ExampleTransactionFactory.scala - Factory for test transactions
  • WellFormedTransactionTest.scala - Well-formedness checks
  • NodeHashV1Test.scala - Hash computation tests

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 6, 2026

🎉 Thank you for your contribution! It appears you have not yet signed the Agreement DA Contributor License Agreement (CLA), which is required for your changes to be incorporated into an Open Source Software (OSS) project. Please kindly read the and reply on a new comment with the following text to agree:


I have hereby read the Digital Asset CLA and agree to its terms


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@trusch trusch force-pushed the external-call/04-canton-protocol branch 2 times, most recently from a7066d8 to 925741f Compare February 6, 2026 09:25
@trusch trusch marked this pull request as draft February 6, 2026 09:27
@trusch trusch force-pushed the external-call/04-canton-protocol branch from 925741f to ac964a2 Compare March 17, 2026 12:15
@trusch trusch force-pushed the external-call/04-canton-protocol branch from ac964a2 to a57f965 Compare March 26, 2026 12:58
trusch added 7 commits April 8, 2026 16:33
…eedback

- Proto: config_hash/input_hex/output_hex (string) -> config/input/output (bytes)
- Proto: Remove call_index field (repeated is already ordered)
- Scala: ExternalCallResult fields now use data.Bytes instead of String
- Test generators: Updated to generate binary data instead of hex strings
…r review

- Add EXTERNAL_CALL to LF test parser (ExprParser.scala)
- Add EXTERNAL_CALL to parser spec (ParsersSpec.scala)
- Add externalCall entry to Builtin_2.dev_.lf
- Add ResultNeedExternalCall to Engine results
- Implement SBExternalCall builtin in Speedy
- Add NeedExternalCall question type
- Update PartialTransaction to store external call results
- Update CostModel for external calls
…alls

- Encode/decode ExternalCallResult in TransactionCoder
- Update serialization version handling
- Extend ActionDescription with external call results
- Update participant_transaction.proto
- Update ViewParticipantData
- Update NodeHashBuilder for external call hashing
@trusch trusch force-pushed the external-call/04-canton-protocol branch from a57f965 to ccdfa1b Compare April 8, 2026 14:51
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.

1 participant