Skip to content

Commit

Permalink
perf: minimze communication between host and WASM module #284 - part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ppedziwiatr committed Dec 5, 2022
1 parent 402e6fc commit 1481c7c
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 119 deletions.
9 changes: 4 additions & 5 deletions src/contract/HandlerBasedContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ export class HandlerBasedContract<State> implements Contract<State> {

const handleResult = await this.evalInteraction<Input, View>(
{
interaction,
interactionTx: dummyTx,
action: interaction,
interaction: dummyTx,
currentTx: []
},
executionContext,
Expand Down Expand Up @@ -658,8 +658,8 @@ export class HandlerBasedContract<State> implements Contract<State> {
};

const interactionData: InteractionData<Input> = {
interaction,
interactionTx,
action: interaction,
interaction: interactionTx,
currentTx
};

Expand Down Expand Up @@ -689,7 +689,6 @@ export class HandlerBasedContract<State> implements Contract<State> {

interactionCall.update({
cacheHit: false,
outputState: this._evaluationOptions.stackTrace.saveState ? result.state : undefined,
executionTime: benchmark.elapsed(true) as number,
valid: result.type === 'ok',
errorMessage: result.errorMessage,
Expand Down
21 changes: 10 additions & 11 deletions src/core/ContractCallRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ export class ContractCallRecord {
}

addInteractionData(interactionData: InteractionData<any>): InteractionCall {
const { interaction, interactionTx } = interactionData;
const { action, interaction } = interactionData;

const interactionCall = InteractionCall.create(
new InteractionInput(
interactionTx.id,
interactionTx.sortKey,
interactionTx.block.height,
interactionTx.block.timestamp,
interaction?.caller,
interaction?.input.function,
interaction?.input,
interactionTx.dry,
interaction.id,
interaction.sortKey,
interaction.block.height,
interaction.block.timestamp,
action?.caller,
action?.input.function,
action?.input,
interaction.dry,
{}
)
);

this.interactions[interactionTx.id] = interactionCall;
this.interactions[interaction.id] = interactionCall;

return interactionCall;
}
Expand Down Expand Up @@ -72,7 +72,6 @@ export class InteractionInput {
export class InteractionOutput {
constructor(
public readonly cacheHit: boolean,
public readonly outputState: any,
public readonly executionTime: number,
public readonly valid: boolean,
public readonly errorMessage: string = '',
Expand Down
7 changes: 7 additions & 0 deletions src/core/WarpPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ export interface WarpPlugin<T, R> {

process(input: T): R;
}

export type EvaluationProgressInput = {
contractTxId: string;
currentInteraction: number;
allInteractions: number;
lastInteractionProcessingTime: string;
}
Loading

0 comments on commit 1481c7c

Please sign in to comment.