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

Algod: Simulation run with extra budget per transaction group #784

Merged
merged 4 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .test-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Configs for testing repo download:
SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing"
SDK_TESTING_BRANCH="master"
SDK_TESTING_BRANCH="simulation-extra-app-budget"
ahangsu marked this conversation as resolved.
Show resolved Hide resolved
SDK_TESTING_HARNESS="test-harness"

INSTALL_ONLY=0
Expand Down
22 changes: 22 additions & 0 deletions src/client/v2/algod/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3318,31 +3318,41 @@ export class SimulateRequest extends BaseModel {
*/
public allowMoreLogging?: boolean;

/**
* Applies extra opcode budget during simulation for each transaction group.
*/
public extraOpcodeBudget?: number | bigint;

/**
* Creates a new `SimulateRequest` object.
* @param txnGroups - The transaction groups to simulate.
* @param allowEmptySignatures - Allow transactions without signatures to be simulated as if they had correct
* signatures.
* @param allowMoreLogging - Lifts limits on log opcode usage during simulation.
* @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group.
*/
constructor({
txnGroups,
allowEmptySignatures,
allowMoreLogging,
extraOpcodeBudget,
}: {
txnGroups: SimulateRequestTransactionGroup[];
allowEmptySignatures?: boolean;
allowMoreLogging?: boolean;
extraOpcodeBudget?: number | bigint;
}) {
super();
this.txnGroups = txnGroups;
this.allowEmptySignatures = allowEmptySignatures;
this.allowMoreLogging = allowMoreLogging;
this.extraOpcodeBudget = extraOpcodeBudget;

this.attribute_map = {
txnGroups: 'txn-groups',
allowEmptySignatures: 'allow-empty-signatures',
allowMoreLogging: 'allow-more-logging',
extraOpcodeBudget: 'extra-opcode-budget',
};
}

Expand All @@ -3359,6 +3369,7 @@ export class SimulateRequest extends BaseModel {
),
allowEmptySignatures: data['allow-empty-signatures'],
allowMoreLogging: data['allow-more-logging'],
extraOpcodeBudget: data['extra-opcode-budget'],
});
/* eslint-enable dot-notation */
}
Expand Down Expand Up @@ -3672,6 +3683,11 @@ export class SimulationEvalOverrides extends BaseModel {
*/
public allowEmptySignatures?: boolean;

/**
* The extra opcode budget added to each transaction group during simulation
*/
public extraOpcodeBudget?: number | bigint;

/**
* The maximum log calls one can make during simulation
*/
Expand All @@ -3686,25 +3702,30 @@ export class SimulationEvalOverrides extends BaseModel {
* Creates a new `SimulationEvalOverrides` object.
* @param allowEmptySignatures - If true, transactions without signatures are allowed and simulated as if they
* were properly signed.
* @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation
* @param maxLogCalls - The maximum log calls one can make during simulation
* @param maxLogSize - The maximum byte number to log during simulation
*/
constructor({
allowEmptySignatures,
extraOpcodeBudget,
maxLogCalls,
maxLogSize,
}: {
allowEmptySignatures?: boolean;
extraOpcodeBudget?: number | bigint;
maxLogCalls?: number | bigint;
maxLogSize?: number | bigint;
}) {
super();
this.allowEmptySignatures = allowEmptySignatures;
this.extraOpcodeBudget = extraOpcodeBudget;
this.maxLogCalls = maxLogCalls;
this.maxLogSize = maxLogSize;

this.attribute_map = {
allowEmptySignatures: 'allow-empty-signatures',
extraOpcodeBudget: 'extra-opcode-budget',
maxLogCalls: 'max-log-calls',
maxLogSize: 'max-log-size',
};
Expand All @@ -3717,6 +3738,7 @@ export class SimulationEvalOverrides extends BaseModel {
/* eslint-disable dot-notation */
return new SimulationEvalOverrides({
allowEmptySignatures: data['allow-empty-signatures'],
extraOpcodeBudget: data['extra-opcode-budget'],
maxLogCalls: data['max-log-calls'],
maxLogSize: data['max-log-size'],
});
Expand Down
1 change: 1 addition & 0 deletions tests/cucumber/integration.tags
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
@send.keyregtxn
@simulate
@simulate.lift_log_limits
@simulate.extra_opcode_budget
18 changes: 18 additions & 0 deletions tests/cucumber/steps/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4751,6 +4751,24 @@ module.exports = function getSteps(options) {
}
);

Then(
'I allow {int} more budget on that simulate request.',
async function (budget) {
this.simulateRequest.extraOpcodeBudget = budget;
}
);

Then(
'I check the simulation result has power packs extra-opcode-budget with extra budget {int}.',
async function (budget) {
assert.notDeepStrictEqual(undefined, this.simulateResponse.evalOverrides);
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
assert.equal(
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
budget,
this.simulateResponse.evalOverrides.extraOpcodeBudget
);
}
);

When('we make a Ready call', async function () {
await this.v2Client.ready().do();
});
Expand Down