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: add historical library tests and remove old inclusion proof contract / related tests #12215

Merged
merged 9 commits into from
Feb 27, 2025

Conversation

sklppy88
Copy link
Contributor

@sklppy88 sklppy88 commented Feb 24, 2025

Adding txe tests to the historical apis, and removing inclusion proofs contract with corresponding (flaky) e2e test

Copy link
Contributor Author

sklppy88 commented Feb 24, 2025

@sklppy88 sklppy88 changed the title init feat: add historical library tests and remove old inclusion proof contract / related tests Feb 24, 2025
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch 25 times, most recently from e720b2a to 393d16c Compare February 24, 2025 12:43
@@ -71,18 +71,24 @@ impl NoteInterface for MockNote {
pub(crate) struct MockNoteBuilder {
value: Field,
contract_address: Option<AztecAddress>,
nonce: Option<Field>,
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 modified to allow for creating deterministic note hashes.

@@ -3,7 +3,7 @@ use dep::protocol_types::{
hash::compute_siloed_nullifier,
};

trait ProveContractDeployment {
pub trait ProveContractDeployment {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were exposed to be used in the counter-contracts due to not being able to test this in aztec-nr.

Copy link
Contributor

Choose a reason for hiding this comment

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

They should be exposed anyway as the history library and the whole of Aztec.nr is to be consumed from contracts.

mod nullifier_inclusion;
mod nullifier_non_inclusion;
mod public_storage;
pub mod contract_inclusion;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exposing all these as well to remove warnings

}

#[private]
fn test_note_inclusion(owner: AztecAddress, storage_slot: Field) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are adding this here because it was the only function from the nuked inclusion proofs contract that was not present but had functionality in a used e2e test.

@sklppy88 sklppy88 marked this pull request as ready for review February 24, 2025 12:44
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch from 393d16c to d8b7add Compare February 24, 2025 13:03
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch 2 times, most recently from 3df202b to 2b5c42c Compare February 27, 2025 14:54
@sklppy88 sklppy88 changed the base branch from ek/fix/make-block-number-in-txe-make-sense to graphite-base/12215 February 27, 2025 15:12
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch from 2b5c42c to 0522cb7 Compare February 27, 2025 15:12
@sklppy88 sklppy88 force-pushed the graphite-base/12215 branch from 8966263 to d74c4a6 Compare February 27, 2025 15:12
@sklppy88 sklppy88 changed the base branch from graphite-base/12215 to ek/fix/make-block-number-in-txe-make-sense February 27, 2025 15:12
@sklppy88 sklppy88 changed the base branch from ek/fix/make-block-number-in-txe-make-sense to graphite-base/12215 February 27, 2025 15:35
@sklppy88 sklppy88 requested a review from benesjan February 27, 2025 15:36
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch from 0522cb7 to 1a5b205 Compare February 27, 2025 15:58
@sklppy88 sklppy88 force-pushed the graphite-base/12215 branch from d74c4a6 to 8181149 Compare February 27, 2025 15:58
@sklppy88 sklppy88 changed the base branch from graphite-base/12215 to master February 27, 2025 15:58
Copy link
Contributor

@benesjan benesjan left a comment

Choose a reason for hiding this comment

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

Looks good. The globals made it way more readable.

Feel free to merge once you address my last comments.

@@ -14,6 +14,11 @@ use crate::oracle::{
use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR;
use protocol_types::traits::Packable;

// This is the first nullifier emitted from the TXe. It is an arbitrary number assigned in the TXe that is
// larger than the first prefilled subtree of the nullifier tree. We use know FIRST_NULLIFIER_EMITTED_IN_TXE exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// larger than the first prefilled subtree of the nullifier tree. We use know FIRST_NULLIFIER_EMITTED_IN_TXE exists
// larger than the first prefilled subtree of the nullifier tree. We know FIRST_NULLIFIER_EMITTED_IN_TXE exists

Where does TXE emit this? I cannot find that the global variable used when emitting it. Would use it for that if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's emitted in the first block that gets automined, txe_oracle.ts:678/760. I didn't want to make a constant that's used across both ts / nr as I thought that would be a bit overkill / not protocol enshrined as a constant.

Copy link
Contributor

Choose a reason for hiding this comment

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

TBH I find this quite problematic as this breaks the tests if that random value injected in txe_oracle.ts changes. I think the best thing here would be to just not use it and insert our own nullifier in the tests. That shouldn't be a problem, no?

Copy link
Contributor Author

@sklppy88 sklppy88 Feb 27, 2025

Choose a reason for hiding this comment

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

Yeah you make a good point. I've added an issue tag here to #12226 and will address in a downstack PR as soon as this is in. Will nuke this completely and not make the assumption that this nullifier will exist.

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 has been addressed in #12360.

(&mut env, contract_address, owner)
}

// These tests need to be here instead of a saner place like aztec-nr/aztec/src/history/contract_inclusion/test.nr
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a comment to noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr that it's tested here since the tests are in a bit of a random location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, have added a comment in that location !

let (env, contract_address) = setup();

let context = env.private();
let header_at_block_before_deployment = context.get_block_header_at(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the header name makes it pretty clear but anyway would assign smt. like CONTRACT_DEPLOYED_AT, I would check it matches in the setup when deploying and then use the value here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep you're 100% correct. Have addressed.

let (env, contract_address) = setup();

let context = env.private();
let header_at_block_before_deployment = context.get_block_header_at(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above would replace the "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.

Thank you, addressed !

let (env, contract_address) = setup();

let context = env.private();
let header_at_block_before_deployment = context.get_block_header_at(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above would replace the "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.

Thank you, addressed !

sklppy88 and others added 8 commits February 27, 2025 16:46
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch 2 times, most recently from 4737290 to 2113ba0 Compare February 27, 2025 17:27
@sklppy88 sklppy88 force-pushed the ek/feat/add-historical-tests-aztec-nr branch from 2113ba0 to 53e8d21 Compare February 27, 2025 18:14
@sklppy88 sklppy88 merged commit a301f72 into master Feb 27, 2025
10 checks passed
@sklppy88 sklppy88 deleted the ek/feat/add-historical-tests-aztec-nr branch February 27, 2025 18:44
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