Skip to content

Commit

Permalink
feat: trace class id and instance
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed Oct 1, 2024
1 parent fee5e1b commit 81b2173
Show file tree
Hide file tree
Showing 22 changed files with 1,083 additions and 761 deletions.
33 changes: 30 additions & 3 deletions barretenberg/cpp/pil/avm/bytecode.pil
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
namespace bytecode(256);

// Raw bytes
pol commit bytes;
pol commit bytes_pc;

// Decomposed into 35 byte chunks to parse into instructions
pol commit decomposed;

// =============== BYTECODE HASHING + ADDRESS DERIVATION =================================================
// Bytes packed into 31 byte chunks
pol commit packed;
pol commit length_remaining;

// Bytecode public commitment hash
pol commit running_hash;

// When this is 1, it represents when reached the end of a contract bytecode
pol commit end_latch;
end_latch * (1 - end_latch) = 0;

// TODO: Come back to this;
// pol commit class_id;
// pol commit contract_address;
/* Derive Class Id */
pol CONTRACT_LEAF = 16;
pol commit arifact_hash;
pol commit private_fn_root;
// class_id = H(CONTRACT_LEAF, artifact_hash, private_fn_root, running_hash)
pol commit class_id;

/* Derive Contract Addr*/
pol CONTRACT_ADDRESS_V1 = 15;
pol PARTIAL_ADDRESS = 27;
// pol SALTED_INIT_HASH = H(PARTIAL_ADDR, salt, init_hash, deployer_addr);
// pol PARTIAL_ADDR = H(PARTIAL_ADDR, class_id, SALTED_INIT_HASH);
pol commit salt;
pol commit initialization_hash;
pol commit deployer_addr;
pol commit public_key_hash;
// contract_address = H(CONTRACT_ADDRESS_V1, public_key_hash, partial_address)
pol commit contract_address;

1 change: 1 addition & 0 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,7 @@ void avm_prove(const std::filesystem::path& calldata_path,
vinfo("hints.l1_to_l2_message_exists_hints size: ", avm_hints.l1_to_l2_message_exists_hints.size());
vinfo("hints.externalcall_hints size: ", avm_hints.externalcall_hints.size());
vinfo("hints.contract_instance_hints size: ", avm_hints.contract_instance_hints.size());
vinfo("hints.contrate_bytecode_hints size: ", avm_hints.all_contract_bytecode.size());

vinfo("initializing crs with size: ", avm_trace::Execution::SRS_SIZE);
init_bn254_crs(avm_trace::Execution::SRS_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,21 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co
polys.binary_op_id.set_if_valid_index(i, rows[i].binary_op_id);
polys.binary_sel_bin.set_if_valid_index(i, rows[i].binary_sel_bin);
polys.binary_start.set_if_valid_index(i, rows[i].binary_start);
polys.bytecode_arifact_hash.set_if_valid_index(i, rows[i].bytecode_arifact_hash);
polys.bytecode_bytes.set_if_valid_index(i, rows[i].bytecode_bytes);
polys.bytecode_bytes_pc.set_if_valid_index(i, rows[i].bytecode_bytes_pc);
polys.bytecode_class_id.set_if_valid_index(i, rows[i].bytecode_class_id);
polys.bytecode_contract_address.set_if_valid_index(i, rows[i].bytecode_contract_address);
polys.bytecode_decomposed.set_if_valid_index(i, rows[i].bytecode_decomposed);
polys.bytecode_deployer_addr.set_if_valid_index(i, rows[i].bytecode_deployer_addr);
polys.bytecode_end_latch.set_if_valid_index(i, rows[i].bytecode_end_latch);
polys.bytecode_initialization_hash.set_if_valid_index(i, rows[i].bytecode_initialization_hash);
polys.bytecode_length_remaining.set_if_valid_index(i, rows[i].bytecode_length_remaining);
polys.bytecode_packed.set_if_valid_index(i, rows[i].bytecode_packed);
polys.bytecode_private_fn_root.set_if_valid_index(i, rows[i].bytecode_private_fn_root);
polys.bytecode_public_key_hash.set_if_valid_index(i, rows[i].bytecode_public_key_hash);
polys.bytecode_running_hash.set_if_valid_index(i, rows[i].bytecode_running_hash);
polys.bytecode_salt.set_if_valid_index(i, rows[i].bytecode_salt);
polys.cmp_a_hi.set_if_valid_index(i, rows[i].cmp_a_hi);
polys.cmp_a_lo.set_if_valid_index(i, rows[i].cmp_a_lo);
polys.cmp_b_hi.set_if_valid_index(i, rows[i].cmp_b_hi);
Expand Down
Loading

0 comments on commit 81b2173

Please sign in to comment.