-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Validate block proposal txs iteratively
- Loading branch information
1 parent
ab3f318
commit da8056a
Showing
41 changed files
with
843 additions
and
930 deletions.
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 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
10 changes: 3 additions & 7 deletions
10
yarn-project/circuit-types/src/tx/validator/empty_validator.ts
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,11 +1,7 @@ | ||
import { type AnyTx, type TxValidator } from './tx_validator.js'; | ||
import { type AnyTx, type TxValidationResult, type TxValidator } from './tx_validator.js'; | ||
|
||
export class EmptyTxValidator<T extends AnyTx = AnyTx> implements TxValidator<T> { | ||
public validateTxs(txs: T[]): Promise<[validTxs: T[], invalidTxs: T[], skippedTxs: T[]]> { | ||
return Promise.resolve([txs, [], []]); | ||
} | ||
|
||
public validateTx(_tx: T): Promise<boolean> { | ||
return Promise.resolve(true); | ||
public validateTx(_tx: T): Promise<TxValidationResult> { | ||
return Promise.resolve({ result: 'valid' }); | ||
} | ||
} |
18 changes: 16 additions & 2 deletions
18
yarn-project/circuit-types/src/tx/validator/tx_validator.ts
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,9 +1,23 @@ | ||
import { type ZodFor } from '@aztec/foundation/schemas'; | ||
|
||
import { z } from 'zod'; | ||
|
||
import { type ProcessedTx } from '../processed_tx.js'; | ||
import { type Tx } from '../tx.js'; | ||
|
||
export type AnyTx = Tx | ProcessedTx; | ||
|
||
export type TxValidationResult = | ||
| { result: 'valid' } | ||
| { result: 'invalid'; reason: string[] } | ||
| { result: 'skipped'; reason: string[] }; | ||
|
||
export interface TxValidator<T extends AnyTx = AnyTx> { | ||
validateTx(tx: T): Promise<boolean>; | ||
validateTxs(txs: T[]): Promise<[validTxs: T[], invalidTxs: T[], skippedTxs?: T[]]>; | ||
validateTx(tx: T): Promise<TxValidationResult>; | ||
} | ||
|
||
export const TxValidationResultSchema = z.discriminatedUnion('result', [ | ||
z.object({ result: z.literal('valid'), reason: z.array(z.string()).optional() }), | ||
z.object({ result: z.literal('invalid'), reason: z.array(z.string()) }), | ||
z.object({ result: z.literal('skipped'), reason: z.array(z.string()) }), | ||
]) satisfies ZodFor<TxValidationResult>; |
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
Oops, something went wrong.