Skip to content

Commit

Permalink
9745: stop execution when an error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Nov 11, 2024
1 parent d5b5c8c commit af823d6
Show file tree
Hide file tree
Showing 7 changed files with 795 additions and 665 deletions.
18 changes: 12 additions & 6 deletions barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ TEST_F(AvmExecutionTests, opCallOpcodes)
// Calldata for l2_gas, da_gas, contract_address, nested_call_args (4 elements),
std::vector<FF> calldata = { 17, 10, 34802342, 1, 2, 3, 4 };
std::string bytecode_preamble;

// Set up Gas offsets
bytecode_preamble += to_hex(OpCode::SET_8) + // opcode SET for gas offset indirect
"00" // Indirect flag
Expand All @@ -2106,19 +2107,24 @@ TEST_F(AvmExecutionTests, opCallOpcodes)
"03" // val 3 (the start of the args array)
"13"; // dst_offset 19
// Set up args size offset
bytecode_preamble += to_hex(OpCode::SET_8) + // opcode SET for ret offset indirect
bytecode_preamble += to_hex(OpCode::SET_8) + // opcode SET for args size indirect
"00" // Indirect flag
+ to_hex(AvmMemoryTag::U32) +
"04" // val 4 (the length of the args array)
"14"; // dst_offset 20
"04" // val 4 - resolved address
"14"; // dst_offset 20
bytecode_preamble += to_hex(OpCode::SET_8) + // opcode SET
"00" // Indirect flag
+ to_hex(AvmMemoryTag::U32) + //
"00" // val 0 (args size)
"04"; // dst_offset 4
// Set up the ret offset
bytecode_preamble += to_hex(OpCode::SET_16) + // opcode SET for ret offset indirect
"00" // Indirect flag
+ to_hex(AvmMemoryTag::U32) +
"0100" // val 256 (the start of where to write the return data)
"0015"; // dst_offset 21
// Set up the success offset
bytecode_preamble += to_hex(OpCode::SET_16) + // opcode SET for ret offset indirect
bytecode_preamble += to_hex(OpCode::SET_16) + // opcode SET for success offset indirect
"00" // Indirect flag
+ to_hex(AvmMemoryTag::U32) +
"0102" // val 258 (write the success flag at ret_offset + ret_size)
Expand Down Expand Up @@ -2206,8 +2212,8 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcode)

std::string bytecode_hex = to_hex(OpCode::SET_8) + // opcode SET
"00" // Indirect flag
+ to_hex(AvmMemoryTag::U8) + to_hex(address_byte) + // val
"01" // dst_offset 0
+ to_hex(AvmMemoryTag::FF) + to_hex(address_byte) + // val
"01" // dst_offset 1
+ to_hex(OpCode::GETCONTRACTINSTANCE) + // opcode GETCONTRACTINSTANCE
"00" // Indirect flag
+ to_hex(static_cast<uint8_t>(ContractInstanceMember::DEPLOYER)) + // member enum
Expand Down
10 changes: 10 additions & 0 deletions barretenberg/cpp/src/barretenberg/vm/avm/trace/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ enum class AvmMemoryTag : uint32_t {

static const uint32_t MAX_MEM_TAG = MEM_TAG_U128;

enum class AvmError : uint32_t {
NO_ERROR,
TAG_ERROR,
ADDR_RES_ERROR,
DIV_ZERO,
PARSING_ERROR,
ENV_VAR_UNKNOWN,
CONTRACT_INST_MEM_UNKNOWN
};

static const size_t NUM_MEM_SPACES = 256;
static const uint8_t INTERNAL_CALL_SPACE_ID = 255;
static const uint32_t MAX_SIZE_INTERNAL_STACK = 1 << 16;
Expand Down
Loading

0 comments on commit af823d6

Please sign in to comment.