@aztec/txe 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c
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/constants.d.ts +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -2
- package/dest/oracle/interfaces.d.ts +10 -7
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +6 -6
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +7 -8
- package/dest/oracle/txe_oracle_top_level_context.d.ts +22 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +124 -78
- package/dest/rpc_translator.d.ts +29 -14
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +108 -45
- package/dest/state_machine/archiver.d.ts +21 -51
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +64 -94
- package/dest/state_machine/dummy_p2p_client.d.ts +9 -6
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +16 -8
- package/dest/state_machine/global_variable_builder.d.ts +6 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +13 -1
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +22 -19
- package/dest/state_machine/mock_epoch_cache.d.ts +12 -10
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +17 -13
- package/dest/state_machine/synchronizer.d.ts +3 -2
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +5 -4
- package/dest/txe_session.d.ts +21 -13
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +97 -48
- package/dest/util/encoding.d.ts +615 -16
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +1 -1
- 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_store.d.ts +10 -0
- package/dest/util/txe_account_store.d.ts.map +1 -0
- package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
- package/dest/util/txe_contract_store.d.ts +12 -0
- package/dest/util/txe_contract_store.d.ts.map +1 -0
- package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
- package/dest/util/txe_public_contract_data_source.d.ts +7 -6
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +11 -11
- package/dest/utils/block_creation.d.ts +21 -6
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +36 -4
- package/dest/utils/tx_effect_creation.d.ts +3 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +4 -7
- package/package.json +18 -17
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +9 -6
- package/src/oracle/txe_oracle_public_context.ts +9 -14
- package/src/oracle/txe_oracle_top_level_context.ts +174 -105
- package/src/rpc_translator.ts +134 -56
- package/src/state_machine/archiver.ts +65 -117
- package/src/state_machine/dummy_p2p_client.ts +22 -10
- package/src/state_machine/global_variable_builder.ts +22 -4
- package/src/state_machine/index.ts +27 -18
- package/src/state_machine/mock_epoch_cache.ts +20 -20
- package/src/state_machine/synchronizer.ts +6 -5
- package/src/txe_session.ts +195 -82
- package/src/util/encoding.ts +1 -1
- package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
- package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
- package/src/util/txe_public_contract_data_source.ts +13 -12
- package/src/utils/block_creation.ts +47 -14
- package/src/utils/tx_effect_creation.ts +5 -12
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type {
|
|
2
3
|
AuthRequest,
|
|
3
4
|
ENR,
|
|
4
5
|
P2P,
|
|
5
6
|
P2PBlockReceivedCallback,
|
|
7
|
+
P2PCheckpointReceivedCallback,
|
|
6
8
|
P2PConfig,
|
|
7
9
|
P2PSyncState,
|
|
8
10
|
PeerId,
|
|
@@ -13,7 +15,7 @@ import type {
|
|
|
13
15
|
} from '@aztec/p2p';
|
|
14
16
|
import type { EthAddress, L2BlockStreamEvent, L2Tips } from '@aztec/stdlib/block';
|
|
15
17
|
import type { PeerInfo } from '@aztec/stdlib/interfaces/server';
|
|
16
|
-
import type {
|
|
18
|
+
import type { BlockProposal, CheckpointAttestation, CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
17
19
|
import type { Tx, TxHash } from '@aztec/stdlib/tx';
|
|
18
20
|
|
|
19
21
|
export class DummyP2P implements P2P {
|
|
@@ -41,10 +43,22 @@ export class DummyP2P implements P2P {
|
|
|
41
43
|
throw new Error('DummyP2P does not implement "broadcastProposal"');
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
public broadcastCheckpointProposal(_proposal: CheckpointProposal): Promise<void> {
|
|
47
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointProposal"');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public broadcastCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
51
|
+
throw new Error('DummyP2P does not implement "broadcastCheckpointAttestations"');
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
public registerBlockProposalHandler(_handler: P2PBlockReceivedCallback): void {
|
|
45
55
|
throw new Error('DummyP2P does not implement "registerBlockProposalHandler"');
|
|
46
56
|
}
|
|
47
57
|
|
|
58
|
+
public registerCheckpointProposalHandler(_handler: P2PCheckpointReceivedCallback): void {
|
|
59
|
+
throw new Error('DummyP2P does not implement "registerCheckpointProposalHandler"');
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
public requestTxs(_txHashes: TxHash[]): Promise<(Tx | undefined)[]> {
|
|
49
63
|
throw new Error('DummyP2P does not implement "requestTxs"');
|
|
50
64
|
}
|
|
@@ -74,7 +88,9 @@ export class DummyP2P implements P2P {
|
|
|
74
88
|
}
|
|
75
89
|
|
|
76
90
|
public getTxStatus(_txHash: TxHash): Promise<'pending' | 'mined' | undefined> {
|
|
77
|
-
|
|
91
|
+
// In TXE there is no concept of transactions but we need to implement this because of tagging. We return 'mined'
|
|
92
|
+
// tx status for any tx hash.
|
|
93
|
+
return Promise.resolve('mined');
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
public iteratePendingTxs(): AsyncIterableIterator<Tx> {
|
|
@@ -113,16 +129,12 @@ export class DummyP2P implements P2P {
|
|
|
113
129
|
throw new Error('DummyP2P does not implement "getTxsByHash"');
|
|
114
130
|
}
|
|
115
131
|
|
|
116
|
-
public
|
|
117
|
-
throw new Error('DummyP2P does not implement "
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public deleteAttestation(_attestation: BlockAttestation): Promise<void> {
|
|
121
|
-
return Promise.resolve();
|
|
132
|
+
public getCheckpointAttestationsForSlot(_slot: SlotNumber, _proposalId?: string): Promise<CheckpointAttestation[]> {
|
|
133
|
+
throw new Error('DummyP2P does not implement "getCheckpointAttestationsForSlot"');
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
public
|
|
125
|
-
throw new Error('DummyP2P does not implement "
|
|
136
|
+
public addCheckpointAttestations(_attestations: CheckpointAttestation[]): Promise<void> {
|
|
137
|
+
throw new Error('DummyP2P does not implement "addCheckpointAttestations"');
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
public getL2BlockHash(_number: number): Promise<string | undefined> {
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
+
import { BlockNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
4
5
|
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
5
|
-
import { type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
|
|
6
|
+
import { type CheckpointGlobalVariables, type GlobalVariableBuilder, GlobalVariables } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
7
8
|
export class TXEGlobalVariablesBuilder implements GlobalVariableBuilder {
|
|
8
|
-
public
|
|
9
|
+
public getCurrentMinFees(): Promise<GasFees> {
|
|
9
10
|
return Promise.resolve(new GasFees(0, 0));
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
public buildGlobalVariables(
|
|
13
|
-
_blockNumber:
|
|
14
|
+
_blockNumber: BlockNumber,
|
|
14
15
|
_coinbase: EthAddress,
|
|
15
16
|
_feeRecipient: AztecAddress,
|
|
16
|
-
_slotNumber?:
|
|
17
|
+
_slotNumber?: SlotNumber,
|
|
17
18
|
): Promise<GlobalVariables> {
|
|
18
19
|
return Promise.resolve(makeGlobalVariables());
|
|
19
20
|
}
|
|
21
|
+
|
|
22
|
+
public buildCheckpointGlobalVariables(
|
|
23
|
+
_coinbase: EthAddress,
|
|
24
|
+
_feeRecipient: AztecAddress,
|
|
25
|
+
_slotNumber: SlotNumber,
|
|
26
|
+
): Promise<CheckpointGlobalVariables> {
|
|
27
|
+
const vars = makeGlobalVariables();
|
|
28
|
+
return Promise.resolve({
|
|
29
|
+
chainId: vars.chainId,
|
|
30
|
+
version: vars.version,
|
|
31
|
+
slotNumber: vars.slotNumber,
|
|
32
|
+
timestamp: vars.timestamp,
|
|
33
|
+
coinbase: vars.coinbase,
|
|
34
|
+
feeRecipient: vars.feeRecipient,
|
|
35
|
+
gasFees: vars.gasFees,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
20
38
|
}
|
|
@@ -2,8 +2,9 @@ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
|
2
2
|
import { TestCircuitVerifier } from '@aztec/bb-prover/test';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { AnchorBlockStore } from '@aztec/pxe/server';
|
|
6
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
7
|
+
import { Checkpoint, L1PublishedData, PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
7
8
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
8
9
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
9
10
|
|
|
@@ -21,13 +22,13 @@ export class TXEStateMachine {
|
|
|
21
22
|
public node: AztecNode,
|
|
22
23
|
public synchronizer: TXESynchronizer,
|
|
23
24
|
public archiver: TXEArchiver,
|
|
24
|
-
public
|
|
25
|
+
public anchorBlockStore: AnchorBlockStore,
|
|
25
26
|
) {}
|
|
26
27
|
|
|
27
28
|
public static async create(db: AztecAsyncKVStore) {
|
|
28
29
|
const archiver = new TXEArchiver(db);
|
|
29
30
|
const synchronizer = await TXESynchronizer.create();
|
|
30
|
-
const
|
|
31
|
+
const anchorBlockStore = new AnchorBlockStore(db);
|
|
31
32
|
|
|
32
33
|
const aztecNodeConfig = {} as AztecNodeConfig;
|
|
33
34
|
|
|
@@ -54,24 +55,32 @@ export class TXEStateMachine {
|
|
|
54
55
|
log,
|
|
55
56
|
);
|
|
56
57
|
|
|
57
|
-
return new this(node, synchronizer, archiver,
|
|
58
|
+
return new this(node, synchronizer, archiver, anchorBlockStore);
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
public async handleL2Block(block: L2Block) {
|
|
62
|
+
// Create a checkpoint from the block - L2Block doesn't have toCheckpoint() method
|
|
63
|
+
// We need to construct the Checkpoint manually
|
|
64
|
+
const checkpoint = await Checkpoint.random(block.checkpointNumber, {
|
|
65
|
+
numBlocks: 1,
|
|
66
|
+
startBlockNumber: Number(block.number),
|
|
67
|
+
});
|
|
68
|
+
// Replace the random block with our actual block
|
|
69
|
+
checkpoint.blocks = [block];
|
|
70
|
+
|
|
71
|
+
const publishedCheckpoint = new PublishedCheckpoint(
|
|
72
|
+
checkpoint,
|
|
73
|
+
new L1PublishedData(
|
|
74
|
+
BigInt(block.header.globalVariables.blockNumber),
|
|
75
|
+
block.header.globalVariables.timestamp,
|
|
76
|
+
block.header.globalVariables.blockNumber.toString(),
|
|
77
|
+
),
|
|
78
|
+
[],
|
|
79
|
+
);
|
|
61
80
|
await Promise.all([
|
|
62
|
-
this.synchronizer.handleL2Block(block),
|
|
63
|
-
this.archiver.
|
|
64
|
-
|
|
65
|
-
block,
|
|
66
|
-
l1: {
|
|
67
|
-
blockHash: block.header.globalVariables.blockNumber.toString(),
|
|
68
|
-
blockNumber: BigInt(block.header.globalVariables.blockNumber),
|
|
69
|
-
timestamp: block.header.globalVariables.timestamp,
|
|
70
|
-
},
|
|
71
|
-
attestations: [],
|
|
72
|
-
}),
|
|
73
|
-
]),
|
|
74
|
-
this.syncDataProvider.setHeader(block.getBlockHeader()),
|
|
81
|
+
this.synchronizer.handleL2Block(block), // L2Block doesn't need toL2Block() conversion
|
|
82
|
+
this.archiver.addCheckpoints([publishedCheckpoint], undefined),
|
|
83
|
+
this.anchorBlockStore.setHeader(block.header), // Use .header property directly
|
|
75
84
|
]);
|
|
76
85
|
}
|
|
77
86
|
}
|
|
@@ -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,47 +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,
|
|
15
|
+
isEscapeHatchOpen: false,
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
getEpochAndSlotNow(): EpochAndSlot {
|
|
19
|
+
getEpochAndSlotNow(): EpochAndSlot & { nowMs: bigint } {
|
|
18
20
|
return {
|
|
19
|
-
epoch:
|
|
20
|
-
slot:
|
|
21
|
+
epoch: EpochNumber.ZERO,
|
|
22
|
+
slot: SlotNumber(0),
|
|
21
23
|
ts: 0n,
|
|
24
|
+
nowMs: 0n,
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
getEpochAndSlotInNextL1Slot(): EpochAndSlot & { now: bigint } {
|
|
26
29
|
return {
|
|
27
|
-
epoch:
|
|
28
|
-
slot:
|
|
30
|
+
epoch: EpochNumber.ZERO,
|
|
31
|
+
slot: SlotNumber(0),
|
|
29
32
|
ts: 0n,
|
|
30
33
|
now: 0n,
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
getProposerIndexEncoding(_epoch:
|
|
37
|
+
getProposerIndexEncoding(_epoch: EpochNumber, _slot: SlotNumber, _seed: bigint): `0x${string}` {
|
|
35
38
|
return '0x00';
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
computeProposerIndex(_slot:
|
|
41
|
+
computeProposerIndex(_slot: SlotNumber, _epoch: EpochNumber, _seed: bigint, _size: bigint): bigint {
|
|
39
42
|
return 0n;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
currentSlot: 0n,
|
|
52
|
-
nextSlot: 0n,
|
|
53
|
-
});
|
|
45
|
+
getCurrentAndNextSlot(): { currentSlot: SlotNumber; nextSlot: SlotNumber } {
|
|
46
|
+
return {
|
|
47
|
+
currentSlot: SlotNumber(0),
|
|
48
|
+
nextSlot: SlotNumber(0),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getProposerAttesterAddressInSlot(_slot: SlotNumber): Promise<EthAddress | undefined> {
|
|
53
|
+
return Promise.resolve(undefined);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
isInCommittee(_slot: SlotTag, _validator: EthAddress): Promise<boolean> {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
4
|
import type { L2Block } from '@aztec/stdlib/block';
|
|
4
5
|
import type {
|
|
5
6
|
MerkleTreeReadOperations,
|
|
@@ -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
|
|
|
@@ -37,7 +38,7 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
37
38
|
* @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
|
|
38
39
|
* @returns A promise that resolves with the block number the world state was synced to
|
|
39
40
|
*/
|
|
40
|
-
public syncImmediate(_minBlockNumber?:
|
|
41
|
+
public syncImmediate(_minBlockNumber?: BlockNumber, _skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber> {
|
|
41
42
|
return Promise.resolve(this.blockNumber);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -48,12 +49,12 @@ export class TXESynchronizer implements WorldStateSynchronizer {
|
|
|
48
49
|
|
|
49
50
|
/** Forks the world state at the given block number, defaulting to the latest one. */
|
|
50
51
|
public fork(block?: number): Promise<MerkleTreeWriteOperations> {
|
|
51
|
-
return this.nativeWorldStateService.fork(block);
|
|
52
|
+
return this.nativeWorldStateService.fork(block ? BlockNumber(block) : undefined);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/** Gets a handle that allows reading the state as it was at the given block number. */
|
|
55
56
|
public getSnapshot(blockNumber: number): MerkleTreeReadOperations {
|
|
56
|
-
return this.nativeWorldStateService.getSnapshot(blockNumber);
|
|
57
|
+
return this.nativeWorldStateService.getSnapshot(BlockNumber(blockNumber));
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/** Backups the db to the target path. */
|