@aztec/txe 0.0.1-commit.fce3e4f → 0.0.1-commit.ffe5b04ea
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 +91 -56
- package/dest/oracle/interfaces.d.ts +33 -29
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +16 -16
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +20 -22
- package/dest/oracle/txe_oracle_top_level_context.d.ts +36 -27
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +206 -98
- package/dest/rpc_translator.d.ts +91 -79
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +330 -170
- 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 +20 -15
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +42 -25
- 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 +26 -15
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +161 -55
- 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 +103 -63
- package/src/oracle/interfaces.ts +36 -32
- package/src/oracle/txe_oracle_public_context.ts +21 -28
- package/src/oracle/txe_oracle_top_level_context.ts +251 -138
- package/src/rpc_translator.ts +368 -174
- package/src/state_machine/archiver.ts +59 -114
- package/src/state_machine/dummy_p2p_client.ts +58 -33
- 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 +222 -103
- 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
|
|
@@ -23,18 +24,18 @@ import type { UInt32, UInt64 } from '@aztec/stdlib/types';
|
|
|
23
24
|
export interface IAvmExecutionOracle {
|
|
24
25
|
isAvm: true;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
address(): Promise<AztecAddress>;
|
|
28
|
+
sender(): Promise<AztecAddress>;
|
|
29
|
+
blockNumber(): Promise<BlockNumber>;
|
|
30
|
+
timestamp(): Promise<bigint>;
|
|
31
|
+
isStaticCall(): Promise<boolean>;
|
|
32
|
+
chainId(): Promise<Fr>;
|
|
33
|
+
version(): Promise<Fr>;
|
|
34
|
+
emitNullifier(nullifier: Fr): Promise<void>;
|
|
35
|
+
emitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
|
+
nullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
37
|
+
storageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
+
storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -43,41 +44,44 @@ export interface IAvmExecutionOracle {
|
|
|
43
44
|
export interface ITxeExecutionOracle {
|
|
44
45
|
isTxe: true;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
): Promise<
|
|
57
|
-
txeAddAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
58
|
-
txeGetLastBlockTimestamp(): Promise<bigint>;
|
|
59
|
-
txeGetLastTxEffects(): Promise<{
|
|
47
|
+
getDefaultAddress(): AztecAddress;
|
|
48
|
+
getNextBlockNumber(): Promise<BlockNumber>;
|
|
49
|
+
getNextBlockTimestamp(): Promise<UInt64>;
|
|
50
|
+
advanceBlocksBy(blocks: number): Promise<void>;
|
|
51
|
+
advanceTimestampBy(duration: UInt64): void;
|
|
52
|
+
deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: Fr): Promise<void>;
|
|
53
|
+
createAccount(secret: Fr): Promise<CompleteAddress>;
|
|
54
|
+
addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr): Promise<CompleteAddress>;
|
|
55
|
+
addAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
56
|
+
getLastBlockTimestamp(): Promise<bigint>;
|
|
57
|
+
getLastTxEffects(): Promise<{
|
|
60
58
|
txHash: TxHash;
|
|
61
59
|
noteHashes: Fr[];
|
|
62
60
|
nullifiers: Fr[];
|
|
63
61
|
}>;
|
|
64
|
-
|
|
62
|
+
getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
63
|
+
privateCallNewFlow(
|
|
65
64
|
from: AztecAddress,
|
|
66
65
|
targetContractAddress: AztecAddress,
|
|
67
66
|
functionSelector: FunctionSelector,
|
|
68
67
|
args: Fr[],
|
|
69
68
|
argsHash: Fr,
|
|
70
69
|
isStaticCall: boolean,
|
|
70
|
+
jobId: string,
|
|
71
71
|
): Promise<Fr[]>;
|
|
72
|
-
|
|
72
|
+
executeUtilityFunction(
|
|
73
73
|
targetContractAddress: AztecAddress,
|
|
74
74
|
functionSelector: FunctionSelector,
|
|
75
75
|
args: Fr[],
|
|
76
|
+
jobId: string,
|
|
76
77
|
): Promise<Fr[]>;
|
|
77
|
-
|
|
78
|
+
publicCallNewFlow(
|
|
78
79
|
from: AztecAddress,
|
|
79
80
|
targetContractAddress: AztecAddress,
|
|
80
81
|
calldata: Fr[],
|
|
81
82
|
isStaticCall: boolean,
|
|
82
83
|
): Promise<Fr[]>;
|
|
84
|
+
// TODO(F-335): Drop this from here as it's not a real oracle handler - it's only called from
|
|
85
|
+
// RPCTranslator::txeGetPrivateEvents and never from Noir.
|
|
86
|
+
syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string): Promise<void>;
|
|
83
87
|
}
|
|
@@ -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 {
|
|
@@ -40,57 +39,55 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
address(): Promise<AztecAddress> {
|
|
44
43
|
return Promise.resolve(this.contractAddress);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
sender(): Promise<AztecAddress> {
|
|
48
47
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
blockNumber(): Promise<BlockNumber> {
|
|
52
51
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
|
|
54
|
+
timestamp(): Promise<bigint> {
|
|
56
55
|
return Promise.resolve(this.globalVariables.timestamp);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
|
|
58
|
+
isStaticCall(): Promise<boolean> {
|
|
60
59
|
return Promise.resolve(false);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
62
|
+
chainId(): Promise<Fr> {
|
|
64
63
|
return Promise.resolve(this.globalVariables.chainId);
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
|
|
66
|
+
version(): Promise<Fr> {
|
|
68
67
|
return Promise.resolve(this.globalVariables.version);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
async
|
|
70
|
+
async emitNullifier(nullifier: Fr) {
|
|
72
71
|
const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
|
|
73
72
|
this.transientSiloedNullifiers.push(siloedNullifier);
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
async
|
|
75
|
+
async emitNoteHash(noteHash: Fr) {
|
|
77
76
|
const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
|
|
78
77
|
// TODO: make the note hash unique - they are only siloed right now
|
|
79
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
|
-
async
|
|
83
|
-
const nullifier = await siloNullifier(targetAddress, innerNullifier!);
|
|
84
|
-
|
|
81
|
+
async nullifierExists(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
|
}
|
|
92
89
|
|
|
93
|
-
async
|
|
90
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
94
91
|
this.logger.debug('AVM storage write', { slot, value });
|
|
95
92
|
|
|
96
93
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -102,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
102
99
|
]);
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
async
|
|
106
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
102
|
+
async storageRead(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
|
|