From a9e421763c6a52ad871cac708417512386e4f3f1 Mon Sep 17 00:00:00 2001 From: Hang Su Date: Wed, 17 May 2023 15:25:37 -0400 Subject: [PATCH 1/4] extra app budget in model --- src/client/v2/algod/models/types.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/client/v2/algod/models/types.ts b/src/client/v2/algod/models/types.ts index 41d4c620f..a4d091eb4 100644 --- a/src/client/v2/algod/models/types.ts +++ b/src/client/v2/algod/models/types.ts @@ -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', }; } @@ -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 */ } @@ -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 */ @@ -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', }; @@ -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'], }); From 24dfea5c9b4140521285433e9d795496e2ea8386 Mon Sep 17 00:00:00 2001 From: Hang Su Date: Wed, 17 May 2023 17:11:49 -0400 Subject: [PATCH 2/4] finalized steps --- .test-env | 2 +- tests/cucumber/integration.tags | 1 + tests/cucumber/steps/steps.js | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.test-env b/.test-env index df783a4fd..86a8adc07 100644 --- a/.test-env +++ b/.test-env @@ -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" SDK_TESTING_HARNESS="test-harness" INSTALL_ONLY=0 diff --git a/tests/cucumber/integration.tags b/tests/cucumber/integration.tags index 69a9c7429..32a59c3a6 100644 --- a/tests/cucumber/integration.tags +++ b/tests/cucumber/integration.tags @@ -15,3 +15,4 @@ @send.keyregtxn @simulate @simulate.lift_log_limits +@simulate.extra_opcode_budget diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index f894fcbb2..3254de8f0 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -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); + assert.equal( + budget, + this.simulateResponse.evalOverrides.extraOpcodeBudget + ); + } + ); + When('we make a Ready call', async function () { await this.v2Client.ready().do(); }); From 6bc5c4ac44f7b7e66f992f3113027bd424f17d5a Mon Sep 17 00:00:00 2001 From: Hang Su Date: Thu, 18 May 2023 16:46:59 -0400 Subject: [PATCH 3/4] pr response --- tests/cucumber/steps/steps.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/cucumber/steps/steps.js b/tests/cucumber/steps/steps.js index 3254de8f0..12824991f 100644 --- a/tests/cucumber/steps/steps.js +++ b/tests/cucumber/steps/steps.js @@ -4739,15 +4739,9 @@ module.exports = function getSteps(options) { Then( 'I check the simulation result has power packs allow-more-logging.', async function () { - assert.notDeepStrictEqual(undefined, this.simulateResponse.evalOverrides); - assert.notDeepStrictEqual( - undefined, - this.simulateResponse.evalOverrides.maxLogCalls - ); - assert.notDeepStrictEqual( - undefined, - this.simulateResponse.evalOverrides.maxLogSize - ); + assert.ok(this.simulateResponse.evalOverrides); + assert.ok(this.simulateResponse.evalOverrides.maxLogCalls); + assert.ok(this.simulateResponse.evalOverrides.maxLogSize); } ); @@ -4761,8 +4755,8 @@ module.exports = function getSteps(options) { 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); - assert.equal( + assert.ok(this.simulateResponse.evalOverrides); + assert.strictEqual( budget, this.simulateResponse.evalOverrides.extraOpcodeBudget ); From a4f9fed3693e21922ba77e8335eae61ec3de695a Mon Sep 17 00:00:00 2001 From: Hang Su <87964331+ahangsu@users.noreply.github.com> Date: Thu, 18 May 2023 19:43:55 -0400 Subject: [PATCH 4/4] Update .test-env --- .test-env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.test-env b/.test-env index 86a8adc07..df783a4fd 100644 --- a/.test-env +++ b/.test-env @@ -1,6 +1,6 @@ # Configs for testing repo download: SDK_TESTING_URL="https://github.com/algorand/algorand-sdk-testing" -SDK_TESTING_BRANCH="simulation-extra-app-budget" +SDK_TESTING_BRANCH="master" SDK_TESTING_HARNESS="test-harness" INSTALL_ONLY=0