@aztec/sequencer-client 0.1.0-alpha23 → 0.1.0-alpha40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.tsbuildinfo +1 -1
- package/dest/block_builder/index.d.ts +2 -2
- package/dest/block_builder/index.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.d.ts +7 -7
- package/dest/block_builder/solo_block_builder.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.js +49 -53
- package/dest/block_builder/solo_block_builder.test.d.ts +2 -2
- package/dest/block_builder/solo_block_builder.test.d.ts.map +1 -1
- package/dest/block_builder/solo_block_builder.test.js +27 -26
- package/dest/block_builder/types.d.ts +1 -1
- package/dest/block_builder/types.d.ts.map +1 -1
- package/dest/client/sequencer-client.d.ts +1 -1
- package/dest/client/sequencer-client.d.ts.map +1 -1
- package/dest/client/sequencer-client.js +3 -3
- package/dest/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +8 -5
- package/dest/global_variable_builder/global_builder.d.ts +17 -0
- package/dest/global_variable_builder/global_builder.d.ts.map +1 -1
- package/dest/global_variable_builder/global_builder.js +1 -1
- package/dest/global_variable_builder/viem-reader.d.ts +0 -12
- package/dest/global_variable_builder/viem-reader.d.ts.map +1 -1
- package/dest/global_variable_builder/viem-reader.js +2 -14
- package/dest/prover/empty.d.ts.map +1 -1
- package/dest/prover/empty.js +1 -1
- package/dest/prover/index.d.ts +23 -0
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/publisher/config.d.ts +3 -3
- package/dest/publisher/config.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.d.ts +3 -3
- package/dest/publisher/l1-publisher.d.ts.map +1 -1
- package/dest/publisher/l1-publisher.js +5 -3
- package/dest/publisher/l1-publisher.test.js +2 -2
- package/dest/publisher/viem-tx-sender.d.ts +4 -4
- package/dest/publisher/viem-tx-sender.d.ts.map +1 -1
- package/dest/publisher/viem-tx-sender.js +11 -11
- package/dest/sequencer/config.d.ts +1 -1
- package/dest/sequencer/config.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.d.ts +2 -2
- package/dest/sequencer/processed_tx.d.ts.map +1 -1
- package/dest/sequencer/processed_tx.js +3 -3
- package/dest/sequencer/public_processor.d.ts +11 -10
- package/dest/sequencer/public_processor.d.ts.map +1 -1
- package/dest/sequencer/public_processor.js +24 -22
- package/dest/sequencer/public_processor.test.js +15 -17
- package/dest/sequencer/sequencer.d.ts +4 -4
- package/dest/sequencer/sequencer.d.ts.map +1 -1
- package/dest/sequencer/sequencer.js +18 -15
- package/dest/sequencer/sequencer.test.js +5 -5
- package/dest/sequencer/utils.d.ts +2 -2
- package/dest/sequencer/utils.d.ts.map +1 -1
- package/dest/sequencer/utils.js +8 -5
- package/dest/simulator/index.d.ts +2 -2
- package/dest/simulator/public_executor.d.ts +3 -20
- package/dest/simulator/public_executor.d.ts.map +1 -1
- package/dest/simulator/public_executor.js +16 -35
- package/dest/simulator/public_kernel.d.ts.map +1 -1
- package/dest/simulator/public_kernel.js +1 -1
- package/dest/simulator/rollup.d.ts.map +1 -1
- package/dest/simulator/rollup.js +1 -1
- package/package.json +10 -10
- package/src/block_builder/index.ts +3 -2
- package/src/block_builder/solo_block_builder.test.ts +46 -38
- package/src/block_builder/solo_block_builder.ts +79 -88
- package/src/block_builder/types.ts +1 -1
- package/src/client/sequencer-client.ts +3 -3
- package/src/config.ts +11 -7
- package/src/global_variable_builder/global_builder.ts +17 -0
- package/src/global_variable_builder/viem-reader.ts +5 -15
- package/src/prover/empty.ts +1 -0
- package/src/prover/index.ts +26 -0
- package/src/publisher/config.ts +3 -2
- package/src/publisher/l1-publisher.test.ts +3 -2
- package/src/publisher/l1-publisher.ts +18 -8
- package/src/publisher/viem-tx-sender.ts +14 -13
- package/src/sequencer/config.ts +1 -1
- package/src/sequencer/processed_tx.ts +3 -3
- package/src/sequencer/public_processor.test.ts +38 -18
- package/src/sequencer/public_processor.ts +33 -25
- package/src/sequencer/sequencer.test.ts +7 -5
- package/src/sequencer/sequencer.ts +20 -16
- package/src/sequencer/utils.ts +19 -11
- package/src/simulator/index.ts +2 -2
- package/src/simulator/public_executor.ts +15 -34
- package/src/simulator/public_kernel.ts +1 -0
- package/src/simulator/rollup.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_kernel.d.ts","sourceRoot":"","sources":["../../src/simulator/public_kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAA+B,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"public_kernel.d.ts","sourceRoot":"","sources":["../../src/simulator/public_kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAA+B,MAAM,oBAAoB,CAAC;AAE/G,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE1D;;GAEG;AACH,qBAAa,gCAAiC,YAAW,4BAA4B;IACnF;;;;OAIG;IACI,+BAA+B,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAKpG;;;;OAIG;IACH,oCAAoC,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAInG"}
|
|
@@ -24,4 +24,4 @@ export class WasmPublicKernelCircuitSimulator {
|
|
|
24
24
|
return simulatePublicKernelCircuit(input);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX2tlcm5lbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zaW11bGF0b3IvcHVibGljX2tlcm5lbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQWdELDJCQUEyQixFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFJL0c7O0dBRUc7QUFDSCxNQUFNLE9BQU8sZ0NBQWdDO0lBQzNDOzs7O09BSUc7SUFDSSwrQkFBK0IsQ0FBQyxLQUF5QjtRQUM5RCxJQUFJLENBQUMsS0FBSyxDQUFDLGNBQWMsQ0FBQyxZQUFZLENBQUMsU0FBUztZQUFFLE1BQU0sSUFBSSxLQUFLLENBQUMseUNBQXlDLENBQUMsQ0FBQztRQUM3RyxPQUFPLDJCQUEyQixDQUFDLEtBQUssQ0FBQyxDQUFDO0lBQzVDLENBQUM7SUFFRDs7OztPQUlHO0lBQ0gsb0NBQW9DLENBQUMsS0FBeUI7UUFDNUQsSUFBSSxLQUFLLENBQUMsY0FBYyxDQUFDLFlBQVksQ0FBQyxTQUFTO1lBQUUsTUFBTSxJQUFJLEtBQUssQ0FBQyx3Q0FBd0MsQ0FBQyxDQUFDO1FBQzNHLE9BQU8sMkJBQTJCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDNUMsQ0FBQztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/simulator/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EAEjB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/simulator/rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EAEjB,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IAChE,OAAO,CAAC,iBAAiB,CAAoB;gBAEjC,IAAI,EAAE,YAAY;IAI9B;;;OAGG;WACiB,GAAG;IAIvB;;;;OAIG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAGlF;;;;OAIG;IACH,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAGpF;;;;OAIG;IACH,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAG5E"}
|
package/dest/simulator/rollup.js
CHANGED
|
@@ -38,4 +38,4 @@ export class WasmRollupCircuitSimulator {
|
|
|
38
38
|
return Promise.resolve(this.rollupWasmWrapper.simulateRootRollup(input));
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
41
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NpbXVsYXRvci9yb2xsdXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUdMLFlBQVksRUFFWixpQkFBaUIsR0FHbEIsTUFBTSxvQkFBb0IsQ0FBQztBQUk1Qjs7R0FFRztBQUNILE1BQU0sT0FBTywwQkFBMEI7SUFHckMsWUFBWSxJQUFrQjtRQUM1QixJQUFJLENBQUMsaUJBQWlCLEdBQUcsSUFBSSxpQkFBaUIsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUN2RCxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksTUFBTSxDQUFDLEtBQUssQ0FBQyxHQUFHO1FBQ3JCLE9BQU8sSUFBSSxJQUFJLENBQUMsTUFBTSxZQUFZLENBQUMsR0FBRyxFQUFFLENBQUMsQ0FBQztJQUM1QyxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILGlCQUFpQixDQUFDLEtBQXVCO1FBQ3ZDLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsaUJBQWlCLENBQUMsa0JBQWtCLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztJQUMzRSxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNILGtCQUFrQixDQUFDLEtBQXdCO1FBQ3pDLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsaUJBQWlCLENBQUMsbUJBQW1CLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztJQUM1RSxDQUFDO0lBQ0Q7Ozs7T0FJRztJQUNILGlCQUFpQixDQUFDLEtBQXVCO1FBQ3ZDLE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsaUJBQWlCLENBQUMsa0JBQWtCLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztJQUMzRSxDQUFDO0NBQ0YifQ==
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/sequencer-client",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-alpha40",
|
|
4
4
|
"exports": "./dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@aztec/acir-simulator": "0.1.0-
|
|
8
|
-
"@aztec/circuits.js": "0.1.0-
|
|
9
|
-
"@aztec/ethereum": "0.1.0-
|
|
10
|
-
"@aztec/foundation": "0.1.0-
|
|
11
|
-
"@aztec/l1-artifacts": "0.1.0-
|
|
12
|
-
"@aztec/merkle-tree": "0.1.0-
|
|
13
|
-
"@aztec/p2p": "0.1.0-
|
|
14
|
-
"@aztec/types": "0.1.0-
|
|
15
|
-
"@aztec/world-state": "0.1.0-
|
|
7
|
+
"@aztec/acir-simulator": "0.1.0-alpha40",
|
|
8
|
+
"@aztec/circuits.js": "0.1.0-alpha40",
|
|
9
|
+
"@aztec/ethereum": "0.1.0-alpha40",
|
|
10
|
+
"@aztec/foundation": "0.1.0-alpha40",
|
|
11
|
+
"@aztec/l1-artifacts": "0.1.0-alpha40",
|
|
12
|
+
"@aztec/merkle-tree": "0.1.0-alpha40",
|
|
13
|
+
"@aztec/p2p": "0.1.0-alpha40",
|
|
14
|
+
"@aztec/types": "0.1.0-alpha40",
|
|
15
|
+
"@aztec/world-state": "0.1.0-alpha40",
|
|
16
16
|
"lodash.chunk": "^4.2.0",
|
|
17
17
|
"lodash.flatmap": "^4.5.0",
|
|
18
18
|
"lodash.pick": "^4.4.0",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { L2Block } from '@aztec/types';
|
|
2
|
-
import { ProcessedTx } from '../sequencer/processed_tx.js';
|
|
3
1
|
import { GlobalVariables, Proof } from '@aztec/circuits.js';
|
|
4
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { L2Block } from '@aztec/types';
|
|
4
|
+
|
|
5
|
+
import { ProcessedTx } from '../sequencer/processed_tx.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Assembles an L2Block from a set of processed transactions.
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
CircuitsWasm,
|
|
6
6
|
Fr,
|
|
7
7
|
GlobalVariables,
|
|
8
|
+
KernelCircuitPublicInputs,
|
|
8
9
|
MAX_NEW_COMMITMENTS_PER_TX,
|
|
9
10
|
MAX_NEW_L2_TO_L1_MSGS_PER_TX,
|
|
10
11
|
MAX_NEW_NULLIFIERS_PER_TX,
|
|
11
12
|
MAX_PUBLIC_CALL_STACK_LENGTH_PER_TX,
|
|
12
13
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
13
|
-
KernelCircuitPublicInputs,
|
|
14
14
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
15
15
|
Proof,
|
|
16
16
|
PublicDataUpdateRequest,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
makeTuple,
|
|
19
19
|
range,
|
|
20
20
|
} from '@aztec/circuits.js';
|
|
21
|
-
import { computeContractLeaf } from '@aztec/circuits.js/abis';
|
|
21
|
+
import { computeBlockHashWithGlobals, computeContractLeaf } from '@aztec/circuits.js/abis';
|
|
22
22
|
import {
|
|
23
23
|
fr,
|
|
24
24
|
makeBaseOrMergeRollupPublicInputs,
|
|
@@ -29,23 +29,26 @@ import {
|
|
|
29
29
|
makeRootRollupPublicInputs,
|
|
30
30
|
} from '@aztec/circuits.js/factories';
|
|
31
31
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
32
|
+
import { to2Fields } from '@aztec/foundation/serialize';
|
|
32
33
|
import {
|
|
33
34
|
ContractData,
|
|
34
35
|
L2Block,
|
|
35
36
|
L2BlockL2Logs,
|
|
36
37
|
MerkleTreeId,
|
|
37
|
-
mockTx,
|
|
38
38
|
PublicDataWrite,
|
|
39
39
|
Tx,
|
|
40
40
|
TxL2Logs,
|
|
41
41
|
makeEmptyLogs,
|
|
42
|
+
mockTx,
|
|
42
43
|
} from '@aztec/types';
|
|
43
44
|
import { MerkleTreeOperations, MerkleTrees } from '@aztec/world-state';
|
|
45
|
+
|
|
44
46
|
import { MockProxy, mock } from 'jest-mock-extended';
|
|
45
47
|
import { default as levelup } from 'levelup';
|
|
46
48
|
import flatMap from 'lodash.flatmap';
|
|
47
49
|
import times from 'lodash.times';
|
|
48
|
-
import { default as memdown
|
|
50
|
+
import { type MemDown, default as memdown } from 'memdown';
|
|
51
|
+
|
|
49
52
|
import { VerificationKeys, getVerificationKeys } from '../mocks/verification_keys.js';
|
|
50
53
|
import { EmptyRollupProver } from '../prover/empty.js';
|
|
51
54
|
import { RollupProver } from '../prover/index.js';
|
|
@@ -54,11 +57,10 @@ import {
|
|
|
54
57
|
makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricTreeRoots,
|
|
55
58
|
makeProcessedTx,
|
|
56
59
|
} from '../sequencer/processed_tx.js';
|
|
57
|
-
import {
|
|
60
|
+
import { getHistoricBlockData } from '../sequencer/utils.js';
|
|
58
61
|
import { RollupSimulator } from '../simulator/index.js';
|
|
59
62
|
import { WasmRollupCircuitSimulator } from '../simulator/rollup.js';
|
|
60
63
|
import { SoloBlockBuilder } from './solo_block_builder.js';
|
|
61
|
-
import { to2Fields } from '@aztec/foundation/serialize';
|
|
62
64
|
|
|
63
65
|
export const createMemDown = () => (memdown as any)() as MemDown<any, any>;
|
|
64
66
|
|
|
@@ -105,9 +107,9 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
105
107
|
mockL1ToL2Messages = new Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(new Fr(0n));
|
|
106
108
|
|
|
107
109
|
// Create mock outputs for simulator
|
|
108
|
-
baseRollupOutputLeft = makeBaseOrMergeRollupPublicInputs();
|
|
109
|
-
baseRollupOutputRight = makeBaseOrMergeRollupPublicInputs();
|
|
110
|
-
rootRollupOutput = makeRootRollupPublicInputs();
|
|
110
|
+
baseRollupOutputLeft = makeBaseOrMergeRollupPublicInputs(0, globalVariables);
|
|
111
|
+
baseRollupOutputRight = makeBaseOrMergeRollupPublicInputs(0, globalVariables);
|
|
112
|
+
rootRollupOutput = makeRootRollupPublicInputs(0, globalVariables);
|
|
111
113
|
|
|
112
114
|
// Set up mocks
|
|
113
115
|
prover.getBaseRollupProof.mockResolvedValue(emptyProof);
|
|
@@ -119,7 +121,7 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
119
121
|
}, 20_000);
|
|
120
122
|
|
|
121
123
|
const makeEmptyProcessedTx = async () => {
|
|
122
|
-
const historicTreeRoots = await
|
|
124
|
+
const historicTreeRoots = await getHistoricBlockData(builderDb);
|
|
123
125
|
return makeEmptyProcessedTxFromHistoricTreeRoots(historicTreeRoots, chainId, version);
|
|
124
126
|
};
|
|
125
127
|
|
|
@@ -147,6 +149,19 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
147
149
|
await expectsDb.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGES_TREE, asBuffer);
|
|
148
150
|
};
|
|
149
151
|
|
|
152
|
+
const updateHistoricBlocksTree = async () => {
|
|
153
|
+
const blockHash = computeBlockHashWithGlobals(
|
|
154
|
+
wasm,
|
|
155
|
+
globalVariables,
|
|
156
|
+
rootRollupOutput.endPrivateDataTreeSnapshot.root,
|
|
157
|
+
rootRollupOutput.endNullifierTreeSnapshot.root,
|
|
158
|
+
rootRollupOutput.endContractTreeSnapshot.root,
|
|
159
|
+
rootRollupOutput.endL1ToL2MessageTreeSnapshot.root,
|
|
160
|
+
rootRollupOutput.endPublicDataTreeRoot,
|
|
161
|
+
);
|
|
162
|
+
await expectsDb.appendLeaves(MerkleTreeId.BLOCKS_TREE, [blockHash.toBuffer()]);
|
|
163
|
+
};
|
|
164
|
+
|
|
150
165
|
const getTreeSnapshot = async (tree: MerkleTreeId) => {
|
|
151
166
|
const treeInfo = await expectsDb.getTreeInfo(tree);
|
|
152
167
|
return new AppendOnlyTreeSnapshot(Fr.fromBuffer(treeInfo.root), Number(treeInfo.size));
|
|
@@ -154,7 +169,7 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
154
169
|
|
|
155
170
|
const buildMockSimulatorInputs = async () => {
|
|
156
171
|
const kernelOutput = makeKernelPublicInputs();
|
|
157
|
-
kernelOutput.constants.
|
|
172
|
+
kernelOutput.constants.blockData = await getHistoricBlockData(expectsDb);
|
|
158
173
|
|
|
159
174
|
const tx = await makeProcessedTx(
|
|
160
175
|
new Tx(
|
|
@@ -187,21 +202,17 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
187
202
|
// Update l1 to l2 data tree
|
|
188
203
|
// And update the root trees now to create proper output to the root rollup circuit
|
|
189
204
|
await updateL1ToL2MessagesTree(mockL1ToL2Messages);
|
|
190
|
-
await expectsDb.updateHistoricRootsTrees();
|
|
191
205
|
rootRollupOutput.endContractTreeSnapshot = await getTreeSnapshot(MerkleTreeId.CONTRACT_TREE);
|
|
192
206
|
rootRollupOutput.endNullifierTreeSnapshot = await getTreeSnapshot(MerkleTreeId.NULLIFIER_TREE);
|
|
193
207
|
rootRollupOutput.endPrivateDataTreeSnapshot = await getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE);
|
|
194
208
|
rootRollupOutput.endPublicDataTreeRoot = (await getTreeSnapshot(MerkleTreeId.PUBLIC_DATA_TREE)).root;
|
|
195
|
-
|
|
196
|
-
MerkleTreeId.CONTRACT_TREE_ROOTS_TREE,
|
|
197
|
-
);
|
|
198
|
-
rootRollupOutput.endTreeOfHistoricPrivateDataTreeRootsSnapshot = await getTreeSnapshot(
|
|
199
|
-
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
|
|
200
|
-
);
|
|
209
|
+
|
|
201
210
|
rootRollupOutput.endL1ToL2MessageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGES_TREE);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
211
|
+
|
|
212
|
+
// Calculate block hash
|
|
213
|
+
rootRollupOutput.globalVariables = globalVariables;
|
|
214
|
+
await updateHistoricBlocksTree();
|
|
215
|
+
rootRollupOutput.endHistoricBlocksTreeSnapshot = await getTreeSnapshot(MerkleTreeId.BLOCKS_TREE);
|
|
205
216
|
|
|
206
217
|
const txs = [...txsLeft, ...txsRight];
|
|
207
218
|
|
|
@@ -220,7 +231,7 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
220
231
|
|
|
221
232
|
const l2Block = L2Block.fromFields({
|
|
222
233
|
number: blockNumber,
|
|
223
|
-
globalVariables
|
|
234
|
+
globalVariables,
|
|
224
235
|
startPrivateDataTreeSnapshot: rootRollupOutput.startPrivateDataTreeSnapshot,
|
|
225
236
|
endPrivateDataTreeSnapshot: rootRollupOutput.endPrivateDataTreeSnapshot,
|
|
226
237
|
startNullifierTreeSnapshot: rootRollupOutput.startNullifierTreeSnapshot,
|
|
@@ -229,15 +240,10 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
229
240
|
endContractTreeSnapshot: rootRollupOutput.endContractTreeSnapshot,
|
|
230
241
|
startPublicDataTreeRoot: rootRollupOutput.startPublicDataTreeRoot,
|
|
231
242
|
endPublicDataTreeRoot: rootRollupOutput.endPublicDataTreeRoot,
|
|
232
|
-
startTreeOfHistoricPrivateDataTreeRootsSnapshot: rootRollupOutput.startTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
233
|
-
endTreeOfHistoricPrivateDataTreeRootsSnapshot: rootRollupOutput.endTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
234
|
-
startTreeOfHistoricContractTreeRootsSnapshot: rootRollupOutput.startTreeOfHistoricContractTreeRootsSnapshot,
|
|
235
|
-
endTreeOfHistoricContractTreeRootsSnapshot: rootRollupOutput.endTreeOfHistoricContractTreeRootsSnapshot,
|
|
236
243
|
startL1ToL2MessageTreeSnapshot: rootRollupOutput.startL1ToL2MessageTreeSnapshot,
|
|
237
244
|
endL1ToL2MessageTreeSnapshot: rootRollupOutput.endL1ToL2MessageTreeSnapshot,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
endTreeOfHistoricL1ToL2MessageTreeRootsSnapshot: rootRollupOutput.endTreeOfHistoricL1ToL2MessageTreeRootsSnapshot,
|
|
245
|
+
startHistoricBlocksTreeSnapshot: rootRollupOutput.startHistoricBlocksTreeSnapshot,
|
|
246
|
+
endHistoricBlocksTreeSnapshot: rootRollupOutput.endHistoricBlocksTreeSnapshot,
|
|
241
247
|
newCommitments,
|
|
242
248
|
newNullifiers,
|
|
243
249
|
newContracts,
|
|
@@ -299,7 +305,7 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
299
305
|
const makeBloatedProcessedTx = async (seed = 0x1) => {
|
|
300
306
|
const tx = mockTx(seed);
|
|
301
307
|
const kernelOutput = KernelCircuitPublicInputs.empty();
|
|
302
|
-
kernelOutput.constants.
|
|
308
|
+
kernelOutput.constants.blockData = await getHistoricBlockData(builderDb);
|
|
303
309
|
kernelOutput.end.publicDataUpdateRequests = makeTuple(
|
|
304
310
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
305
311
|
i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)),
|
|
@@ -378,8 +384,8 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
378
384
|
expect(l2Block.number).toEqual(blockNumber);
|
|
379
385
|
}, 20_000);
|
|
380
386
|
|
|
381
|
-
// This test specifically tests nullifier values which previously caused
|
|
382
|
-
it('
|
|
387
|
+
// This test specifically tests nullifier values which previously caused e2e_private_token test to fail
|
|
388
|
+
it('e2e_private_token edge case regression test on nullifier values', async () => {
|
|
383
389
|
const simulator = await WasmRollupCircuitSimulator.new();
|
|
384
390
|
const prover = new EmptyRollupProver();
|
|
385
391
|
builder = new SoloBlockBuilder(builderDb, vks, simulator, prover);
|
|
@@ -388,12 +394,6 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
388
394
|
updateVals[0] = 19777494491628650244807463906174285795660759352776418619064841306523677458742n;
|
|
389
395
|
updateVals[1] = 10246291467305176436335175657884940686778521321101740385288169037814567547848n;
|
|
390
396
|
|
|
391
|
-
await builderDb.batchInsert(
|
|
392
|
-
MerkleTreeId.NULLIFIER_TREE,
|
|
393
|
-
updateVals.map(v => toBufferBE(v, 32)),
|
|
394
|
-
BaseRollupInputs.NULLIFIER_SUBTREE_HEIGHT,
|
|
395
|
-
);
|
|
396
|
-
|
|
397
397
|
// new added values
|
|
398
398
|
const tx = await makeEmptyProcessedTx();
|
|
399
399
|
tx.data.end.newNullifiers[0] = new Fr(
|
|
@@ -402,8 +402,16 @@ describe('sequencer/solo_block_builder', () => {
|
|
|
402
402
|
tx.data.end.newNullifiers[1] = new Fr(
|
|
403
403
|
17490072961923661940560522096125238013953043065748521735636170028491723851741n,
|
|
404
404
|
);
|
|
405
|
+
|
|
405
406
|
const txs = [tx, await makeEmptyProcessedTx(), await makeEmptyProcessedTx(), await makeEmptyProcessedTx()];
|
|
406
407
|
|
|
408
|
+
// Must be built after the txs are created
|
|
409
|
+
await builderDb.batchInsert(
|
|
410
|
+
MerkleTreeId.NULLIFIER_TREE,
|
|
411
|
+
updateVals.map(v => toBufferBE(v, 32)),
|
|
412
|
+
BaseRollupInputs.NULLIFIER_SUBTREE_HEIGHT,
|
|
413
|
+
);
|
|
414
|
+
|
|
407
415
|
const [l2Block] = await builder.buildL2Block(globalVariables, txs, mockL1ToL2Messages);
|
|
408
416
|
|
|
409
417
|
expect(l2Block.number).toEqual(blockNumber);
|
|
@@ -2,18 +2,16 @@ import {
|
|
|
2
2
|
AppendOnlyTreeSnapshot,
|
|
3
3
|
BaseOrMergeRollupPublicInputs,
|
|
4
4
|
BaseRollupInputs,
|
|
5
|
-
CONTRACT_TREE_ROOTS_TREE_HEIGHT,
|
|
6
5
|
CircuitsWasm,
|
|
7
6
|
ConstantBaseRollupData,
|
|
8
7
|
GlobalVariables,
|
|
9
|
-
|
|
8
|
+
HISTORIC_BLOCKS_TREE_HEIGHT,
|
|
10
9
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
11
10
|
MembershipWitness,
|
|
12
11
|
MergeRollupInputs,
|
|
13
12
|
NULLIFIER_TREE_HEIGHT,
|
|
14
13
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
15
14
|
NullifierLeafPreimage,
|
|
16
|
-
PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT,
|
|
17
15
|
PreviousKernelData,
|
|
18
16
|
PreviousRollupData,
|
|
19
17
|
Proof,
|
|
@@ -25,24 +23,25 @@ import {
|
|
|
25
23
|
VerificationKey,
|
|
26
24
|
makeTuple,
|
|
27
25
|
} from '@aztec/circuits.js';
|
|
28
|
-
import { computeContractLeaf } from '@aztec/circuits.js/abis';
|
|
29
|
-
import { MerkleTreeId, ContractData, L2Block, PublicDataWrite, TxL2Logs, L2BlockL2Logs } from '@aztec/types';
|
|
30
|
-
import { MerkleTreeOperations } from '@aztec/world-state';
|
|
31
|
-
import chunk from 'lodash.chunk';
|
|
32
|
-
import flatMap from 'lodash.flatmap';
|
|
33
|
-
import { VerificationKeys } from '../mocks/verification_keys.js';
|
|
34
|
-
import { RollupProver } from '../prover/index.js';
|
|
35
|
-
import { RollupSimulator } from '../simulator/index.js';
|
|
36
|
-
|
|
26
|
+
import { computeBlockHash, computeBlockHashWithGlobals, computeContractLeaf } from '@aztec/circuits.js/abis';
|
|
37
27
|
import { toFriendlyJSON } from '@aztec/circuits.js/utils';
|
|
38
28
|
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
29
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
39
30
|
import { Fr } from '@aztec/foundation/fields';
|
|
40
31
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
41
32
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
33
|
+
import { ContractData, L2Block, L2BlockL2Logs, MerkleTreeId, PublicDataWrite, TxL2Logs } from '@aztec/types';
|
|
34
|
+
import { MerkleTreeOperations } from '@aztec/world-state';
|
|
35
|
+
|
|
36
|
+
import chunk from 'lodash.chunk';
|
|
37
|
+
import flatMap from 'lodash.flatmap';
|
|
38
|
+
|
|
39
|
+
import { VerificationKeys } from '../mocks/verification_keys.js';
|
|
40
|
+
import { RollupProver } from '../prover/index.js';
|
|
42
41
|
import { ProcessedTx } from '../sequencer/processed_tx.js';
|
|
42
|
+
import { RollupSimulator } from '../simulator/index.js';
|
|
43
43
|
import { BlockBuilder } from './index.js';
|
|
44
44
|
import { AllowedTreeNames, OutputWithTreeSnapshot } from './types.js';
|
|
45
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
46
45
|
|
|
47
46
|
const frToBigInt = (fr: Fr) => toBigIntBE(fr.toBuffer());
|
|
48
47
|
const bigintToFr = (num: bigint) => new Fr(num);
|
|
@@ -86,20 +85,16 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
86
85
|
startNullifierTreeSnapshot,
|
|
87
86
|
startContractTreeSnapshot,
|
|
88
87
|
startPublicDataTreeSnapshot,
|
|
89
|
-
startTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
90
|
-
startTreeOfHistoricContractTreeRootsSnapshot,
|
|
91
88
|
startL1ToL2MessageTreeSnapshot,
|
|
92
|
-
|
|
89
|
+
startHistoricBlocksTreeSnapshot,
|
|
93
90
|
] = await Promise.all(
|
|
94
91
|
[
|
|
95
92
|
MerkleTreeId.PRIVATE_DATA_TREE,
|
|
96
93
|
MerkleTreeId.NULLIFIER_TREE,
|
|
97
94
|
MerkleTreeId.CONTRACT_TREE,
|
|
98
95
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
99
|
-
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
|
|
100
|
-
MerkleTreeId.CONTRACT_TREE_ROOTS_TREE,
|
|
101
96
|
MerkleTreeId.L1_TO_L2_MESSAGES_TREE,
|
|
102
|
-
MerkleTreeId.
|
|
97
|
+
MerkleTreeId.BLOCKS_TREE,
|
|
103
98
|
].map(tree => this.getTreeSnapshot(tree)),
|
|
104
99
|
);
|
|
105
100
|
|
|
@@ -114,10 +109,8 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
114
109
|
endNullifierTreeSnapshot,
|
|
115
110
|
endContractTreeSnapshot,
|
|
116
111
|
endPublicDataTreeRoot,
|
|
117
|
-
endTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
118
|
-
endTreeOfHistoricContractTreeRootsSnapshot,
|
|
119
112
|
endL1ToL2MessageTreeSnapshot,
|
|
120
|
-
|
|
113
|
+
endHistoricBlocksTreeSnapshot,
|
|
121
114
|
} = circuitsOutput;
|
|
122
115
|
|
|
123
116
|
// Collect all new nullifiers, commitments, and contracts from all txs in this block
|
|
@@ -156,14 +149,10 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
156
149
|
endContractTreeSnapshot,
|
|
157
150
|
startPublicDataTreeRoot: startPublicDataTreeSnapshot.root,
|
|
158
151
|
endPublicDataTreeRoot,
|
|
159
|
-
startTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
160
|
-
endTreeOfHistoricPrivateDataTreeRootsSnapshot,
|
|
161
|
-
startTreeOfHistoricContractTreeRootsSnapshot,
|
|
162
|
-
endTreeOfHistoricContractTreeRootsSnapshot,
|
|
163
152
|
startL1ToL2MessageTreeSnapshot,
|
|
164
153
|
endL1ToL2MessageTreeSnapshot,
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
startHistoricBlocksTreeSnapshot,
|
|
155
|
+
endHistoricBlocksTreeSnapshot,
|
|
167
156
|
newCommitments,
|
|
168
157
|
newNullifiers,
|
|
169
158
|
newL2ToL1Msgs,
|
|
@@ -194,7 +183,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
194
183
|
'nullifierTreeRoot',
|
|
195
184
|
'l1ToL2MessagesTreeRoot',
|
|
196
185
|
] as const) {
|
|
197
|
-
if (tx.data.constants.
|
|
186
|
+
if (tx.data.constants.blockData[historicTreeRoot].isZero()) {
|
|
198
187
|
throw new Error(`Empty ${historicTreeRoot} for tx: ${toFriendlyJSON(tx)}`);
|
|
199
188
|
}
|
|
200
189
|
}
|
|
@@ -306,12 +295,45 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
306
295
|
// Update the root trees with the latest data and contract tree roots,
|
|
307
296
|
// and validate them against the output of the root circuit simulation
|
|
308
297
|
this.debug(`Updating and validating root trees`);
|
|
309
|
-
await this.db.
|
|
298
|
+
await this.db.updateHistoricBlocksTree(left[0].constants.globalVariables);
|
|
299
|
+
|
|
310
300
|
await this.validateRootOutput(rootOutput);
|
|
311
301
|
|
|
312
302
|
return [rootOutput, rootProof];
|
|
313
303
|
}
|
|
314
304
|
|
|
305
|
+
async updateHistoricBlocksTree(globalVariables: GlobalVariables) {
|
|
306
|
+
// Calculate the block hash and add it to the historic block hashes tree
|
|
307
|
+
const blockHash = await this.calculateBlockHash(globalVariables);
|
|
308
|
+
await this.db.appendLeaves(MerkleTreeId.BLOCKS_TREE, [blockHash.toBuffer()]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
protected async calculateBlockHash(globals: GlobalVariables) {
|
|
312
|
+
const [privateDataTreeRoot, nullifierTreeRoot, contractTreeRoot, publicDataTreeRoot, l1ToL2MessageTreeRoot] = (
|
|
313
|
+
await Promise.all(
|
|
314
|
+
[
|
|
315
|
+
MerkleTreeId.PRIVATE_DATA_TREE,
|
|
316
|
+
MerkleTreeId.NULLIFIER_TREE,
|
|
317
|
+
MerkleTreeId.CONTRACT_TREE,
|
|
318
|
+
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
319
|
+
MerkleTreeId.L1_TO_L2_MESSAGES_TREE,
|
|
320
|
+
].map(tree => this.getTreeSnapshot(tree)),
|
|
321
|
+
)
|
|
322
|
+
).map(r => r.root);
|
|
323
|
+
|
|
324
|
+
const wasm = await CircuitsWasm.get();
|
|
325
|
+
const blockHash = computeBlockHashWithGlobals(
|
|
326
|
+
wasm,
|
|
327
|
+
globals,
|
|
328
|
+
privateDataTreeRoot,
|
|
329
|
+
nullifierTreeRoot,
|
|
330
|
+
contractTreeRoot,
|
|
331
|
+
l1ToL2MessageTreeRoot,
|
|
332
|
+
publicDataTreeRoot,
|
|
333
|
+
);
|
|
334
|
+
return blockHash;
|
|
335
|
+
}
|
|
336
|
+
|
|
315
337
|
// Validate that the new roots we calculated from manual insertions match the outputs of the simulation
|
|
316
338
|
protected async validateTrees(rollupOutput: BaseOrMergeRollupPublicInputs | RootRollupPublicInputs) {
|
|
317
339
|
await Promise.all([
|
|
@@ -326,9 +348,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
326
348
|
protected async validateRootOutput(rootOutput: RootRollupPublicInputs) {
|
|
327
349
|
await Promise.all([
|
|
328
350
|
this.validateTrees(rootOutput),
|
|
329
|
-
this.
|
|
330
|
-
this.validateRootTree(rootOutput, MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE, 'PrivateData'),
|
|
331
|
-
this.validateRootTree(rootOutput, MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE, 'L1ToL2Message'),
|
|
351
|
+
this.validateTree(rootOutput, MerkleTreeId.BLOCKS_TREE, 'HistoricBlocks'),
|
|
332
352
|
this.validateTree(rootOutput, MerkleTreeId.L1_TO_L2_MESSAGES_TREE, 'L1ToL2Message'),
|
|
333
353
|
]);
|
|
334
354
|
}
|
|
@@ -378,7 +398,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
378
398
|
protected validateSimulatedTree(
|
|
379
399
|
localTree: AppendOnlyTreeSnapshot,
|
|
380
400
|
simulatedTree: AppendOnlyTreeSnapshot,
|
|
381
|
-
name: 'PrivateData' | 'Contract' | 'Nullifier' | 'L1ToL2Message',
|
|
401
|
+
name: 'PrivateData' | 'Contract' | 'Nullifier' | 'L1ToL2Message' | 'HistoricBlocks',
|
|
382
402
|
label?: string,
|
|
383
403
|
) {
|
|
384
404
|
if (!simulatedTree.root.toBuffer().equals(localTree.root.toBuffer())) {
|
|
@@ -415,15 +435,6 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
415
435
|
return path.toFieldArray();
|
|
416
436
|
};
|
|
417
437
|
|
|
418
|
-
const newHistoricContractDataTreeRootSiblingPath = await getRootTreeSiblingPath(
|
|
419
|
-
MerkleTreeId.CONTRACT_TREE_ROOTS_TREE,
|
|
420
|
-
);
|
|
421
|
-
const newHistoricPrivateDataTreeRootSiblingPath = await getRootTreeSiblingPath(
|
|
422
|
-
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
|
|
423
|
-
);
|
|
424
|
-
const newHistoricL1ToL2MessageTreeRootSiblingPath = await getRootTreeSiblingPath(
|
|
425
|
-
MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE,
|
|
426
|
-
);
|
|
427
438
|
const newL1ToL2MessageTreeRootSiblingPath = await this.getSubtreeSiblingPath(
|
|
428
439
|
MerkleTreeId.L1_TO_L2_MESSAGES_TREE,
|
|
429
440
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
@@ -431,19 +442,18 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
431
442
|
|
|
432
443
|
// Get tree snapshots
|
|
433
444
|
const startL1ToL2MessageTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGES_TREE);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
);
|
|
445
|
+
|
|
446
|
+
// Get historic block tree roots
|
|
447
|
+
const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE);
|
|
448
|
+
const newHistoricBlocksTreeSiblingPath = await getRootTreeSiblingPath(MerkleTreeId.BLOCKS_TREE);
|
|
437
449
|
|
|
438
450
|
return RootRollupInputs.from({
|
|
439
451
|
previousRollupData,
|
|
440
|
-
newHistoricContractDataTreeRootSiblingPath,
|
|
441
|
-
newHistoricPrivateDataTreeRootSiblingPath,
|
|
442
452
|
newL1ToL2Messages,
|
|
443
|
-
newHistoricL1ToL2MessageTreeRootSiblingPath,
|
|
444
453
|
newL1ToL2MessageTreeRootSiblingPath,
|
|
445
454
|
startL1ToL2MessageTreeSnapshot,
|
|
446
|
-
|
|
455
|
+
startHistoricBlocksTreeSnapshot,
|
|
456
|
+
newHistoricBlocksTreeSiblingPath,
|
|
447
457
|
});
|
|
448
458
|
}
|
|
449
459
|
|
|
@@ -498,28 +508,21 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
498
508
|
return new MembershipWitness(height, index, assertLength(path.toFieldArray(), height));
|
|
499
509
|
}
|
|
500
510
|
|
|
501
|
-
protected
|
|
502
|
-
|
|
503
|
-
tx.data.constants.historicTreeRoots.privateHistoricTreeRoots.contractTreeRoot,
|
|
504
|
-
MerkleTreeId.CONTRACT_TREE_ROOTS_TREE,
|
|
505
|
-
CONTRACT_TREE_ROOTS_TREE_HEIGHT,
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
protected getDataMembershipWitnessFor(tx: ProcessedTx) {
|
|
510
|
-
return this.getMembershipWitnessFor(
|
|
511
|
-
tx.data.constants.historicTreeRoots.privateHistoricTreeRoots.privateDataTreeRoot,
|
|
512
|
-
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
|
|
513
|
-
PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT,
|
|
514
|
-
);
|
|
515
|
-
}
|
|
511
|
+
protected async getHistoricTreesMembershipWitnessFor(tx: ProcessedTx) {
|
|
512
|
+
const wasm = await CircuitsWasm.get();
|
|
516
513
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
514
|
+
const blockData = tx.data.constants.blockData;
|
|
515
|
+
const { privateDataTreeRoot, nullifierTreeRoot, contractTreeRoot, l1ToL2MessagesTreeRoot } = blockData;
|
|
516
|
+
const blockHash = computeBlockHash(
|
|
517
|
+
wasm,
|
|
518
|
+
blockData.globalVariablesHash,
|
|
519
|
+
privateDataTreeRoot,
|
|
520
|
+
nullifierTreeRoot,
|
|
521
|
+
contractTreeRoot,
|
|
522
|
+
l1ToL2MessagesTreeRoot,
|
|
523
|
+
blockData.publicDataTreeRoot,
|
|
522
524
|
);
|
|
525
|
+
return this.getMembershipWitnessFor(blockHash, MerkleTreeId.BLOCKS_TREE, HISTORIC_BLOCKS_TREE_HEIGHT);
|
|
523
526
|
}
|
|
524
527
|
|
|
525
528
|
protected async getConstantBaseRollupData(globalVariables: GlobalVariables): Promise<ConstantBaseRollupData> {
|
|
@@ -528,13 +531,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
528
531
|
mergeRollupVkHash: DELETE_FR,
|
|
529
532
|
privateKernelVkTreeRoot: FUTURE_FR,
|
|
530
533
|
publicKernelVkTreeRoot: FUTURE_FR,
|
|
531
|
-
|
|
532
|
-
startTreeOfHistoricPrivateDataTreeRootsSnapshot: await this.getTreeSnapshot(
|
|
533
|
-
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
|
|
534
|
-
),
|
|
535
|
-
startTreeOfHistoricL1ToL2MsgTreeRootsSnapshot: await this.getTreeSnapshot(
|
|
536
|
-
MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE,
|
|
537
|
-
),
|
|
534
|
+
startHistoricBlocksTreeRootsSnapshot: await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE),
|
|
538
535
|
globalVariables,
|
|
539
536
|
});
|
|
540
537
|
}
|
|
@@ -609,6 +606,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
609
606
|
const startContractTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.CONTRACT_TREE);
|
|
610
607
|
const startPrivateDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PRIVATE_DATA_TREE);
|
|
611
608
|
const startPublicDataTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.PUBLIC_DATA_TREE);
|
|
609
|
+
const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE);
|
|
612
610
|
|
|
613
611
|
// Get the subtree sibling paths for the circuit
|
|
614
612
|
const newCommitmentsSubtreeSiblingPath = await this.getSubtreeSiblingPath(
|
|
@@ -673,6 +671,7 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
673
671
|
startContractTreeSnapshot,
|
|
674
672
|
startPrivateDataTreeSnapshot,
|
|
675
673
|
startPublicDataTreeRoot: startPublicDataTreeSnapshot.root,
|
|
674
|
+
startHistoricBlocksTreeSnapshot,
|
|
676
675
|
newCommitmentsSubtreeSiblingPath,
|
|
677
676
|
newContractsSubtreeSiblingPath,
|
|
678
677
|
newNullifiersSubtreeSiblingPath: newNullifiersSubtreeSiblingPath.toFieldArray(),
|
|
@@ -684,17 +683,9 @@ export class SoloBlockBuilder implements BlockBuilder {
|
|
|
684
683
|
),
|
|
685
684
|
lowNullifierMembershipWitness: lowNullifierMembershipWitnesses,
|
|
686
685
|
kernelData: [this.getKernelDataFor(left), this.getKernelDataFor(right)],
|
|
687
|
-
|
|
688
|
-
await this.
|
|
689
|
-
await this.
|
|
690
|
-
],
|
|
691
|
-
historicPrivateDataTreeRootMembershipWitnesses: [
|
|
692
|
-
await this.getDataMembershipWitnessFor(left),
|
|
693
|
-
await this.getDataMembershipWitnessFor(right),
|
|
694
|
-
],
|
|
695
|
-
historicL1ToL2MsgTreeRootMembershipWitnesses: [
|
|
696
|
-
await this.getL1ToL2MessageMembershipWitnessFor(left),
|
|
697
|
-
await this.getL1ToL2MessageMembershipWitnessFor(right),
|
|
686
|
+
historicBlocksTreeRootMembershipWitnesses: [
|
|
687
|
+
await this.getHistoricTreesMembershipWitnessFor(left),
|
|
688
|
+
await this.getHistoricTreesMembershipWitnessFor(right),
|
|
698
689
|
],
|
|
699
690
|
});
|
|
700
691
|
}
|
|
@@ -5,7 +5,7 @@ import { AppendOnlyTreeSnapshot, BaseOrMergeRollupPublicInputs, RootRollupPublic
|
|
|
5
5
|
*/
|
|
6
6
|
export type AllowedTreeNames<T extends BaseOrMergeRollupPublicInputs | RootRollupPublicInputs> =
|
|
7
7
|
T extends RootRollupPublicInputs
|
|
8
|
-
? 'PrivateData' | 'Contract' | 'Nullifier' | 'L1ToL2Message'
|
|
8
|
+
? 'PrivateData' | 'Contract' | 'Nullifier' | 'L1ToL2Message' | 'HistoricBlocks'
|
|
9
9
|
: 'PrivateData' | 'Contract' | 'Nullifier';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { P2P } from '@aztec/p2p';
|
|
2
|
+
import { ContractDataSource, L1ToL2MessageSource, L2BlockSource } from '@aztec/types';
|
|
2
3
|
import { WorldStateSynchroniser } from '@aztec/world-state';
|
|
3
4
|
|
|
4
|
-
import { ContractDataSource, L1ToL2MessageSource, L2BlockSource } from '@aztec/types';
|
|
5
5
|
import { SoloBlockBuilder } from '../block_builder/solo_block_builder.js';
|
|
6
6
|
import { SequencerClientConfig } from '../config.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getGlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
8
|
+
import { Sequencer, getL1Publisher, getVerificationKeys } from '../index.js';
|
|
8
9
|
import { EmptyRollupProver } from '../prover/empty.js';
|
|
9
10
|
import { PublicProcessorFactory } from '../sequencer/public_processor.js';
|
|
10
11
|
import { WasmRollupCircuitSimulator } from '../simulator/rollup.js';
|
|
11
|
-
import { getGlobalVariableBuilder } from '../global_variable_builder/index.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Encapsulates the full sequencer and publisher.
|