@aztec/txe 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
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/oracle/interfaces.d.ts +2 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +3 -2
- package/dest/oracle/txe_oracle_top_level_context.d.ts +16 -13
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +77 -61
- package/dest/rpc_translator.d.ts +15 -9
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +49 -35
- package/dest/state_machine/archiver.d.ts +20 -67
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +57 -178
- package/dest/state_machine/dummy_p2p_client.d.ts +8 -7
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +13 -10
- package/dest/state_machine/global_variable_builder.d.ts +2 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +1 -1
- package/dest/state_machine/index.d.ts +4 -4
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +28 -10
- package/dest/state_machine/mock_epoch_cache.d.ts +7 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +10 -7
- 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 +17 -14
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +86 -48
- package/dest/util/encoding.d.ts +17 -17
- 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 +4 -4
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +10 -10
- package/dest/utils/block_creation.d.ts +4 -4
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +16 -5
- package/dest/utils/tx_effect_creation.d.ts +2 -3
- package/dest/utils/tx_effect_creation.d.ts.map +1 -1
- package/dest/utils/tx_effect_creation.js +3 -6
- package/package.json +16 -16
- package/src/constants.ts +3 -0
- package/src/index.ts +1 -1
- package/src/oracle/interfaces.ts +1 -1
- package/src/oracle/txe_oracle_public_context.ts +3 -3
- package/src/oracle/txe_oracle_top_level_context.ts +110 -78
- package/src/rpc_translator.ts +53 -45
- package/src/state_machine/archiver.ts +52 -220
- package/src/state_machine/dummy_p2p_client.ts +18 -13
- package/src/state_machine/global_variable_builder.ts +1 -1
- package/src/state_machine/index.ts +30 -8
- package/src/state_machine/mock_epoch_cache.ts +10 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +165 -86
- 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 +9 -9
- package/src/utils/block_creation.ts +17 -16
- package/src/utils/tx_effect_creation.ts +3 -11
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"block_creation.d.ts","sourceRoot":"","sources":["../../src/utils/block_creation.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAA2C,MAAM,iCAAiC,CAAC;AAEvG,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAQ,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,WAAW,GAAG,EAAE,CAExE;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,CAAC,CAYtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,yBAAyB,EACrC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,OAAO,CAAC,CAelB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { Body, L2Block
|
|
5
|
-
import { makeContentCommitment } from '@aztec/stdlib/testing';
|
|
5
|
+
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
6
6
|
import { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
7
|
+
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
7
8
|
/**
|
|
8
9
|
* Returns a transaction request hash that is valid for transactions that are the only ones in a block.
|
|
9
10
|
* @param blockNumber The number for the block in which there is a single transaction.
|
|
@@ -20,7 +21,14 @@ export async function insertTxEffectIntoWorldTrees(txEffect, worldTrees) {
|
|
|
20
21
|
export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
21
22
|
const stateReference = await worldTrees.getStateReference();
|
|
22
23
|
const archiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
23
|
-
return
|
|
24
|
+
return BlockHeader.from({
|
|
25
|
+
lastArchive: new AppendOnlyTreeSnapshot(new Fr(archiveInfo.root), Number(archiveInfo.size)),
|
|
26
|
+
spongeBlobHash: Fr.ZERO,
|
|
27
|
+
state: stateReference,
|
|
28
|
+
globalVariables,
|
|
29
|
+
totalFees: Fr.ZERO,
|
|
30
|
+
totalManaUsed: Fr.ZERO
|
|
31
|
+
});
|
|
24
32
|
}
|
|
25
33
|
/**
|
|
26
34
|
* Creates an L2Block with proper archive chaining.
|
|
@@ -37,9 +45,12 @@ export async function makeTXEBlockHeader(worldTrees, globalVariables) {
|
|
|
37
45
|
*/ export async function makeTXEBlock(worldTrees, globalVariables, txEffects) {
|
|
38
46
|
const header = await makeTXEBlockHeader(worldTrees, globalVariables);
|
|
39
47
|
// Update the archive tree with this block's header hash
|
|
40
|
-
await worldTrees.updateArchive(header
|
|
48
|
+
await worldTrees.updateArchive(header);
|
|
41
49
|
// Get the new archive state after updating
|
|
42
50
|
const newArchiveInfo = await worldTrees.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
43
51
|
const newArchive = new AppendOnlyTreeSnapshot(new Fr(newArchiveInfo.root), Number(newArchiveInfo.size));
|
|
44
|
-
|
|
52
|
+
// L2Block requires checkpointNumber and indexWithinCheckpoint
|
|
53
|
+
const checkpointNumber = CheckpointNumber.fromBlockNumber(globalVariables.blockNumber);
|
|
54
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(0);
|
|
55
|
+
return new L2Block(newArchive, header, new Body(txEffects), checkpointNumber, indexWithinCheckpoint);
|
|
45
56
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import type { ExecutionNoteCache } from '@aztec/pxe/simulator';
|
|
4
3
|
import { TxEffect } from '@aztec/stdlib/tx';
|
|
5
|
-
export declare function makeTxEffect(noteCache: ExecutionNoteCache,
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
export declare function makeTxEffect(noteCache: ExecutionNoteCache, txBlockNumber: BlockNumber): Promise<TxEffect>;
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZWZmZWN0X2NyZWF0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvdHhfZWZmZWN0X2NyZWF0aW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRS9ELE9BQU8sRUFBRSxRQUFRLEVBQVUsTUFBTSxrQkFBa0IsQ0FBQztBQUVwRCx3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxrQkFBa0IsRUFBRSxhQUFhLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0F1Qi9HIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"tx_effect_creation.d.ts","sourceRoot":"","sources":["../../src/utils/tx_effect_creation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAC;AAEpD,wBAAsB,YAAY,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuB/G"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash } from '@aztec/stdlib/hash';
|
|
3
3
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
4
|
-
export async function makeTxEffect(noteCache,
|
|
4
|
+
export async function makeTxEffect(noteCache, txBlockNumber) {
|
|
5
5
|
const txEffect = TxEffect.empty();
|
|
6
|
-
|
|
7
|
-
const nonceGenerator =
|
|
6
|
+
noteCache.finish();
|
|
7
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
8
8
|
txEffect.noteHashes = await Promise.all(noteCache.getAllNotes().map(async (pendingNote, i)=>computeUniqueNoteHash(await computeNoteHashNonce(nonceGenerator, i), await siloNoteHash(pendingNote.note.contractAddress, pendingNote.noteHashForConsumption))));
|
|
9
9
|
// Nullifiers are already siloed
|
|
10
10
|
txEffect.nullifiers = noteCache.getAllNullifiers();
|
|
11
|
-
if (usedProtocolNullifierForNonces) {
|
|
12
|
-
txEffect.nullifiers.unshift(protocolNullifier);
|
|
13
|
-
}
|
|
14
11
|
txEffect.txHash = new TxHash(new Fr(txBlockNumber));
|
|
15
12
|
return txEffect;
|
|
16
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.0b941701",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -61,27 +61,27 @@
|
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@aztec/accounts": "0.0.1-commit.
|
|
65
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
66
|
-
"@aztec/aztec-node": "0.0.1-commit.
|
|
67
|
-
"@aztec/aztec.js": "0.0.1-commit.
|
|
68
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
71
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
72
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
73
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
74
|
-
"@aztec/pxe": "0.0.1-commit.
|
|
75
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
76
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
64
|
+
"@aztec/accounts": "0.0.1-commit.0b941701",
|
|
65
|
+
"@aztec/archiver": "0.0.1-commit.0b941701",
|
|
66
|
+
"@aztec/aztec-node": "0.0.1-commit.0b941701",
|
|
67
|
+
"@aztec/aztec.js": "0.0.1-commit.0b941701",
|
|
68
|
+
"@aztec/bb-prover": "0.0.1-commit.0b941701",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.0b941701",
|
|
70
|
+
"@aztec/foundation": "0.0.1-commit.0b941701",
|
|
71
|
+
"@aztec/key-store": "0.0.1-commit.0b941701",
|
|
72
|
+
"@aztec/kv-store": "0.0.1-commit.0b941701",
|
|
73
|
+
"@aztec/protocol-contracts": "0.0.1-commit.0b941701",
|
|
74
|
+
"@aztec/pxe": "0.0.1-commit.0b941701",
|
|
75
|
+
"@aztec/simulator": "0.0.1-commit.0b941701",
|
|
76
|
+
"@aztec/stdlib": "0.0.1-commit.0b941701",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.0b941701",
|
|
78
78
|
"zod": "^3.23.8"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@jest/globals": "^30.0.0",
|
|
82
82
|
"@types/jest": "^30.0.0",
|
|
83
83
|
"@types/node": "^22.15.17",
|
|
84
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
84
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
85
85
|
"jest": "^30.0.0",
|
|
86
86
|
"jest-mock-extended": "^4.0.0",
|
|
87
87
|
"ts-node": "^10.9.1",
|
package/src/constants.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
fromSingle,
|
|
34
34
|
toSingle,
|
|
35
35
|
} from './util/encoding.js';
|
|
36
|
-
import type { ContractArtifactWithHash } from './util/
|
|
36
|
+
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
37
37
|
|
|
38
38
|
const sessions = new Map<number, TXESession>();
|
|
39
39
|
|
package/src/oracle/interfaces.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface IAvmExecutionOracle {
|
|
|
35
35
|
avmOpcodeEmitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
36
|
avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise<boolean>;
|
|
37
37
|
avmOpcodeStorageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
-
avmOpcodeStorageRead(slot: Fr): Promise<Fr>;
|
|
38
|
+
avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -101,8 +101,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
101
101
|
]);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
async avmOpcodeStorageRead(slot: Fr): Promise<Fr> {
|
|
105
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
104
|
+
async avmOpcodeStorageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
105
|
+
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
106
106
|
|
|
107
107
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
108
108
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
@@ -119,7 +119,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
119
119
|
)) as PublicDataTreeLeafPreimage
|
|
120
120
|
).leaf.value;
|
|
121
121
|
|
|
122
|
-
this.logger.debug('AVM storage read', { slot, value });
|
|
122
|
+
this.logger.debug('AVM storage read', { slot, contractAddress, value });
|
|
123
123
|
|
|
124
124
|
return value;
|
|
125
125
|
}
|
|
@@ -13,14 +13,16 @@ import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@az
|
|
|
13
13
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
14
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
AddressStore,
|
|
17
|
+
CapsuleStore,
|
|
18
|
+
NoteStore,
|
|
19
19
|
ORACLE_VERSION,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
PrivateEventStore,
|
|
21
|
+
RecipientTaggingStore,
|
|
22
|
+
SenderAddressBookStore,
|
|
23
|
+
SenderTaggingStore,
|
|
23
24
|
enrichPublicSimulationError,
|
|
25
|
+
syncState,
|
|
24
26
|
} from '@aztec/pxe/server';
|
|
25
27
|
import {
|
|
26
28
|
ExecutionNoteCache,
|
|
@@ -48,7 +50,7 @@ import {
|
|
|
48
50
|
PublicContractsDB,
|
|
49
51
|
PublicProcessor,
|
|
50
52
|
} from '@aztec/simulator/server';
|
|
51
|
-
import { type ContractArtifact, EventSelector, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
53
|
+
import { type ContractArtifact, EventSelector, FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
52
54
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
53
55
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
54
56
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -79,10 +81,10 @@ import {
|
|
|
79
81
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
80
82
|
import { ForkCheckpoint } from '@aztec/world-state';
|
|
81
83
|
|
|
84
|
+
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
82
85
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
83
|
-
import {
|
|
84
|
-
import type {
|
|
85
|
-
import type { TXEContractDataProvider } from '../util/txe_contract_data_provider.js';
|
|
86
|
+
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
87
|
+
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
86
88
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
87
89
|
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
88
90
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
@@ -95,15 +97,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
95
97
|
|
|
96
98
|
constructor(
|
|
97
99
|
private stateMachine: TXEStateMachine,
|
|
98
|
-
private
|
|
99
|
-
private
|
|
100
|
+
private contractStore: TXEContractStore,
|
|
101
|
+
private noteStore: NoteStore,
|
|
100
102
|
private keyStore: KeyStore,
|
|
101
|
-
private
|
|
102
|
-
private
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
103
|
+
private addressStore: AddressStore,
|
|
104
|
+
private accountStore: TXEAccountStore,
|
|
105
|
+
private senderTaggingStore: SenderTaggingStore,
|
|
106
|
+
private recipientTaggingStore: RecipientTaggingStore,
|
|
107
|
+
private senderAddressBookStore: SenderAddressBookStore,
|
|
108
|
+
private capsuleStore: CapsuleStore,
|
|
109
|
+
private privateEventStore: PrivateEventStore,
|
|
110
|
+
private jobId: string,
|
|
107
111
|
private nextBlockTimestamp: bigint,
|
|
108
112
|
private version: Fr,
|
|
109
113
|
private chainId: Fr,
|
|
@@ -154,7 +158,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
async txeGetLastTxEffects() {
|
|
157
|
-
const
|
|
161
|
+
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
|
+
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
158
163
|
|
|
159
164
|
if (block!.body.txEffects.length != 1) {
|
|
160
165
|
// Note that calls like env.mine() will result in blocks with no transactions, hitting this
|
|
@@ -168,7 +173,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
168
173
|
|
|
169
174
|
async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
170
175
|
return (
|
|
171
|
-
await this.
|
|
176
|
+
await this.privateEventStore.getPrivateEvents(selector, {
|
|
172
177
|
contractAddress,
|
|
173
178
|
scopes: [scope],
|
|
174
179
|
fromBlock: 0,
|
|
@@ -204,8 +209,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
204
209
|
if (!secret.equals(Fr.ZERO)) {
|
|
205
210
|
await this.txeAddAccount(artifact, instance, secret);
|
|
206
211
|
} else {
|
|
207
|
-
await this.
|
|
208
|
-
await this.
|
|
212
|
+
await this.contractStore.addContractInstance(instance);
|
|
213
|
+
await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
|
|
209
214
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
210
215
|
}
|
|
211
216
|
}
|
|
@@ -214,12 +219,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
214
219
|
const partialAddress = await computePartialAddress(instance);
|
|
215
220
|
|
|
216
221
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
217
|
-
await this.
|
|
218
|
-
await this.
|
|
222
|
+
await this.contractStore.addContractInstance(instance);
|
|
223
|
+
await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
|
|
219
224
|
|
|
220
225
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
221
|
-
await this.
|
|
222
|
-
await this.
|
|
226
|
+
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
227
|
+
await this.addressStore.addCompleteAddress(completeAddress);
|
|
223
228
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
224
229
|
|
|
225
230
|
return completeAddress;
|
|
@@ -228,15 +233,15 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
228
233
|
async txeCreateAccount(secret: Fr) {
|
|
229
234
|
// This is a foot gun !
|
|
230
235
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
231
|
-
await this.
|
|
232
|
-
await this.
|
|
236
|
+
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
237
|
+
await this.addressStore.addCompleteAddress(completeAddress);
|
|
233
238
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
234
239
|
|
|
235
240
|
return completeAddress;
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
async txeAddAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
239
|
-
const account = await this.
|
|
244
|
+
const account = await this.accountStore.getAccount(address);
|
|
240
245
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
241
246
|
|
|
242
247
|
const schnorr = new Schnorr();
|
|
@@ -281,10 +286,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
281
286
|
isStaticCall: boolean = false,
|
|
282
287
|
) {
|
|
283
288
|
this.logger.verbose(
|
|
284
|
-
`Executing external function ${await this.
|
|
289
|
+
`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
285
290
|
);
|
|
286
291
|
|
|
287
|
-
const artifact = await this.
|
|
292
|
+
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
288
293
|
if (!artifact) {
|
|
289
294
|
const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)'))
|
|
290
295
|
? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.'
|
|
@@ -292,22 +297,32 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
292
297
|
throw new Error(message);
|
|
293
298
|
}
|
|
294
299
|
|
|
300
|
+
// Sync notes before executing private function to discover notes from previous transactions
|
|
301
|
+
const utilityExecutor = async (call: FunctionCall) => {
|
|
302
|
+
await this.executeUtilityCall(call);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
await syncState(targetContractAddress, this.contractStore, functionSelector, utilityExecutor);
|
|
306
|
+
|
|
295
307
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
296
308
|
|
|
297
309
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
298
310
|
|
|
299
311
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
300
|
-
|
|
301
312
|
const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
|
|
302
|
-
|
|
303
313
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
304
314
|
|
|
305
315
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
306
316
|
|
|
307
|
-
const blockHeader = await this.stateMachine.
|
|
317
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
308
318
|
|
|
309
319
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
310
320
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
321
|
+
// In production, the account contract sets the min revertible counter before calling the app function.
|
|
322
|
+
// Since TXE bypasses the account contract, we simulate this by setting minRevertibleSideEffectCounter to 1,
|
|
323
|
+
// marking all side effects as revertible.
|
|
324
|
+
const minRevertibleSideEffectCounter = 1;
|
|
325
|
+
await noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
311
326
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
312
327
|
|
|
313
328
|
const simulator = new WASMSimulator();
|
|
@@ -318,6 +333,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
318
333
|
callContext,
|
|
319
334
|
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
320
335
|
blockHeader,
|
|
336
|
+
utilityExecutor,
|
|
321
337
|
/** List of transient auth witnesses to be used during this simulation */
|
|
322
338
|
Array.from(this.authwits.values()),
|
|
323
339
|
/** List of transient auth witnesses to be used during this simulation */
|
|
@@ -325,18 +341,20 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
325
341
|
HashedValuesCache.create([new HashedValues(args, argsHash)]),
|
|
326
342
|
noteCache,
|
|
327
343
|
taggingIndexCache,
|
|
328
|
-
this.
|
|
329
|
-
this.
|
|
344
|
+
this.contractStore,
|
|
345
|
+
this.noteStore,
|
|
330
346
|
this.keyStore,
|
|
331
|
-
this.
|
|
347
|
+
this.addressStore,
|
|
332
348
|
this.stateMachine.node,
|
|
333
|
-
this.stateMachine.
|
|
334
|
-
this.
|
|
335
|
-
this.
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
|
|
339
|
-
|
|
349
|
+
this.stateMachine.anchorBlockStore,
|
|
350
|
+
this.senderTaggingStore,
|
|
351
|
+
this.recipientTaggingStore,
|
|
352
|
+
this.senderAddressBookStore,
|
|
353
|
+
this.capsuleStore,
|
|
354
|
+
this.privateEventStore,
|
|
355
|
+
this.jobId,
|
|
356
|
+
0, // totalPublicArgsCount
|
|
357
|
+
minRevertibleSideEffectCounter, // (start) sideEffectCounter
|
|
340
358
|
undefined, // log
|
|
341
359
|
undefined, // scopes
|
|
342
360
|
/**
|
|
@@ -372,19 +390,21 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
372
390
|
}),
|
|
373
391
|
);
|
|
374
392
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
result = new PrivateExecutionResult(executionResult, Fr.ZERO, publicFunctionsCalldata);
|
|
393
|
+
noteCache.finish();
|
|
394
|
+
const nonceGenerator = noteCache.getNonceGenerator();
|
|
395
|
+
result = new PrivateExecutionResult(executionResult, nonceGenerator, publicFunctionsCalldata);
|
|
379
396
|
} catch (err) {
|
|
380
397
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
381
398
|
}
|
|
382
399
|
|
|
383
|
-
// According to the protocol rules,
|
|
384
|
-
//
|
|
385
|
-
//
|
|
386
|
-
const
|
|
387
|
-
|
|
400
|
+
// According to the protocol rules, there must be at least one nullifier in the tx. The first nullifier is used as
|
|
401
|
+
// the nonce generator for the note hashes.
|
|
402
|
+
// We pass the non-zero minRevertibleSideEffectCounter to make sure the side effects are split correctly.
|
|
403
|
+
const { publicInputs } = await generateSimulatedProvingResult(
|
|
404
|
+
result,
|
|
405
|
+
this.contractStore,
|
|
406
|
+
minRevertibleSideEffectCounter,
|
|
407
|
+
);
|
|
388
408
|
|
|
389
409
|
const globals = makeGlobalVariables();
|
|
390
410
|
globals.blockNumber = blockNumber;
|
|
@@ -395,7 +415,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
395
415
|
|
|
396
416
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
397
417
|
|
|
398
|
-
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.
|
|
418
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
|
|
399
419
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
400
420
|
const config = PublicSimulatorConfig.from({
|
|
401
421
|
skipFeeEnforcement: true,
|
|
@@ -434,7 +454,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
434
454
|
} else if (!processedTx.revertCode.isOK()) {
|
|
435
455
|
if (processedTx.revertReason) {
|
|
436
456
|
try {
|
|
437
|
-
await enrichPublicSimulationError(processedTx.revertReason, this.
|
|
457
|
+
await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
|
|
438
458
|
// eslint-disable-next-line no-empty
|
|
439
459
|
} catch {}
|
|
440
460
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -479,7 +499,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
479
499
|
isStaticCall: boolean,
|
|
480
500
|
) {
|
|
481
501
|
this.logger.verbose(
|
|
482
|
-
`Executing public function ${await this.
|
|
502
|
+
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
483
503
|
);
|
|
484
504
|
|
|
485
505
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
@@ -492,7 +512,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
492
512
|
|
|
493
513
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
494
514
|
|
|
495
|
-
const anchorBlockHeader = await this.stateMachine.
|
|
515
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
496
516
|
|
|
497
517
|
const calldataHash = await computeCalldataHash(calldata);
|
|
498
518
|
const calldataHashedValues = new HashedValues(calldata, calldataHash);
|
|
@@ -506,7 +526,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
506
526
|
|
|
507
527
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
508
528
|
|
|
509
|
-
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.
|
|
529
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
|
|
510
530
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
511
531
|
const config = PublicSimulatorConfig.from({
|
|
512
532
|
skipFeeEnforcement: true,
|
|
@@ -574,7 +594,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
574
594
|
} else if (!processedTx.revertCode.isOK()) {
|
|
575
595
|
if (processedTx.revertReason) {
|
|
576
596
|
try {
|
|
577
|
-
await enrichPublicSimulationError(processedTx.revertReason, this.
|
|
597
|
+
await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
|
|
578
598
|
// eslint-disable-next-line no-empty
|
|
579
599
|
} catch {}
|
|
580
600
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -620,21 +640,32 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
620
640
|
functionSelector: FunctionSelector,
|
|
621
641
|
args: Fr[],
|
|
622
642
|
) {
|
|
623
|
-
const artifact = await this.
|
|
643
|
+
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
624
644
|
if (!artifact) {
|
|
625
645
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
626
646
|
}
|
|
627
647
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
};
|
|
648
|
+
// Sync notes before executing utility function to discover notes from previous transactions
|
|
649
|
+
await syncState(targetContractAddress, this.contractStore, functionSelector, async call => {
|
|
650
|
+
await this.executeUtilityCall(call);
|
|
651
|
+
});
|
|
633
652
|
|
|
634
|
-
const
|
|
635
|
-
|
|
636
|
-
|
|
653
|
+
const call = new FunctionCall(
|
|
654
|
+
artifact.name,
|
|
655
|
+
targetContractAddress,
|
|
656
|
+
functionSelector,
|
|
657
|
+
FunctionType.UTILITY,
|
|
658
|
+
false,
|
|
659
|
+
false,
|
|
660
|
+
args,
|
|
661
|
+
[],
|
|
637
662
|
);
|
|
663
|
+
|
|
664
|
+
return this.executeUtilityCall(call);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
private async executeUtilityCall(call: FunctionCall): Promise<Fr[]> {
|
|
668
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
638
669
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
639
670
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
640
671
|
}
|
|
@@ -645,25 +676,26 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
645
676
|
});
|
|
646
677
|
|
|
647
678
|
try {
|
|
648
|
-
const anchorBlockHeader = await this.stateMachine.
|
|
679
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
649
680
|
const oracle = new UtilityExecutionOracle(
|
|
650
681
|
call.to,
|
|
651
682
|
[],
|
|
652
683
|
[],
|
|
653
684
|
anchorBlockHeader,
|
|
654
|
-
this.
|
|
655
|
-
this.
|
|
685
|
+
this.contractStore,
|
|
686
|
+
this.noteStore,
|
|
656
687
|
this.keyStore,
|
|
657
|
-
this.
|
|
688
|
+
this.addressStore,
|
|
658
689
|
this.stateMachine.node,
|
|
659
|
-
this.stateMachine.
|
|
660
|
-
this.
|
|
661
|
-
this.
|
|
662
|
-
this.
|
|
663
|
-
this.
|
|
690
|
+
this.stateMachine.anchorBlockStore,
|
|
691
|
+
this.recipientTaggingStore,
|
|
692
|
+
this.senderAddressBookStore,
|
|
693
|
+
this.capsuleStore,
|
|
694
|
+
this.privateEventStore,
|
|
695
|
+
this.jobId,
|
|
664
696
|
);
|
|
665
697
|
const acirExecutionResult = await new WASMSimulator()
|
|
666
|
-
.executeUserCircuit(toACVMWitness(0, args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
698
|
+
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
667
699
|
.catch((err: Error) => {
|
|
668
700
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
669
701
|
throw new ExecutionError(
|