Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predicate compilation succeeds when it should not #5966

Closed
SwayStar123 opened this issue May 6, 2024 · 2 comments
Closed

Predicate compilation succeeds when it should not #5966

SwayStar123 opened this issue May 6, 2024 · 2 comments
Assignees

Comments

@SwayStar123
Copy link
Member

SwayStar123 commented May 6, 2024

A simple predicate with an unwrap contains the revert opcode, which should fail compilation but does not

This later fails with (looks like a VM error)

Transaction(Validation("PredicateVerificationFailed(PanicInstruction(PanicInstruction { reason: ContractInstructionNotAllowed, instruction: RVRT { value: 0x0 } (bytes: 36 00 00 00) }))"))
@xunilrj xunilrj self-assigned this May 6, 2024
@xunilrj
Copy link
Contributor

xunilrj commented May 6, 2024

The error seems to be coming from https://github.com/FuelLabs/fuel-vm/blob/a3f4f1e9ca57d3960c90e50cb7b1b22de15cbc2a/fuel-vm/src/interpreter/executors/instruction.rs#L94

The VM checks what opcodes are allowed at https://github.com/FuelLabs/fuel-vm/blob/master/fuel-asm/src/lib.rs#L688, we check which are NOT allowed at https://github.com/FuelLabs/sway/blob/master/sway-core/src/asm_generation/fuel/checks.rs.

Maybe it is worthy to do the same as the VM and avoid future problems. But we want the keep the current approach we use the VM documentation and check if there any other OPCODE missing.

https://github.com/FuelLabs/fuel-specs/blob/master/src/fuel-vm/index.md#predicate-verification
During predicate mode, hitting any contract instruction causes predicate verification to halt, returning Boolean false.

@xunilrj
Copy link
Contributor

xunilrj commented May 10, 2024

We will implement a static check at #5986

@xunilrj xunilrj closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants