Skip to content

Commit

Permalink
Merge pull request #1183 from Concordium/sc-review-build
Browse files Browse the repository at this point in the history
Sc review build
  • Loading branch information
dragosgd authored Dec 12, 2024
2 parents 0985d49 + 3d055d0 commit 9777fce
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
9 changes: 9 additions & 0 deletions source/mainnet/docs/smart-contracts/best-practices/costs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Cost reduction

There are several ways that you can reduce transaction costs when developing your smart contracts.

.. _sc-costs-custom-allocator:

Use a custom allocator
======================

Expand Down Expand Up @@ -45,8 +47,15 @@ For very complex contracts it may be beneficial to run benchmarks to see
whether ``bump_alloc`` is the best option. See the Rust `allocator <https://doc.rust-lang.org/std/alloc/index.html#the-global_allocator-attribute>`_
documentation for more context and details on using custom allocators.

.. note::

One interesting thing to know is that you need to be careful to not enable ``bump_alloc``
when using the smart contract types in other programs (e.g. `a long-lived indexer <https://github.com/Concordium/concordium-dapp-examples/blob/main/trackAndTrace/indexer/Cargo.toml#L27>`_)

There are other allocators available, for example ``dlmalloc``, that can be used instead.

.. _sc-costs-use-state:

Use State-* types for maps, sets, and boxes
===========================================

Expand Down
5 changes: 4 additions & 1 deletion source/mainnet/docs/smart-contracts/guides/build-schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Build a contract schema

This guide will show you how to build a smart contract schema, how to export it
to a file, and/or embed the schema into the smart contract module, all using
``cargo-concordium``.
|cargo-concordium|_.

.. note ::
Expand Down Expand Up @@ -277,3 +277,6 @@ commands print the base64 representation of the schema to the console:
$cargo concordium schema-base64 --module "/some/path/module.wasm.v1"
$cargo concordium schema-base64 --module "/some/path/module.wasm.v1" --out -
.. _cargo-concordium: https://crates.io/crates/cargo-concordium
.. |cargo-concordium| replace:: ``cargo-concordium``
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Preparation
===========

Make sure to have Rust and Cargo installed and the ``wasm32-unknown-unknown``
target, together with ``cargo-concordium`` and the Rust source code for a smart
target, together with |cargo-concordium|_ and the Rust source code for a smart
contract module, you wish to compile.

.. seealso::
Expand Down Expand Up @@ -117,3 +117,6 @@ For example, running the following command will output your smart contract modul
for V1 contracts. Concordium recommends using the wasm module with the ``.v1`` extension
(the most-up-to date smart contract version).
The file ``my_module.wasm.v1`` will be used when :ref:`deploying <deploy-module>` a smart contract on-chain.

.. _cargo-concordium: https://crates.io/crates/cargo-concordium
.. |cargo-concordium| replace:: ``cargo-concordium``
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You also need to have the following installed:
.. seealso::

For instructions on how to install the developer tools, see
:ref:`build-contract`.
:ref:`setup-env`.

What are fallback entrypoints
=============================
Expand Down
4 changes: 4 additions & 0 deletions source/mainnet/docs/smart-contracts/guides/json-params.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ JSON parameters

This guide explains how to interact with the CIS-2 smart contract functions by providing input JSON parameters. This guide uses the `cis2-multi smart contract <https://github.com/Concordium/concordium-rust-smart-contracts/tree/main/examples/cis2-multi>`__ as a starting point, and then continues with a couple of custom input types.

.. seealso::

For a guide on how to interact with a smart contract using JSON parameters see :ref:`interact-instance-json-parameters`.

A smart contract implementing CIS-2 must export the following functions: ``transfer()``, ``updateOperator()``, ``balanceOf()``, ``operatorOf()``, and ``tokenMetadata()``. This topic briefly describes what the required functions do and how to interact with them using JSON parameters one by one.

transfer() and TransferParams
Expand Down
1 change: 1 addition & 0 deletions source/mainnet/docs/smart-contracts/guides/no-std.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ You can update your `Cargo.toml` file by using:
In ``concordium-std`` version ``>=10.0.0``, `bump_alloc <https://docs.rs/concordium-std/10.0.0/concordium_std/#use-a-custom-allocator>`_ is a feature and needs to be explicitly enabled.
When ``std`` feature is enabled, the allocator provided by the Rust standard library is used
by default but when the ``wee_alloc``/``bump_alloc`` feature is enabled in addition, `bump_alloc <https://docs.rs/concordium-std/10.0.0/concordium_std/#use-a-custom-allocator>`_ ( or `wee_alloc <https://docs.rs/wee_alloc/>`_) is used instead.
Read :ref:`sc-costs-custom-allocator` for more information on custom allocators.

You can enable the ``std`` feature and the ``wee_alloc`` feature in ``concordium-std`` version in the range of ``>=6.0.0`` and ``<10.0.0`` by using:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ The *from scratch* option guides you through the process when you want to start
.. note::

``Wee_alloc`` is unmaintained currently and hence an optional feature for backward compatibility.
There are other allocators available, for example `dlmalloc <https://docs.rs/dlmalloc/>`_.
There are other allocators available, read :ref:`sc-costs-custom-allocator` for a guide on how to use one.

.. seealso::

Expand Down

0 comments on commit 9777fce

Please sign in to comment.