Skip to content

Commit

Permalink
Merge pull request #1728 from o1-labs/feature/actions-reducers-warning
Browse files Browse the repository at this point in the history
Add reducer API production warning
  • Loading branch information
ymekuria authored Jul 9, 2024
2 parents 221717f + 1c736ad commit 9f0274f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- A warning about the current reducer API limitations, as well as a mention of active work to mitigate them was added to doc comments and examples https://github.com/o1-labs/o1js/pull/1728

- `ForeignField`-based representation of scalars via `ScalarField` https://github.com/o1-labs/o1js/pull/1705
- Introduced new V2 methods for nullifier operations: `isUnusedV2()`, `assertUnusedV2()`, and `setUsedV2()` https://github.com/o1-labs/o1js/pull/1715

Expand Down
6 changes: 5 additions & 1 deletion src/examples/zkapps/dex/dex-with-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* This DEX implementation differs from ./dex.ts in two ways:
* - More minimal & realistic; stuff designed only for testing protocol features was removed
* - Uses an async pattern with actions that lets users claim funds later and reduces account updates
*/
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
import {
Account,
AccountUpdate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
*
* This is mainly intended as an example for using `Iterator` and `MerkleList`, but it might also be useful as
* a blueprint for processing actions in a custom and more explicit way.
*/
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
import {
Field,
Mina,
Expand Down
6 changes: 5 additions & 1 deletion src/examples/zkapps/reducer/actions-as-merkle-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
*
* This is mainly intended as an example for using `MerkleList`, but it might also be useful as
* a blueprint for processing actions in a custom and more explicit way.
*/
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
import {
Bool,
Mina,
Expand Down
4 changes: 4 additions & 0 deletions src/examples/zkapps/reducer/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ In this example, the keys are public keys, and the values are arbitrary field el
This utilizes the `Reducer` as an append online list of actions, which are then looked at to find the value corresponding to a specific key.
Warning: The reducer API in o1js is currently not safe to use in production applications. The reduce()
method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
in progress to mitigate this limitation.
```ts
// js
Expand Down
8 changes: 8 additions & 0 deletions src/examples/zkapps/reducer/reducer-composite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* This example demonstrates a pattern to use actions for concurrent state updates.
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/

import {
Field,
state,
Expand Down
11 changes: 9 additions & 2 deletions src/examples/zkapps/voting/demo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// used to do a dry run, without tests
// ./run ./src/examples/zkapps/voting/demo.ts

/*
* used to do a dry run, without tests
* ./run ./src/examples/zkapps/voting/demo.ts
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/

import { Mina, AccountUpdate, PrivateKey, UInt64, Reducer, Bool } from 'o1js';
import { VotingApp, VotingAppParams } from './factory.js';
Expand Down
5 changes: 5 additions & 0 deletions src/examples/zkapps/voting/membership.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
import {
Field,
SmartContract,
Expand Down
5 changes: 5 additions & 0 deletions src/examples/zkapps/voting/voting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
import {
Field,
SmartContract,
Expand Down
3 changes: 3 additions & 0 deletions src/lib/mina/actions/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ type ReducerReturn<Action> = {
* );
* ```
*
* Warning: The reducer API in o1js is currently not safe to use in production applications. The `reduce()`
* method breaks if more than the hard-coded number (default: 32) of actions are pending. Work is actively
* in progress to mitigate this limitation.
*/
reduce<State>(
actions: MerkleList<MerkleList<Action>>,
Expand Down

0 comments on commit 9f0274f

Please sign in to comment.