@aztec/txe 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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/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 +85 -52
- package/dest/oracle/interfaces.d.ts +12 -9
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +7 -7
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +10 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +23 -14
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +177 -79
- package/dest/rpc_translator.d.ts +30 -18
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +127 -60
- package/dest/state_machine/archiver.d.ts +21 -52
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +63 -94
- package/dest/state_machine/dummy_p2p_client.d.ts +19 -14
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +41 -24
- package/dest/state_machine/global_variable_builder.d.ts +6 -5
- 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 +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +40 -23
- package/dest/state_machine/mock_epoch_cache.d.ts +9 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +14 -7
- 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 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +151 -52
- package/dest/util/encoding.d.ts +618 -19
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +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_public_contract_data_source.d.ts +8 -8
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +12 -29
- 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 +38 -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 -18
- package/src/constants.ts +3 -0
- package/src/index.ts +97 -60
- package/src/oracle/interfaces.ts +11 -8
- package/src/oracle/txe_oracle_public_context.ts +12 -19
- package/src/oracle/txe_oracle_top_level_context.ts +213 -124
- package/src/rpc_translator.ts +156 -60
- package/src/state_machine/archiver.ts +59 -114
- package/src/state_machine/dummy_p2p_client.ts +57 -32
- package/src/state_machine/global_variable_builder.ts +21 -4
- package/src/state_machine/index.ts +60 -21
- package/src/state_machine/mock_epoch_cache.ts +15 -11
- package/src/state_machine/synchronizer.ts +6 -5
- package/src/txe_session.ts +207 -100
- 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_public_contract_data_source.ts +20 -45
- package/src/utils/block_creation.ts +49 -15
- 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
- package/dest/util/txe_contract_data_provider.js +0 -22
- package/src/util/txe_contract_data_provider.ts +0 -36
package/src/oracle/interfaces.ts
CHANGED
|
@@ -2,10 +2,11 @@ import type { ContractArtifact } from '@aztec/aztec.js/abi';
|
|
|
2
2
|
import { CompleteAddress } from '@aztec/aztec.js/addresses';
|
|
3
3
|
import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
4
4
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
5
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
6
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
+
import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type {
|
|
9
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
9
10
|
|
|
10
11
|
// These interfaces complement the ones defined in PXE, and combined with those contain the full list of oracles used by
|
|
11
12
|
// aztec-nr. In particular, these include the ones needed to run Brillig code associated to #[external("public")] functions that has
|
|
@@ -25,16 +26,16 @@ export interface IAvmExecutionOracle {
|
|
|
25
26
|
|
|
26
27
|
avmOpcodeAddress(): Promise<AztecAddress>;
|
|
27
28
|
avmOpcodeSender(): Promise<AztecAddress>;
|
|
28
|
-
avmOpcodeBlockNumber(): Promise<
|
|
29
|
+
avmOpcodeBlockNumber(): Promise<BlockNumber>;
|
|
29
30
|
avmOpcodeTimestamp(): Promise<bigint>;
|
|
30
31
|
avmOpcodeIsStaticCall(): Promise<boolean>;
|
|
31
32
|
avmOpcodeChainId(): Promise<Fr>;
|
|
32
33
|
avmOpcodeVersion(): Promise<Fr>;
|
|
33
34
|
avmOpcodeEmitNullifier(nullifier: Fr): Promise<void>;
|
|
34
35
|
avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
|
|
35
|
-
avmOpcodeNullifierExists(
|
|
36
|
+
avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
36
37
|
avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
37
|
-
avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
|
|
38
|
+
avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -43,7 +44,8 @@ export interface IAvmExecutionOracle {
|
|
|
43
44
|
export interface ITxeExecutionOracle {
|
|
44
45
|
isTxe: true;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
txeGetDefaultAddress(): AztecAddress;
|
|
48
|
+
txeGetNextBlockNumber(): Promise<BlockNumber>;
|
|
47
49
|
txeGetNextBlockTimestamp(): Promise<UInt64>;
|
|
48
50
|
txeAdvanceBlocksBy(blocks: number): Promise<void>;
|
|
49
51
|
txeAdvanceTimestampBy(duration: UInt64): void;
|
|
@@ -61,6 +63,7 @@ export interface ITxeExecutionOracle {
|
|
|
61
63
|
noteHashes: Fr[];
|
|
62
64
|
nullifiers: Fr[];
|
|
63
65
|
}>;
|
|
66
|
+
txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
64
67
|
txePrivateCallNewFlow(
|
|
65
68
|
from: AztecAddress,
|
|
66
69
|
targetContractAddress: AztecAddress,
|
|
@@ -69,7 +72,7 @@ export interface ITxeExecutionOracle {
|
|
|
69
72
|
argsHash: Fr,
|
|
70
73
|
isStaticCall: boolean,
|
|
71
74
|
): Promise<Fr[]>;
|
|
72
|
-
|
|
75
|
+
txeExecuteUtilityFunction(
|
|
73
76
|
targetContractAddress: AztecAddress,
|
|
74
77
|
functionSelector: FunctionSelector,
|
|
75
78
|
args: Fr[],
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
4
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import {
|
|
6
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
6
7
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
7
|
-
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
8
8
|
import {
|
|
9
9
|
MerkleTreeId,
|
|
10
10
|
type MerkleTreeWriteOperations,
|
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
PublicDataTreeLeafPreimage,
|
|
13
13
|
} from '@aztec/stdlib/trees';
|
|
14
14
|
import { GlobalVariables, TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
15
|
-
import type { UInt32 } from '@aztec/stdlib/types';
|
|
16
15
|
|
|
17
|
-
import { insertTxEffectIntoWorldTrees,
|
|
16
|
+
import { insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
18
17
|
import type { IAvmExecutionOracle } from './interfaces.js';
|
|
19
18
|
|
|
20
19
|
export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
@@ -48,7 +47,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
48
47
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
avmOpcodeBlockNumber(): Promise<
|
|
50
|
+
avmOpcodeBlockNumber(): Promise<BlockNumber> {
|
|
52
51
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -79,13 +78,11 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
79
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
async avmOpcodeNullifierExists(
|
|
83
|
-
const nullifier = await siloNullifier(targetAddress, innerNullifier!);
|
|
84
|
-
|
|
81
|
+
async avmOpcodeNullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
85
82
|
const treeIndex = (
|
|
86
|
-
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
83
|
+
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
87
84
|
)[0];
|
|
88
|
-
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(
|
|
85
|
+
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
|
|
89
86
|
|
|
90
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
91
88
|
}
|
|
@@ -102,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
102
99
|
]);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
|
|
106
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
102
|
+
async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
|
+
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
107
104
|
|
|
108
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
109
106
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
@@ -120,7 +117,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
120
117
|
)) as PublicDataTreeLeafPreimage
|
|
121
118
|
).leaf.value;
|
|
122
119
|
|
|
123
|
-
this.logger.debug('AVM storage read', { slot, value });
|
|
120
|
+
this.logger.debug('AVM storage read', { slot, contractAddress, value });
|
|
124
121
|
|
|
125
122
|
return value;
|
|
126
123
|
}
|
|
@@ -133,11 +130,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
133
130
|
const txEffect = this.makeTxEffect();
|
|
134
131
|
await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
|
|
135
132
|
|
|
136
|
-
const block =
|
|
137
|
-
makeAppendOnlyTreeSnapshot(),
|
|
138
|
-
await makeTXEBlockHeader(this.forkedWorldTrees, this.globalVariables),
|
|
139
|
-
new Body([txEffect]),
|
|
140
|
-
);
|
|
133
|
+
const block = await makeTXEBlock(this.forkedWorldTrees, this.globalVariables, [txEffect]);
|
|
141
134
|
|
|
142
135
|
await this.forkedWorldTrees.close();
|
|
143
136
|
|