Skip to content

Commit 273f71b

Browse files
committed
Add CAD33 for CVM CAD3 extensions
1 parent 5d3a8d8 commit 273f71b

File tree

2 files changed

+46
-17
lines changed

2 files changed

+46
-17
lines changed

docs/cad/003_encoding/README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -627,34 +627,20 @@ Implementations which require more than 63 fields MAY adopt their own scheme to
627627
- Have the Record specify one field which contains a vector of additional fields
628628
- Use the first field (index 0) to specify the interpretation of following fields (which may contain arbitrary values as sub-structures)
629629

630-
### `0xB0` - `0xB1` Byte Flags (Boolean)
631-
632-
The possible Boolean values are `true` and `false`, which are coded as 1-byte Byte Flags.
633-
634-
```
635-
Encoded as:
636-
0xB0 <=> false
637-
0xB1 <=> true
638-
```
639-
640-
The two Boolean Values `true` or `false` have the Encodings `0xb1` and `0xb0` respectively.
641-
642-
Note: These Tags are chosen to aid human readability, such that the first hexadecimal digit `b` suggests "binary" or "boolean", and the second hexadecimal digit represents the bit value.
643-
644-
### `0xB2`-`0xBF` Byte Flags (Extensible)
630+
### `0xB0`-`0xBF` Byte Flags (Extensible)
645631

646632
Byte flags are one byte encodings (similar to Booleans) available for application specific use.
647633

648634
```
649635
`0xBn`
650636
651637
Where
652-
- n = a hex value from 2-15
638+
- n = a hex value from 0-15
653639
```
654640

655641
Applications MAY use byte flags as a efficient single byte value, i.e. the complete value encoding is always exactly one byte. For example, the encoding `0xb2` might represent an "unknown" value in ternary logic.
656642

657-
Values `0xb0` and `0xb1` are already reserved for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
643+
Values `0xb0` and `0xb1` are typically used for the two boolean values, though an application MAY repurpose these as single byte values (along with `0x00` and `0x10`) providing these values are not needed for some other purpose.
658644

659645
Fun Idea: A 1-byte Lisp where `0x10` is an opening paren, `0x00` is a closing paren and `0xb0 - 0xbf` are the allowable tokens.
660646

@@ -721,6 +707,10 @@ Examples:
721707
- an application might define `0xE5` as an extension where the value references a known JSON schema.
722708
- another application might define `0xE0` as an enum where the values are the possible states of a finite state machine
723709

710+
### `0xF0` - `0xFE` Reserved
711+
712+
These values are reserved for possible future CAD3 extensions. at present they are illegal
713+
724714
### `0xFF` Illegal
725715

726716
The `0xFF` tag is always illegal as a tag byte in any encoding.

docs/cad/033_cvmtypes/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# CAD033: Convex CVM Types
2+
3+
## Overview
4+
5+
Convex uses the CAD3 format to represent data.
6+
7+
CAD3 is an extensible format, so Convex data types are represented using CAD3 extensions. This CAD lists the extension types and specifications used.
8+
9+
## Format
10+
11+
### `0xB0` - `0xB1` Boolean
12+
13+
The possible Boolean values are `true` and `false`, which are coded as 1-byte Byte Flags.
14+
15+
```
16+
Encoded as:
17+
0xB0 <=> false
18+
0xB1 <=> true
19+
```
20+
21+
The two Boolean Values `true` or `false` have the Encodings `0xb1` and `0xb0` respectively.
22+
23+
Note: These Tags are chosen to aid human readability, such that the first hexadecimal digit `b` suggests "binary" or "boolean", and the second hexadecimal digit represents the bit value.
24+
25+
### `0xEA` Address
26+
27+
Addresses are used to reference sequentially allocated accounts in Convex, conventionally written as `#14567`. As such, they are conveniently encoded as CAD3 extension values with the tag `0xEA`
28+
29+
```
30+
0xEA <VLQ Count = address number>
31+
```
32+
33+
An Address is encoded by the tag byte followed by a VLQ Encoding of the 64-bit value of the Address.
34+
35+
The address number MUST be positive, i.e. a 63-bit positive integer.
36+
37+
Since addresses are allocated sequentially from zero (and accounts can be re-used), this usually results in a short encoding.
38+
39+
Addresses MAY be used by implementations outside the CVM for other types of sequentially allocated values.

0 commit comments

Comments
 (0)