@aztec/simulator 0.61.0 → 0.63.0
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/acvm/acvm.d.ts +2 -16
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +2 -70
- package/dest/acvm/oracle/oracle.d.ts +4 -3
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +11 -9
- package/dest/acvm/oracle/typed_oracle.d.ts +5 -4
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +9 -6
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +4 -3
- package/dest/avm/avm_machine_state.d.ts +27 -8
- package/dest/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/avm/avm_machine_state.js +6 -10
- package/dest/avm/avm_memory_types.d.ts +8 -0
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +5 -1
- package/dest/avm/avm_simulator.d.ts +2 -19
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +12 -14
- package/dest/avm/avm_tree.d.ts +249 -0
- package/dest/avm/avm_tree.d.ts.map +1 -0
- package/dest/avm/avm_tree.js +637 -0
- package/dest/avm/errors.d.ts +4 -17
- package/dest/avm/errors.d.ts.map +1 -1
- package/dest/avm/errors.js +21 -50
- package/dest/avm/fixtures/index.d.ts +7 -2
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +12 -12
- package/dest/avm/index.d.ts +1 -0
- package/dest/avm/index.d.ts.map +1 -1
- package/dest/avm/index.js +2 -1
- package/dest/avm/journal/journal.d.ts +43 -24
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +172 -39
- package/dest/avm/journal/nullifiers.d.ts +5 -4
- package/dest/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/avm/journal/nullifiers.js +2 -3
- package/dest/avm/journal/public_storage.d.ts +6 -5
- package/dest/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/avm/journal/public_storage.js +1 -1
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +4 -10
- package/dest/avm/opcodes/arithmetic.d.ts +4 -1
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +18 -4
- package/dest/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/avm/opcodes/bitwise.js +1 -3
- package/dest/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/avm/opcodes/comparators.js +1 -2
- package/dest/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/avm/opcodes/contract.js +2 -3
- package/dest/avm/opcodes/control_flow.d.ts +4 -0
- package/dest/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/avm/opcodes/control_flow.js +26 -11
- package/dest/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/avm/opcodes/conversion.js +1 -2
- package/dest/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/avm/opcodes/ec_add.js +5 -11
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +1 -2
- package/dest/avm/opcodes/external_calls.d.ts +4 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +38 -22
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +1 -4
- package/dest/avm/opcodes/instruction.d.ts +4 -0
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +7 -1
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +1 -7
- package/dest/avm/opcodes/misc.js +3 -3
- package/dest/avm/opcodes/multi_scalar_mul.d.ts.map +1 -1
- package/dest/avm/opcodes/multi_scalar_mul.js +6 -5
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +2 -4
- package/dest/avm/serialization/bytecode_serialization.d.ts +1 -6
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +24 -20
- package/dest/avm/serialization/instruction_serialization.d.ts +2 -2
- package/dest/avm/serialization/instruction_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +7 -10
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +19 -18
- package/dest/client/db_oracle.d.ts +22 -8
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/db_oracle.js +1 -1
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +5 -4
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +3 -2
- package/dest/client/view_data_oracle.d.ts +6 -12
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +10 -12
- package/dest/common/errors.d.ts +15 -2
- package/dest/common/errors.d.ts.map +1 -1
- package/dest/common/errors.js +85 -4
- package/dest/mocks/fixtures.d.ts +9 -28
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +12 -57
- package/dest/public/dual_side_effect_trace.d.ts +34 -26
- package/dest/public/dual_side_effect_trace.d.ts.map +1 -1
- package/dest/public/dual_side_effect_trace.js +48 -36
- package/dest/public/enqueued_call_side_effect_trace.d.ts +96 -33
- package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
- package/dest/public/enqueued_call_side_effect_trace.js +212 -138
- package/dest/public/execution.d.ts +50 -17
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -29
- package/dest/public/executor.d.ts +28 -11
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +33 -33
- package/dest/public/index.d.ts +4 -5
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +4 -5
- package/dest/public/public_db_sources.d.ts +1 -0
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +21 -19
- package/dest/public/public_processor.d.ts +7 -11
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +60 -42
- package/dest/public/public_processor_metrics.d.ts +3 -3
- package/dest/public/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor_metrics.js +1 -1
- package/dest/public/public_tx_context.d.ts +130 -0
- package/dest/public/public_tx_context.d.ts.map +1 -0
- package/dest/public/public_tx_context.js +293 -0
- package/dest/public/public_tx_simulator.d.ts +36 -0
- package/dest/public/public_tx_simulator.d.ts.map +1 -0
- package/dest/public/public_tx_simulator.js +148 -0
- package/dest/public/side_effect_trace.d.ts +30 -15
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +70 -16
- package/dest/public/side_effect_trace_interface.d.ts +43 -12
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/transitional_adapters.d.ts +9 -0
- package/dest/public/transitional_adapters.d.ts.map +1 -0
- package/dest/public/transitional_adapters.js +127 -0
- package/dest/public/utils.d.ts +5 -0
- package/dest/public/utils.d.ts.map +1 -0
- package/dest/public/utils.js +30 -0
- package/dest/test/utils.d.ts +2 -2
- package/dest/test/utils.d.ts.map +1 -1
- package/dest/test/utils.js +4 -4
- package/package.json +12 -9
- package/src/acvm/acvm.ts +3 -94
- package/src/acvm/oracle/oracle.ts +14 -12
- package/src/acvm/oracle/typed_oracle.ts +10 -6
- package/src/avm/avm_gas.ts +3 -2
- package/src/avm/avm_machine_state.ts +28 -12
- package/src/avm/avm_memory_types.ts +5 -0
- package/src/avm/avm_simulator.ts +13 -16
- package/src/avm/avm_tree.ts +785 -0
- package/src/avm/errors.ts +25 -48
- package/src/avm/fixtures/index.ts +16 -12
- package/src/avm/index.ts +1 -0
- package/src/avm/journal/journal.ts +291 -52
- package/src/avm/journal/nullifiers.ts +7 -7
- package/src/avm/journal/public_storage.ts +5 -5
- package/src/avm/opcodes/accrued_substate.ts +3 -9
- package/src/avm/opcodes/arithmetic.ts +26 -4
- package/src/avm/opcodes/bitwise.ts +0 -2
- package/src/avm/opcodes/comparators.ts +0 -1
- package/src/avm/opcodes/contract.ts +1 -2
- package/src/avm/opcodes/control_flow.ts +29 -10
- package/src/avm/opcodes/conversion.ts +0 -1
- package/src/avm/opcodes/ec_add.ts +6 -9
- package/src/avm/opcodes/environment_getters.ts +0 -1
- package/src/avm/opcodes/external_calls.ts +39 -21
- package/src/avm/opcodes/hashing.ts +0 -3
- package/src/avm/opcodes/instruction.ts +7 -0
- package/src/avm/opcodes/memory.ts +0 -6
- package/src/avm/opcodes/misc.ts +2 -2
- package/src/avm/opcodes/multi_scalar_mul.ts +5 -4
- package/src/avm/opcodes/storage.ts +1 -3
- package/src/avm/serialization/bytecode_serialization.ts +31 -22
- package/src/avm/serialization/instruction_serialization.ts +2 -2
- package/src/client/client_execution_context.ts +24 -21
- package/src/client/db_oracle.ts +31 -8
- package/src/client/private_execution.ts +5 -4
- package/src/client/unconstrained_execution.ts +2 -1
- package/src/client/view_data_oracle.ts +14 -13
- package/src/common/errors.ts +119 -3
- package/src/mocks/fixtures.ts +15 -106
- package/src/public/dual_side_effect_trace.ts +138 -50
- package/src/public/enqueued_call_side_effect_trace.ts +352 -212
- package/src/public/execution.ts +58 -42
- package/src/public/executor.ts +52 -67
- package/src/public/index.ts +7 -5
- package/src/public/public_db_sources.ts +22 -19
- package/src/public/public_processor.ts +111 -73
- package/src/public/public_processor_metrics.ts +3 -3
- package/src/public/public_tx_context.ts +411 -0
- package/src/public/public_tx_simulator.ts +232 -0
- package/src/public/side_effect_trace.ts +154 -28
- package/src/public/side_effect_trace_interface.ts +92 -14
- package/src/public/transitional_adapters.ts +347 -0
- package/src/public/utils.ts +32 -0
- package/src/test/utils.ts +9 -2
- package/dest/public/enqueued_call_simulator.d.ts +0 -43
- package/dest/public/enqueued_call_simulator.d.ts.map +0 -1
- package/dest/public/enqueued_call_simulator.js +0 -156
- package/dest/public/enqueued_calls_processor.d.ts +0 -43
- package/dest/public/enqueued_calls_processor.d.ts.map +0 -1
- package/dest/public/enqueued_calls_processor.js +0 -209
- package/dest/public/hints_builder.d.ts +0 -29
- package/dest/public/hints_builder.d.ts.map +0 -1
- package/dest/public/hints_builder.js +0 -75
- package/dest/public/public_kernel.d.ts +0 -30
- package/dest/public/public_kernel.d.ts.map +0 -1
- package/dest/public/public_kernel.js +0 -67
- package/dest/public/public_kernel_circuit_simulator.d.ts +0 -25
- package/dest/public/public_kernel_circuit_simulator.d.ts.map +0 -1
- package/dest/public/public_kernel_circuit_simulator.js +0 -2
- package/dest/public/public_kernel_tail_simulator.d.ts +0 -15
- package/dest/public/public_kernel_tail_simulator.d.ts.map +0 -1
- package/dest/public/public_kernel_tail_simulator.js +0 -39
- package/src/public/enqueued_call_simulator.ts +0 -360
- package/src/public/enqueued_calls_processor.ts +0 -372
- package/src/public/hints_builder.ts +0 -168
- package/src/public/public_kernel.ts +0 -100
- package/src/public/public_kernel_circuit_simulator.ts +0 -32
- package/src/public/public_kernel_tail_simulator.ts +0 -97
package/src/avm/errors.ts
CHANGED
|
@@ -21,6 +21,13 @@ export class NoBytecodeForContractError extends AvmExecutionError {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export class ArithmeticError extends AvmExecutionError {
|
|
25
|
+
constructor(message: string) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.name = 'ArithmeticError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
/**
|
|
25
32
|
* Error is thrown when the program counter goes to an invalid location.
|
|
26
33
|
* There is no instruction at the provided pc
|
|
@@ -78,18 +85,6 @@ export class StaticCallAlterationError extends InstructionExecutionError {
|
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
/**
|
|
82
|
-
* Error thrown to propagate a nested call's revert.
|
|
83
|
-
* @param message - the error's message
|
|
84
|
-
* @param nestedError - the revert reason of the nested call
|
|
85
|
-
*/
|
|
86
|
-
export class RethrownError extends AvmExecutionError {
|
|
87
|
-
constructor(message: string, public nestedError: AvmRevertReason) {
|
|
88
|
-
super(message);
|
|
89
|
-
this.name = 'RethrownError';
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
88
|
/**
|
|
94
89
|
* Meaningfully named alias for ExecutionError when used in the context of the AVM.
|
|
95
90
|
* Maintains a recursive structure reflecting the AVM's external callstack/errorstack, where
|
|
@@ -101,22 +96,28 @@ export class AvmRevertReason extends ExecutionError {
|
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
|
|
104
|
-
|
|
105
|
-
* Helper to create a "revert reason" error optionally with a nested error cause.
|
|
106
|
-
*
|
|
107
|
-
* @param message - the error message
|
|
108
|
-
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
109
|
-
* @param nestedError - the error that caused this one (if this is not the root-cause itself)
|
|
110
|
-
*/
|
|
111
|
-
function createRevertReason(message: string, context: AvmContext, nestedError?: AvmRevertReason): AvmRevertReason {
|
|
99
|
+
function createRevertReason(message: string, revertData: Fr[], context: AvmContext): AvmRevertReason {
|
|
112
100
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Properly fix this.
|
|
113
101
|
// If the function selector is the public dispatch selector, we need to extract the actual function selector from the calldata.
|
|
114
102
|
// We should remove this because the AVM (or public protocol) shouldn't be aware of the public dispatch calling convention.
|
|
115
103
|
let functionSelector = context.environment.functionSelector;
|
|
116
|
-
|
|
104
|
+
// We drop the returnPc information.
|
|
105
|
+
const internalCallStack = context.machineState.internalCallStack.map(entry => entry.callPc);
|
|
117
106
|
if (functionSelector.toField().equals(new Fr(PUBLIC_DISPATCH_SELECTOR)) && context.environment.calldata.length > 0) {
|
|
118
107
|
functionSelector = FunctionSelector.fromField(context.environment.calldata[0]);
|
|
119
108
|
}
|
|
109
|
+
|
|
110
|
+
// If we are reverting due to the same error that we have been tracking, we use the nested error as the cause.
|
|
111
|
+
let nestedError = undefined;
|
|
112
|
+
const revertDataEquals = (a: Fr[], b: Fr[]) => a.length === b.length && a.every((v, i) => v.equals(b[i]));
|
|
113
|
+
if (
|
|
114
|
+
context.machineState.collectedRevertInfo &&
|
|
115
|
+
revertDataEquals(context.machineState.collectedRevertInfo.revertDataRepresentative, revertData)
|
|
116
|
+
) {
|
|
117
|
+
nestedError = context.machineState.collectedRevertInfo.recursiveRevertReason;
|
|
118
|
+
message = context.machineState.collectedRevertInfo.recursiveRevertReason.message;
|
|
119
|
+
}
|
|
120
|
+
|
|
120
121
|
return new AvmRevertReason(
|
|
121
122
|
message,
|
|
122
123
|
/*failingFunction=*/ {
|
|
@@ -129,16 +130,13 @@ function createRevertReason(message: string, context: AvmContext, nestedError?:
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
/**
|
|
132
|
-
* Create a "revert reason" error for an exceptional halt
|
|
133
|
-
* creating the recursive structure if the halt was a RethrownError.
|
|
133
|
+
* Create a "revert reason" error for an exceptional halt.
|
|
134
134
|
*
|
|
135
135
|
* @param haltingError - the lower-level error causing the exceptional halt
|
|
136
136
|
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
137
137
|
*/
|
|
138
138
|
export function revertReasonFromExceptionalHalt(haltingError: AvmExecutionError, context: AvmContext): AvmRevertReason {
|
|
139
|
-
|
|
140
|
-
const nestedError = haltingError instanceof RethrownError ? haltingError.nestedError : undefined;
|
|
141
|
-
return createRevertReason(haltingError.message, context, nestedError);
|
|
139
|
+
return createRevertReason(haltingError.message, [], context);
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
/**
|
|
@@ -148,26 +146,5 @@ export function revertReasonFromExceptionalHalt(haltingError: AvmExecutionError,
|
|
|
148
146
|
* @param context - the context of the AVM execution used to extract the failingFunction and noirCallStack
|
|
149
147
|
*/
|
|
150
148
|
export function revertReasonFromExplicitRevert(revertData: Fr[], context: AvmContext): AvmRevertReason {
|
|
151
|
-
|
|
152
|
-
return createRevertReason(revertMessage, context);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Interpret revert data as a message string.
|
|
157
|
-
*
|
|
158
|
-
* @param revertData - output data of an explicit REVERT instruction
|
|
159
|
-
*/
|
|
160
|
-
export function decodeRevertDataAsMessage(revertData: Fr[]): string {
|
|
161
|
-
if (revertData.length === 0) {
|
|
162
|
-
return 'Assertion failed';
|
|
163
|
-
} else {
|
|
164
|
-
try {
|
|
165
|
-
// We remove the first element which is the 'error selector'.
|
|
166
|
-
const revertOutput = revertData.slice(1);
|
|
167
|
-
// Try to interpret the output as a text string.
|
|
168
|
-
return 'Assertion failed: ' + String.fromCharCode(...revertOutput.map(fr => fr.toNumber()));
|
|
169
|
-
} catch (e) {
|
|
170
|
-
return 'Assertion failed: <cannot interpret as string>';
|
|
171
|
-
}
|
|
172
|
-
}
|
|
149
|
+
return createRevertReason('Assertion failed: ', revertData, context);
|
|
173
150
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isNoirCallStackUnresolved } from '@aztec/circuit-types';
|
|
1
|
+
import { type MerkleTreeWriteOperations, isNoirCallStackUnresolved } from '@aztec/circuit-types';
|
|
2
2
|
import { GasFees, GlobalVariables, MAX_L2_GAS_PER_ENQUEUED_CALL } from '@aztec/circuits.js';
|
|
3
|
-
import {
|
|
3
|
+
import { type FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi';
|
|
4
4
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -10,7 +10,7 @@ import { strict as assert } from 'assert';
|
|
|
10
10
|
import { mock } from 'jest-mock-extended';
|
|
11
11
|
import merge from 'lodash.merge';
|
|
12
12
|
|
|
13
|
-
import { type WorldStateDB,
|
|
13
|
+
import { type WorldStateDB, resolveAssertionMessageFromRevertData, traverseCauseChain } from '../../index.js';
|
|
14
14
|
import { type PublicSideEffectTraceInterface } from '../../public/side_effect_trace_interface.js';
|
|
15
15
|
import { AvmContext } from '../avm_context.js';
|
|
16
16
|
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
@@ -42,6 +42,8 @@ export function initPersistableStateManager(overrides?: {
|
|
|
42
42
|
trace?: PublicSideEffectTraceInterface;
|
|
43
43
|
publicStorage?: PublicStorage;
|
|
44
44
|
nullifiers?: NullifierManager;
|
|
45
|
+
doMerkleOperations?: boolean;
|
|
46
|
+
merkleTrees?: MerkleTreeWriteOperations;
|
|
45
47
|
}): AvmPersistableStateManager {
|
|
46
48
|
const worldStateDB = overrides?.worldStateDB || mock<WorldStateDB>();
|
|
47
49
|
return new AvmPersistableStateManager(
|
|
@@ -49,6 +51,8 @@ export function initPersistableStateManager(overrides?: {
|
|
|
49
51
|
overrides?.trace || mock<PublicSideEffectTraceInterface>(),
|
|
50
52
|
overrides?.publicStorage || new PublicStorage(worldStateDB),
|
|
51
53
|
overrides?.nullifiers || new NullifierManager(worldStateDB),
|
|
54
|
+
overrides?.doMerkleOperations || false,
|
|
55
|
+
overrides?.merkleTrees || mock<MerkleTreeWriteOperations>(),
|
|
52
56
|
);
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -124,33 +128,33 @@ export function getAvmTestContractFunctionSelector(functionName: string): Functi
|
|
|
124
128
|
return FunctionSelector.fromNameAndParameters(artifact.name, params);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
export function
|
|
131
|
+
export function getAvmTestContractArtifact(functionName: string): FunctionArtifact {
|
|
128
132
|
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
|
|
129
133
|
assert(
|
|
130
134
|
!!artifact?.bytecode,
|
|
131
135
|
`No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`,
|
|
132
136
|
);
|
|
137
|
+
return artifact;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function getAvmTestContractBytecode(functionName: string): Buffer {
|
|
141
|
+
const artifact = getAvmTestContractArtifact(functionName);
|
|
133
142
|
return artifact.bytecode;
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
export function resolveAvmTestContractAssertionMessage(
|
|
137
146
|
functionName: string,
|
|
138
147
|
revertReason: AvmRevertReason,
|
|
148
|
+
output: Fr[],
|
|
139
149
|
): string | undefined {
|
|
140
|
-
const functionArtifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
|
|
141
|
-
|
|
142
150
|
traverseCauseChain(revertReason, cause => {
|
|
143
151
|
revertReason = cause as AvmRevertReason;
|
|
144
152
|
});
|
|
145
153
|
|
|
154
|
+
const functionArtifact = AvmTestContractArtifact.functions.find(f => f.name === functionName);
|
|
146
155
|
if (!functionArtifact || !revertReason.noirCallStack || !isNoirCallStackUnresolved(revertReason.noirCallStack)) {
|
|
147
156
|
return undefined;
|
|
148
157
|
}
|
|
149
158
|
|
|
150
|
-
|
|
151
|
-
if (!debugMetadata) {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return resolveAssertionMessage(revertReason.noirCallStack, debugMetadata);
|
|
159
|
+
return resolveAssertionMessageFromRevertData(output, functionArtifact);
|
|
156
160
|
}
|
package/src/avm/index.ts
CHANGED