@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.d3ec352c
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/dest/bin/index.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/oracle/interfaces.d.ts +5 -4
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +3 -3
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts +3 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +26 -17
- package/dest/rpc_translator.d.ts +10 -7
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +26 -16
- package/dest/state_machine/archiver.d.ts +14 -8
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +16 -3
- package/dest/state_machine/dummy_p2p_client.d.ts +4 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +3 -0
- package/dest/state_machine/global_variable_builder.d.ts +3 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/index.d.ts +1 -1
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +1 -1
- package/dest/state_machine/mock_epoch_cache.d.ts +6 -5
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +8 -7
- package/dest/state_machine/synchronizer.d.ts +5 -4
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +4 -4
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +8 -5
- package/dest/util/encoding.d.ts +15 -15
- package/dest/util/expected_failure_error.d.ts +1 -1
- package/dest/util/expected_failure_error.d.ts.map +1 -1
- package/dest/util/txe_account_data_provider.d.ts +1 -1
- package/dest/util/txe_account_data_provider.d.ts.map +1 -1
- package/dest/util/txe_contract_data_provider.d.ts +1 -1
- package/dest/util/txe_contract_data_provider.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts +4 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/utils/block_creation.d.ts +3 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +1 -1
- package/dest/utils/tx_effect_creation.d.ts +3 -2
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +5 -5
- package/package.json +18 -17
- package/src/oracle/interfaces.ts +4 -3
- package/src/oracle/txe_oracle_public_context.ts +2 -2
- package/src/oracle/txe_oracle_top_level_context.ts +27 -18
- package/src/rpc_translator.ts +31 -17
- package/src/state_machine/archiver.ts +28 -10
- package/src/state_machine/dummy_p2p_client.ts +6 -1
- package/src/state_machine/global_variable_builder.ts +3 -2
- package/src/state_machine/index.ts +1 -1
- package/src/state_machine/mock_epoch_cache.ts +12 -11
- package/src/state_machine/synchronizer.ts +8 -6
- package/src/txe_session.ts +11 -9
- package/src/util/txe_public_contract_data_source.ts +3 -2
- package/src/utils/block_creation.ts +3 -1
- package/src/utils/tx_effect_creation.ts +7 -6
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EpochAndSlot, EpochCacheInterface, EpochCommitteeInfo, SlotTag } from '@aztec/epoch-cache';
|
|
2
|
+
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -10,46 +11,46 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
10
11
|
return Promise.resolve({
|
|
11
12
|
committee: undefined,
|
|
12
13
|
seed: 0n,
|
|
13
|
-
epoch:
|
|
14
|
+
epoch: EpochNumber.ZERO,
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
getEpochAndSlotNow(): EpochAndSlot {
|
|
18
19
|
return {
|
|
19
|
-
epoch:
|
|
20
|
-
slot:
|
|
20
|
+
epoch: EpochNumber.ZERO,
|
|
21
|
+
slot: SlotNumber(0),
|
|
21
22
|
ts: 0n,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint } {
|
|
26
27
|
return {
|
|
27
|
-
epoch:
|
|
28
|
-
slot:
|
|
28
|
+
epoch: EpochNumber.ZERO,
|
|
29
|
+
slot: SlotNumber(0),
|
|
29
30
|
ts: 0n,
|
|
30
31
|
now: 0n,
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
getProposerIndexEncoding(_epoch:
|
|
35
|
+
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
35
36
|
return '0x00';
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
computeProposerIndex(_slot:
|
|
39
|
+
computeProposerIndex(_slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, _size: bigint): bigint {
|
|
39
40
|
return 0n;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
getProposerAttesterAddressInCurrentOrNextSlot(): Promise<{
|
|
43
44
|
currentProposer: EthAddress | undefined;
|
|
44
45
|
nextProposer: EthAddress | undefined;
|
|
45
|
-
currentSlot:
|
|
46
|
-
nextSlot:
|
|
46
|
+
currentSlot: SlotNumber;
|
|
47
|
+
nextSlot: SlotNumber;
|
|
47
48
|
}> {
|
|
48
49
|
return Promise.resolve({
|
|
49
50
|
currentProposer: undefined,
|
|
50
51
|
nextProposer: undefined,
|
|
51
|
-
currentSlot:
|
|
52
|
-
nextSlot:
|
|
52
|
+
currentSlot: SlotNumber(0),
|
|
53
|
+
nextSlot: SlotNumber(0),
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import type {
|
|
4
|
+
import type { L2BlockNew } from '@aztec/stdlib/block';
|
|
4
5
|
import type {
|
|
5
6
|
MerkleTreeReadOperations,
|
|
6
7
|
MerkleTreeWriteOperations,
|
|
@@ -12,7 +13,7 @@ import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
|
12
13
|
|
|
13
14
|
export class TXESynchronizer implements WorldStateSynchronizer {
|
|
14
15
|
// This works when set to 1 as well.
|
|
15
|
-
private blockNumber =
|
|
16
|
+
private blockNumber = BlockNumber.ZERO;
|
|
16
17
|
|
|
17
18
|
constructor(public nativeWorldStateService: NativeWorldStateService) {}
|
|
18
19
|
|
|
@@ -22,10 +23,11 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
22
23
|
return new this(nativeWorldStateService);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
public async handleL2Block(block:
|
|
26
|
+
public async handleL2Block(block: L2BlockNew) {
|
|
26
27
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
27
28
|
block,
|
|
28
29
|
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
|
|
30
|
+
true,
|
|
29
31
|
);
|
|
30
32
|
|
|
31
33
|
this.blockNumber = block.header.globalVariables.blockNumber;
|
|
@@ -37,7 +39,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
37
39
|
* @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
|
|
38
40
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
39
41
|
*/
|
|
40
|
-
public syncImmediate(_minBlockNumber?:
|
|
42
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber> {
|
|
41
43
|
return Promise.resolve(this.blockNumber);
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -48,12 +50,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
48
50
|
|
|
49
51
|
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
50
52
|
public fork(block?: number): Promise<MerkleTreeWriteOperations> {
|
|
51
|
-
return this.nativeWorldStateService.fork(block);
|
|
53
|
+
return this.nativeWorldStateService.fork(block ? BlockNumber(block) : undefined);
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
/** Gets a handle that allows reading the state as it was at the given block number. */
|
|
55
57
|
public getSnapshot(blockNumber: number): MerkleTreeReadOperations {
|
|
56
|
-
return this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
58
|
+
return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/** Backups the db to the target path. */
|
package/src/txe_session.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -25,10 +26,10 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
25
26
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
27
|
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
27
28
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
29
|
+
import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
28
30
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
29
31
|
import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
30
32
|
import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
31
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
32
33
|
|
|
33
34
|
import { z } from 'zod';
|
|
34
35
|
|
|
@@ -66,7 +67,7 @@ type SessionState =
|
|
|
66
67
|
| {
|
|
67
68
|
name: 'PRIVATE';
|
|
68
69
|
nextBlockGlobalVariables: GlobalVariables;
|
|
69
|
-
|
|
70
|
+
protocolNullifier: Fr;
|
|
70
71
|
noteCache: ExecutionNoteCache;
|
|
71
72
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
72
73
|
}
|
|
@@ -101,7 +102,7 @@ export type TXEOracleFunctionName = Exclude<
|
|
|
101
102
|
export interface TXESessionStateHandler {
|
|
102
103
|
enterTopLevelState(): Promise<void>;
|
|
103
104
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
104
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
105
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
105
106
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -270,7 +271,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
270
271
|
|
|
271
272
|
async enterPrivateState(
|
|
272
273
|
contractAddress: AztecAddress = DEFAULT_ADDRESS,
|
|
273
|
-
anchorBlockNumber?:
|
|
274
|
+
anchorBlockNumber?: BlockNumber,
|
|
274
275
|
): Promise<PrivateContextInputs> {
|
|
275
276
|
this.exitTopLevelState();
|
|
276
277
|
|
|
@@ -288,14 +289,15 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
288
289
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
289
290
|
|
|
290
291
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
291
|
-
blockNumber: latestBlock!.globalVariables.blockNumber + 1,
|
|
292
|
+
blockNumber: BlockNumber(latestBlock!.globalVariables.blockNumber + 1),
|
|
292
293
|
timestamp: this.nextBlockTimestamp,
|
|
293
294
|
version: this.version,
|
|
294
295
|
chainId: this.chainId,
|
|
295
296
|
});
|
|
296
297
|
|
|
297
298
|
const txRequestHash = getSingleTxBlockRequestHash(nextBlockGlobalVariables.blockNumber);
|
|
298
|
-
const
|
|
299
|
+
const protocolNullifier = await computeProtocolNullifier(txRequestHash);
|
|
300
|
+
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
299
301
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
300
302
|
|
|
301
303
|
this.oracleHandler = new PrivateExecutionOracle(
|
|
@@ -316,7 +318,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
316
318
|
// difference resides in that the simulator has all information needed in order to run the simulation, while ours
|
|
317
319
|
// will be ongoing as the different oracles will be invoked from the Noir test, until eventually the private
|
|
318
320
|
// execution finishes.
|
|
319
|
-
this.state = { name: 'PRIVATE', nextBlockGlobalVariables,
|
|
321
|
+
this.state = { name: 'PRIVATE', nextBlockGlobalVariables, protocolNullifier, noteCache, taggingIndexCache };
|
|
320
322
|
this.logger.debug(`Entered state ${this.state.name}`);
|
|
321
323
|
|
|
322
324
|
return (this.oracleHandler as PrivateExecutionOracle).getPrivateContextInputs();
|
|
@@ -329,7 +331,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
329
331
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
330
332
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.blockNumber;
|
|
331
333
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
332
|
-
blockNumber: latestBlockNumber + 1,
|
|
334
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
333
335
|
timestamp: this.nextBlockTimestamp,
|
|
334
336
|
version: this.version,
|
|
335
337
|
chainId: this.chainId,
|
|
@@ -392,7 +394,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
392
394
|
// logs (other effects like enqueued public calls don't need to be considered since those are not allowed).
|
|
393
395
|
const txEffect = await makeTxEffect(
|
|
394
396
|
this.state.noteCache,
|
|
395
|
-
this.state.
|
|
397
|
+
this.state.protocolNullifier,
|
|
396
398
|
this.state.nextBlockGlobalVariables.blockNumber,
|
|
397
399
|
);
|
|
398
400
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import type { ContractDataProvider } from '@aztec/pxe/server';
|
|
3
4
|
import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
@@ -14,11 +15,11 @@ import {
|
|
|
14
15
|
export class TXEPublicContractDataSource implements ContractDataSource {
|
|
15
16
|
#privateFunctionsRoot: Map<string, Buffer> = new Map();
|
|
16
17
|
constructor(
|
|
17
|
-
private blockNumber:
|
|
18
|
+
private blockNumber: BlockNumber,
|
|
18
19
|
private contractDataProvider: ContractDataProvider,
|
|
19
20
|
) {}
|
|
20
21
|
|
|
21
|
-
getBlockNumber(): Promise<
|
|
22
|
+
getBlockNumber(): Promise<BlockNumber> {
|
|
22
23
|
return Promise.resolve(this.blockNumber);
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
5
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
7
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
8
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import { L2BlockHeader } from '@aztec/stdlib/block';
|
|
@@ -16,7 +17,7 @@ import { GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
|
16
17
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
17
18
|
* @returns The transaction request hash.
|
|
18
19
|
*/
|
|
19
|
-
export function getSingleTxBlockRequestHash(blockNumber:
|
|
20
|
+
export function getSingleTxBlockRequestHash(blockNumber: BlockNumber): Fr {
|
|
20
21
|
return new Fr(blockNumber + 9999); // Why does this need to be a high number? Why do small numbered nullifiers already exist?
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -58,5 +59,6 @@ export async function makeTXEBlockHeader(
|
|
|
58
59
|
Fr.ZERO,
|
|
59
60
|
Fr.ZERO,
|
|
60
61
|
Fr.ZERO,
|
|
62
|
+
Fr.ZERO,
|
|
61
63
|
);
|
|
62
64
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
3
4
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
@@ -5,13 +6,13 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
|
5
6
|
|
|
6
7
|
export async function makeTxEffect(
|
|
7
8
|
noteCache: ExecutionNoteCache,
|
|
8
|
-
|
|
9
|
-
txBlockNumber:
|
|
9
|
+
protocolNullifier: Fr,
|
|
10
|
+
txBlockNumber: BlockNumber,
|
|
10
11
|
): Promise<TxEffect> {
|
|
11
12
|
const txEffect = TxEffect.empty();
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
-
const nonceGenerator =
|
|
14
|
+
const { usedProtocolNullifierForNonces } = noteCache.finish();
|
|
15
|
+
const nonceGenerator = usedProtocolNullifierForNonces ? protocolNullifier : noteCache.getAllNullifiers()[0];
|
|
15
16
|
|
|
16
17
|
txEffect.noteHashes = await Promise.all(
|
|
17
18
|
noteCache
|
|
@@ -27,8 +28,8 @@ export async function makeTxEffect(
|
|
|
27
28
|
// Nullifiers are already siloed
|
|
28
29
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
29
30
|
|
|
30
|
-
if (
|
|
31
|
-
txEffect.nullifiers.unshift(
|
|
31
|
+
if (usedProtocolNullifierForNonces) {
|
|
32
|
+
txEffect.nullifiers.unshift(protocolNullifier);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|