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

feat(avm): class id derivation #12263

Merged
merged 4 commits into from
Feb 26, 2025

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.

@IlyasRidhuan IlyasRidhuan force-pushed the ir/02-24-feat_avm_class_id_derivation branch from 8cfc56a to 44a43eb Compare February 25, 2025 22:43
@@ -156,6 +156,18 @@ const PIL_CONSTANTS = [
'MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS',
];

const PIL_GENERATORS: string[] = [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generators weren't included in the PIL in the previous PR - followed the same approach as the cpp gen

for (size_t i = 0; i < num_perm_events; i++) {
std::array<FF, 3> perm_input = { 0, 0, 0 };
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 was actually a little bug in poseidon2_hash.pil 😱. We weren't cleaning out the input array between permutation runs.

@@ -67,21 +67,20 @@ namespace poseidon2_hash;
// The permutation output values are represented by b_0, b_1, b_2, b_3
// This most definitely could be simplified to a lower degree check
// The next perm input is constrained to be the previous perm output + the new values to be hashed if we
// are not at the start or the end of hashing
pol NEXT_INPUT_IS_PREV_OUTPUT_SEL = (1 - LATCH_CONDITION) * (1 - start);
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 was a bug 😨 . It was too relaxed, it's changed to only be the (1 - LATCH_CONDITION)

@@ -43,4 +43,13 @@ namespace constants;
pol START_EMIT_NULLIFIER_WRITE_OFFSET = 207;
pol START_EMIT_L2_TO_L1_MSG_WRITE_OFFSET = 223;
pol START_EMIT_UNENCRYPTED_LOG_WRITE_OFFSET = 225;
pol GENERATOR_INDEX__NOTE_HASH_NONCE = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not used but part of constants gen right now

}

// TODO: This should probably be refined and moved to bc_retrieval test file once that exists
TEST(ClassIdDerivationConstrainingTest, WithRetrievalInteraction)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When bc_retrieval is being properly done, we should move the test to there

@IlyasRidhuan IlyasRidhuan marked this pull request as ready for review February 25, 2025 23:11
Copy link
Contributor

@fcarreiro fcarreiro left a comment

Choose a reason for hiding this comment

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

LGTM!

// H(GENERATOR_INDEX__CONTRACT_LEAF, artifact_hash, private_function_root, public_bytecode_commitment)
pol commit class_id;

pol commit temp_constant_for_lookup;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a todo comment about the constants?

// Since the inputs to poseidon2 have to be chunks of 3, we need two lookups if we want to do this in a single row
#[CLASS_ID_POSEIDON2_0]
sel { temp_constant_for_lookup, artifact_hash, private_function_root, class_id }
in poseidon2_hash.sel { poseidon2_hash.input_0, poseidon2_hash.input_1, poseidon2_hash.input_2, poseidon2_hash.output };
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use a more fine grained selector like poseidon2_hash.end? Saves us inverses etc! (same below).

@IlyasRidhuan IlyasRidhuan force-pushed the ir/02-24-feat_avm_class_id_derivation branch from a02e2f7 to dd671ad Compare February 26, 2025 11:02
@IlyasRidhuan IlyasRidhuan enabled auto-merge (squash) February 26, 2025 11:02
@IlyasRidhuan IlyasRidhuan merged commit a0c4124 into master Feb 26, 2025
10 checks passed
@IlyasRidhuan IlyasRidhuan deleted the ir/02-24-feat_avm_class_id_derivation branch February 26, 2025 11:34
TomAFrench added a commit that referenced this pull request Feb 26, 2025
* master: (92 commits)
  chore: Log prover publisher address on creation (#12267)
  feat: https for bootnode in devnet (#12161)
  feat(avm): support shifts in lookups (#12280)
  feat(docs): Add flamegraph tool to counter contract tutorial (#12202)
  feat(spartan): 192 node 1 tps - additional validator service (#12238)
  feat(avm): class id derivation (#12263)
  docs: Fees doc snippets and code snippets (#12229)
  refactor: proving cost in fee header (#12048)
  fix: prometheus scrapes itself in the cluster (#12277)
  feat: metrics (#12256)
  chore: cleanup stdlib internal imports (#12274)
  git subrepo push --branch=master noir-projects/aztec-nr
  git_subrepo.sh: Fix parent in .gitrepo file. [skip ci]
  chore: replace relative paths to noir-protocol-circuits
  git subrepo push --branch=master barretenberg
  fix: Enforce no import side effects (#12268)
  refactor!: note interfaces (#12106)
  yolo undenoise tests
  feat: new transcript functionality to hash elements without including in proof (#12233)
  chore: remove gcloud metrics (#12265)
  ...
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