Skip to content

feat: Macro define_verify_openvm_stark #1620

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 2 commits into from
May 12, 2025

Conversation

nyunyunyunyu
Copy link
Contributor

@nyunyunyunyu nyunyunyunyu commented May 2, 2025

  • Add a RISC-V custom instruction nativestorew into Rv32IoTranspilerExtension.
  • Add macro define_verify_openvm_stark, which can define a function for guest program to verify a stark proof.

closes INT-3896

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from c316819 to 3d10170 Compare May 2, 2025 02:03

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from 3d10170 to 1402e28 Compare May 2, 2025 02:17
@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from 1402e28 to 78f0f29 Compare May 2, 2025 23:06

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from 78f0f29 to fd2cc4d Compare May 5, 2025 01:56

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu changed the title [HOLD] feat: Macro define_verify_openvm_stark feat: Macro define_verify_openvm_stark May 5, 2025
@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from fd2cc4d to 25061e4 Compare May 5, 2025 05:47
@nyunyunyunyu nyunyunyunyu requested a review from jonathanpwang May 5, 2025 05:47

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/root-dsl-asm branch 2 times, most recently from 906e765 to e56163d Compare May 5, 2025 06:17
@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from 25061e4 to d946854 Compare May 5, 2025 06:19

This comment has been minimized.

Base automatically changed from feat/root-dsl-asm to feat/verify_e2e_stark May 5, 2025 21:18
@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from d946854 to 70a005c Compare May 5, 2025 21:22

This comment has been minimized.

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from a9d152f to 7b2dd5c Compare May 6, 2025 22:29

This comment has been minimized.

@@ -72,6 +72,10 @@ the guest must take care to validate all data and account for behavior in cases
| printstr | I | 0001011 | 011 | 0x1 | Tries to convert `[rd..rd + rs1]_2` to UTF-8 string and print to host stdout. Will print error message if conversion fails. |
| hintrandom | I | 0001011 | 011 | 0x2 | Resets the hint stream to `4 * rd` random bytes from `rand::rngs::OsRng` on the host. |

| RISC-V Inst | FMT | opcode[6:0] | funct3 | funct7 | RISC-V description and notes |
|--------------|-----|-------------|---------|---------|---------------------------------------------------------------------------------------------------------------------------------|
| nativestorew | R | 0001011 | 111 | 2 | Stores the 4-byte word `rs1` at address `rd` in native address space. The address `rd` must be aligned to a 4-byte boundary. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| nativestorew | R | 0001011 | 111 | 2 | Stores the 4-byte word `rs1` at address `rd` in native address space. The address `rd` must be aligned to a 4-byte boundary. |
| nativestorew | R | 0001011 | 111 | 0x2 | Stores the 4-byte word `rs1` at address `rd` in native address space. The address `rd` must be aligned to a 4-byte boundary. |

nit: for consistency

(RV32_REGISTER_NUM_LIMBS * dec_insn.rs1) as isize,
(RV32_REGISTER_NUM_LIMBS * dec_insn.rd) as isize,
0,
1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have constant for this addr space?

.map(|x| x as u32)
.collect();

let key = ASM_FILENAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the filename part of the key?
and if it is part of the key, why the base filename and not the full path?

/// little-endian bytes.
#[macro_export]
macro_rules! define_verify_openvm_stark {
($fn_name: ident, $asm_folder: expr, $asm_filename: literal) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the separation between folder vs filename?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I didn't figure out how to split a constant string in macro at compile time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant why did you need the key to just be the filename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it's more friendly to add inputs into key-value store. "/usr/abc/xxx/verifier.asm" is much more weird than "verifier.asm"...

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except that the key calculation should be moved into a function.

Either in this PR or another, let's move the macro into a dedicated crate as we discussed.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify_e2e_stark branch from b10d91f to d7a1322 Compare May 9, 2025 20:47
@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from 7b2dd5c to e539dd3 Compare May 9, 2025 20:50

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu force-pushed the feat/verify-vm-stark branch from e539dd3 to 66d85df Compare May 12, 2025 16:44
Copy link

group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (-40 [-3.3%]) 1,166 334,014 17,675,762 - - -
fibonacci (+14 [+0.6%]) 2,483 1,500,277 50,589,503 - - -
regex (+18 [+0.2%]) 7,498 4,165,226 166,511,152 - - -
ecrecover (+9 [+0.6%]) 1,395 289,447 14,470,186 - - -
pairing (-45 [-1.0%]) 4,527 1,820,436 95,832,407 - - -

Commit: 66d85df

Benchmark Workflow

@nyunyunyunyu nyunyunyunyu merged commit c942537 into feat/verify_e2e_stark May 12, 2025
26 checks passed
@nyunyunyunyu nyunyunyunyu deleted the feat/verify-vm-stark branch May 12, 2025 22:18
nyunyunyunyu added a commit that referenced this pull request May 15, 2025
- Add a RISC-V custom instruction `nativestorew` into
`Rv32IoTranspilerExtension`.
- Add macro `define_verify_openvm_stark`, which can define a function
for guest program to verify a stark proof.

closes INT-3896
jonathanpwang pushed a commit that referenced this pull request May 16, 2025
- Add a RISC-V custom instruction `nativestorew` into
`Rv32IoTranspilerExtension`.
- Add macro `define_verify_openvm_stark`, which can define a function
for guest program to verify a stark proof.

closes INT-3896
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

Successfully merging this pull request may close these issues.

2 participants