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

print zkrom error in debug mode #105

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Changes from all 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
6 changes: 4 additions & 2 deletions src/sm/sm_main/sm_main_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Mask256 = Scalar.sub(Scalar.shl(Scalar.e(1), 256), 1);
const byteMaskOn256 = Scalar.bor(Scalar.shl(Mask256, 256), Scalar.shr(Mask256, 8n));

let fullTracer;
let debug;

module.exports = async function execute(pols, input, rom, config = {}, metadata = {}) {

Expand All @@ -42,7 +43,7 @@ module.exports = async function execute(pols, input, rom, config = {}, metadata
testTools.setup(config.test, evalCommand);
}

const debug = config && config.debug;
debug = config && config.debug;
const flagTracer = config && config.tracer;
const verboseFullTracer = config.verboseFullTracer;
const N = pols.zkPC.length;
Expand Down Expand Up @@ -1008,7 +1009,6 @@ module.exports = async function execute(pols, input, rom, config = {}, metadata
throw new Error(`HashK(${addr}) do not match, pos ${pos+k} is ${bm} and should be ${bh} ${sourceRef}`)
}
}

const paddingA = Scalar.shr(a, size * 8);
if (!Scalar.isZero(paddingA)) {
throw new Error(`HashK(${addr}) incoherent size (${size}) and data (0x${a.toString(16)}) padding (0x${paddingA.toString(16)}) (w=${step}) ${sourceRef}`);
Expand Down Expand Up @@ -2471,6 +2471,8 @@ function eval_eventLog(ctx, tag) {
if (tag.params.length < 1) throw new Error(`Invalid number of parameters (1 > ${tag.params.length}) function ${tag.funcName} ${ctx.sourceRef}`);
if (fullTracer)
fullTracer.handleEvent(ctx, tag);
if (debug && tag.params[0].varName == 'onError')
console.log(`Error triggered zkrom: ${tag.params[1].varName}\nsource: ${ctx.sourceRef}`);
}

function eval_cond(ctx, tag) {
Expand Down