Skip to content

Commit

Permalink
doc: minor nits
Browse files Browse the repository at this point in the history
  • Loading branch information
cusma committed Oct 9, 2024
1 parent 6c8652b commit 5b39eda
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions ARCs/arc-0064.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
arc: 64
title: AVM Run Time Errors Source Map
description: Informative AVM run time errors based on Program Counter Source Map
description: Informative AVM run time errors based on program counter source map
author: Cosimo Bassi (@cusma), Tasos Bitsios (@tasosbit), Steve Ferrigno (@nullun)
discussions-to: https://github.com/algorandfoundation/ARCs/issues/305
status: Draft
Expand All @@ -13,7 +13,7 @@ created: 2024-08-05
## Abstract

This document introduces conventions for rising informative run time error messages
on the Algorand Virtual Machine (AVM) based on the Program Counter Source Map.
on the Algorand Virtual Machine (AVM) based on a program counter *source map*.

## Motivation

Expand All @@ -23,8 +23,8 @@ The lack of native error handling semantics could lead to fragmentation of tooli
and frictions for AVM clients, who are unable to retrieve informative and useful
hints about the occurred run time failures.

This ARC formalizes conventions to raise AVM run time errors based on Program Counter
Source Map.
This ARC formalizes conventions to raise AVM run time errors based on a program
counter source map.

## Specification

Expand All @@ -37,26 +37,26 @@ in this document are to be interpreted as described in <a href="https://datatrac
### Program Counter Error Source Map

> TEAL source code instructions are uniquely identified by a program counter, returned
> by the Algod node API upon AVM run time failure.
> in the Algod API response upon AVM run time failure.
> The Program Counter Source Map maps program counters back to the original TEAL
> A program counter source map maps program counters back to the original TEAL
> source code lines.
> The Program Counter Error Source Map convention is based on error messages stored
> The program counter error source map convention is based on error messages written
> as comments in the TEAL source code.
When a program wants to emit a run time error, the developer **MUST**:
When a program wants to emit a run time error, it **MUST**:

1. Precede the failing TEAL instruction with a comment (error message);
1. Produce the Program Counter Source Map for the client.
1. Produce a program counter source map for the client.

Upon a program run time failure, the Algod API returns the failed *program counter*
(`pc`).

Using the program counter, the client **MUST**:

1. Retrieve the error message preceding the failed TEAL instruction from the Program
Counter Source Map;
1. Retrieve the error message preceding the failed TEAL instruction from the program
counter source map;
1. Return the error message.

### Example
Expand All @@ -71,29 +71,28 @@ assert [pc=3]

> The evaluation of the example program would result in a run time error on the
> `assert` instruction, returning the failed program counter (`[pc=3]`) as part
> of the Algod API response. Using the Program Counter Source Map, the client is
> of the Algod API response. Using a program counter source map, the client is
> then able to retrieve and return the corresponding error message `ERR_LOGIC_FALSE`
> (i.e. the comment preceding the failed program counter).
## Rationale

The Program Counter Error Source Map convention for AVM run time error messages
The program counter error source map convention for AVM run time error messages
presents the following PROS and CONS.

### PROS

- No opcode budget required to rise errors;
- No program size consumed by error messages.

### CONS

- Standard Program Source Map required for clients to map errors to failed Program
Counter;
- Developers need to create an extra “Errors Source Map” to map program assertion
locations to specific error codes;
- Portability: Errors Source Map needs to be kept up to date through different
- Standard program source maps required for clients to map errors to failed program
counter;
- Developers or compilers need to create an extra “errors source map” to map program
assertion locations to specific error codes;
- Portability: errors source map needs to be kept up to date through different
iterations of a program;
- Error message not returned directly by Algod API.
- Error message not returned directly in the Algod API response.

## Security Considerations

Expand Down

0 comments on commit 5b39eda

Please sign in to comment.