Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
## [0.6.7] - 31-07-2025
## [0.7.0] - Unreleased

### Changed

* Serialization: Move all variable-length items to end of encoding
(GP [#418](https://github.com/gavofyork/graypaper/pull/418))

## [0.6.7] - 07-08-2025

### Changed

Expand Down
119 changes: 56 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,73 @@
# Test Vectors for the JAM Protocol
# Test Vectors for the JAM Protocol (0.6.7)

## Codec

- [Codec](./codec/README.md)

## Erasure Coding
## Classes

- [Codec](./codec/README.md)
- [Erasure Coding](./erasure/README.md)
- [State Transition Function](./stf/README.md)
- [Block Import Traces](./traces/README.md)

## State Transition Functions

We offer two types of test vectors:

- **Tiny**: designed for quick adjustments and prototyping, with reduced
- validators count: 6
- cores count: 2
- epoch period: 12
- core assignment rotation period: 4
- ticket attempts: 3

- **Full**: vectors with production specs
- validators count: 1023
- cores count: 341
- epoch period: 600
- core assignment rotation period: 10
- ticket attempts: 2

For more information refer to the community [docs](https://docs.jamcha.in/basics/chain-spec).

### STF Output

Technically, the STF execution process does not inherently produce auxiliary
outputs beyond the success or failure result. In this context, we propose
an extension to include additional information that may be beneficial for
implementors or useful for executing other subsystems reliant on values
generated post-STF execution.

When the error or success values are not pertinent to your test vector
processing procedures, you may disregard them as necessary.

A mapping of error code semantics is provided within the ASN.1 schema for each
specific subsystem.

### Vectors
## Binary To JSON

- [Safrole](./stf/safrole/README.md)
- [Disputes](./stf/disputes/README.md)
- [History](./stf/history/README.md)
- [Assurances](./stf/assurances/README.md)
- [Reports](./stf/reports/README.md)
- [Statistics](./stf/statistics/README.md)
- [Authorizations](./stf/authorizations/README.md)
- [Preimages](./stf/preimages/README.md)
- [Accumulate](./stf/accumulate/README.md)
The repository binary test vector files can be converted to their JSON
equivalents for easier inspection and debugging. Use the provided conversion
script to transform binary files into human-readable JSON format:

## Block Import Traces
```bash
./scripts/convert-all.sh
```

- [Fallback](./traces/fallback): fallback block authoring, no-safrole, no-work-reports
- [Safrole](./traces/safrole): safrole block authoring, no-work-reports
- [Work Reports L0](./traces/reports-l0): basic work reports, no-safrole
This script requires the [jam-types](https://github.com/davxy/jam-types-py)
Python library to be installed.

## Vectors Validation
## Validation

Validation scripts are included to verify the JSON files against the expected
ASN.1 syntax provided with the test vectors. These scripts currently rely on my
[asn1tools](https://github.com/davxy/asn1tools) fork.

## Binary To JSON
```bash
./scripts/validate-all.sh.sh
```

The repository binary test vector files can be converted to their JSON
equivalents for easier inspection and debugging. Use the provided conversion
script to transform binary files into human-readable JSON format:
## Chainspec Parameters

```bash
./scripts/convert-all.sh
For more information refer to the community [docs](https://docs.jamcha.in/basics/chain-spec).

### Tiny

```yaml
chain: tiny
num_validators: 6
num_cores: 2
preimage_expunge_period: 32
slot_duration: 6
epoch_duration: 12
contest_duration: 10
tickets_per_validator: 3
max_tickets_per_extrinsic: 3
rotation_period: 4
num_ec_pieces_per_segment: 1026
max_block_gas: 20000000
max_refine_gas: 1000000000
```

This conversion script requires the [jam-types](https://github.com/davxy/jam-types)
Python library to be installed.
### Full

All parameters here must match the Gray Paper.

```yaml
chain: full
num_validators: 1023
num_cores: 341
preimage_expunge_period: 19200
slot_duration: 6
epoch_duration: 600
contest_duration: 500
tickets_per_validator: 2
max_tickets_per_extrinsic: 16
rotation_period: 10
num_ec_pieces_per_segment: 6
max_block_gas: 3500000000
max_refine_gas: 5000000000
```
7 changes: 4 additions & 3 deletions codec/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@
"block": Block,
}


def convert(spec_name):
print(f"\n[Converting codec ({spec_name})]")
spec.set_spec(spec_name)
for filename in glob.glob(f"{spec_name}/*.bin"):
print("* Converting ", filename)
basename = os.path.splitext(os.path.basename(filename))[0]
basename = re.sub(r'_\d+$', '', basename)
class_type = dump_classes[basename]
class_type = dump_classes.get(basename)
if class_type is None:
print("* Skipping: ", filename)
continue
convert_to_json(filename, class_type)

for spec_name in ["tiny", "full"]:
Expand Down
Binary file modified codec/full/block.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions codec/full/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -4103,11 +4103,11 @@
]
},
"tickets_mark": null,
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"offenders_mark": [
"0x4418fb8c85bb3985394a8c2756d3643457ce614546202a2f50b093d762499ace"
],
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"seal": "0x31dc5b1e9423eccff9bccd6549eae8034162158000d5be9339919cc03d14046e6431c14cbb172b3aed702b9e9869904b1f39a6fe1f3e904b0fd536f13e8cac496682e1c81898e88e604904fa7c3e496f9a8771ef1102cc29d567c4aad283f7b0"
},
"extrinsic": {
Expand Down Expand Up @@ -4159,6 +4159,7 @@
},
"core_index": 3,
"authorizer_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"auth_gas_used": 0,
"auth_output": "0x0102030405",
"segment_root_lookup": [],
"results": [
Expand Down Expand Up @@ -4194,8 +4195,7 @@
"exports": 0
}
}
],
"auth_gas_used": 0
]
},
"slot": 42,
"signatures": [
Expand Down
Binary file modified codec/full/extrinsic.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions codec/full/extrinsic.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"core_index": 3,
"authorizer_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"auth_gas_used": 0,
"auth_output": "0x0102030405",
"segment_root_lookup": [],
"results": [
Expand Down Expand Up @@ -82,8 +83,7 @@
"exports": 0
}
}
],
"auth_gas_used": 0
]
},
"slot": 42,
"signatures": [
Expand Down
Binary file modified codec/full/guarantees_extrinsic.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions codec/full/guarantees_extrinsic.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"core_index": 3,
"authorizer_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"auth_gas_used": 0,
"auth_output": "0x0102030405",
"segment_root_lookup": [],
"results": [
Expand Down Expand Up @@ -53,8 +54,7 @@
"exports": 0
}
}
],
"auth_gas_used": 0
]
},
"slot": 42,
"signatures": [
Expand Down
Binary file modified codec/full/header_0.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions codec/full/header_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -4102,10 +4102,10 @@
]
},
"tickets_mark": null,
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"offenders_mark": [
"0x4418fb8c85bb3985394a8c2756d3643457ce614546202a2f50b093d762499ace"
],
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"seal": "0x31dc5b1e9423eccff9bccd6549eae8034162158000d5be9339919cc03d14046e6431c14cbb172b3aed702b9e9869904b1f39a6fe1f3e904b0fd536f13e8cac496682e1c81898e88e604904fa7c3e496f9a8771ef1102cc29d567c4aad283f7b0"
}
Binary file modified codec/full/header_1.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion codec/full/header_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2406,8 +2406,8 @@
"attempt": 1
}
],
"offenders_mark": [],
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"offenders_mark": [],
"seal": "0x31dc5b1e9423eccff9bccd6549eae8034162158000d5be9339919cc03d14046e6431c14cbb172b3aed702b9e9869904b1f39a6fe1f3e904b0fd536f13e8cac496682e1c81898e88e604904fa7c3e496f9a8771ef1102cc29d567c4aad283f7b0"
}
Binary file modified codec/full/work_item.bin
Binary file not shown.
6 changes: 3 additions & 3 deletions codec/full/work_item.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"service": 16909060,
"code_hash": "0x70a50829851e8f6a8c80f92806ae0e95eb7c06ad064e311cc39107b3219e532e",
"payload": "0x0102030405",
"refine_gas_limit": 42,
"accumulate_gas_limit": 42,
"export_count": 4,
"payload": "0x0102030405",
"import_segments": [
{
"tree_root": "0x461236a7eb29dcffc1dd282ce1de0e0ed691fc80e91e02276fe8f778f088a1b8",
Expand All @@ -27,6 +28,5 @@
"hash": "0x6c437d85cd8327f42a35d427ede1b5871347d3aae7442f2df1ff80f834acf17a",
"len": 17
}
],
"export_count": 4
]
}
Binary file modified codec/full/work_package.bin
Binary file not shown.
20 changes: 9 additions & 11 deletions codec/full/work_package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"authorization": "0x0102030405",
"auth_code_host": 305419896,
"authorizer": {
"code_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"params": "0x00010203040506070809"
},
"auth_code_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"context": {
"anchor": "0xc0564c5e0de0942589df4343ad1956da66797240e2a2f2d6f8116b5047768986",
"state_root": "0xf6967658df626fa39cbfb6014b50196d23bc2cfbfa71a7591ca7715472dd2b48",
Expand All @@ -13,13 +9,16 @@
"lookup_anchor_slot": 33,
"prerequisites": []
},
"authorization": "0x0102030405",
"authorizer_config": "0x00010203040506070809",
"items": [
{
"service": 16909060,
"code_hash": "0x70a50829851e8f6a8c80f92806ae0e95eb7c06ad064e311cc39107b3219e532e",
"payload": "0x0102030405",
"refine_gas_limit": 42,
"accumulate_gas_limit": 42,
"export_count": 4,
"payload": "0x0102030405",
"import_segments": [
{
"tree_root": "0x461236a7eb29dcffc1dd282ce1de0e0ed691fc80e91e02276fe8f778f088a1b8",
Expand All @@ -43,15 +42,15 @@
"hash": "0x6c437d85cd8327f42a35d427ede1b5871347d3aae7442f2df1ff80f834acf17a",
"len": 17
}
],
"export_count": 4
]
},
{
"service": 84281096,
"code_hash": "0xfcfc857dab216daf41f409c2012685846e4d34aedfeacaf84d9adfebda73fae6",
"payload": "0x030201",
"refine_gas_limit": 77,
"accumulate_gas_limit": 77,
"export_count": 7,
"payload": "0x030201",
"import_segments": [
{
"tree_root": "0x3e5d0bea78537414bd1cfdaeb0f22d743bcaba5dbffacbabce8457f4cd78f69b",
Expand All @@ -75,8 +74,7 @@
"hash": "0xcc2f47030ff8a9fe8d02e8eb87e86d4db05b57258d30f9d81acb3b280d04e877",
"len": 34
}
],
"export_count": 7
]
}
]
}
Binary file modified codec/full/work_report.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions codec/full/work_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"core_index": 3,
"authorizer_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"auth_gas_used": 0,
"auth_output": "0x0102030405",
"segment_root_lookup": [],
"results": [
Expand Down Expand Up @@ -51,6 +52,5 @@
"exports": 0
}
}
],
"auth_gas_used": 0
]
}
Binary file modified codec/tiny/block.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions codec/tiny/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
]
},
"tickets_mark": null,
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"offenders_mark": [
"0x4418fb8c85bb3985394a8c2756d3643457ce614546202a2f50b093d762499ace"
],
"author_index": 3,
"entropy_source": "0xae85d6635e9ae539d0846b911ec86a27fe000f619b78bcac8a74b77e36f6dbcf49a52360f74a0233cea0775356ab0512fafff0683df08fae3cb848122e296cbc50fed22418ea55f19e55b3c75eb8b0ec71dcae0d79823d39920bf8d6a2256c5f",
"seal": "0x31dc5b1e9423eccff9bccd6549eae8034162158000d5be9339919cc03d14046e6431c14cbb172b3aed702b9e9869904b1f39a6fe1f3e904b0fd536f13e8cac496682e1c81898e88e604904fa7c3e496f9a8771ef1102cc29d567c4aad283f7b0"
},
"extrinsic": {
Expand Down Expand Up @@ -91,6 +91,7 @@
},
"core_index": 3,
"authorizer_hash": "0x022e5e165cc8bd586404257f5cd6f5a31177b5c951eb076c7c10174f90006eef",
"auth_gas_used": 0,
"auth_output": "0x0102030405",
"segment_root_lookup": [],
"results": [
Expand Down Expand Up @@ -126,8 +127,7 @@
"exports": 0
}
}
],
"auth_gas_used": 0
]
},
"slot": 42,
"signatures": [
Expand Down
Binary file modified codec/tiny/extrinsic.bin
Binary file not shown.
Loading