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

concordium-smart-contract-engine

Concordium's smart contract execution engine

10 releases (5 major breaking)

6.0.0 Sep 9, 2024
5.0.0 Mar 25, 2024
4.0.0 Jan 22, 2024
3.1.0 Oct 18, 2023
1.0.1 Mar 20, 2023

#6 in #v0

Download history 97/week @ 2024-08-26 113/week @ 2024-09-02 299/week @ 2024-09-09 191/week @ 2024-09-16 140/week @ 2024-09-23 114/week @ 2024-09-30 63/week @ 2024-10-07 96/week @ 2024-10-14 12/week @ 2024-10-21 48/week @ 2024-10-28 131/week @ 2024-11-04 46/week @ 2024-11-11 129/week @ 2024-11-18 82/week @ 2024-11-25 48/week @ 2024-12-02 115/week @ 2024-12-09

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

Custom license

1.5MB
27K 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

~16MB
~232K SLoC