1
1
import { TestCircuitVerifier } from '@aztec/bb-prover' ;
2
2
import { EthAddress } from '@aztec/foundation/eth-address' ;
3
3
import { Fr } from '@aztec/foundation/fields' ;
4
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree' ;
4
5
import type { P2P } from '@aztec/p2p' ;
6
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts' ;
5
7
import { computeFeePayerBalanceLeafSlot } from '@aztec/protocol-contracts/fee-juice' ;
6
8
import type { GlobalVariableBuilder } from '@aztec/sequencer-client' ;
7
9
import { AztecAddress } from '@aztec/stdlib/aztec-address' ;
@@ -14,7 +16,15 @@ import { RollupValidationRequests } from '@aztec/stdlib/kernel';
14
16
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging' ;
15
17
import { mockTx } from '@aztec/stdlib/testing' ;
16
18
import { MerkleTreeId , PublicDataTreeLeaf , PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees' ;
17
- import { BlockHeader , GlobalVariables , MaxBlockNumber , TX_ERROR_INVALID_BLOCK_NUMBER } from '@aztec/stdlib/tx' ;
19
+ import {
20
+ BlockHeader ,
21
+ GlobalVariables ,
22
+ MaxBlockNumber ,
23
+ TX_ERROR_DUPLICATE_NULLIFIER_IN_TX ,
24
+ TX_ERROR_INCORRECT_L1_CHAIN_ID ,
25
+ TX_ERROR_INCORRECT_ROLLUP_VERSION ,
26
+ TX_ERROR_INVALID_BLOCK_NUMBER ,
27
+ } from '@aztec/stdlib/tx' ;
18
28
19
29
import { readFileSync } from 'fs' ;
20
30
import { type MockProxy , mock } from 'jest-mock-extended' ;
@@ -41,6 +51,10 @@ describe('aztec node', () => {
41
51
numberOfNonRevertiblePublicCallRequests : 0 ,
42
52
numberOfRevertiblePublicCallRequests : 0 ,
43
53
feePayer,
54
+ chainId,
55
+ version : rollupVersion ,
56
+ vkTreeRoot : getVKTreeRoot ( ) ,
57
+ protocolContractTreeRoot,
44
58
} ) ;
45
59
} ;
46
60
@@ -131,10 +145,6 @@ describe('aztec node', () => {
131
145
describe ( 'tx validation' , ( ) => {
132
146
it ( 'tests that the node correctly validates double spends' , async ( ) => {
133
147
const txs = await Promise . all ( [ mockTxForRollup ( 0x10000 ) , mockTxForRollup ( 0x20000 ) ] ) ;
134
- txs . forEach ( tx => {
135
- tx . data . constants . txContext . chainId = chainId ;
136
- tx . data . constants . txContext . version = rollupVersion ;
137
- } ) ;
138
148
const doubleSpendTx = txs [ 0 ] ;
139
149
const doubleSpendWithExistingTx = txs [ 1 ] ;
140
150
lastBlockNumber += 1 ;
@@ -144,7 +154,10 @@ describe('aztec node', () => {
144
154
// We push a duplicate nullifier that was created in the same transaction
145
155
doubleSpendTx . data . forRollup ! . end . nullifiers [ 1 ] = doubleSpendTx . data . forRollup ! . end . nullifiers [ 0 ] ;
146
156
147
- expect ( await node . isValidTx ( doubleSpendTx ) ) . toEqual ( { result : 'invalid' , reason : [ 'Duplicate nullifier in tx' ] } ) ;
157
+ expect ( await node . isValidTx ( doubleSpendTx ) ) . toEqual ( {
158
+ result : 'invalid' ,
159
+ reason : [ TX_ERROR_DUPLICATE_NULLIFIER_IN_TX ] ,
160
+ } ) ;
148
161
149
162
expect ( await node . isValidTx ( doubleSpendWithExistingTx ) ) . toEqual ( { result : 'valid' } ) ;
150
163
@@ -169,37 +182,26 @@ describe('aztec node', () => {
169
182
170
183
it ( 'tests that the node correctly validates chain id' , async ( ) => {
171
184
const tx = await mockTxForRollup ( 0x10000 ) ;
172
- tx . data . constants . txContext . chainId = chainId ;
173
- tx . data . constants . txContext . version = rollupVersion ;
174
-
175
185
expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'valid' } ) ;
176
186
177
187
// We make the chain id on the tx not equal to the configured chain id
178
188
tx . data . constants . txContext . chainId = new Fr ( 1n + chainId . toBigInt ( ) ) ;
179
189
180
- expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'invalid' , reason : [ 'Incorrect chain id' ] } ) ;
190
+ expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'invalid' , reason : [ TX_ERROR_INCORRECT_L1_CHAIN_ID ] } ) ;
181
191
} ) ;
182
192
183
193
it ( 'tests that the node correctly validates rollup version' , async ( ) => {
184
194
const tx = await mockTxForRollup ( 0x10000 ) ;
185
- tx . data . constants . txContext . chainId = chainId ;
186
- tx . data . constants . txContext . version = rollupVersion ;
187
-
188
195
expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'valid' } ) ;
189
196
190
197
// We make the chain id on the tx not equal to the configured chain id
191
198
tx . data . constants . txContext . version = new Fr ( 1n + rollupVersion . toBigInt ( ) ) ;
192
199
193
- expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'invalid' , reason : [ 'Incorrect rollup version' ] } ) ;
200
+ expect ( await node . isValidTx ( tx ) ) . toEqual ( { result : 'invalid' , reason : [ TX_ERROR_INCORRECT_ROLLUP_VERSION ] } ) ;
194
201
} ) ;
195
202
196
203
it ( 'tests that the node correctly validates max block numbers' , async ( ) => {
197
204
const txs = await Promise . all ( [ mockTxForRollup ( 0x10000 ) , mockTxForRollup ( 0x20000 ) , mockTxForRollup ( 0x30000 ) ] ) ;
198
- txs . forEach ( tx => {
199
- tx . data . constants . txContext . chainId = chainId ;
200
- tx . data . constants . txContext . version = rollupVersion ;
201
- } ) ;
202
-
203
205
const noMaxBlockNumberMetadata = txs [ 0 ] ;
204
206
const invalidMaxBlockNumberMetadata = txs [ 1 ] ;
205
207
const validMaxBlockNumberMetadata = txs [ 2 ] ;
@@ -226,19 +228,19 @@ describe('aztec node', () => {
226
228
} ) ;
227
229
} ) ;
228
230
229
- describe ( 'Node Info' , ( ) => {
230
- it ( 'returns the correct node version' , async ( ) => {
231
- const releasePleaseVersionFile = readFileSync (
232
- resolve ( dirname ( fileURLToPath ( import . meta. url ) ) , '../../../../.release-please-manifest.json' ) ,
233
- ) . toString ( ) ;
234
- const releasePleaseVersion = JSON . parse ( releasePleaseVersionFile ) [ '.' ] ;
235
-
236
- const nodeInfo = await node . getNodeInfo ( ) ;
237
- expect ( nodeInfo . nodeVersion ) . toBe ( releasePleaseVersion ) ;
231
+ describe ( 'getters' , ( ) => {
232
+ describe ( 'node info' , ( ) => {
233
+ it ( 'returns the correct node version' , async ( ) => {
234
+ const releasePleaseVersionFile = readFileSync (
235
+ resolve ( dirname ( fileURLToPath ( import . meta. url ) ) , '../../../../.release-please-manifest.json' ) ,
236
+ ) . toString ( ) ;
237
+ const releasePleaseVersion = JSON . parse ( releasePleaseVersionFile ) [ '.' ] ;
238
+
239
+ const nodeInfo = await node . getNodeInfo ( ) ;
240
+ expect ( nodeInfo . nodeVersion ) . toBe ( releasePleaseVersion ) ;
241
+ } ) ;
238
242
} ) ;
239
- } ) ;
240
243
241
- describe ( 'getters' , ( ) => {
242
244
describe ( 'getBlockHeader' , ( ) => {
243
245
let initialHeader : BlockHeader ;
244
246
let header1 : BlockHeader ;
0 commit comments