From 63438a8ec65e5cd658f2dc5627c7302bcfdec25d Mon Sep 17 00:00:00 2001 From: Xinding Wei Date: Thu, 9 Jan 2025 01:29:48 +0800 Subject: [PATCH] Make all chip records serde --- Cargo.lock | 383 +++++++++--------- Cargo.toml | 1 + crates/circuits/mod-builder/Cargo.toml | 2 + crates/circuits/mod-builder/src/core_chip.rs | 5 + crates/vm/Cargo.toml | 1 + crates/vm/src/arch/execution.rs | 3 +- crates/vm/src/arch/integration_api.rs | 8 +- crates/vm/src/arch/testing/test_adapter.rs | 3 +- crates/vm/src/system/memory/controller/mod.rs | 2 +- crates/vm/src/system/native_adapter/mod.rs | 8 +- crates/vm/src/system/public_values/core.rs | 3 +- extensions/algebra/circuit/Cargo.toml | 1 + .../circuit/src/modular_chip/addsub.rs | 3 + .../algebra/circuit/src/modular_chip/is_eq.rs | 7 +- .../circuit/src/modular_chip/muldiv.rs | 3 + extensions/native/circuit/Cargo.toml | 2 + .../circuit/src/adapters/convert_adapter.rs | 6 +- .../src/adapters/loadstore_native_adapter.rs | 7 +- .../src/adapters/native_vectorized_adapter.rs | 5 +- extensions/native/circuit/src/castf/core.rs | 4 +- .../circuit/src/field_arithmetic/core.rs | 3 +- .../circuit/src/field_extension/core.rs | 3 +- extensions/native/circuit/src/jal/core.rs | 3 +- .../native/circuit/src/loadstore/core.rs | 4 +- extensions/native/compiler/src/lib.rs | 43 +- extensions/rv32-adapters/Cargo.toml | 3 + extensions/rv32-adapters/src/eq_mod.rs | 9 +- extensions/rv32-adapters/src/heap_branch.rs | 5 +- extensions/rv32-adapters/src/vec_heap.rs | 13 +- .../rv32-adapters/src/vec_heap_two_reads.rs | 13 +- extensions/rv32im/circuit/Cargo.toml | 1 + extensions/rv32im/circuit/src/adapters/alu.rs | 7 +- .../rv32im/circuit/src/adapters/branch.rs | 5 +- .../rv32im/circuit/src/adapters/hintstore.rs | 6 +- .../rv32im/circuit/src/adapters/jalr.rs | 5 +- .../rv32im/circuit/src/adapters/loadstore.rs | 7 +- extensions/rv32im/circuit/src/adapters/mul.rs | 5 +- .../rv32im/circuit/src/adapters/rdwrite.rs | 3 +- extensions/rv32im/circuit/src/auipc/core.rs | 3 +- .../rv32im/circuit/src/base_alu/core.rs | 7 +- .../rv32im/circuit/src/branch_eq/core.rs | 5 +- .../rv32im/circuit/src/branch_lt/core.rs | 5 +- extensions/rv32im/circuit/src/divrem/core.rs | 10 +- .../rv32im/circuit/src/hintstore/core.rs | 3 +- extensions/rv32im/circuit/src/jal_lui/core.rs | 4 +- extensions/rv32im/circuit/src/jalr/core.rs | 2 + .../rv32im/circuit/src/less_than/core.rs | 6 +- .../circuit/src/load_sign_extend/core.rs | 6 +- .../rv32im/circuit/src/loadstore/core.rs | 7 +- extensions/rv32im/circuit/src/mul/core.rs | 7 +- extensions/rv32im/circuit/src/mulh/core.rs | 7 +- extensions/rv32im/circuit/src/shift/core.rs | 8 +- extensions/rv32im/transpiler/Cargo.toml | 1 + .../rv32im/transpiler/src/instructions.rs | 113 +++++- 54 files changed, 537 insertions(+), 252 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 790acdb641..00ea9576c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.15" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6259a506ab13e1d658796c31e6e39d2e2ee89243bcc505ddc613b35732e0a430" +checksum = "788bb18e8f61d5d9340b52143f27771daf7e1dccbaf2741621d2493f9debf52e" dependencies = [ "alloy-rlp", "bytes", @@ -93,7 +93,6 @@ dependencies = [ "derive_more 1.0.0", "foldhash", "hashbrown 0.15.2", - "hex-literal", "indexmap 2.7.0", "itoa", "k256", @@ -127,7 +126,7 @@ checksum = "5a833d97bf8a5f0f878daf2c8451fff7de7f9de38baa5a45d936ec718d81255a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -211,9 +210,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "ark-ff" @@ -354,13 +353,13 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-trait" -version = "0.1.83" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -381,7 +380,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -392,9 +391,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-config" -version = "1.5.10" +version = "1.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b49afaa341e8dd8577e1a2200468f98956d6eda50bcf4a53246cc00174ba924" +checksum = "c03a50b30228d3af8865ce83376b4e99e1ffa34728220fe2860e4df0bb5278d6" dependencies = [ "aws-credential-types", "aws-runtime", @@ -403,7 +402,7 @@ dependencies = [ "aws-sdk-sts", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.60.7", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -434,9 +433,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.4.4" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5ac934720fbb46206292d2c75b57e67acfc56fe7dfd34fb9a02334af08409ea" +checksum = "b16d1aa50accc11a4b4d5c50f7fb81cc0cf60328259c587d0e6b0f11385bde46" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -460,9 +459,9 @@ dependencies = [ [[package]] name = "aws-sdk-s3" -version = "1.65.0" +version = "1.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3ba2c5c0f2618937ce3d4a5ad574b86775576fa24006bcb3128c6e2cbf3c34e" +checksum = "bc5ddf1dc70287dc9a2f953766a1fe15e3e74aef02fd1335f2afa475c9b4f4fc" dependencies = [ "aws-credential-types", "aws-runtime", @@ -471,7 +470,7 @@ dependencies = [ "aws-smithy-checksums", "aws-smithy-eventstream", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -494,15 +493,15 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.50.0" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ca43a4ef210894f93096039ef1d6fa4ad3edfabb3be92b80908b9f2e4b4eab" +checksum = "1605dc0bf9f0a4b05b451441a17fcb0bda229db384f23bf5cead3adbab0664ac" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -516,15 +515,15 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.51.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abaf490c2e48eed0bb8e2da2fb08405647bd7f253996e0f93b981958ea0f73b0" +checksum = "59f3f73466ff24f6ad109095e0f3f2c830bfb4cd6c8b12f744c8e61ebf4d3ba1" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-runtime", "aws-smithy-runtime-api", "aws-smithy-types", @@ -538,15 +537,15 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.51.0" +version = "1.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b68fde0d69c8bfdc1060ea7da21df3e39f6014da316783336deff0a9ec28f4bf" +checksum = "249b2acaa8e02fd4718705a9494e3eb633637139aa4bb09d70965b0448e865db" dependencies = [ "aws-credential-types", "aws-runtime", "aws-smithy-async", "aws-smithy-http", - "aws-smithy-json 0.61.1", + "aws-smithy-json", "aws-smithy-query", "aws-smithy-runtime", "aws-smithy-runtime-api", @@ -590,9 +589,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.1" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +checksum = "427cb637d15d63d6f9aae26358e1c9a9c09d5aa490d64b09354c8217cfef0f28" dependencies = [ "futures-util", "pin-project-lite", @@ -652,15 +651,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "aws-smithy-json" -version = "0.60.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" -dependencies = [ - "aws-smithy-types", -] - [[package]] name = "aws-smithy-json" version = "0.61.1" @@ -682,9 +672,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.7.4" +version = "1.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f20685047ca9d6f17b994a07f629c813f08b5bce65523e47124879e60103d45" +checksum = "a05dd41a70fc74051758ee75b5c4db2c0ca070ed9229c3df50e9475cda1cb985" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -726,9 +716,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.2.9" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd94a32b3a7d55d3806fe27d98d3ad393050439dd05eb53ece36ec5e3d3510" +checksum = "38ddc9bd6c28aeb303477170ddd183760a956a03e083b3902a990238a7e3792d" dependencies = [ "base64-simd", "bytes", @@ -981,9 +971,9 @@ dependencies = [ [[package]] name = "bon" -version = "3.3.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f265cdb2e8501f1c952749e78babe8f1937be92c98120e5f78fc72d634682bad" +checksum = "fe7acc34ff59877422326db7d6f2d845a582b16396b6b08194942bf34c6528ab" dependencies = [ "bon-macros", "rustversion", @@ -991,9 +981,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "3.3.0" +version = "3.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38aa5c627cd7706490e5b003d685f8b9d69bc343b1a00b9fdd01e75fdf6827cf" +checksum = "4159dd617a7fbc9be6a692fe69dc2954f8e6bb6bb5e4d7578467441390d77fd0" dependencies = [ "darling", "ident_case", @@ -1001,7 +991,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1018,9 +1008,9 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" [[package]] name = "byteorder" @@ -1160,9 +1150,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.4" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" dependencies = [ "jobserver", "libc", @@ -1223,9 +1213,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" dependencies = [ "clap_builder", "clap_derive", @@ -1233,9 +1223,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" dependencies = [ "anstream", "anstyle", @@ -1245,14 +1235,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1269,12 +1259,12 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -1423,18 +1413,18 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -1451,18 +1441,18 @@ dependencies = [ [[package]] name = "crossbeam-queue" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -1556,7 +1546,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1567,7 +1557,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1628,7 +1618,7 @@ checksum = "d150dea618e920167e5973d70ae6ece4385b7164e0d799fe7c122dd0a5d912ad" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1641,7 +1631,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.1", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1661,7 +1651,7 @@ checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "unicode-xid", ] @@ -1736,7 +1726,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1861,7 +1851,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -1872,23 +1862,23 @@ checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", ] [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -1962,6 +1952,17 @@ dependencies = [ "bytes", ] +[[package]] +name = "fastrlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce8dba4714ef14b8274c371879b175aa55b16b30f269663f19d576f380018dc4" +dependencies = [ + "arrayvec", + "auto_impl", + "bytes", +] + [[package]] name = "ff" version = "0.12.1" @@ -2034,9 +2035,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" [[package]] name = "form_urlencoded" @@ -2129,7 +2130,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -2153,9 +2154,9 @@ dependencies = [ [[package]] name = "glob" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "goblin" @@ -2511,9 +2512,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" dependencies = [ "bytes", "futures-channel", @@ -2687,7 +2688,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -2734,7 +2735,7 @@ checksum = "a0eb5a3343abf848c0984fe4604b2b105da9539376e24fc0a3b0007411ae4fd9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -2909,9 +2910,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.168" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libgit2-sys" @@ -2953,9 +2954,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" dependencies = [ "cc", "libc", @@ -2971,9 +2972,9 @@ checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -3058,9 +3059,9 @@ dependencies = [ [[package]] name = "memuse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" +checksum = "3d97bbf43eb4f088f8ca469930cde17fa036207c9a5e02ccc5107c4e8b17c964" [[package]] name = "metrics" @@ -3081,7 +3082,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3131,9 +3132,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] @@ -3343,9 +3344,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -3406,6 +3407,7 @@ dependencies = [ "openvm-stark-sdk", "rand", "serde", + "serde_arrays", "serde_with", "strum", "tracing", @@ -3417,7 +3419,7 @@ version = "0.1.0" dependencies = [ "openvm-macros-common", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3441,7 +3443,7 @@ version = "0.2.0-alpha" dependencies = [ "openvm-macros-common", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3649,6 +3651,7 @@ dependencies = [ "rayon", "rustc-hash 2.1.0", "serde", + "serde_arrays", "static_assertions", "test-case", "test-log", @@ -3665,7 +3668,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3697,7 +3700,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3783,7 +3786,7 @@ version = "0.2.0-alpha" dependencies = [ "openvm-macros-common", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3825,7 +3828,7 @@ dependencies = [ "quote", "strum", "strum_macros", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3903,7 +3906,7 @@ dependencies = [ name = "openvm-macros-common" version = "0.2.0-alpha" dependencies = [ - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -3923,6 +3926,8 @@ dependencies = [ "openvm-stark-backend", "openvm-stark-sdk", "rand", + "serde", + "serde_with", "sha3", "tracing", ] @@ -3950,6 +3955,8 @@ dependencies = [ "rand", "rayon", "serde", + "serde_arrays", + "serde_with", "strum", "test-case", "test-log", @@ -4003,7 +4010,7 @@ dependencies = [ "openvm-stark-backend", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -4193,6 +4200,9 @@ dependencies = [ "openvm-stark-backend", "openvm-stark-sdk", "rand", + "serde", + "serde_arrays", + "serde_with", "test-case", "test-log", "tracing", @@ -4219,6 +4229,7 @@ dependencies = [ "openvm-stark-sdk", "rand", "serde", + "serde_arrays", "strum", "test-case", "test-log", @@ -4263,6 +4274,7 @@ dependencies = [ "openvm-stark-backend", "openvm-transpiler", "rrs-lib", + "serde", "strum", "tracing", ] @@ -4549,9 +4561,9 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-float" -version = "4.5.0" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65ee1f9701bf938026630b455d5315f490640234259037edb259798b3bcf85e" +checksum = "7bb71e1b3fa6ca1c61f383464aaf2bb0e2f8e772a1f01d486832464de363b951" dependencies = [ "num-traits", ] @@ -5022,15 +5034,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.6", + "thiserror 2.0.9", "ucd-trie", ] [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -5158,12 +5170,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.25" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +checksum = "483f8c21f64f3ea09fe0f30f5d48c3e8eefe5dac9129f0075f76593b4c1da705" dependencies = [ "proc-macro2", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -5219,7 +5231,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -5253,9 +5265,9 @@ dependencies = [ [[package]] name = "quanta" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773ce68d0bb9bc7ef20be3536ffe94e223e1f365bd374108b2659fac0c65cfe6" +checksum = "3bd1fe6824cea6538803de3ff1bc0cf3949024db3d43c9643024bfb33a807c0e" dependencies = [ "crossbeam-utils", "libc", @@ -5283,9 +5295,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -5605,16 +5617,18 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" +checksum = "f5ef8fb1dd8de3870cb8400d51b4c2023854bbafd5431a3ac7e7317243e22d2f" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", "ark-ff 0.4.2", "bytes", - "fastrlp", + "fastrlp 0.3.1", + "fastrlp 0.4.0", "num-bigint 0.4.6", + "num-integer", "num-traits", "parity-scale-codec", "primitive-types", @@ -5677,9 +5691,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags 2.6.0", "errno", @@ -5733,9 +5747,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "rusty-fork" @@ -5796,7 +5810,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -5871,9 +5885,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -5908,9 +5922,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -5935,20 +5949,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "indexmap 2.7.0", "itoa", @@ -5968,9 +5982,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "base64 0.22.1", "chrono", @@ -5986,14 +6000,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6112,7 +6126,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "snark-verifier" version = "0.1.8" -source = "git+https://github.com/axiom-crypto/snark-verifier?branch=zkvm-v0.1#9b617fc0539a5f5e009f8d907cf74040f90d4f85" +source = "git+https://github.com/axiom-crypto/snark-verifier?branch=zkvm-v0.1#001b25ef0b387c54ed342de2ff6f423fca6db0f6" dependencies = [ "halo2-base", "halo2-ecc", @@ -6133,7 +6147,7 @@ dependencies = [ [[package]] name = "snark-verifier-sdk" version = "0.1.8" -source = "git+https://github.com/axiom-crypto/snark-verifier?branch=zkvm-v0.1#9b617fc0539a5f5e009f8d907cf74040f90d4f85" +source = "git+https://github.com/axiom-crypto/snark-verifier?branch=zkvm-v0.1#001b25ef0b387c54ed342de2ff6f423fca6db0f6" dependencies = [ "ark-std 0.3.0", "bincode 1.3.3", @@ -6196,7 +6210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6248,7 +6262,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6285,9 +6299,9 @@ dependencies = [ [[package]] name = "symbolic-common" -version = "12.12.3" +version = "12.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ba5365997a4e375660bed52f5b42766475d5bc8ceb1bb13fea09c469ea0f49" +checksum = "cd33e73f154e36ec223c18013f7064a2c120f1162fc086ac9933542def186b00" dependencies = [ "debugid", "memmap2", @@ -6297,9 +6311,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.12.3" +version = "12.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beff338b2788519120f38c59ff4bb15174f52a183e547bac3d6072c2c0aa48aa" +checksum = "89e51191290147f071777e37fe111800bb82a9059f9c95b19d2dd41bfeddf477" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -6319,9 +6333,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", @@ -6336,7 +6350,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6353,12 +6367,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", @@ -6393,7 +6408,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6404,7 +6419,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "test-case-core", ] @@ -6427,7 +6442,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6452,11 +6467,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.6" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ - "thiserror-impl 2.0.6", + "thiserror-impl 2.0.9", ] [[package]] @@ -6467,18 +6482,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] name = "thiserror-impl" -version = "2.0.6" +version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +checksum = "7b50fa271071aae2e6ee85f842e2e28ba8cd2c5fb67f11fcb1fd70b276f9e7d4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6584,9 +6599,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -6601,13 +6616,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6692,7 +6707,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -6972,7 +6987,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "wasm-bindgen-shared", ] @@ -6994,7 +7009,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7205,9 +7220,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "39281189af81c07ec09db316b302a3e67bf9bd7cbf6c820b50e35fee9c2fa980" dependencies = [ "memchr", ] @@ -7265,7 +7280,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "synstructure", ] @@ -7287,7 +7302,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -7307,7 +7322,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", "synstructure", ] @@ -7328,7 +7343,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] @@ -7350,7 +7365,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.95", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 965ef73fdc..a663ea4159 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,6 +225,7 @@ getset = "0.1.3" rrs-lib = "0.1.0" rand = { version = "0.8.5", default-features = false } hex = { version = "0.4.3", default-features = false } +serde_arrays = "0.1.0" # default-features = false for no_std for use in guest programs itertools = { version = "0.13.0", default-features = false } diff --git a/crates/circuits/mod-builder/Cargo.toml b/crates/circuits/mod-builder/Cargo.toml index 46d990236a..17c907e3df 100644 --- a/crates/circuits/mod-builder/Cargo.toml +++ b/crates/circuits/mod-builder/Cargo.toml @@ -23,6 +23,8 @@ num-traits.workspace = true tracing.workspace = true itertools.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_with.workspace = true [dev-dependencies] openvm-circuit-primitives = { workspace = true } diff --git a/crates/circuits/mod-builder/src/core_chip.rs b/crates/circuits/mod-builder/src/core_chip.rs index c90f70cf75..3a787190e0 100644 --- a/crates/circuits/mod-builder/src/core_chip.rs +++ b/crates/circuits/mod-builder/src/core_chip.rs @@ -17,6 +17,8 @@ use openvm_stark_backend::{ p3_matrix::{dense::RowMajorMatrix, Matrix}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, DisplayFromStr}; use crate::{ utils::{biguint_to_limbs_vec, limbs_to_biguint}, @@ -161,7 +163,10 @@ where } } +#[serde_as] +#[derive(Serialize, Deserialize)] pub struct FieldExpressionRecord { + #[serde_as(as = "Vec")] pub inputs: Vec, pub flags: Vec, } diff --git a/crates/vm/Cargo.toml b/crates/vm/Cargo.toml index ab1d7a39be..33955ffb04 100644 --- a/crates/vm/Cargo.toml +++ b/crates/vm/Cargo.toml @@ -27,6 +27,7 @@ enum_dispatch.workspace = true backtrace.workspace = true rand.workspace = true serde.workspace = true +serde_arrays.workspace = true toml.workspace = true once_cell.workspace = true cfg-if.workspace = true diff --git a/crates/vm/src/arch/execution.rs b/crates/vm/src/arch/execution.rs index fc33405688..e4bfcbe9d2 100644 --- a/crates/vm/src/arch/execution.rs +++ b/crates/vm/src/arch/execution.rs @@ -5,6 +5,7 @@ use openvm_instructions::{ instruction::Instruction, program::DEFAULT_PC_STEP, PhantomDiscriminant, VmOpcode, }; use openvm_stark_backend::{interaction::InteractionBuilder, p3_field::FieldAlgebra}; +use serde::{Deserialize, Serialize}; use thiserror::Error; use super::Streams; @@ -105,7 +106,7 @@ impl> InstructionExecutor for Rc> { } } -#[derive(Clone, Copy, Debug, PartialEq, Default, AlignedBorrow)] +#[derive(Clone, Copy, Debug, PartialEq, Default, AlignedBorrow, Serialize, Deserialize)] #[repr(C)] pub struct ExecutionState { pub pc: T, diff --git a/crates/vm/src/arch/integration_api.rs b/crates/vm/src/arch/integration_api.rs index 5d7bb6707f..ee4bd76a31 100644 --- a/crates/vm/src/arch/integration_api.rs +++ b/crates/vm/src/arch/integration_api.rs @@ -19,6 +19,7 @@ use openvm_stark_backend::{ rap::{get_air_name, AnyRap, BaseAirWithPublicValues, PartitionedBaseAir}, Chip, ChipUsageGetter, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use super::{ExecutionState, InstructionExecutor, Result}; use crate::system::memory::{MemoryController, OfflineMemory}; @@ -40,9 +41,9 @@ pub trait VmAdapterInterface { /// The adapter AIR should also own `ExecutionBridge` and `MemoryBridge`. pub trait VmAdapterChip { /// Records generated by adapter before main instruction execution - type ReadRecord: Send; + type ReadRecord: Send + Serialize + DeserializeOwned; /// Records generated by adapter after main instruction execution - type WriteRecord: Send; + type WriteRecord: Send + Serialize + DeserializeOwned; /// AdapterAir should not have public values type Air: BaseAir + Clone; @@ -110,7 +111,7 @@ pub trait VmAdapterAir: BaseAir { /// Trait to be implemented on primitive chip to integrate with the machine. pub trait VmCoreChip> { /// Minimum data that must be recorded to be able to generate trace for one row of `PrimitiveAir`. - type Record: Send; + type Record: Send + Serialize + DeserializeOwned; /// The primitive AIR with main constraints that do not depend on memory and other architecture-specifics. type Air: BaseAirWithPublicValues + Clone; @@ -481,6 +482,7 @@ impl VmAdapterInterfac /// An interface that is fully determined during runtime. This should **only** be used as a last resort when static /// compile-time guarantees cannot be made. +#[derive(Serialize, Deserialize)] pub struct DynAdapterInterface(PhantomData); impl VmAdapterInterface for DynAdapterInterface { diff --git a/crates/vm/src/arch/testing/test_adapter.rs b/crates/vm/src/arch/testing/test_adapter.rs index d37bbb1eed..2a3a40aea8 100644 --- a/crates/vm/src/arch/testing/test_adapter.rs +++ b/crates/vm/src/arch/testing/test_adapter.rs @@ -11,6 +11,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use crate::{ arch::{ @@ -47,7 +48,7 @@ impl TestAdapterChip { } } -#[derive(Clone)] +#[derive(Clone, Serialize, Deserialize)] pub struct TestAdapterRecord { pub from_pc: u32, pub operands: [T; 7], diff --git a/crates/vm/src/system/memory/controller/mod.rs b/crates/vm/src/system/memory/controller/mod.rs index fb2f5cd3e6..a5d26efe86 100644 --- a/crates/vm/src/system/memory/controller/mod.rs +++ b/crates/vm/src/system/memory/controller/mod.rs @@ -56,7 +56,7 @@ pub const MERKLE_AIR_OFFSET: usize = 1; /// The offset of the boundary AIR in AIRs of MemoryController. pub const BOUNDARY_AIR_OFFSET: usize = 0; -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct RecordId(pub usize); pub type MemoryImage = FxHashMap; diff --git a/crates/vm/src/system/native_adapter/mod.rs b/crates/vm/src/system/native_adapter/mod.rs index 804a3b6fed..da1f3e2bfc 100644 --- a/crates/vm/src/system/native_adapter/mod.rs +++ b/crates/vm/src/system/native_adapter/mod.rs @@ -24,6 +24,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use crate::system::memory::{OfflineMemory, RecordId}; @@ -52,8 +53,9 @@ impl NativeAdapterChip } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct NativeReadRecord { + #[serde(with = "serde_arrays")] pub reads: [(RecordId, [F; 1]); R], } @@ -67,9 +69,11 @@ impl NativeReadRecord { } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct NativeWriteRecord { pub from_state: ExecutionState, + #[serde(with = "serde_arrays")] pub writes: [(RecordId, [F; 1]); W], } diff --git a/crates/vm/src/system/public_values/core.rs b/crates/vm/src/system/public_values/core.rs index 7d5e008ac7..b844d0a730 100644 --- a/crates/vm/src/system/public_values/core.rs +++ b/crates/vm/src/system/public_values/core.rs @@ -10,6 +10,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use crate::{ arch::{ @@ -95,7 +96,7 @@ impl VmCoreAir { value: F, index: F, diff --git a/extensions/algebra/circuit/Cargo.toml b/extensions/algebra/circuit/Cargo.toml index d2addd60cd..70239ccc6d 100644 --- a/extensions/algebra/circuit/Cargo.toml +++ b/extensions/algebra/circuit/Cargo.toml @@ -30,6 +30,7 @@ strum = { workspace = true } derive-new = { workspace = true } serde.workspace = true serde_with = { workspace = true } +serde_arrays = { workspace = true } [dev-dependencies] halo2curves-axiom = { workspace = true } diff --git a/extensions/algebra/circuit/src/modular_chip/addsub.rs b/extensions/algebra/circuit/src/modular_chip/addsub.rs index 091907aa06..e43274e223 100644 --- a/extensions/algebra/circuit/src/modular_chip/addsub.rs +++ b/extensions/algebra/circuit/src/modular_chip/addsub.rs @@ -22,6 +22,8 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::Deserialize; +use serde_with::serde_derive::Serialize; /// The number of limbs and limb bits are determined at runtime. #[derive(Clone)] @@ -131,6 +133,7 @@ impl ModularAddSubCoreChip { } } +#[derive(Serialize, Deserialize)] pub struct ModularAddSubCoreRecord { pub x: BigUint, pub y: BigUint, diff --git a/extensions/algebra/circuit/src/modular_chip/is_eq.rs b/extensions/algebra/circuit/src/modular_chip/is_eq.rs index 2545afb2dc..f61fab98ea 100644 --- a/extensions/algebra/circuit/src/modular_chip/is_eq.rs +++ b/extensions/algebra/circuit/src/modular_chip/is_eq.rs @@ -24,7 +24,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; - +use serde::{Deserialize, Serialize}; // Given two numbers b and c, we want to prove that a) b == c or b != c, depending on // result of cmp_result and b) b, c < N for some modulus N that is passed into the AIR // at runtime (i.e. when chip is instantiated). @@ -234,12 +234,15 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct ModularIsEqualCoreRecord { pub is_setup: bool, + #[serde(with = "serde_arrays")] pub b: [T; READ_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; READ_LIMBS], pub cmp_result: T, + #[serde(with = "serde_arrays")] pub eq_marker: [T; READ_LIMBS], pub b_diff_idx: usize, pub c_diff_idx: usize, diff --git a/extensions/algebra/circuit/src/modular_chip/muldiv.rs b/extensions/algebra/circuit/src/modular_chip/muldiv.rs index 61f51e9c03..58e04a8aed 100644 --- a/extensions/algebra/circuit/src/modular_chip/muldiv.rs +++ b/extensions/algebra/circuit/src/modular_chip/muldiv.rs @@ -22,6 +22,8 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::Deserialize; +use serde_with::serde_derive::Serialize; /// The number of limbs and limb bits are determined at runtime. #[derive(Clone)] @@ -146,6 +148,7 @@ impl ModularMulDivCoreChip { } } +#[derive(Serialize, Deserialize)] pub struct ModularMulDivCoreRecord { pub x: BigUint, pub y: BigUint, diff --git a/extensions/native/circuit/Cargo.toml b/extensions/native/circuit/Cargo.toml index c347714048..8f74284cdf 100644 --- a/extensions/native/circuit/Cargo.toml +++ b/extensions/native/circuit/Cargo.toml @@ -27,6 +27,8 @@ derive_more = { workspace = true, features = ["from"] } rand.workspace = true eyre.workspace = true serde.workspace = true +serde_arrays.workspace = true +serde_with.workspace = true rayon.workspace = true [dev-dependencies] diff --git a/extensions/native/circuit/src/adapters/convert_adapter.rs b/extensions/native/circuit/src/adapters/convert_adapter.rs index d2889dcb4a..338191e12a 100644 --- a/extensions/native/circuit/src/adapters/convert_adapter.rs +++ b/extensions/native/circuit/src/adapters/convert_adapter.rs @@ -24,13 +24,15 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct VectorReadRecord { + #[serde(with = "serde_arrays")] pub reads: [RecordId; NUM_READS], } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct VectorWriteRecord { pub from_state: ExecutionState, pub writes: [RecordId; 1], diff --git a/extensions/native/circuit/src/adapters/loadstore_native_adapter.rs b/extensions/native/circuit/src/adapters/loadstore_native_adapter.rs index 37936f0cd8..1b258c7e99 100644 --- a/extensions/native/circuit/src/adapters/loadstore_native_adapter.rs +++ b/extensions/native/circuit/src/adapters/loadstore_native_adapter.rs @@ -25,6 +25,7 @@ use openvm_stark_backend::{ p3_air::{AirBuilder, BaseAir}, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; pub struct NativeLoadStoreInstruction { pub is_valid: T, @@ -73,7 +74,8 @@ impl NativeLoadStoreAdapterChip { pub pointer1_read: RecordId, pub pointer2_read: Option, @@ -90,7 +92,8 @@ pub struct NativeLoadStoreReadRecord { pub g: F, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct NativeLoadStoreWriteRecord { pub from_state: ExecutionState, pub write_id: RecordId, diff --git a/extensions/native/circuit/src/adapters/native_vectorized_adapter.rs b/extensions/native/circuit/src/adapters/native_vectorized_adapter.rs index 6fccfae660..c3bae1cee1 100644 --- a/extensions/native/circuit/src/adapters/native_vectorized_adapter.rs +++ b/extensions/native/circuit/src/adapters/native_vectorized_adapter.rs @@ -24,6 +24,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; #[allow(dead_code)] #[derive(Debug)] @@ -48,13 +49,13 @@ impl NativeVectorizedAdapterChip { } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct NativeVectorizedReadRecord { pub b: RecordId, pub c: RecordId, } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct NativeVectorizedWriteRecord { pub from_state: ExecutionState, pub a: RecordId, diff --git a/extensions/native/circuit/src/castf/core.rs b/extensions/native/circuit/src/castf/core.rs index dca15b2e47..97a803f8b4 100644 --- a/extensions/native/circuit/src/castf/core.rs +++ b/extensions/native/circuit/src/castf/core.rs @@ -18,6 +18,8 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; + // LIMB_BITS is the size of the limbs in bits. pub(crate) const LIMB_BITS: usize = 8; // the final limb has only 6 bits @@ -95,7 +97,7 @@ where } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct CastFRecord { pub in_val: F, pub out_val: [F; RV32_REGISTER_NUM_LIMBS], diff --git a/extensions/native/circuit/src/field_arithmetic/core.rs b/extensions/native/circuit/src/field_arithmetic/core.rs index 015aa4bebb..aac9b41089 100644 --- a/extensions/native/circuit/src/field_arithmetic/core.rs +++ b/extensions/native/circuit/src/field_arithmetic/core.rs @@ -14,6 +14,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; #[repr(C)] #[derive(AlignedBorrow)] @@ -101,7 +102,7 @@ where } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct FieldArithmeticRecord { pub opcode: FieldArithmeticOpcode, pub a: F, diff --git a/extensions/native/circuit/src/field_extension/core.rs b/extensions/native/circuit/src/field_extension/core.rs index 9a283168ba..da2f2b48ff 100644 --- a/extensions/native/circuit/src/field_extension/core.rs +++ b/extensions/native/circuit/src/field_extension/core.rs @@ -18,6 +18,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; pub const BETA: usize = 11; pub const EXT_DEG: usize = 4; @@ -129,7 +130,7 @@ where } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct FieldExtensionRecord { pub opcode: FieldExtensionOpcode, pub x: [F; EXT_DEG], diff --git a/extensions/native/circuit/src/jal/core.rs b/extensions/native/circuit/src/jal/core.rs index 8e8d101677..44cb2ce21b 100644 --- a/extensions/native/circuit/src/jal/core.rs +++ b/extensions/native/circuit/src/jal/core.rs @@ -13,6 +13,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; #[repr(C)] #[derive(AlignedBorrow)] @@ -64,7 +65,7 @@ where } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct JalRecord { pub imm: F, } diff --git a/extensions/native/circuit/src/loadstore/core.rs b/extensions/native/circuit/src/loadstore/core.rs index 8015c3d075..3747b9d561 100644 --- a/extensions/native/circuit/src/loadstore/core.rs +++ b/extensions/native/circuit/src/loadstore/core.rs @@ -17,6 +17,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; use super::super::adapters::loadstore_native_adapter::NativeLoadStoreInstruction; @@ -35,12 +36,13 @@ pub struct NativeLoadStoreCoreCols { pub data_write: [T; NUM_CELLS], } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct NativeLoadStoreCoreRecord { pub opcode: NativeLoadStoreOpcode, pub pointer_reads: [F; 2], pub data_read: F, + #[serde(with = "serde_arrays")] pub data_write: [F; NUM_CELLS], } diff --git a/extensions/native/compiler/src/lib.rs b/extensions/native/compiler/src/lib.rs index ab02f3eb26..bed189f3d2 100644 --- a/extensions/native/compiler/src/lib.rs +++ b/extensions/native/compiler/src/lib.rs @@ -4,6 +4,7 @@ use openvm_instructions::UsizeOpcode; use openvm_instructions_derive::UsizeOpcode; use openvm_rv32im_transpiler::BranchEqualOpcode; +use serde::{Deserialize, Serialize}; use strum::{EnumCount, EnumIter, FromRepr, IntoEnumIterator}; extern crate alloc; @@ -25,7 +26,19 @@ pub mod prelude { // ================================================================================================= #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x100] #[repr(usize)] @@ -67,7 +80,19 @@ pub enum CastfOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x130] #[repr(usize)] @@ -79,7 +104,19 @@ pub enum FieldArithmeticOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x140] #[repr(usize)] diff --git a/extensions/rv32-adapters/Cargo.toml b/extensions/rv32-adapters/Cargo.toml index 6ca1714849..3eb824907a 100644 --- a/extensions/rv32-adapters/Cargo.toml +++ b/extensions/rv32-adapters/Cargo.toml @@ -20,6 +20,9 @@ itertools.workspace = true tracing.workspace = true derive-new.workspace = true rand.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_arrays.workspace = true +serde_with.workspace = true [dev-dependencies] openvm-stark-sdk = { workspace = true } diff --git a/extensions/rv32-adapters/src/eq_mod.rs b/extensions/rv32-adapters/src/eq_mod.rs index 51ce916290..e25d858b3e 100644 --- a/extensions/rv32-adapters/src/eq_mod.rs +++ b/extensions/rv32-adapters/src/eq_mod.rs @@ -37,6 +37,8 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; /// This adapter reads from NUM_READS <= 2 pointers and writes to a register. /// * The data is read from the heap (address space 2), and the pointers @@ -273,17 +275,20 @@ impl< } } -#[derive(Clone, Debug)] +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rv32IsEqualModReadRecord< const NUM_READS: usize, const BLOCKS_PER_READ: usize, const BLOCK_SIZE: usize, > { + #[serde(with = "serde_arrays")] pub rs: [RecordId; NUM_READS], + #[serde_as(as = "[[_; BLOCKS_PER_READ]; NUM_READS]")] pub reads: [[RecordId; BLOCKS_PER_READ]; NUM_READS], } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rv32IsEqualModWriteRecord { pub from_state: ExecutionState, pub rd_id: RecordId, diff --git a/extensions/rv32-adapters/src/heap_branch.rs b/extensions/rv32-adapters/src/heap_branch.rs index b1b97eb9d2..33d5aef7dd 100644 --- a/extensions/rv32-adapters/src/heap_branch.rs +++ b/extensions/rv32-adapters/src/heap_branch.rs @@ -38,6 +38,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; /// This adapter reads from NUM_READS <= 2 pointers. /// * The data is read from the heap (address space 2), and the pointers @@ -201,9 +202,11 @@ impl } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rv32HeapBranchReadRecord { + #[serde(with = "serde_arrays")] pub rs_reads: [RecordId; NUM_READS], + #[serde(with = "serde_arrays")] pub heap_reads: [RecordId; NUM_READS], } diff --git a/extensions/rv32-adapters/src/vec_heap.rs b/extensions/rv32-adapters/src/vec_heap.rs index 0da4d506fd..9ca9c6ba98 100644 --- a/extensions/rv32-adapters/src/vec_heap.rs +++ b/extensions/rv32-adapters/src/vec_heap.rs @@ -37,6 +37,8 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; /// This adapter reads from R (R <= 2) pointers and writes to 1 pointer. /// * The data is read from the heap (address space 2), and the pointers @@ -96,7 +98,9 @@ impl< } } -#[derive(Clone, Debug)] +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32VecHeapReadRecord< F: Field, const NUM_READS: usize, @@ -104,19 +108,22 @@ pub struct Rv32VecHeapReadRecord< const READ_SIZE: usize, > { /// Read register value from address space e=1 + #[serde_as(as = "[_; NUM_READS]")] pub rs: [RecordId; NUM_READS], /// Read register value from address space d=1 pub rd: RecordId, pub rd_val: F, + #[serde_as(as = "[[_; BLOCKS_PER_READ]; NUM_READS]")] pub reads: [[RecordId; BLOCKS_PER_READ]; NUM_READS], } -#[derive(Clone, Debug)] +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rv32VecHeapWriteRecord { pub from_state: ExecutionState, - + #[serde_as(as = "[_; BLOCKS_PER_WRITE]")] pub writes: [RecordId; BLOCKS_PER_WRITE], } diff --git a/extensions/rv32-adapters/src/vec_heap_two_reads.rs b/extensions/rv32-adapters/src/vec_heap_two_reads.rs index d3addf938c..ae421b7479 100644 --- a/extensions/rv32-adapters/src/vec_heap_two_reads.rs +++ b/extensions/rv32-adapters/src/vec_heap_two_reads.rs @@ -37,6 +37,8 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; /// This adapter reads from 2 pointers and writes to 1 pointer. /// * The data is read from the heap (address space 2), and the pointers @@ -107,7 +109,9 @@ impl< } } -#[derive(Clone, Debug)] +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32VecHeapTwoReadsReadRecord< F: Field, const BLOCKS_PER_READ1: usize, @@ -122,14 +126,17 @@ pub struct Rv32VecHeapTwoReadsReadRecord< pub rd_val: F, + #[serde_as(as = "[_; BLOCKS_PER_READ1]")] pub reads1: [RecordId; BLOCKS_PER_READ1], + #[serde_as(as = "[_; BLOCKS_PER_READ2]")] pub reads2: [RecordId; BLOCKS_PER_READ2], } -#[derive(Clone, Debug)] +#[serde_as] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Rv32VecHeapTwoReadsWriteRecord { pub from_state: ExecutionState, - + #[serde_as(as = "[_; BLOCKS_PER_WRITE]")] pub writes: [RecordId; BLOCKS_PER_WRITE], } diff --git a/extensions/rv32im/circuit/Cargo.toml b/extensions/rv32im/circuit/Cargo.toml index 4dfafe90c9..4a25fb47bc 100644 --- a/extensions/rv32im/circuit/Cargo.toml +++ b/extensions/rv32im/circuit/Cargo.toml @@ -28,6 +28,7 @@ eyre.workspace = true num-bigint.workspace = true num-integer.workspace = true serde = { workspace = true, features = ["derive", "std"] } +serde_arrays.workspace = true [dev-dependencies] openvm-stark-sdk = { workspace = true } diff --git a/extensions/rv32im/circuit/src/adapters/alu.rs b/extensions/rv32im/circuit/src/adapters/alu.rs index 5c32e4aae2..bef2568c5d 100644 --- a/extensions/rv32im/circuit/src/adapters/alu.rs +++ b/extensions/rv32im/circuit/src/adapters/alu.rs @@ -29,6 +29,7 @@ use openvm_stark_backend::{ p3_air::{AirBuilder, BaseAir}, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::{RV32_CELL_BITS, RV32_REGISTER_NUM_LIMBS}; @@ -57,7 +58,8 @@ impl Rv32BaseAluAdapterChip { } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32BaseAluReadRecord { /// Read register value from address space d=1 pub rs1: RecordId, @@ -69,7 +71,8 @@ pub struct Rv32BaseAluReadRecord { pub rs2_imm: F, } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32BaseAluWriteRecord { pub from_state: ExecutionState, /// Write to destination register diff --git a/extensions/rv32im/circuit/src/adapters/branch.rs b/extensions/rv32im/circuit/src/adapters/branch.rs index e478ffde2d..a30b302874 100644 --- a/extensions/rv32im/circuit/src/adapters/branch.rs +++ b/extensions/rv32im/circuit/src/adapters/branch.rs @@ -26,6 +26,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::RV32_REGISTER_NUM_LIMBS; @@ -53,7 +54,7 @@ impl Rv32BranchAdapterChip { } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Rv32BranchReadRecord { /// Read register value from address space d = 1 pub rs1: RecordId, @@ -61,7 +62,7 @@ pub struct Rv32BranchReadRecord { pub rs2: RecordId, } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Rv32BranchWriteRecord { pub from_state: ExecutionState, } diff --git a/extensions/rv32im/circuit/src/adapters/hintstore.rs b/extensions/rv32im/circuit/src/adapters/hintstore.rs index e6d6e9f9a6..2b9f67e6b0 100644 --- a/extensions/rv32im/circuit/src/adapters/hintstore.rs +++ b/extensions/rv32im/circuit/src/adapters/hintstore.rs @@ -31,6 +31,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::{compose, RV32_REGISTER_NUM_LIMBS}; use crate::adapters::RV32_CELL_BITS; @@ -65,7 +66,8 @@ impl Rv32HintStoreAdapterChip { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32HintStoreReadRecord { pub rs1_record: RecordId, pub rs1_ptr: F, @@ -75,7 +77,7 @@ pub struct Rv32HintStoreReadRecord { pub mem_ptr_limbs: [F; 2], } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32HintStoreWriteRecord { pub from_state: ExecutionState, pub record_id: RecordId, diff --git a/extensions/rv32im/circuit/src/adapters/jalr.rs b/extensions/rv32im/circuit/src/adapters/jalr.rs index e2dc59772d..ee639dbd46 100644 --- a/extensions/rv32im/circuit/src/adapters/jalr.rs +++ b/extensions/rv32im/circuit/src/adapters/jalr.rs @@ -27,6 +27,7 @@ use openvm_stark_backend::{ p3_air::{AirBuilder, BaseAir}, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::RV32_REGISTER_NUM_LIMBS; @@ -52,12 +53,12 @@ impl Rv32JalrAdapterChip { } } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32JalrReadRecord { pub rs1: RecordId, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32JalrWriteRecord { pub from_state: ExecutionState, pub rd_id: Option, diff --git a/extensions/rv32im/circuit/src/adapters/loadstore.rs b/extensions/rv32im/circuit/src/adapters/loadstore.rs index e408358273..b5b90547a6 100644 --- a/extensions/rv32im/circuit/src/adapters/loadstore.rs +++ b/extensions/rv32im/circuit/src/adapters/loadstore.rs @@ -37,6 +37,7 @@ use openvm_stark_backend::{ p3_air::{AirBuilder, BaseAir}, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::{compose, RV32_REGISTER_NUM_LIMBS}; use crate::adapters::RV32_CELL_BITS; @@ -122,7 +123,8 @@ impl Rv32LoadStoreAdapterChip { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32LoadStoreReadRecord { pub rs1_record: RecordId, pub rs1_ptr: F, @@ -135,7 +137,8 @@ pub struct Rv32LoadStoreReadRecord { pub mem_as: F, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32LoadStoreWriteRecord { pub from_state: ExecutionState, /// This will be a write to a register in case of Load and a write to RISC-V memory in case of Stores diff --git a/extensions/rv32im/circuit/src/adapters/mul.rs b/extensions/rv32im/circuit/src/adapters/mul.rs index cca2d8fcbd..da03c70fe2 100644 --- a/extensions/rv32im/circuit/src/adapters/mul.rs +++ b/extensions/rv32im/circuit/src/adapters/mul.rs @@ -26,6 +26,7 @@ use openvm_stark_backend::{ p3_air::BaseAir, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::RV32_REGISTER_NUM_LIMBS; @@ -53,14 +54,14 @@ impl Rv32MultAdapterChip { } } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Rv32MultReadRecord { /// Reads from operand registers pub rs1: RecordId, pub rs2: RecordId, } -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct Rv32MultWriteRecord { pub from_state: ExecutionState, /// Write to destination register diff --git a/extensions/rv32im/circuit/src/adapters/rdwrite.rs b/extensions/rv32im/circuit/src/adapters/rdwrite.rs index e1f49924d5..a453489483 100644 --- a/extensions/rv32im/circuit/src/adapters/rdwrite.rs +++ b/extensions/rv32im/circuit/src/adapters/rdwrite.rs @@ -27,6 +27,7 @@ use openvm_stark_backend::{ p3_air::{AirBuilder, BaseAir}, p3_field::{Field, FieldAlgebra, PrimeField32}, }; +use serde::{Deserialize, Serialize}; use super::RV32_REGISTER_NUM_LIMBS; @@ -73,7 +74,7 @@ impl Rv32CondRdWriteAdapterChip { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32RdWriteWriteRecord { pub from_state: ExecutionState, pub rd_id: Option, diff --git a/extensions/rv32im/circuit/src/auipc/core.rs b/extensions/rv32im/circuit/src/auipc/core.rs index b2daf75480..9e3c87b6b5 100644 --- a/extensions/rv32im/circuit/src/auipc/core.rs +++ b/extensions/rv32im/circuit/src/auipc/core.rs @@ -20,6 +20,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use crate::adapters::{RV32_CELL_BITS, RV32_REGISTER_NUM_LIMBS}; @@ -125,7 +126,7 @@ where } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32AuipcCoreRecord { pub imm_limbs: [F; RV32_REGISTER_NUM_LIMBS - 1], pub pc_limbs: [F; RV32_REGISTER_NUM_LIMBS - 1], diff --git a/extensions/rv32im/circuit/src/base_alu/core.rs b/extensions/rv32im/circuit/src/base_alu/core.rs index 448dc988e9..f7812e79e1 100644 --- a/extensions/rv32im/circuit/src/base_alu/core.rs +++ b/extensions/rv32im/circuit/src/base_alu/core.rs @@ -21,6 +21,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -157,11 +158,15 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "T: Serialize + DeserializeOwned")] pub struct BaseAluCoreRecord { pub opcode: BaseAluOpcode, + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], } diff --git a/extensions/rv32im/circuit/src/branch_eq/core.rs b/extensions/rv32im/circuit/src/branch_eq/core.rs index 677db3ff29..f18a8b222e 100644 --- a/extensions/rv32im/circuit/src/branch_eq/core.rs +++ b/extensions/rv32im/circuit/src/branch_eq/core.rs @@ -17,6 +17,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -123,10 +124,12 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct BranchEqualCoreRecord { pub opcode: BranchEqualOpcode, + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], pub cmp_result: T, pub imm: T, diff --git a/extensions/rv32im/circuit/src/branch_lt/core.rs b/extensions/rv32im/circuit/src/branch_lt/core.rs index c10bcc17a8..d03c69ee82 100644 --- a/extensions/rv32im/circuit/src/branch_lt/core.rs +++ b/extensions/rv32im/circuit/src/branch_lt/core.rs @@ -21,6 +21,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -173,10 +174,12 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct BranchLessThanCoreRecord { pub opcode: BranchLessThanOpcode, + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], pub cmp_result: T, pub cmp_lt: T, diff --git a/extensions/rv32im/circuit/src/divrem/core.rs b/extensions/rv32im/circuit/src/divrem/core.rs index cf7e30fdfc..da5c8709ac 100644 --- a/extensions/rv32im/circuit/src/divrem/core.rs +++ b/extensions/rv32im/circuit/src/divrem/core.rs @@ -24,6 +24,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -343,12 +344,17 @@ impl DivRemCoreChip { pub opcode: DivRemOpcode, + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub q: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub r: [T; NUM_LIMBS], pub zero_divisor: T, pub r_zero: T, @@ -356,7 +362,9 @@ pub struct DivRemCoreRecord { pub c_sign: T, pub q_sign: T, pub sign_xor: T, + #[serde(with = "serde_arrays")] pub r_prime: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub r_inv: [T; NUM_LIMBS], pub lt_diff_val: T, pub lt_diff_idx: usize, diff --git a/extensions/rv32im/circuit/src/hintstore/core.rs b/extensions/rv32im/circuit/src/hintstore/core.rs index 1dc0495340..99242cfce2 100644 --- a/extensions/rv32im/circuit/src/hintstore/core.rs +++ b/extensions/rv32im/circuit/src/hintstore/core.rs @@ -20,6 +20,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use crate::adapters::{RV32_CELL_BITS, RV32_REGISTER_NUM_LIMBS}; @@ -31,7 +32,7 @@ pub struct Rv32HintStoreCoreCols { pub data: [T; RV32_REGISTER_NUM_LIMBS], } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rv32HintStoreCoreRecord { pub data: [F; RV32_REGISTER_NUM_LIMBS], } diff --git a/extensions/rv32im/circuit/src/jal_lui/core.rs b/extensions/rv32im/circuit/src/jal_lui/core.rs index 65de3a8116..d2b4e02887 100644 --- a/extensions/rv32im/circuit/src/jal_lui/core.rs +++ b/extensions/rv32im/circuit/src/jal_lui/core.rs @@ -24,6 +24,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use crate::adapters::{RV32_CELL_BITS, RV32_REGISTER_NUM_LIMBS, RV_J_TYPE_IMM_BITS}; @@ -132,7 +133,8 @@ where } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Field")] pub struct Rv32JalLuiCoreRecord { pub rd_data: [F; RV32_REGISTER_NUM_LIMBS], pub imm: F, diff --git a/extensions/rv32im/circuit/src/jalr/core.rs b/extensions/rv32im/circuit/src/jalr/core.rs index 0591ddef33..22191fbf86 100644 --- a/extensions/rv32im/circuit/src/jalr/core.rs +++ b/extensions/rv32im/circuit/src/jalr/core.rs @@ -25,6 +25,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use crate::adapters::{compose, RV32_CELL_BITS, RV32_REGISTER_NUM_LIMBS}; @@ -46,6 +47,7 @@ pub struct Rv32JalrCoreCols { pub imm_sign: T, } +#[derive(Serialize, Deserialize)] pub struct Rv32JalrCoreRecord { pub imm: F, pub rs1_data: [F; RV32_REGISTER_NUM_LIMBS], diff --git a/extensions/rv32im/circuit/src/less_than/core.rs b/extensions/rv32im/circuit/src/less_than/core.rs index 977cfa2a20..6bb221c89a 100644 --- a/extensions/rv32im/circuit/src/less_than/core.rs +++ b/extensions/rv32im/circuit/src/less_than/core.rs @@ -21,6 +21,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -151,10 +152,13 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "T: Serialize + DeserializeOwned")] pub struct LessThanCoreRecord { pub opcode: LessThanOpcode, + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], pub cmp_result: T, pub b_msb_f: T, diff --git a/extensions/rv32im/circuit/src/load_sign_extend/core.rs b/extensions/rv32im/circuit/src/load_sign_extend/core.rs index 1e55af7f67..c96db16401 100644 --- a/extensions/rv32im/circuit/src/load_sign_extend/core.rs +++ b/extensions/rv32im/circuit/src/load_sign_extend/core.rs @@ -20,6 +20,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::adapters::LoadStoreInstruction; @@ -44,11 +45,14 @@ pub struct LoadSignExtendCoreCols { pub prev_data: [T; NUM_CELLS], } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Serialize + DeserializeOwned")] pub struct LoadSignExtendCoreRecord { pub opcode: Rv32LoadStoreOpcode, pub most_sig_bit: bool, + #[serde(with = "serde_arrays")] pub shifted_read_data: [F; NUM_CELLS], + #[serde(with = "serde_arrays")] pub prev_data: [F; NUM_CELLS], pub shift_amount: u32, } diff --git a/extensions/rv32im/circuit/src/loadstore/core.rs b/extensions/rv32im/circuit/src/loadstore/core.rs index 29e8991f30..abc0ac9eed 100644 --- a/extensions/rv32im/circuit/src/loadstore/core.rs +++ b/extensions/rv32im/circuit/src/loadstore/core.rs @@ -12,6 +12,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::adapters::LoadStoreInstruction; @@ -54,12 +55,16 @@ pub struct LoadStoreCoreCols { pub write_data: [T; NUM_CELLS], } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(bound = "F: Serialize + DeserializeOwned")] pub struct LoadStoreCoreRecord { pub opcode: Rv32LoadStoreOpcode, pub shift: u32, + #[serde(with = "serde_arrays")] pub read_data: [F; NUM_CELLS], + #[serde(with = "serde_arrays")] pub prev_data: [F; NUM_CELLS], + #[serde(with = "serde_arrays")] pub write_data: [F; NUM_CELLS], } diff --git a/extensions/rv32im/circuit/src/mul/core.rs b/extensions/rv32im/circuit/src/mul/core.rs index 5b5bb795ba..9373b03578 100644 --- a/extensions/rv32im/circuit/src/mul/core.rs +++ b/extensions/rv32im/circuit/src/mul/core.rs @@ -18,6 +18,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; #[repr(C)] #[derive(AlignedBorrow)] @@ -134,10 +135,14 @@ impl MultiplicationCoreChip { + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], } diff --git a/extensions/rv32im/circuit/src/mulh/core.rs b/extensions/rv32im/circuit/src/mulh/core.rs index 5dfe2db760..8b4260da43 100644 --- a/extensions/rv32im/circuit/src/mulh/core.rs +++ b/extensions/rv32im/circuit/src/mulh/core.rs @@ -21,6 +21,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -215,12 +216,16 @@ impl MulHCoreChip { pub opcode: MulHOpcode, + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub a_mul: [T; NUM_LIMBS], pub b_ext: T, pub c_ext: T, diff --git a/extensions/rv32im/circuit/src/shift/core.rs b/extensions/rv32im/circuit/src/shift/core.rs index dd75f554e6..18a31110e6 100644 --- a/extensions/rv32im/circuit/src/shift/core.rs +++ b/extensions/rv32im/circuit/src/shift/core.rs @@ -22,6 +22,7 @@ use openvm_stark_backend::{ p3_field::{Field, FieldAlgebra, PrimeField32}, rap::BaseAirWithPublicValues, }; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use strum::IntoEnumIterator; #[repr(C)] @@ -230,12 +231,17 @@ where } } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Serialize, Deserialize)] +#[serde(bound = "T: Serialize + DeserializeOwned")] pub struct ShiftCoreRecord { pub opcode: ShiftOpcode, + #[serde(with = "serde_arrays")] pub a: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub b: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub c: [T; NUM_LIMBS], + #[serde(with = "serde_arrays")] pub bit_shift_carry: [T; NUM_LIMBS], pub bit_shift: usize, pub limb_shift: usize, diff --git a/extensions/rv32im/transpiler/Cargo.toml b/extensions/rv32im/transpiler/Cargo.toml index 537760b6ef..a3f612076d 100644 --- a/extensions/rv32im/transpiler/Cargo.toml +++ b/extensions/rv32im/transpiler/Cargo.toml @@ -16,3 +16,4 @@ tracing = { workspace = true } openvm-rv32im-guest = { workspace = true } openvm-instructions-derive = { workspace = true } strum = { workspace = true } +serde = { workspace = true, features = ["derive"] } diff --git a/extensions/rv32im/transpiler/src/instructions.rs b/extensions/rv32im/transpiler/src/instructions.rs index fb3cb7e011..5bde700f22 100644 --- a/extensions/rv32im/transpiler/src/instructions.rs +++ b/extensions/rv32im/transpiler/src/instructions.rs @@ -9,10 +9,23 @@ use openvm_instructions::UsizeOpcode; use openvm_instructions_derive::UsizeOpcode; +use serde::{Deserialize, Serialize}; use strum::{EnumCount, EnumIter, FromRepr}; #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x200] #[repr(usize)] @@ -25,7 +38,19 @@ pub enum BaseAluOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x205] #[repr(usize)] @@ -36,7 +61,19 @@ pub enum ShiftOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x208] #[repr(usize)] @@ -47,7 +84,19 @@ pub enum LessThanOpcode { // TODO[jpw]: life would be easier if we split LOADB,LOADH into a separate enum #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x210] #[repr(usize)] @@ -65,7 +114,19 @@ pub enum Rv32LoadStoreOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x220] #[repr(usize)] @@ -76,7 +137,19 @@ pub enum BranchEqualOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x225] #[repr(usize)] @@ -130,7 +203,19 @@ pub enum MulOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x251] #[repr(usize)] @@ -142,7 +227,19 @@ pub enum MulHOpcode { } #[derive( - Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, EnumCount, EnumIter, FromRepr, UsizeOpcode, + Copy, + Clone, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + EnumCount, + EnumIter, + FromRepr, + UsizeOpcode, + Serialize, + Deserialize, )] #[opcode_offset = 0x254] #[repr(usize)]