Architecture
How does ULM work?
The ULM architecture is built on four core components that enable its multilanguage smart contract capabilities:
ULM Interface
The ULM interface acts as a standardized gateway for all language semantics to interact with the blockchain state. It serves two primary functions:
Providing a uniform method for all language semantics to modify the global blockchain state.
Managing the instantiation of the correct semantics module and dispatching the contract call accordingly.
Language Registry
The language registry is a smart contract that manages the ecosystem of support languages. Its essential functions include:
Storing records of registered languages, including language name, ID, and a hash of the verified semantics binary.
Allowing users to query information about support languages.
Enabling validator nodes to verify the integrity of language semantics.
Formal Semantics Modules
These modules are a collection of isolated modules built using the K framework. They represent the execution environment for each supported language. To add a language to the Language Registry, users follow this process:
Upload the formal language semantics definition to the front end.
The backend generates the semantics interpreter and uploads the binary to a public remote service.
To activate the language, the user interacts with the language registry contract to record
language_name
,language_id
,hash(language_semantics_bin)
On-chain.
Unified Gas Model
The gas model in ULM ensures security and fairness across all language semantics. It standardizes execution cost across all languages, enforcing consistent performance and security.
It's decoupled from individual language semantics, applying uniformly based solely on the computational resources needed to execute a semantics rule for all language semantics.
It guarantees termination of contract execution, preventing endless loops or excessive resource consumption.
It enhances security by preventing the injection of malicious gas models.
Together, these components create a cohesive environment for cross-language smart contracts, with each part playing a crucial role in security, extensibility, and efficient state modification.
The diagram above illustrates how ULM works. When a transaction is forwarded by the client to ULM for execution, ULM reads the current blockchain state and prepares call parameters for the K execution engine. A key parameter is the language module, which specifies the language used for the transaction. This is determined from the language ID stored in the first few bytes of the contract’s code—whether it’s a contract being deployed or one being called.
Once identified, ULM loads the corresponding language module in K, providing it with all initial parameters required to execute the transaction. During execution, K may need additional state information, such as account balances and storage fields. To obtain this data, K calls back into the ULM interface, which consults the client and provides the required information back to K. If K needs to execute nested calls to other contracts, the ULM interface processes each call to determine the appropriate language, load the relevant state parameters, and spawn a new instance of K to handle the inner transaction.
When execution completes, K returns an execution receipt, which includes the return code, a list of touched accounts, and a record of changes to the global state. The ULM then passes this receipt to the client for finalization before initiating the next transaction in the pipeline. The ULM represents a groundbreaking shift in blockchain technology, enabling smart contracts in any programming language to coexist, interact, and execute securely on the same blockchain. By decoupling the execution layer from specific programming languages and enforcing a standardized gas model and account isolation, ULM achieves a balance of flexibility, security, and extensibility. This approach lowers barriers to entry for developers and allows decentralized applications to reach new levels of complexity and accessibility. The ULM opens a world of possibilities for the future of decentralized applications, where developers can harness the best tools for their specific needs while benefiting from the stability and interoperability of a unified blockchain environment.
Last updated