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: separate bytecode logs from unencrypted logs #9891

Merged
merged 11 commits into from
Nov 14, 2024
Merged

Conversation

MirandaWood
Copy link
Contributor

@MirandaWood MirandaWood commented Nov 11, 2024

Adds bytecode logs to a new array: contractClassLogs, emitted from private only. This PR:

  • Adds contract class logs to all public inputs from private and all tx effects
  • Adds new ts classes for contract class logs (also built from UnencryptedLogs, as they have the same structure and logic)
  • Adds getContractClassLogs to pxe, log stores, archiver
  • Uses these logs to manage contract class registration
  • Removes unencrypted logs from private (was only used for contract instance events, which are now in encrypted logs)

closes #9590

@MirandaWood MirandaWood self-assigned this Nov 11, 2024
@MirandaWood MirandaWood added the e2e-all CI: Enables this CI job. label Nov 13, 2024
@MirandaWood MirandaWood marked this pull request as ready for review November 13, 2024 11:27
Copy link
Contributor

github-actions bot commented Nov 13, 2024

Changes to circuit sizes

Generated at commit: 7b42e8c38c4a8c4567b508d83555609eed540ac2, compared to commit: 5997c823077d686107408caa8b4d148e115b62ac

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_base_private +2,155 ❌ +0.65% +18,049 ❌ +0.53%
rollup_base_public +2,237 ❌ +0.48% +16,356 ❌ +0.43%
private_kernel_empty +5 ❌ +0.82% +5 ❌ +0.00%
private_kernel_reset -70 ✅ -0.08% -80 ✅ -0.01%
private_kernel_reset_4_4_4_4_4_4_4_4_1 -70 ✅ -0.22% -109 ✅ -0.13%
private_kernel_init -319 ✅ -1.47% -384 ✅ -1.10%
private_kernel_inner -544 ✅ -1.43% -651 ✅ -1.13%
private_kernel_tail -362 ✅ -8.06% -531 ✅ -4.07%
private_kernel_tail_to_public -1,468 ✅ -7.79% -1,796 ✅ -5.74%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_base_private 335,062 (+2,155) +0.65% 3,450,602 (+18,049) +0.53%
rollup_base_public 472,329 (+2,237) +0.48% 3,786,954 (+16,356) +0.43%
private_kernel_empty 612 (+5) +0.82% 942,839 (+5) +0.00%
private_kernel_reset 84,027 (-70) -0.08% 618,037 (-80) -0.01%
private_kernel_reset_4_4_4_4_4_4_4_4_1 32,385 (-70) -0.22% 86,491 (-109) -0.13%
private_kernel_init 21,407 (-319) -1.47% 34,503 (-384) -1.10%
private_kernel_inner 37,549 (-544) -1.43% 56,879 (-651) -1.13%
private_kernel_tail 4,131 (-362) -8.06% 12,514 (-531) -4.07%
private_kernel_tail_to_public 17,384 (-1,468) -7.79% 29,504 (-1,796) -5.74%

Comment on lines +457 to +467
// The reset circuit checks that capped_size must be greater than or equal to all non-empty logs.
// Since there is no current config with ENCRYPTED_LOG_SILOING_AMOUNT = 0 (only 1+), it defaults to 1,
// so the circuit fails when we have more than 1 log and require no siloing.
const numLogsNoSiloing = this.previousKernel.end.encryptedLogsHashes.filter(
l => !l.logHash.isEmpty() && l.logHash.randomness.isZero(),
).length;
const cappedSize = !numToSilo && numLogsNoSiloing > 1 ? numLogsNoSiloing : numToSilo;
// NB: This is a little flimsy, and only works because we have either ENCRYPTED_LOG_SILOING_AMOUNT=1 or 8.
// e.g. if we have 2 logs that need siloing, and 2 that dont, then numLogs = ENCRYPTED_LOG_SILOING_AMOUNT = 2
// This would fail because the circuit thinks that cappedSize = 2, but we have 4 logs.
this.requestedDimensions.ENCRYPTED_LOG_SILOING_AMOUNT = cappedSize;
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 fixes something I believe is in master - reset will fail for any number of encrypted logs which don't need siloing above 1.
It works now because we'd never tested more than 1 encrypted log with randomness set to 0. In that case, ENCRYPTED_LOG_SILOING_AMOUNT=0 in the above function, and the reset variant with =1 is chosen. Since there is only 1 log overall, it passes. Otherwise, it fails the capped_size check for the same reasons we modify the NULLIFIER_SILOING_AMOUNT just above this fn.

Copy link
Collaborator

@LeilaWang LeilaWang left a comment

Choose a reason for hiding this comment

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

Great work!

@@ -47,8 +52,13 @@ export class Tx extends Gossipable {
public encryptedLogs: EncryptedTxL2Logs,
/**
* Unencrypted logs generated by the tx.
* NOTE: These do not get filled, but remain here so enqueued_calls_processor.ts can accumulate public logs
Copy link
Collaborator

Choose a reason for hiding this comment

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

We really shouldn't change the tx directly for new logs :(
But I'll refactor it in my next pr!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, it was becoming a huge pain to try and rework the calls processor to store them elsewhere in this PR :(

@MirandaWood MirandaWood merged commit b12d3e4 into master Nov 14, 2024
99 checks passed
@MirandaWood MirandaWood deleted the mw/bytecode-logs branch November 14, 2024 12:35
TomAFrench added a commit that referenced this pull request Nov 14, 2024
* master: (245 commits)
  chore: pull signed bitshifts from sync PR (#9939)
  chore: pull frontend changes from sync PR (#9935)
  feat: separate bytecode logs from unencrypted logs (#9891)
  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: token naming issue (#9950)
  feat: multiplier oracle (#9902)
  refactor: token refunds cleanup (#9943)
  chore: Use stack based recursion instead of function recursion (#9947)
  feat: parallelize DIE pass (#9933)
  feat(avm): Simulator enforces integral tag for DIV and field tag for FDIV (#9944)
  chore(avm): bugfixing witness generation for add, sub, mul for FF (#9938)
  feat: Google Cloud Kubernetes cluster + AWS Firewall Rules (#9915)
  chore: nuking ancient redundant test (#9941)
  fix: include 'master' version for aztec-up scripts (#9940)
  chore: fixing test contract fixture (#9909)
  refactor: token naming cleanup (#9904)
  chore: pull SSA parser from sync PR (#9928)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e-all CI: Enables this CI job.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a separate array of logs for bytecode.
2 participants