-
Notifications
You must be signed in to change notification settings - Fork 238
add external_call primitive. #22408
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
base: main
Are you sure you want to change the base?
add external_call primitive. #22408
Conversation
|
Hello, thank you for your contribution! This change touches a critical component of Canton and as such must be carefully examined through multiple perspectives: determinism, liveness, security, testing, etc. This is why we would kindly ask that you capture all of these aspects in a design doc that we can then comment on and over which we can iterate together. To give you a sense of why such a document is needed, we’ve compiled below a starter list of potential issues or points to clarify that come to mind. More of them will certainly arise as you iterate on the design. We would like to share with you a design doc template that you can use as a starting point. This template is currently a google doc that we cannot easily make world readable. We will convert it into a markdown document or issue template in due time. In the meantime, would you mind sharing a google address we could share the google doc with?
|
|
@paulbrauner-da Thank you for your detailed feedback, I'm happy to work on a design doc together for this. You can use [email protected] for sharing the doc. I'm also in the cf-global-syncronizer-appdev slack channel if you want to reach out directly. I'm happy to address all issues :) |
|
Thanks @trusch, I have shared a read-only copy of the template with you. |
Add External Call Functionality to DAML
Summary
This PR introduces a new builtin primitive
BEExternalCallthat enables DAML contracts to make deterministic HTTP calls to external services. This feature allows integration with external systems (oracles, price feeds, computation services) while maintaining DAML's deterministic execution guarantees required for distributed ledger consensus.This is part of the implementation of CIP-0091.
Key Features
1. New
DA.ExternalModuleexternalCall: High-level function for making external HTTP callsfunctionId,configHex, andinputHexparametersisHexandisBytesHex: Validation helpers for hex-encoded dataBytesHex: Type alias for hex-encoded byte strings2. Production-Ready HTTP Client (
ExternalHttpClient)3. Deterministic Execution Model
configHexparameter ensures all participants use the same service version4. Cost Model Integration
DAML_EXTERNAL_CALL_COST_<FUNCTION_ID>(env) ordaml.external.call.cost.<functionId>(sys prop)5. Comprehensive Error Handling
Technical Changes
Language & Compiler Changes
BEExternalCallbuiltin to DAML-LF AST and proto definitionsRuntime Changes
SBExternalCallin Speedy interpreterExternalHttpClientwith production-grade HTTP client implementationDocumentation
DA-External.rstTesting
ExternalCall.damlConfiguration
The external call functionality can be configured via environment variables or system properties:
DAML_EXTERNAL_CALL_ENDPOINTdaml.external.call.endpointhttp://127.0.0.1:1606/api/v1/external-callDAML_EXTERNAL_CALL_JWT_TOKENdaml.external.call.jwt.tokenDAML_EXTERNAL_CALL_JWT_TOKEN_FILEdaml.external.call.jwt.token.fileDAML_EXTERNAL_CALL_TLS_INSECUREdaml.external.call.tls.insecurefalseDAML_EXTERNAL_CALL_CONNECT_TIMEOUT_MSdaml.external.call.connect.timeout.ms500DAML_EXTERNAL_CALL_REQUEST_TIMEOUT_MSdaml.external.call.request.timeout.ms8000DAML_EXTERNAL_CALL_MAX_TOTAL_TIMEOUT_MSdaml.external.call.max.total.timeout.ms25000DAML_EXTERNAL_CALL_MAX_RETRIESdaml.external.call.max.retries3DAML_EXTERNAL_CALL_COST_<FUNCTION_ID>daml.external.call.cost.<functionId>0Example Usage
Security Considerations
Breaking Changes
None. This is a new feature that does not affect existing DAML code.
Testing