Skip to content

Commit

Permalink
Merge pull request #6 from XuJiandong/invalid-instruction
Browse files Browse the repository at this point in the history
docs: invalid instruction from ckb-vm
  • Loading branch information
quake authored Sep 26, 2024
2 parents be23cdb + 1efa3f8 commit ff23d16
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions general-error/invalid-instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Invalid Instruction Error in CKB-VM

## Supported RISC-V Extensions

The CKB-VM supports the following RISC-V extensions:

- I (Base Integer Instruction Set)
- M (Integer Multiplication and Division)
- B (Bit Manipulation)
- C (Compressed Instructions)

## Identifying Invalid Instructions

When an `InvalidInstruction` error occurs, it indicates that the instruction is
not part of the supported instruction sets listed above.

### Using CKB-Debugger for Analysis

You can analyze the problematic instruction using the
[ckb-debugger](https://github.com/nervosnetwork/ckb-standalone-debugger) tool:

```bash
ckb-debugger --mode decode-instruction <instruction>
```

#### Example

```bash
$ ckb-debugger --mode decode-instruction 336213423
Assembly = lr_d a1,s4,zero
Binary = 00010100000010100011010110101111
Hexadecimal = 140a35af
Instruction set = A
```

## Resolving Atomic Instructions

If the instruction set is identified as `A`, it means it's an atomic
instruction. These are not supported by default in CKB-VM. To resolve issues
with atomic instructions, refer to the [CKB Script Templates
repository](https://github.com/cryptape/ckb-script-templates/tree/main?tab=readme-ov-file#molecule-uses-bytes-crates).

## Additional Resources

- [ckb-std](https://github.com/nervosnetwork/ckb-std)
- [CKB-VM Documentation](https://github.com/nervosnetwork/ckb-vm)
- [RISC-V Specification](https://riscv.org/technical/specifications/)

0 comments on commit ff23d16

Please sign in to comment.