Skip to content

feat(external-call): Add proto definitions and data types#438

Open
trusch wants to merge 1 commit intodigital-asset:mainfrom
zenith-network:external-call/01-proto-types
Open

feat(external-call): Add proto definitions and data types#438
trusch wants to merge 1 commit intodigital-asset:mainfrom
zenith-network:external-call/01-proto-types

Conversation

@trusch
Copy link
Copy Markdown

@trusch trusch commented Feb 6, 2026

Summary

This PR adds the foundational proto definitions and Scala data types for the external call feature. It defines how external call results are represented in transactions and the language AST.

Changes

Proto Definitions

daml_lf2.proto

enum BuiltinFunction {
  // ... existing values ...
  BUILTIN_EXTERNAL_CALL = 74;
}

transaction.proto

message ExternalCallResult {
  string extension_id = 1;
  string function_id = 2;
  bytes config = 3;
  bytes input = 4;
  bytes output = 5;
}

message Node.Exercise {
  // ... existing fields ...
  repeated ExternalCallResult external_call_results = 18;
}

Scala Data Types

Node.scala

  • Added externalCallResults: Seq[ExternalCallResult] to Exercise node
  • Added ExternalCallResult case class

Ast.scala

  • Added BEExternalCall to BuiltinFunction sealed trait

LanguageFeatureGen.scala

  • Added feature flag for external calls

Transaction.scala

  • Updated transaction traversal to include external call results

SerializationVersion.scala

  • Added support for serializing external call results

Validation

Typing.scala

  • Added type checking for BEExternalCall builtin

Decoding

DecodeV2.scala

  • Added decoder for BUILTIN_EXTERNAL_CALL

Testing

  • TransactionSpec.scala - Transaction with external calls
  • ValueGenerators.scala - Generators for external call results

@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.

Copy link
Copy Markdown

@paulbrauner-da paulbrauner-da left a comment

Choose a reason for hiding this comment

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

Overall looks good but please address comments.

Comment on lines +129 to +131
string config_hash = 3; // Hash of the extension configuration for version validation
string input_hex = 4; // Hex-encoded input data sent to the extension
string output_hex = 5; // Hex-encoded output data returned by the extension
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

config_hash, input_hex, and output_hex should have type bytes, not string. The daml language doesn't support strings, that's why we use an hex encoding in LF. (We may introduce proper support for bytes in LF one day.) But in the transaction, it is a waste of space to represent them as strings.

string config_hash = 3; // Hash of the extension configuration for version validation
string input_hex = 4; // Hex-encoded input data sent to the extension
string output_hex = 5; // Hex-encoded output data returned by the extension
int32 call_index = 6; // Index of this call within the exercise node (for ordering)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This not needed because repeated is ordered.

Comment on lines +26 to +31
extensionId: String,
functionId: String,
configHash: String,
inputHex: String,
outputHex: String,
callIndex: Int,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same comment as in the protobuf definition: configHash, inputHex and outputHex should be daml.lf.data.Bytes. callIndex is not necessary.


//SECP256K1_VALIDATE_KEY = 4001; // REMAINS HERE TEMPORARELY TO PARSE CHECKED IN DARS

EXTERNAL_CALL = 5001; // *Available in versions >= 2.dev*
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LF (the language that the daml compiler produces and that the engine consumes) is separate from the language of the transactions produced by the engine, even if they tend to refer to them as "LF transactions". For that reason, we tend to introduce LF changes and transaction changes in separate PRs. I suggest you split this PR into a transaction one and an LF one.

When you modify LF you also need to:

  • Modify LF syntax test parser in com.digitalasset.daml.lf.testing.parser and its spec.
  • Add a trivial test for typing in TypingSpec (which uses the parser above)
  • Add it to Builtin_2.dev_.lf

…l calls

- Add EXTERNAL_CALL builtin to daml_lf2.proto
- Add ExternalCallResult to transaction.proto
- Extend Node.scala with externalCallResults field
- Update Ast.scala with BEExternalCall
- Add language feature flag
@trusch trusch force-pushed the external-call/01-proto-types branch from 34dd477 to 9c23c57 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.

2 participants