#smart-contracts #execution #invoke #state #v0 #execution-engine #concordium

concordium-smart-contract-engine

Concordium's smart contract execution engine

9 stable releases (4 major)

5.0.0 Mar 25, 2024
4.0.0 Jan 22, 2024
3.1.0 Oct 18, 2023
2.0.0 Jun 16, 2023
1.0.1 Mar 20, 2023

#42 in Magic Beans

Download history 44/week @ 2023-12-22 33/week @ 2023-12-29 149/week @ 2024-01-05 114/week @ 2024-01-12 182/week @ 2024-01-19 171/week @ 2024-01-26 91/week @ 2024-02-02 183/week @ 2024-02-09 198/week @ 2024-02-16 235/week @ 2024-02-23 321/week @ 2024-03-01 318/week @ 2024-03-08 268/week @ 2024-03-15 691/week @ 2024-03-22 566/week @ 2024-03-29 659/week @ 2024-04-05

2,245 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
~224K SLoC