Skip to content

Commit

Permalink
Add input param chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Sep 30, 2022
1 parent 3511691 commit a1ff282
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/sm/sm_main/sm_main_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,8 @@ function eval_functionCall(ctx, tag) {
return eval_getNumBatch(ctx, tag);
} else if (tag.funcName == "getTimestamp") {
return eval_getTimestamp(ctx, tag);
} else if (tag.funcName == "getChainId") {
return eval_getChainId(ctx, tag);
} else if (tag.funcName == "getBatchHashData") {
return eval_getBatchHashData(ctx, tag);
} else if (tag.funcName == "getGlobalExitRoot") {
Expand Down Expand Up @@ -2266,6 +2268,11 @@ function eval_getTimestamp(ctx, tag) {
return [ctx.Fr.e(ctx.input.timestamp), ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero];
}

function eval_getChainId(ctx, tag) {
if (tag.params.length != 0) throw new Error(`Invalid number of parameters function ${tag.funcName}: ${ctx.ln} at ${ctx.fileName}:${ctx.line}`);
return [ctx.Fr.e(ctx.input.chainID), ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero, ctx.Fr.zero];
}

function eval_eventLog(ctx, tag) {
if (tag.params.length < 1) throw new Error(`Invalid number of parameters function ${tag.funcName}: ${ctx.ln} at ${ctx.fileName}:${ctx.line}`);
if(fullTracer) fullTracer.handleEvent(ctx, tag)
Expand Down Expand Up @@ -2684,6 +2691,7 @@ function preprocessTxs(ctx) {
newStateRoot,
globalExitRoot,
timestamp,
chainID
} = ctx.input;

ctx.input.batchHashData = calculateBatchHashData(
Expand All @@ -2699,7 +2707,8 @@ function preprocessTxs(ctx) {
newLocalExitRoot,
ctx.input.batchHashData,
numBatch,
timestamp
timestamp,
chainID
);

ctx.input.accessedStorage = [new Map()]
Expand Down

0 comments on commit a1ff282

Please sign in to comment.