Skip to content

Commit

Permalink
add params size to quote
Browse files Browse the repository at this point in the history
  • Loading branch information
modship committed Oct 18, 2024
1 parent 147c349 commit 5bb0912
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions assembly/env/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export namespace env {
ascPeriod: u64,
ascThread: u8,
maxGas: u64,
paramsSize: u64,
): u64;

@external("massa", "assembly_script_deferred_call_register")
Expand Down
8 changes: 5 additions & 3 deletions assembly/std/deferredCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { Slot } from './context';
* @returns Mas amount
*
*/
export function deferredCallQuote(targetSlot: Slot, maxGas: u64): u64 {
return env.deferredCallQuote(targetSlot.period, targetSlot.thread, maxGas);
export function deferredCallQuote(targetSlot: Slot, maxGas: u64, paramsSize: u64): u64 {
return env.deferredCallQuote(targetSlot.period, targetSlot.thread, maxGas, paramsSize);
}

/**
Expand Down Expand Up @@ -84,17 +84,19 @@ export function findCheapestSlot(
startPeriod: u64,
endPeriod: u64,
maxGas: u64,
paramsSize: u64,
): Slot {
let cheapestSlotPeriod: u64 = startPeriod;
let cheapestSlotThread: u8 = 0;
let cheapestSlotPrice: u64 = deferredCallQuote(
new Slot(startPeriod, 0),
maxGas,
paramsSize
);

for (let period = startPeriod; period <= endPeriod; period++) {
for (let thread: u8 = 1; thread < 32; thread++) {
const price = deferredCallQuote(new Slot(period, thread), maxGas);
const price = deferredCallQuote(new Slot(period, thread), maxGas, paramsSize);
if (price < cheapestSlotPrice) {
cheapestSlotPrice = price;
cheapestSlotPeriod = period;
Expand Down

0 comments on commit 5bb0912

Please sign in to comment.