Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Actions/Events limit #883

Merged
merged 9 commits into from
May 2, 2023
18 changes: 8 additions & 10 deletions src/lib/mina.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ import { SmartContract } from './zkapp.js';
import { invalidTransactionError } from './errors.js';
import { Types } from '../provable/types.js';
import { Account } from './mina/account.js';
import {
proofCost,
signedPairCost,
signedSingleCost,
costLimit,
maxActionElements,
maxEventElements,
} from './mina/constants.js';

export {
createTransaction,
Expand Down Expand Up @@ -1389,16 +1397,6 @@ async function verifyAccountUpdate(
}

function verifyTransactionLimits({ accountUpdates }: ZkappCommand) {
// constants used to calculate cost of a transaction - originally defined in the genesis_constants file in the mina repo
const proofCost = 10.26;
const signedPairCost = 10.08;
const signedSingleCost = 9.14;
const costLimit = 69.45;

// constants that define the maximum number of events in one transaction
const maxActionElements = 16;
const maxEventElements = 16;

let eventElements = { events: 0, actions: 0 };

let authKinds = accountUpdates.map((update) => {
Expand Down
26 changes: 26 additions & 0 deletions src/lib/mina/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This file contains constants used in the Mina protocol.
* Originally defined in the mina_compile_config file in the mina repo:
* https://github.com/MinaProtocol/mina/blob/develop/src/lib/mina_compile_config/mina_compile_config.ml
*/

// ---- Constants used to calculate cost of a transaction ----
// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#LL67C21-L67C21
export const proofCost = 10.26 as const;

// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#LL69C8-L69C8
export const signedPairCost = 10.08 as const;

// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#L71
export const signedSingleCost = 9.14 as const;

// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#L73
export const costLimit = 69.45 as const;
// ----

// --- Constants to define the maximum number of events and actions in a transaction ----
// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#L75
export const maxActionElements = 100 as const;
// Defined in https://github.com/MinaProtocol/mina/blob/e39abf79b7fdf96717eb8a8ee88ec42ba1e2663d/src/lib/mina_compile_config/mina_compile_config.ml#L77
export const maxEventElements = 100 as const;
// ----