-
Notifications
You must be signed in to change notification settings - Fork 0
Fix(prover): fix issues blocking Rust std program verification #511
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
82ca002
fix executor bugs
ColoCarletti c9bf7b9
Merge branch 'main' into fix/prover-bus-bugs
ColoCarletti 5fef274
Merge branch 'main' into fix/prover-bus-bugs
ColoCarletti c524af0
fix coments
ColoCarletti 4146d9f
Merge branch 'fix/prover-bus-bugs' of github.com:yetanotherco/lambda_…
ColoCarletti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| .attribute 5, "rv64i2p1" | ||
| .globl main | ||
| main: | ||
| # Exercises W-suffix instructions (ADDIW, SRLIW) on a register holding | ||
| # a 64-bit value with non-zero upper 32 bits. The executor's Log must | ||
| # store the full 64-bit register value in src1_val/src2_val so the | ||
| # prover's MEMW_R Memory bus chain stays consistent. | ||
|
|
||
| # Load a 64-bit value with non-zero hi32 into a0 (x10). | ||
| # 0xDEADBEEF_12345678 | ||
| li t0, 0xDEADBEEF # t0 = 0xDEADBEEF (sign-extended) | ||
| slli t0, t0, 32 # t0 = 0xDEADBEEF_00000000 | ||
| li t1, 0x12345678 | ||
| or a0, t0, t1 # a0 = 0xDEADBEEF_12345678 | ||
|
|
||
| # Execute ADDIW on a0 — reads a0 (64-bit) but operates on lower 32. | ||
| # If src1_val is truncated to 32 bits, the upper 0xDEADBEEF is lost and | ||
| # the prover's MEMW_R chain for x10 word 1 won't balance. | ||
| addiw t2, a0, 1 # t2 = sign_extend32(0x12345678 + 1) = 0x12345679 | ||
|
|
||
| # Execute SRLIW — another W-suffix that reads a0. | ||
| srliw t3, a0, 4 # t3 = sign_extend32(0x12345678 >> 4) = 0x01234567 | ||
|
|
||
| # Commit 8 bytes of a0 (the original 64-bit value should be intact). | ||
| # a0 was never written by ADDIW/SRLIW (they write t2/t3, not a0). | ||
| addi a1, sp, -8 # buf on stack | ||
| sd a0, 0(a1) # store a0 to buf | ||
| li a0, 1 # fd = 1 | ||
| li a2, 8 # count = 8 | ||
| li a7, 64 # Commit | ||
| ecall | ||
|
|
||
| # Halt | ||
| li a0, 0 | ||
| li a7, 93 | ||
| ecall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [target.riscv64im-lambda-vm-elf] | ||
| rustflags = [ | ||
| "-C", "link-arg=-e", | ||
| "-C", "link-arg=main", | ||
| "-C", "passes=lower-atomic" | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [workspace] | ||
|
|
||
| [package] | ||
| name = "pure_commit" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Minimal Rust guest program: no_std, no_main, no allocator, no syscalls crate. | ||
| // Uses only raw inline `asm!("ecall")` for Commit (64) and Halt (93). | ||
| // Serves as a control case in the prover test suite (`test_pure_commit_rust`): | ||
| // verifies that Rust can compile to a provable ELF when the heap allocator is | ||
| // bypassed, independent of the Rust-std startup path. | ||
| #![no_std] | ||
| #![no_main] | ||
|
|
||
| use core::arch::asm; | ||
| use core::panic::PanicInfo; | ||
|
|
||
| #[panic_handler] | ||
| fn panic(_info: &PanicInfo) -> ! { | ||
| loop {} | ||
| } | ||
|
|
||
| #[unsafe(export_name = "main")] | ||
| pub extern "C" fn main() -> ! { | ||
| // Commit 4 bytes [0xAA, 0xBB, 0xCC, 0xDD] | ||
| let buf: [u8; 4] = [0xAA, 0xBB, 0xCC, 0xDD]; | ||
| unsafe { | ||
| asm!( | ||
| "ecall", | ||
| inlateout("a0") 1usize => _, // fd = stdout; ecall overwrites a0 | ||
| in("a1") buf.as_ptr(), | ||
| in("a2") 4usize, | ||
| in("a7") 64usize, // Commit | ||
| ); | ||
| } | ||
| // Halt | ||
| unsafe { | ||
| asm!( | ||
| "ecall", | ||
| inlateout("a0") 0usize => _, // exit_code = 0; ecall overwrites a0 | ||
| in("a7") 93usize, // Halt | ||
| ); | ||
| } | ||
| loop {} | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.