@aztec/txe 0.0.1-commit.3469e52 → 0.0.1-commit.54489865
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 +3 -3
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +5 -5
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +6 -6
- package/dest/oracle/txe_oracle_top_level_context.d.ts +1 -1
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +10 -8
- package/dest/rpc_translator.d.ts +11 -5
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +35 -23
- package/dest/state_machine/archiver.d.ts +2 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +5 -6
- package/dest/state_machine/index.d.ts +3 -3
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +18 -9
- package/dest/state_machine/mock_epoch_cache.d.ts +4 -2
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +2 -1
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +1 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +5 -4
- package/dest/utils/block_creation.d.ts +5 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +5 -5
- package/package.json +15 -15
- package/src/oracle/interfaces.ts +2 -2
- package/src/oracle/txe_oracle_public_context.ts +8 -10
- package/src/oracle/txe_oracle_top_level_context.ts +26 -7
- package/src/rpc_translator.ts +39 -26
- package/src/state_machine/archiver.ts +4 -8
- package/src/state_machine/index.ts +26 -12
- package/src/state_machine/mock_epoch_cache.ts +2 -1
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +10 -2
- package/src/utils/block_creation.ts +6 -6
|
@@ -17,18 +17,14 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
17
17
|
private readonly updater = new ArchiverDataStoreUpdater(this.store);
|
|
18
18
|
|
|
19
19
|
constructor(db: AztecAsyncKVStore) {
|
|
20
|
-
const store = new KVArchiverDataStore(db, 9999);
|
|
20
|
+
const store = new KVArchiverDataStore(db, 9999, { epochDuration: 32 });
|
|
21
21
|
super(store);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
await this.updater.setNewCheckpointData(checkpoints, result);
|
|
27
|
-
return true;
|
|
24
|
+
public async addCheckpoints(checkpoints: PublishedCheckpoint[], result?: ValidateCheckpointResult): Promise<void> {
|
|
25
|
+
await this.updater.addCheckpoints(checkpoints, result);
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
// Abstract method implementations
|
|
31
|
-
|
|
32
28
|
public getRollupAddress(): Promise<EthAddress> {
|
|
33
29
|
throw new Error('TXE Archiver does not implement "getRollupAddress"');
|
|
34
30
|
}
|
|
@@ -63,7 +59,7 @@ export class TXEArchiver extends ArchiverDataSourceBase {
|
|
|
63
59
|
if (!checkpointedBlock) {
|
|
64
60
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpointed block found for block number ${number}`);
|
|
65
61
|
}
|
|
66
|
-
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber(number), 1);
|
|
62
|
+
const checkpoint = await this.store.getRangeOfCheckpoints(CheckpointNumber.fromBlockNumber(number), 1);
|
|
67
63
|
if (checkpoint.length === 0) {
|
|
68
64
|
throw new Error(`L2Tips requested from TXE Archiver but no checkpoint found for block number ${number}`);
|
|
69
65
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
|
+
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
7
|
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
-
import {
|
|
8
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
9
|
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
8
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
9
12
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
10
13
|
|
|
11
14
|
import { TXEArchiver } from './archiver.js';
|
|
@@ -58,15 +61,26 @@ export class TXEStateMachine {
|
|
|
58
61
|
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
public async handleL2Block(block:
|
|
62
|
-
// Create a checkpoint from the block
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
public async handleL2Block(block: L2Block) {
|
|
65
|
+
// Create a checkpoint from the block manually
|
|
66
|
+
const checkpoint = new Checkpoint(
|
|
67
|
+
block.archive,
|
|
68
|
+
CheckpointHeader.from({
|
|
69
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
70
|
+
inHash: Fr.ZERO,
|
|
71
|
+
blobsHash: Fr.ZERO,
|
|
72
|
+
blockHeadersHash: Fr.ZERO,
|
|
73
|
+
epochOutHash: Fr.ZERO,
|
|
74
|
+
slotNumber: block.header.globalVariables.slotNumber,
|
|
75
|
+
timestamp: block.header.globalVariables.timestamp,
|
|
76
|
+
coinbase: block.header.globalVariables.coinbase,
|
|
77
|
+
feeRecipient: block.header.globalVariables.feeRecipient,
|
|
78
|
+
gasFees: block.header.globalVariables.gasFees,
|
|
79
|
+
totalManaUsed: block.header.totalManaUsed,
|
|
80
|
+
}),
|
|
81
|
+
[block],
|
|
82
|
+
CheckpointNumber.fromBlockNumber(block.number),
|
|
83
|
+
);
|
|
70
84
|
|
|
71
85
|
const publishedCheckpoint = new PublishedCheckpoint(
|
|
72
86
|
checkpoint,
|
|
@@ -78,9 +92,9 @@ export class TXEStateMachine {
|
|
|
78
92
|
[],
|
|
79
93
|
);
|
|
80
94
|
await Promise.all([
|
|
81
|
-
this.synchronizer.handleL2Block(block),
|
|
95
|
+
this.synchronizer.handleL2Block(block),
|
|
82
96
|
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
83
|
-
this.anchorBlockStore.setHeader(block.header),
|
|
97
|
+
this.anchorBlockStore.setHeader(block.header),
|
|
84
98
|
]);
|
|
85
99
|
}
|
|
86
100
|
}
|
|
@@ -16,11 +16,12 @@ export class MockEpochCache implements EpochCacheInterface {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getEpochAndSlotNow(): EpochAndSlot {
|
|
19
|
+
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
20
20
|
return {
|
|
21
21
|
epoch: EpochNumber.ZERO,
|
|
22
22
|
slot: SlotNumber(0),
|
|
23
23
|
ts: 0n,
|
|
24
|
+
nowMs: 0n,
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
2
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import type {
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import type {
|
|
6
6
|
MerkleTreeReadOperations,
|
|
7
7
|
MerkleTreeWriteOperations,
|
|
@@ -23,7 +23,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
23
23
|
return new this(nativeWorldStateService);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
public async handleL2Block(block:
|
|
26
|
+
public async handleL2Block(block: L2Block) {
|
|
27
27
|
await this.nativeWorldStateService.handleL2BlockAndMessages(
|
|
28
28
|
block,
|
|
29
29
|
Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero),
|
package/src/txe_session.ts
CHANGED
|
@@ -152,7 +152,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
152
152
|
const addressStore = new AddressStore(store);
|
|
153
153
|
const privateEventStore = new PrivateEventStore(store);
|
|
154
154
|
const contractStore = new TXEContractStore(store);
|
|
155
|
-
const noteStore =
|
|
155
|
+
const noteStore = new NoteStore(store);
|
|
156
156
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
157
157
|
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
158
158
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -162,7 +162,13 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
162
162
|
|
|
163
163
|
// Create job coordinator and register staged stores
|
|
164
164
|
const jobCoordinator = new JobCoordinator(store);
|
|
165
|
-
jobCoordinator.registerStores([
|
|
165
|
+
jobCoordinator.registerStores([
|
|
166
|
+
capsuleStore,
|
|
167
|
+
senderTaggingStore,
|
|
168
|
+
recipientTaggingStore,
|
|
169
|
+
privateEventStore,
|
|
170
|
+
noteStore,
|
|
171
|
+
]);
|
|
166
172
|
|
|
167
173
|
// Register protocol contracts.
|
|
168
174
|
for (const { contractClass, instance, artifact } of protocolContracts) {
|
|
@@ -310,6 +316,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
310
316
|
this.noteStore,
|
|
311
317
|
this.stateMachine.node,
|
|
312
318
|
this.stateMachine.anchorBlockStore,
|
|
319
|
+
this.currentJobId,
|
|
313
320
|
).syncNoteNullifiers(contractAddress);
|
|
314
321
|
|
|
315
322
|
// Private execution has two associated block numbers: the anchor block (i.e. the historical block that is used to
|
|
@@ -403,6 +410,7 @@ export class TXESession implements TXESessionStateHandler {
|
|
|
403
410
|
this.noteStore,
|
|
404
411
|
this.stateMachine.node,
|
|
405
412
|
this.stateMachine.anchorBlockStore,
|
|
413
|
+
this.currentJobId,
|
|
406
414
|
).syncNoteNullifiers(contractAddress);
|
|
407
415
|
|
|
408
416
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { Body,
|
|
10
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
11
11
|
import { AppendOnlyTreeSnapshot, MerkleTreeId, type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
12
12
|
import { BlockHeader, GlobalVariables, TxEffect } from '@aztec/stdlib/tx';
|
|
13
13
|
|
|
@@ -61,7 +61,7 @@ export async function makeTXEBlockHeader(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Creates an
|
|
64
|
+
* Creates an L2Block with proper archive chaining.
|
|
65
65
|
* This function:
|
|
66
66
|
* 1. Gets the current archive state as lastArchive for the header
|
|
67
67
|
* 2. Creates the block header
|
|
@@ -71,13 +71,13 @@ export async function makeTXEBlockHeader(
|
|
|
71
71
|
* @param worldTrees - The world trees to read/write from
|
|
72
72
|
* @param globalVariables - Global variables for the block
|
|
73
73
|
* @param txEffects - Transaction effects to include in the block
|
|
74
|
-
* @returns The created
|
|
74
|
+
* @returns The created L2Block with proper archive chaining
|
|
75
75
|
*/
|
|
76
76
|
export async function makeTXEBlock(
|
|
77
77
|
worldTrees: MerkleTreeWriteOperations,
|
|
78
78
|
globalVariables: GlobalVariables,
|
|
79
79
|
txEffects: TxEffect[],
|
|
80
|
-
): Promise<
|
|
80
|
+
): Promise<L2Block> {
|
|
81
81
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
82
82
|
|
|
83
83
|
// Update the archive tree with this block's header hash
|
|
@@ -87,9 +87,9 @@ export async function makeTXEBlock(
|
|
|
87
87
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
88
88
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
89
89
|
|
|
90
|
-
//
|
|
90
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint
|
|
91
91
|
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
92
92
|
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
93
93
|
|
|
94
|
-
return new
|
|
94
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
95
95
|
}
|