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

fix: unencryptedlogs witgen #8669

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IlyasRidhuan
Copy link
Contributor

Please read contributing guidelines and remove this line.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @IlyasRidhuan and the rest of your teammates on Graphite Graphite

+ to_hex(OpCode::CAST_8) + // opcode CAST
"00" // Indirect flag
+ to_hex(AvmMemoryTag::FF) +
std::string bytecode_hex = to_hex(OpCode::SET_8) + // opcode Set
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just some formatting

@@ -1902,13 +1901,15 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes)
// CHECK EMIT UNENCRYPTED LOG
auto emit_log_row =
std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_emit_unencrypted_log == 1; });
EXPECT_EQ(emit_log_row->main_ia, 1);
// Trust me bro for now, this is the truncated sha output
FF expected_hash = FF(std::string("0x006db65fd59fd356f6729140571b5bcd6bb3b83492a16e1bf0a3884442fc3c8a"));
Copy link
Contributor Author

@IlyasRidhuan IlyasRidhuan Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that witgen calculates the truncated sha256 hash of the logs, we need to do the same - I promise this is the real hash

@@ -57,8 +57,8 @@ class AvmKernelTraceBuilder {
std::unordered_map<uint32_t, uint32_t> kernel_output_selector_counter;

AvmKernelTraceBuilder(uint32_t initial_side_effect_counter, VmPublicInputs public_inputs, ExecutionHints hints)
: initial_side_effect_counter(initial_side_effect_counter)
, public_inputs(std::move(public_inputs))
: public_inputs(std::move(public_inputs))
Copy link
Contributor Author

@IlyasRidhuan IlyasRidhuan Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to re-order this because public_inputs is now public (because i need it to get the contract address until we have bytecode hashing) and clang complains if it's not initialized first

@@ -92,14 +92,16 @@ class AvmKernelTraceBuilder {
void op_nullifier_exists(uint32_t clk, uint32_t side_effect_counter, const FF& nullifier, uint32_t result);
void op_emit_nullifier(uint32_t clk, uint32_t side_effect_counter, const FF& nullifier);
void op_l1_to_l2_msg_exists(uint32_t clk, uint32_t side_effect_counter, const FF& message, uint32_t result);
void op_emit_unencrypted_log(uint32_t clk, uint32_t side_effect_counter, const FF& log_hash);
void op_emit_unencrypted_log(uint32_t clk, uint32_t side_effect_counter, const FF& log_hash, const FF& log_length);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emit_unencrypted_log actually has metadata, but we weren't properly handling

// we need to add four to the length here.
// https://github.com/AztecProtocol/aztec-packages/issues/6578#issuecomment-2125003435
this.unencryptedLogsHashes.push(new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length + 4)));
this.unencryptedLogsHashes.push(new LogHash(basicLogHash, this.sideEffectCounter, new Fr(ulog.length)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the +4 is actually already handled in the .length call of the class

@IlyasRidhuan IlyasRidhuan force-pushed the ir/09-19-fix_unencryptedlogs_witgen branch from 8299a93 to ce9c31c Compare September 20, 2024 15:50
@IlyasRidhuan IlyasRidhuan force-pushed the ir/09-19-fix_unencryptedlogs_witgen branch from ce9c31c to db50ed4 Compare September 20, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants