-
Notifications
You must be signed in to change notification settings - Fork 310
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
chore: Validate RPC inputs #9672
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
df5e611
Schema for proving job source
spalladino 3a81faa
Schema test for proving job source
spalladino 419d95b
Test for prover node schema
spalladino be74193
Fix for parsing coerced schemas
spalladino fb2843a
Schema for archiver
spalladino 8135429
PXE schema
spalladino 41442a5
Add ZodFor type
spalladino f599158
Schema for aztec node
spalladino bcd164f
Schema for bot runner
spalladino a9659d0
Schema for prover agent api
spalladino cdfa8cb
Schema for txe dispatcher api
spalladino b09a6bb
Add service interface to remove stop method from apis
spalladino bd3a935
Switch to safe json rpc server and client and delete old ones
spalladino 255fe5d
Clean up class conversion code
spalladino 938a014
Fixes post rebase
spalladino ec4b562
Extra logging
spalladino 2a24bf0
AztecAddress is no longer a Fr
spalladino 124ff85
Ignore artifact metadata until 6021 lands
spalladino 00320a9
Use a nullable optional type for optional parameters
spalladino 94fe1a9
Handle serialized objects in abi encoder
spalladino 62995ae
Fix tests
spalladino d0c04d4
Update protocol contracts
spalladino 3e66c1e
Fix pxe setup
spalladino 153762b
Minor fixes
spalladino 24eb6f8
Fix wrong PXE call that has been broken for over a year
spalladino 369fb71
Fixes after another rebase
spalladino 51f104d
Do not default listen addr to IPv4 if not set on startHttpServer
spalladino 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 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 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,2 +1,11 @@ | ||
export * from './archiver_client.js'; | ||
export * from './archiver_server.js'; | ||
import { type ArchiverApi, ArchiverApiSchema } from '@aztec/circuit-types'; | ||
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; | ||
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
|
||
export function createArchiverClient(url: string, fetch = makeFetch([1, 2, 3], true)): ArchiverApi { | ||
return createSafeJsonRpcClient<ArchiverApi>(url, ArchiverApiSchema, false, 'archiver', fetch); | ||
} | ||
|
||
export function createArchiverRpcServer(handler: ArchiverApi) { | ||
return createSafeJsonRpcServer(handler, ArchiverApiSchema); | ||
} |
This file contains 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,66 +1,11 @@ | ||
import { | ||
type AztecNode, | ||
EncryptedL2NoteLog, | ||
EncryptedNoteL2BlockL2Logs, | ||
EpochProofQuote, | ||
ExtendedUnencryptedL2Log, | ||
L2Block, | ||
LogId, | ||
NullifierMembershipWitness, | ||
PublicDataWitness, | ||
PublicSimulationOutput, | ||
SiblingPath, | ||
Tx, | ||
TxEffect, | ||
TxHash, | ||
TxReceipt, | ||
UnencryptedL2BlockL2Logs, | ||
} from '@aztec/circuit-types'; | ||
import { FunctionSelector, Header, PublicKeys } from '@aztec/circuits.js'; | ||
import { NoteSelector } from '@aztec/foundation/abi'; | ||
import { AztecAddress } from '@aztec/foundation/aztec-address'; | ||
import { Buffer32 } from '@aztec/foundation/buffer'; | ||
import { EthAddress } from '@aztec/foundation/eth-address'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
import { JsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
import { type AztecNode, AztecNodeApiSchema } from '@aztec/circuit-types'; | ||
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server'; | ||
|
||
/** | ||
* Wrap an AztecNode instance with a JSON RPC HTTP server. | ||
* @param node - The AztecNode | ||
* @returns An JSON-RPC HTTP server | ||
*/ | ||
export function createAztecNodeRpcServer(node: AztecNode) { | ||
const rpc = new JsonRpcServer( | ||
node, | ||
{ | ||
AztecAddress, | ||
EthAddress, | ||
ExtendedUnencryptedL2Log, | ||
Fr, | ||
FunctionSelector, | ||
Header, | ||
L2Block, | ||
TxEffect, | ||
LogId, | ||
TxHash, | ||
Buffer32, | ||
PublicDataWitness, | ||
PublicKeys, | ||
SiblingPath, | ||
}, | ||
{ | ||
EncryptedNoteL2BlockL2Logs, | ||
EncryptedL2NoteLog, | ||
NoteSelector, | ||
NullifierMembershipWitness, | ||
PublicSimulationOutput, | ||
Tx, | ||
TxReceipt, | ||
UnencryptedL2BlockL2Logs, | ||
EpochProofQuote, | ||
}, | ||
// disable methods not part of the AztecNode interface | ||
['start', 'stop'], | ||
); | ||
return rpc; | ||
return createSafeJsonRpcServer(node, AztecNodeApiSchema); | ||
} |
This file contains 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 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 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 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 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 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,97 +1,12 @@ | ||
import { | ||
AuthWitness, | ||
CountedNoteLog, | ||
CountedPublicExecutionRequest, | ||
EncryptedL2Log, | ||
EncryptedL2NoteLog, | ||
EncryptedNoteL2BlockL2Logs, | ||
EventMetadata, | ||
ExtendedNote, | ||
ExtendedUnencryptedL2Log, | ||
L2Block, | ||
LogId, | ||
Note, | ||
NullifierMembershipWitness, | ||
type PXE, | ||
PrivateExecutionResult, | ||
SiblingPath, | ||
Tx, | ||
TxEffect, | ||
TxExecutionRequest, | ||
TxHash, | ||
TxProvingResult, | ||
TxReceipt, | ||
TxSimulationResult, | ||
UnencryptedL2BlockL2Logs, | ||
UnencryptedL2Log, | ||
UniqueNote, | ||
} from '@aztec/circuit-types'; | ||
import { | ||
AztecAddress, | ||
CompleteAddress, | ||
EthAddress, | ||
Fr, | ||
FunctionSelector, | ||
GrumpkinScalar, | ||
Point, | ||
PrivateCircuitPublicInputs, | ||
PublicKeys, | ||
} from '@aztec/circuits.js'; | ||
import { EventSelector, NoteSelector } from '@aztec/foundation/abi'; | ||
import { Buffer32 } from '@aztec/foundation/buffer'; | ||
import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; | ||
import { type PXE, PXESchema } from '@aztec/circuit-types'; | ||
import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; | ||
|
||
/** | ||
* Creates a JSON-RPC client to remotely talk to PXE. | ||
* @param url - The URL of the PXE. | ||
* @param fetch - The fetch implementation to use. | ||
* @returns A JSON-RPC client of PXE. | ||
*/ | ||
export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)): PXE => | ||
createJsonRpcClient<PXE>( | ||
url, | ||
{ | ||
AuthWitness, | ||
AztecAddress, | ||
CompleteAddress, | ||
FunctionSelector, | ||
EthAddress, | ||
EventSelector, | ||
ExtendedNote, | ||
UniqueNote, | ||
ExtendedUnencryptedL2Log, | ||
Fr, | ||
GrumpkinScalar, | ||
L2Block, | ||
TxEffect, | ||
LogId, | ||
Note, | ||
Point, | ||
PublicKeys, | ||
TxExecutionRequest, | ||
TxHash, | ||
Buffer32, | ||
SiblingPath, | ||
}, | ||
{ | ||
EncryptedNoteL2BlockL2Logs, | ||
EncryptedL2NoteLog, | ||
EncryptedL2Log, | ||
EventMetadata, | ||
UnencryptedL2Log, | ||
NoteSelector, | ||
NullifierMembershipWitness, | ||
TxSimulationResult, | ||
TxProvingResult, | ||
PrivateCircuitPublicInputs, | ||
PrivateExecutionResult, | ||
CountedPublicExecutionRequest, | ||
CountedNoteLog, | ||
Tx, | ||
TxReceipt, | ||
UnencryptedL2BlockL2Logs, | ||
}, | ||
false, | ||
'pxe', | ||
fetch, | ||
) as PXE; | ||
export function createPXEClient(url: string, fetch = makeFetch([1, 2, 3], false)): PXE { | ||
return createSafeJsonRpcClient<PXE>(url, PXESchema, false, 'pxe', fetch); | ||
} |
This file contains 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
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.
Very happy to get rid of the inheritance here