#blockchain #smart #haskell #cryptography #engine #zero-knowledge-proofs #smart-contracts

concordium-smart-contract-engine

Concordium's smart contract execution engine

8 stable releases (3 major)

4.0.0 Jan 22, 2024
3.1.0 Oct 18, 2023
3.0.0 Aug 21, 2023
2.0.0 Jun 16, 2023
1.0.0 Feb 3, 2023

#2421 in Magic Beans

Download history 118/week @ 2023-10-29 308/week @ 2023-11-05 80/week @ 2023-11-12 215/week @ 2023-11-19 257/week @ 2023-11-26 134/week @ 2023-12-03 183/week @ 2023-12-10 138/week @ 2023-12-17 65/week @ 2023-12-24 92/week @ 2023-12-31 191/week @ 2024-01-07 158/week @ 2024-01-14 271/week @ 2024-01-21 241/week @ 2024-01-28 190/week @ 2024-02-04 229/week @ 2024-02-11

944 downloads per month
Used in 3 crates (2 directly)

Custom license

1.5MB
26K SLoC

concordium-smart-contract-engine

A library that provides an implementation of execution of smart contracts on top of the concordium-wasm library that implements the underlying Wasm execution.

In particular this library is used by the Concordium node to execute both V0 and V1 smart contracts. It is also used by other Concordium tools, such as cargo-concordium, to provide build and test functionality.

Versioning

This crate follows semantic versioning guidelines. Change in minimum supported rust version will be accompanied by a minor version increase.


lib.rs:

This library provides functionality that builds on top of the Wasm engine and adds high-level functions for executing smart contracts on the Concordium chain.

Concordium supports two versions of smart contracts, the legacy [v0] version and the [v1] version. The latter is essentially better in every way. They differ in two main ways

  • [v0] uses message passing for inter-contract communication, and has a flat state. The state is limited to 16kB and the entire state is written every time a contract update is done.
  • [v1] uses synchronous calls for inter-contract communication, and its state is a trie-based structure, which supports efficient partial state updates. The trie is implemented in the v1::trie module.

Both [v0] and [v1] modules are structured similarly. The main entrypoints used by users of this library are v0::invoke_init (resp. v1::invoke_init) and v0::invoke_receive (resp. v1::invoke_receive) functions, and their variants.

The respective modules provide more details on the data types involved, and any specifics of the different versions.

Features

This crate has the following features. None are enabled by default.

display-state

This feature exposes the function display_tree for displaying the V1 contract state in a reasonably readable format. This is useful for deep inspection of smart contract state, and debugging.

async

Exposes construction of smart contract state from streams of key-value pairs, such as those received from the node's API. See

enable-ffi

This enables foreign function exports. This is an internal feature and there are no guarantees about the stability of foreign exports.

fuzz-coverage and fuzz

These features are also internal and exist to support fuzzing. They are used to derive Arbitrary instances and to disable inlining, the latter is necessary since the fuzzer used has bugs which prevent the coverage report being generated when functions are inlined.

Dependencies

~15MB
~223K SLoC