-
Notifications
You must be signed in to change notification settings - Fork 596
feat(pxe)!: add source and block-range filtering to get_logs_by_tag #23326
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
Open
nchamo
wants to merge
3
commits into
merge-train/fairies
Choose a base branch
from
nchamo/f-657-add-fromto-block-range-filtering-to-get_logs_by_tag
base: merge-train/fairies
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 57 additions & 11 deletions
68
noir-projects/aztec-nr/aztec/src/messages/processing/log_retrieval_request.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 71 additions & 2 deletions
73
yarn-project/pxe/src/contract_function_simulator/noir-structs/log_retrieval_request.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,88 @@ | ||
| import { BlockNumber } from '@aztec/foundation/branded-types'; | ||
| import { Fr } from '@aztec/foundation/curves/bn254'; | ||
| import { AztecAddress } from '@aztec/stdlib/aztec-address'; | ||
| import { Tag } from '@aztec/stdlib/logs'; | ||
|
|
||
| import { LogRetrievalRequest } from './log_retrieval_request.js'; | ||
| import { LogRetrievalRequest, LogSource } from './log_retrieval_request.js'; | ||
|
|
||
| describe('LogRetrievalRequest', () => { | ||
| it('output of Noir serialization deserializes as expected', () => { | ||
| it('output of Noir serialization with defaults deserializes as expected', () => { | ||
| const serialized = [ | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000002', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000002', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| ].map(Fr.fromHexString); | ||
|
|
||
| const request = LogRetrievalRequest.fromFields(serialized); | ||
|
|
||
| expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); | ||
| expect(request.tag).toEqual(new Tag(new Fr(2))); | ||
| expect(request.source).toEqual(LogSource.PUBLIC_AND_PRIVATE); | ||
| expect(request.fromBlock).toBeUndefined(); | ||
| expect(request.toBlock).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('output of Noir serialization with values deserializes as expected', () => { | ||
| const serialized = [ | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000002', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x000000000000000000000000000000000000000000000000000000000000000a', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000014', | ||
| ].map(Fr.fromHexString); | ||
|
|
||
| const request = LogRetrievalRequest.fromFields(serialized); | ||
|
|
||
| expect(request.contractAddress).toEqual(AztecAddress.fromBigInt(1n)); | ||
| expect(request.tag).toEqual(new Tag(new Fr(2))); | ||
| expect(request.source).toEqual(LogSource.PUBLIC); | ||
| expect(request.fromBlock).toEqual(BlockNumber(10)); | ||
| expect(request.toBlock).toEqual(BlockNumber(20)); | ||
| }); | ||
|
|
||
| it('rejects an invalid LogSource value', () => { | ||
| const serialized = [ | ||
| '0x0000000000000000000000000000000000000000000000000000000000000001', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000002', | ||
| '0x000000000000000000000000000000000000000000000000000000000000002a', // 42 — invalid | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| '0x0000000000000000000000000000000000000000000000000000000000000000', | ||
| ].map(Fr.fromHexString); | ||
|
|
||
| expect(() => LogRetrievalRequest.fromFields(serialized)).toThrow(/Invalid LogSource value 42/); | ||
| }); | ||
|
|
||
| it('accepts all valid LogSource values', () => { | ||
| for (const source of [LogSource.PRIVATE, LogSource.PUBLIC, LogSource.PUBLIC_AND_PRIVATE]) { | ||
| const fields = new LogRetrievalRequest(AztecAddress.fromBigInt(1n), new Tag(new Fr(2)), source).toFields(); | ||
| const restored = LogRetrievalRequest.fromFields(fields); | ||
| expect(restored.source).toEqual(source); | ||
| } | ||
| }); | ||
|
|
||
| it('round-trips through toFields and fromFields', () => { | ||
| const original = new LogRetrievalRequest( | ||
| AztecAddress.fromBigInt(42n), | ||
| new Tag(new Fr(99)), | ||
| LogSource.PRIVATE, | ||
| BlockNumber(5), | ||
| BlockNumber(100), | ||
| ); | ||
|
|
||
| const restored = LogRetrievalRequest.fromFields(original.toFields()); | ||
|
|
||
| expect(restored.contractAddress).toEqual(original.contractAddress); | ||
| expect(restored.tag).toEqual(original.tag); | ||
| expect(restored.source).toEqual(original.source); | ||
| expect(restored.fromBlock).toEqual(original.fromBlock); | ||
| expect(restored.toBlock).toEqual(original.toBlock); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected this to be 12 (the version we decided protocol contracts were going to use), but apparently we are keeping it up to date with PXE's version