@aztec/txe 0.0.1-commit.9b94fc1 → 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/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 +8 -8
- package/dest/rpc_translator.d.ts +3 -3
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +14 -11
- package/dest/state_machine/archiver.d.ts +9 -4
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +16 -3
- package/dest/state_machine/global_variable_builder.d.ts +3 -3
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/index.js +1 -1
- 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 +3 -2
- 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/tx_effect_creation.d.ts +3 -2
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/package.json +17 -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 +10 -10
- package/src/rpc_translator.ts +22 -8
- package/src/state_machine/archiver.ts +23 -6
- package/src/state_machine/global_variable_builder.ts +2 -2
- package/src/state_machine/index.ts +1 -1
- package/src/state_machine/synchronizer.ts +8 -6
- package/src/txe_session.ts +5 -5
- package/src/util/txe_public_contract_data_source.ts +3 -2
- package/src/utils/block_creation.ts +2 -1
- package/src/utils/tx_effect_creation.ts +2 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ArchiverStoreHelper, KVArchiverDataStore, type PublishedL2Block } from '@aztec/archiver';
|
|
2
2
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
3
|
-
import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import type { L2Block, L2BlockSource, L2Tips, ValidateBlockResult } from '@aztec/stdlib/block';
|
|
9
|
+
import type { Checkpoint, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
9
10
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
11
|
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
11
12
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
@@ -32,7 +33,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
32
33
|
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
33
34
|
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
34
35
|
*/
|
|
35
|
-
public getBlockNumber(): Promise<
|
|
36
|
+
public getBlockNumber(): Promise<BlockNumber> {
|
|
36
37
|
return this.store.getSynchedL2BlockNumber();
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -40,7 +41,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
40
41
|
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
41
42
|
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
42
43
|
*/
|
|
43
|
-
public getProvenBlockNumber(): Promise<
|
|
44
|
+
public getProvenBlockNumber(): Promise<BlockNumber> {
|
|
44
45
|
return this.store.getSynchedL2BlockNumber();
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -57,7 +58,7 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
57
58
|
if (number == 0) {
|
|
58
59
|
return undefined;
|
|
59
60
|
}
|
|
60
|
-
const blocks = await this.store.getPublishedBlocks(number, 1);
|
|
61
|
+
const blocks = await this.store.getPublishedBlocks(BlockNumber(number), 1);
|
|
61
62
|
return blocks.length === 0 ? undefined : blocks[0];
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -82,12 +83,20 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
82
83
|
if (number === 0) {
|
|
83
84
|
return undefined;
|
|
84
85
|
}
|
|
85
|
-
const headers = await this.store.getBlockHeaders(number, 1);
|
|
86
|
+
const headers = await this.store.getBlockHeaders(BlockNumber(number), 1);
|
|
86
87
|
return headers.length === 0 ? undefined : headers[0];
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
public getBlocks(from: number, limit: number, _proven?: boolean): Promise<L2Block[]> {
|
|
90
|
-
return this.getPublishedBlocks(from, limit).then(blocks => blocks.map(b => b.block));
|
|
91
|
+
return this.getPublishedBlocks(BlockNumber(from), limit).then(blocks => blocks.map(b => b.block));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public getPublishedCheckpoints(_from: CheckpointNumber, _limit: number): Promise<PublishedCheckpoint[]> {
|
|
95
|
+
throw new Error('TXE Archiver does not implement "getPublishedCheckpoints"');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public getCheckpointByArchive(_archive: Fr): Promise<Checkpoint | undefined> {
|
|
99
|
+
throw new Error('TXE Archiver does not implement "getCheckpointByArchive"');
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
public getL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
@@ -98,6 +107,10 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
98
107
|
throw new Error('TXE Archiver does not implement "getL2EpochNumber"');
|
|
99
108
|
}
|
|
100
109
|
|
|
110
|
+
public getCheckpointsForEpoch(_epochNumber: EpochNumber): Promise<Checkpoint[]> {
|
|
111
|
+
throw new Error('TXE Archiver does not implement "getCheckpointsForEpoch"');
|
|
112
|
+
}
|
|
113
|
+
|
|
101
114
|
public getBlocksForEpoch(_epochNumber: EpochNumber): Promise<L2Block[]> {
|
|
102
115
|
throw new Error('TXE Archiver does not implement "getBlocksForEpoch"');
|
|
103
116
|
}
|
|
@@ -106,6 +119,10 @@ export class TXEArchiver extends ArchiverStoreHelper implements L2BlockSource {
|
|
|
106
119
|
throw new Error('TXE Archiver does not implement "getBlockHeadersForEpoch"');
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
public getL1ToL2MessagesForCheckpoint(_checkpointNumber: CheckpointNumber): Promise<Fr[]> {
|
|
123
|
+
throw new Error('TXE Archiver does not implement "getL1ToL2MessagesForCheckpoint"');
|
|
124
|
+
}
|
|
125
|
+
|
|
109
126
|
public isEpochComplete(_epochNumber: EpochNumber): Promise<boolean> {
|
|
110
127
|
throw new Error('TXE Archiver does not implement "isEpochComplete"');
|
|
111
128
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -11,7 +11,7 @@ export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
public buildGlobalVariables(
|
|
14
|
-
_blockNumber:
|
|
14
|
+
_blockNumber: BlockNumber,
|
|
15
15
|
_coinbase: EthAddress,
|
|
16
16
|
_feeRecipient: AztecAddress,
|
|
17
17
|
_slotNumber?: SlotNumber,
|
|
@@ -59,7 +59,7 @@ export class TXEStateMachine {
|
|
|
59
59
|
|
|
60
60
|
public async handleL2Block(block: L2Block) {
|
|
61
61
|
await Promise.all([
|
|
62
|
-
this.synchronizer.handleL2Block(block),
|
|
62
|
+
this.synchronizer.handleL2Block(block.toL2Block()),
|
|
63
63
|
this.archiver.addBlocks([
|
|
64
64
|
PublishedL2Block.fromFields({
|
|
65
65
|
block,
|
|
@@ -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';
|
|
@@ -29,7 +30,6 @@ import { computeProtocolNullifier } from '@aztec/stdlib/hash';
|
|
|
29
30
|
import { PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
30
31
|
import { makeAppendOnlyTreeSnapshot, makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
31
32
|
import { CallContext, GlobalVariables, TxContext } from '@aztec/stdlib/tx';
|
|
32
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
33
33
|
|
|
34
34
|
import { z } from 'zod';
|
|
35
35
|
|
|
@@ -102,7 +102,7 @@ export type TXEOracleFunctionName = Exclude<
|
|
|
102
102
|
export interface TXESessionStateHandler {
|
|
103
103
|
enterTopLevelState(): Promise<void>;
|
|
104
104
|
enterPublicState(contractAddress?: AztecAddress): Promise<void>;
|
|
105
|
-
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?:
|
|
105
|
+
enterPrivateState(contractAddress?: AztecAddress, anchorBlockNumber?: BlockNumber): Promise<PrivateContextInputs>;
|
|
106
106
|
enterUtilityState(contractAddress?: AztecAddress): Promise<void>;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -271,7 +271,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
271
271
|
|
|
272
272
|
async enterPrivateState(
|
|
273
273
|
contractAddress: AztecAddress = DEFAULT_ADDRESS,
|
|
274
|
-
anchorBlockNumber?:
|
|
274
|
+
anchorBlockNumber?: BlockNumber,
|
|
275
275
|
): Promise<PrivateContextInputs> {
|
|
276
276
|
this.exitTopLevelState();
|
|
277
277
|
|
|
@@ -289,7 +289,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
289
289
|
const latestBlock = await this.stateMachine.node.getBlockHeader('latest');
|
|
290
290
|
|
|
291
291
|
const nextBlockGlobalVariables = makeGlobalVariables(undefined, {
|
|
292
|
-
blockNumber: latestBlock!.globalVariables.blockNumber + 1,
|
|
292
|
+
blockNumber: BlockNumber(latestBlock!.globalVariables.blockNumber + 1),
|
|
293
293
|
timestamp: this.nextBlockTimestamp,
|
|
294
294
|
version: this.version,
|
|
295
295
|
chainId: this.chainId,
|
|
@@ -331,7 +331,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
331
331
|
// the test. The block therefore gets the *next* block number and timestamp.
|
|
332
332
|
const latestBlockNumber = (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.blockNumber;
|
|
333
333
|
const globalVariables = makeGlobalVariables(undefined, {
|
|
334
|
-
blockNumber: latestBlockNumber + 1,
|
|
334
|
+
blockNumber: BlockNumber(latestBlockNumber + 1),
|
|
335
335
|
timestamp: this.nextBlockTimestamp,
|
|
336
336
|
version: this.version,
|
|
337
337
|
chainId: this.chainId,
|
|
@@ -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
|
|
|
@@ -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';
|
|
@@ -6,7 +7,7 @@ import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
|
6
7
|
export async function makeTxEffect(
|
|
7
8
|
noteCache: ExecutionNoteCache,
|
|
8
9
|
protocolNullifier: Fr,
|
|
9
|
-
txBlockNumber:
|
|
10
|
+
txBlockNumber: BlockNumber,
|
|
10
11
|
): Promise<TxEffect> {
|
|
11
12
|
const txEffect = TxEffect.empty();
|
|
12
13
|
|