Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 2cb54fe

Browse files
committed
Added events and removed gas estimation from solidity code #45 NilFoundation/evm-placeholder-verification#86
1 parent c79dd46 commit 2cb54fe

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

include/nil/blueprint/transpiler/templates/modular_verifier.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
103103
uint256 Z_at_xi;
104104
uint256 l0;
105105
uint256[f_parts] F;
106-
uint256 gas;
107106
bool b;
108107
}
109108
@@ -151,10 +150,9 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
151150
function verify(
152151
bytes calldata blob,
153152
uint256[] calldata public_input
154-
) public view returns (bool result) {
153+
) public returns (bool result) {
155154
verifier_state memory state;
156155
state.b = true;
157-
state.gas = gasleft();
158156
state.xi = basic_marshalling.get_uint256_be(blob, $EVAL_PROOF_OFFSET$);
159157
state.Z_at_xi = addmod(field.pow_small(state.xi, rows_amount, modulus), modulus-1, modulus);
160158
state.l0 = mulmod(
@@ -166,7 +164,7 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
166164
//0. Direct public input check
167165
if(public_input.length > 0) {
168166
if (!public_input_direct(blob[$TABLE_Z_OFFSET$:$TABLE_Z_OFFSET$+$QUOTIENT_OFFSET$], public_input, state)) {
169-
console.log("Wrong public input!");
167+
emit WrongPublicInput();
170168
state.b = false;
171169
}
172170
}
@@ -225,7 +223,6 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
225223
F_consolidated = addmod(F_consolidated, mulmod(state.F[i],transcript.get_field_challenge(tr_state, modulus), modulus), modulus);
226224
unchecked{i++;}
227225
}
228-
uint256 points_num = basic_marshalling.get_length(blob, $EVAL_PROOF_OFFSET$ + 0x20);
229226
transcript.update_transcript_b32_by_offset_calldata(tr_state, blob, 0x59);
230227
}
231228
@@ -241,7 +238,7 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
241238
if(!modular_commitment_scheme_$TEST_NAME$.verify_eval(
242239
blob[z_offset - 0x8:], commitments, state.xi, tr_state.current_challenge
243240
)) {
244-
console.log("Error from commitment scheme!");
241+
emit WrongCommitment();
245242
state.b = false;
246243
}
247244
}
@@ -260,13 +257,16 @@ contract modular_verifier_$TEST_NAME$ is IModularVerifier{
260257
unchecked{i++;}
261258
}
262259
if( F_consolidated != mulmod(T_consolidated, state.Z_at_xi, modulus) ) {
263-
console.log("Error. Table does't satisfy constraint system");
260+
emit ConstraintSystemNotSatisfied();
264261
state.b = false;
265262
}
266-
if(state.b) console.log("SUCCESS!"); else console.log("FAILURE!");
263+
if(state.b) {
264+
emit ProofVerified();
265+
} else {
266+
emit ProofVerificationFailed();
267+
}
267268
}
268269
269-
console.log("Gas for verification:", state.gas-gasleft());
270270
result = state.b;
271271
}
272272
}

0 commit comments

Comments
 (0)