Skip to content

Commit

Permalink
Merge pull request #1683 from o1-labs/fix/state-overflow-error
Browse files Browse the repository at this point in the history
Fix the error message when using too many onchain state fields (once and for all)
  • Loading branch information
mitschabaude authored Jun 12, 2024
2 parents 6f1407e + 88e8f92 commit 2b187fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/mina/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ function createState<T>(defaultValue?: T): InternalStateType<T> {
stateAsFields.forEach((x, i) => {
let appStateSlot =
accountUpdate.body.update.appState[layout.offset + i];
if (!appStateSlot)
throw Error(
`Attempted to set on-chain state variable \`${this._contract?.key}\`. Currently, only a total of 8 fields elements of on-chain state are supported.`
);
AccountUpdate.setValue(appStateSlot, x);
});
},
Expand Down Expand Up @@ -382,6 +378,11 @@ function getLayout(scClass: typeof SmartContract) {
layout.set(key, { offset, length });
offset += length;
});
if (offset > 8) {
throw Error(
`Found ${offset} on-chain state field elements on ${scClass.name}. Currently, only a total of 8 field elements of state are supported.`
);
}
}
return sc.layout;
}
Expand Down

0 comments on commit 2b187fb

Please sign in to comment.