Skip to content

Conversation

@ma2bd
Copy link
Contributor

@ma2bd ma2bd commented Nov 18, 2025

Motivation

Backport machine engine PRs

Proposal

Backport machine engine PRs

Test Plan

CI

* Fixes linera-io#841
* Demonstrate how to embed parameters in the "extra" field of `View`s to
help with code structure. (I mentioned this possibility to @kikakkz once
but we had no example to show.)

Allow creators of a market to specify a fixed decimal precision for
prices.
* The amount to be paid for an order is: `amount = quantity *
price/10^precision`.
* If `quantity` (expressed in "attos", the lowest precision for
`Amount`) is not a multiple of 10^precision, then the order is simply
invalid.

We modify the code in several steps:
* add application parameters to storage context
* nit: rename `next_order_number` into `next_order_id`
* rename "amount" into "quantity" + add integration tests
* reorganize the code (moving methods closer to their main object)
* finally, add the notion of "price decimals"

Discussion:
* AFAICT it is very standard for market prices to have fixed precision.
Eventually, `Amount`s should probably have a configurable (reduced)
precision as well.
* Parameters being immutable, copying them in the `extra` field is
pretty harmless. One could also embed the entire runtime using
`Arc<Mutex<ContractRuntime<MyContractState>>` but this is arguably a
tradeoff (e.g. any view can now schedule outgoing messages).

stacked with linera-io#4971 and linera-io#4972

CI

- These changes should be backported to the latest `testnet` branch,
then
    - be released in a new SDK,
@ma2bd ma2bd changed the base branch from main to testnet_conway November 18, 2025 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant