diff --git a/Cargo.lock b/Cargo.lock index 6c3ca814..f3ed3aaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,24 +102,24 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "alloy" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", + "alloy-consensus 1.5.2", "alloy-contract", "alloy-core", - "alloy-eips 1.4.3", - "alloy-genesis 1.4.3", - "alloy-network 1.4.3", - "alloy-provider 1.4.3", + "alloy-eips 1.5.2", + "alloy-genesis 1.5.2", + "alloy-network 1.5.2", + "alloy-provider 1.5.2", "alloy-pubsub", - "alloy-rpc-client 1.4.3", - "alloy-rpc-types 1.4.3", - "alloy-serde 1.4.3", - "alloy-signer 1.4.3 (git+https://github.com/alloy-rs/alloy)", + "alloy-rpc-client 1.5.2", + "alloy-rpc-types 1.5.2", + "alloy-serde 1.5.2", + "alloy-signer 1.5.2 (git+https://github.com/alloy-rs/alloy)", "alloy-signer-local", - "alloy-transport 1.4.3", - "alloy-transport-http 1.4.3", + "alloy-transport 1.5.2", + "alloy-transport-http 1.5.2", "alloy-transport-ipc", "alloy-transport-ws", "alloy-trie 0.9.3", @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "alloy-chains" -version = "0.2.27" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db5bcdd086f0b1b9610140a12c59b757397be90bd130d8d836fc8da0815a34" +checksum = "90f374d3c6d729268bbe2d0e0ff992bb97898b2df756691a62ee1d5f0506bc39" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -165,15 +165,15 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-eips 1.4.3", + "alloy-eips 1.5.2", "alloy-primitives", "alloy-rlp", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "alloy-trie 0.9.3", - "alloy-tx-macros 1.4.3", + "alloy-tx-macros 1.5.2", "auto_impl", "borsh", "c-kzg", @@ -204,33 +204,33 @@ dependencies = [ [[package]] name = "alloy-consensus-any" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-eips 1.4.3", + "alloy-consensus 1.5.2", + "alloy-eips 1.5.2", "alloy-primitives", "alloy-rlp", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "serde", ] [[package]] name = "alloy-contract" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", + "alloy-consensus 1.5.2", "alloy-dyn-abi", "alloy-json-abi", - "alloy-network 1.4.3", - "alloy-network-primitives 1.4.3", + "alloy-network 1.5.2", + "alloy-network-primitives 1.5.2", "alloy-primitives", - "alloy-provider 1.4.3", + "alloy-provider 1.5.2", "alloy-pubsub", - "alloy-rpc-types-eth 1.4.3", + "alloy-rpc-types-eth 1.5.2", "alloy-sol-types", - "alloy-transport 1.4.3", + "alloy-transport 1.5.2", "futures", "futures-util", "serde_json", @@ -306,6 +306,18 @@ dependencies = [ "thiserror 2.0.18", ] +[[package]] +name = "alloy-eip7928" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3231de68d5d6e75332b7489cfcc7f4dfabeba94d990a10e4b923af0e6623540" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "borsh", + "serde", +] + [[package]] name = "alloy-eips" version = "1.0.41" @@ -329,15 +341,16 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-eip2124", "alloy-eip2930", "alloy-eip7702", + "alloy-eip7928", "alloy-primitives", "alloy-rlp", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "auto_impl", "borsh", "c-kzg", @@ -384,12 +397,12 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-eips 1.4.3", + "alloy-eips 1.5.2", "alloy-primitives", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "alloy-trie 0.9.3", "borsh", "serde", @@ -437,8 +450,8 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -476,19 +489,19 @@ dependencies = [ [[package]] name = "alloy-network" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-consensus-any 1.4.3", - "alloy-eips 1.4.3", - "alloy-json-rpc 1.4.3", - "alloy-network-primitives 1.4.3", + "alloy-consensus 1.5.2", + "alloy-consensus-any 1.5.2", + "alloy-eips 1.5.2", + "alloy-json-rpc 1.5.2", + "alloy-network-primitives 1.5.2", "alloy-primitives", - "alloy-rpc-types-any 1.4.3", - "alloy-rpc-types-eth 1.4.3", - "alloy-serde 1.4.3", - "alloy-signer 1.4.3 (git+https://github.com/alloy-rs/alloy)", + "alloy-rpc-types-any 1.5.2", + "alloy-rpc-types-eth 1.5.2", + "alloy-serde 1.5.2", + "alloy-signer 1.5.2 (git+https://github.com/alloy-rs/alloy)", "alloy-sol-types", "async-trait", "auto_impl", @@ -513,13 +526,13 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-eips 1.4.3", + "alloy-consensus 1.5.2", + "alloy-eips 1.5.2", "alloy-primitives", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "serde", ] @@ -622,27 +635,27 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-chains", - "alloy-consensus 1.4.3", - "alloy-eips 1.4.3", - "alloy-json-rpc 1.4.3", - "alloy-network 1.4.3", - "alloy-network-primitives 1.4.3", + "alloy-consensus 1.5.2", + "alloy-eips 1.5.2", + "alloy-json-rpc 1.5.2", + "alloy-network 1.5.2", + "alloy-network-primitives 1.5.2", "alloy-primitives", "alloy-pubsub", - "alloy-rpc-client 1.4.3", + "alloy-rpc-client 1.5.2", "alloy-rpc-types-anvil", - "alloy-rpc-types-debug 1.4.3", - "alloy-rpc-types-eth 1.4.3", - "alloy-rpc-types-trace 1.4.3", + "alloy-rpc-types-debug 1.5.2", + "alloy-rpc-types-eth 1.5.2", + "alloy-rpc-types-trace 1.5.2", "alloy-rpc-types-txpool", - "alloy-signer 1.4.3 (git+https://github.com/alloy-rs/alloy)", + "alloy-signer 1.5.2 (git+https://github.com/alloy-rs/alloy)", "alloy-sol-types", - "alloy-transport 1.4.3", - "alloy-transport-http 1.4.3", + "alloy-transport 1.5.2", + "alloy-transport-http 1.5.2", "alloy-transport-ipc", "alloy-transport-ws", "async-stream", @@ -667,12 +680,12 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-json-rpc 1.4.3", + "alloy-json-rpc 1.5.2", "alloy-primitives", - "alloy-transport 1.4.3", + "alloy-transport 1.5.2", "auto_impl", "bimap", "futures", @@ -732,14 +745,14 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-json-rpc 1.4.3", + "alloy-json-rpc 1.5.2", "alloy-primitives", "alloy-pubsub", - "alloy-transport 1.4.3", - "alloy-transport-http 1.4.3", + "alloy-transport 1.5.2", + "alloy-transport-http 1.5.2", "alloy-transport-ipc", "alloy-transport-ws", "futures", @@ -768,28 +781,28 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", "alloy-rpc-types-anvil", - "alloy-rpc-types-debug 1.4.3", - "alloy-rpc-types-engine 1.4.3", - "alloy-rpc-types-eth 1.4.3", - "alloy-rpc-types-trace 1.4.3", + "alloy-rpc-types-debug 1.5.2", + "alloy-rpc-types-engine 1.5.2", + "alloy-rpc-types-eth 1.5.2", + "alloy-rpc-types-trace 1.5.2", "alloy-rpc-types-txpool", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "serde", ] [[package]] name = "alloy-rpc-types-anvil" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 1.4.3", - "alloy-serde 1.4.3", + "alloy-rpc-types-eth 1.5.2", + "alloy-serde 1.5.2", "serde", ] @@ -805,12 +818,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-any" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus-any 1.4.3", - "alloy-rpc-types-eth 1.4.3", - "alloy-serde 1.4.3", + "alloy-consensus-any 1.5.2", + "alloy-rpc-types-eth 1.5.2", + "alloy-serde 1.5.2", ] [[package]] @@ -826,8 +839,8 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", "derive_more 2.1.1", @@ -850,14 +863,14 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-eips 1.4.3", + "alloy-consensus 1.5.2", + "alloy-eips 1.5.2", "alloy-primitives", "alloy-rlp", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "derive_more 2.1.1", "rand 0.8.5", "serde", @@ -886,16 +899,16 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-consensus-any 1.4.3", - "alloy-eips 1.4.3", - "alloy-network-primitives 1.4.3", + "alloy-consensus 1.5.2", + "alloy-consensus-any 1.5.2", + "alloy-eips 1.5.2", + "alloy-network-primitives 1.5.2", "alloy-primitives", "alloy-rlp", - "alloy-serde 1.4.3", + "alloy-serde 1.5.2", "alloy-sol-types", "itertools 0.14.0", "serde", @@ -919,12 +932,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 1.4.3", - "alloy-serde 1.4.3", + "alloy-rpc-types-eth 1.5.2", + "alloy-serde 1.5.2", "serde", "serde_json", "thiserror 2.0.18", @@ -932,12 +945,12 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", - "alloy-rpc-types-eth 1.4.3", - "alloy-serde 1.4.3", + "alloy-rpc-types-eth 1.5.2", + "alloy-serde 1.5.2", "serde", ] @@ -953,8 +966,8 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", "serde", @@ -977,9 +990,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.4.3" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb10ccd49d0248df51063fce6b716f68a315dd912d55b32178c883fd48b4021d" +checksum = "2f7481dc8316768f042495eaf305d450c32defbc9bce09d8bf28afcd956895bb" dependencies = [ "alloy-primitives", "async-trait", @@ -992,8 +1005,8 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-primitives", "async-trait", @@ -1006,13 +1019,13 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-consensus 1.4.3", - "alloy-network 1.4.3", + "alloy-consensus 1.5.2", + "alloy-network 1.5.2", "alloy-primitives", - "alloy-signer 1.4.3 (git+https://github.com/alloy-rs/alloy)", + "alloy-signer 1.5.2 (git+https://github.com/alloy-rs/alloy)", "async-trait", "k256", "rand 0.8.5", @@ -1117,10 +1130,10 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-json-rpc 1.4.3", + "alloy-json-rpc 1.5.2", "auto_impl", "base64 0.22.1", "derive_more 2.1.1", @@ -1153,11 +1166,11 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-json-rpc 1.4.3", - "alloy-transport 1.4.3", + "alloy-json-rpc 1.5.2", + "alloy-transport 1.5.2", "reqwest 0.12.28", "serde_json", "tower 0.5.3", @@ -1167,12 +1180,12 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ - "alloy-json-rpc 1.4.3", + "alloy-json-rpc 1.5.2", "alloy-pubsub", - "alloy-transport 1.4.3", + "alloy-transport 1.5.2", "bytes", "futures", "interprocess", @@ -1186,11 +1199,11 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "alloy-pubsub", - "alloy-transport 1.4.3", + "alloy-transport 1.5.2", "futures", "http 1.4.0", "serde_json", @@ -1246,8 +1259,8 @@ dependencies = [ [[package]] name = "alloy-tx-macros" -version = "1.4.3" -source = "git+https://github.com/alloy-rs/alloy#35522b7f9ed6e68cd4ec992451e261e0fae0ad00" +version = "1.5.2" +source = "git+https://github.com/alloy-rs/alloy#3f6af62c83fc4f2decf46cd797d0e608834cf0b9" dependencies = [ "darling", "proc-macro2", @@ -2936,9 +2949,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.53" +version = "1.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755d2fce177175ffca841e9a06afdb2c4ab0f593d53b4dee48147dfaade85932" +checksum = "6354c81bbfd62d9cfa9cb3c773c2b7b2a3a482d569de977fd0e961f6e7c00583" dependencies = [ "find-msvc-tools", "jobserver", @@ -5000,9 +5013,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.30.10" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9" +checksum = "74a4d85559e2637d3d839438b5b3d75c31e655276f9544d72475c36b92fabbed" [[package]] name = "glob" @@ -5100,7 +5113,7 @@ dependencies = [ [[package]] name = "guest-executor" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-consensus 1.0.41", "alloy-evm", @@ -5541,7 +5554,7 @@ dependencies = [ [[package]] name = "host-executor" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-chains", "alloy-consensus 1.0.41", @@ -5794,7 +5807,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.1", + "socket2 0.6.2", "system-configuration 0.6.1", "tokio", "tower-service", @@ -6381,9 +6394,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libp2p" @@ -7186,7 +7199,7 @@ dependencies = [ [[package]] name = "mpt" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -7353,12 +7366,12 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23" +checksum = "cd6c30ed10fa69cc491d491b85cc971f6bdeb8e7367b7cde2ee6cc878d583fae" dependencies = [ "bytes", - "futures", + "futures-util", "libc", "log", "tokio", @@ -7496,9 +7509,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" [[package]] name = "num-integer" @@ -8887,10 +8900,11 @@ dependencies = [ [[package]] name = "primitives" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-eips 1.0.41", "alloy-genesis 1.0.41", + "alloy-primitives", "alloy-rpc-types 1.0.41", "eyre", "reth-chainspec", @@ -8959,9 +8973,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -9222,7 +9236,7 @@ dependencies = [ [[package]] name = "provider" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-json-rpc 1.0.41", "alloy-provider 1.0.41", @@ -9273,7 +9287,7 @@ dependencies = [ "quinn-udp", "rustc-hash 2.1.1", "rustls 0.23.36", - "socket2 0.6.1", + "socket2 0.6.2", "thiserror 2.0.18", "tokio", "tracing", @@ -9310,16 +9324,16 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.1", + "socket2 0.6.2", "tracing", "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -10379,7 +10393,7 @@ dependencies = [ [[package]] name = "rpc-db" version = "0.1.0" -source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#403401c045c42a8681431ca7009bd57d62e1f1df" +source = "git+https://github.com/ProjectZKM/reth-processor?branch=feat%2Fslot-state-check#0b280a7cc8cd7c12bcf28a06fbdef3cb9a9ae196" dependencies = [ "alloy-consensus 1.0.41", "alloy-primitives", @@ -11336,9 +11350,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" dependencies = [ "libc", "windows-sys 0.60.2", @@ -12195,9 +12209,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.45" +version = "0.3.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e442fc33d7fdb45aa9bfeb312c095964abdf596f7567261062b2a7107aaabd" +checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5" dependencies = [ "deranged", "itoa", @@ -12212,15 +12226,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b36ee98fd31ec7426d599183e8fe26932a8dc1fb76ddb6214d05493377d34ca" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e552d1249bf61ac2a52db88179fd0673def1e1ad8243a00d9ec9ed71fee3dd" +checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4" dependencies = [ "num-conv", "time-core", @@ -12272,7 +12286,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.6.1", + "socket2 0.6.2", "tokio-macros", "windows-sys 0.61.2", ] @@ -14012,8 +14026,8 @@ dependencies = [ [[package]] name = "zkm-build" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "anyhow", "cargo_metadata", @@ -14023,8 +14037,8 @@ dependencies = [ [[package]] name = "zkm-core-executor" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "anyhow", "bincode", @@ -14061,8 +14075,8 @@ dependencies = [ [[package]] name = "zkm-core-machine" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "bincode", "cfg-if", @@ -14113,8 +14127,8 @@ dependencies = [ [[package]] name = "zkm-cuda" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "bincode", "ctrlc", @@ -14131,8 +14145,8 @@ dependencies = [ [[package]] name = "zkm-curves" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "cfg-if", "curve25519-dalek", @@ -14155,8 +14169,8 @@ dependencies = [ [[package]] name = "zkm-derive" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "quote", "syn 1.0.109", @@ -14164,8 +14178,8 @@ dependencies = [ [[package]] name = "zkm-lib" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "bincode", "cfg-if", @@ -14177,8 +14191,8 @@ dependencies = [ [[package]] name = "zkm-primitives" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "bincode", "hex", @@ -14195,8 +14209,8 @@ dependencies = [ [[package]] name = "zkm-prover" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "anyhow", "bincode", @@ -14233,8 +14247,8 @@ dependencies = [ [[package]] name = "zkm-recursion-circuit" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "hashbrown 0.14.5", "itertools 0.13.0", @@ -14266,8 +14280,8 @@ dependencies = [ [[package]] name = "zkm-recursion-compiler" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "backtrace", "itertools 0.13.0", @@ -14287,8 +14301,8 @@ dependencies = [ [[package]] name = "zkm-recursion-core" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "backtrace", "ff 0.13.1", @@ -14324,8 +14338,8 @@ dependencies = [ [[package]] name = "zkm-recursion-derive" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "quote", "syn 1.0.109", @@ -14333,8 +14347,8 @@ dependencies = [ [[package]] name = "zkm-recursion-gnark-ffi" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "anyhow", "bincode", @@ -14357,11 +14371,11 @@ dependencies = [ [[package]] name = "zkm-sdk" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "alloy-primitives", - "alloy-signer 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "alloy-signer 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "anyhow", "async-trait", "bincode", @@ -14404,8 +14418,8 @@ dependencies = [ [[package]] name = "zkm-stark" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "arrayref", "hashbrown 0.14.5", @@ -14446,8 +14460,8 @@ dependencies = [ [[package]] name = "zkm-verifier" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "anyhow", "ark-bn254", @@ -14481,8 +14495,8 @@ dependencies = [ [[package]] name = "zkm-zkvm" -version = "1.2.3" -source = "git+https://github.com/ProjectZKM/Ziren#58f41aaaee16b20d8591ae4b239b75e08a50343a" +version = "1.2.4" +source = "git+https://github.com/ProjectZKM/Ziren#c59a2090a4e76896629708c5239bdf9927320a78" dependencies = [ "bincode", "cfg-if", diff --git a/circuits/cron-header-chain-proof.sh b/circuits/cron-header-chain-proof.sh index 8bf4d092..5307187a 100644 --- a/circuits/cron-header-chain-proof.sh +++ b/circuits/cron-header-chain-proof.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e -#CMD="cargo run -r --bin header-chain-proof --package header-chain-proof --" +source .env +BITCOIN_NETWORK=$BITCOIN_NETWORK cargo build -r --bin header-chain-proof --package header-chain-proof CMD="../target/release/header-chain-proof" DATA="data/header-chain" diff --git a/circuits/operator-proof/guest/Cargo.toml b/circuits/operator-proof/guest/Cargo.toml index 46c4fb1e..519efdeb 100644 --- a/circuits/operator-proof/guest/Cargo.toml +++ b/circuits/operator-proof/guest/Cargo.toml @@ -27,7 +27,6 @@ bitcoin = { version = "0.32.6", features = ["serde", "rand", "secp-recovery"] } alloy-primitives = { version = "1.0.0", features = ["sha3-keccak", "map-foldhash", "serde"], default-features = false } #revm = { git = "https://github.com/ziren-patches/revm", branch = "patch-31.0.2", features = ["serde", "bn"], default-features = false } sha2 = "0.10.9" -serde_cbor = "0.11.2" [patch.crates-io] diff --git a/circuits/operator-proof/host/Cargo.toml b/circuits/operator-proof/host/Cargo.toml index 89de54b0..fe903662 100644 --- a/circuits/operator-proof/host/Cargo.toml +++ b/circuits/operator-proof/host/Cargo.toml @@ -33,7 +33,6 @@ primitives.workspace = true provider.workspace = true bitcoin-script.workspace = true alloy-provider = { workspace = true, default-features = false } -#serde_cbor.workspace = true util.workspace = true diff --git a/crates/bitvm2-ga/src/tests.rs b/crates/bitvm2-ga/src/tests.rs index da07345a..ee059478 100644 --- a/crates/bitvm2-ga/src/tests.rs +++ b/crates/bitvm2-ga/src/tests.rs @@ -7,7 +7,6 @@ mod tests { Address, Amount, EcdsaSighashType, Network, OutPoint, PublicKey, ScriptBuf, TapSighashType, Transaction, TxIn, TxOut, Txid, XOnlyPublicKey, hashes::Hash, key::Keypair, }; - use bitcoin_light_client_circuit::{PROOF_SIZE, PUBLIC_INPUTS_SIZE}; use bitcoincore_rpc::{Auth, Client as BtcdClient, RpcApi}; use bitvm::{ chunk::api::{NUM_HASH, NUM_PUBS, NUM_U256}, @@ -64,7 +63,6 @@ mod tests { Network::Testnet4 => "testnet4", Network::Signet => "signet", Network::Bitcoin => "bitcoin", - _ => "regtest", }; unsafe { std::env::set_var(ENV_KEY, v); diff --git a/crates/bitvm2-ga/src/types.rs b/crates/bitvm2-ga/src/types.rs index a9fefae7..ab41581a 100644 --- a/crates/bitvm2-ga/src/types.rs +++ b/crates/bitvm2-ga/src/types.rs @@ -462,7 +462,7 @@ pub fn get_magic_bytes(net: &Network) -> Vec { } pub mod node_serializer { - use serde::{self, Deserialize, Deserializer, Serializer, ser::Error}; + use serde::{self, Deserialize, Deserializer, Serializer}; use std::str::FromStr; pub mod address { @@ -494,7 +494,8 @@ pub mod node_serializer { use bitvm::chunk::api::{NUM_HASH, NUM_PUBS, NUM_U256}; use bitvm::signatures::{Wots, Wots16, Wots32}; use goat::disprove_scripts::{NUM_GUEST_PUBS_ASSERT, NUM_GUEST_PUBS_EXTRA}; - use std::collections::HashMap; + use serde::de::Error as DeError; + use serde::ser::SerializeSeq; pub fn serialize( pubkeys: &OperatorWotsPublicKeys, @@ -503,124 +504,143 @@ pub mod node_serializer { where S: Serializer, { - let mut pubkeys_map: HashMap>> = HashMap::new(); - let mut index = 0; - - // wots pk for guest pubin - for pk in pubkeys.0 { - let v: Vec> = pk.iter().map(|x| x.to_vec()).collect(); - pubkeys_map.insert(index, v); - index += 1; + let total_len = pubkeys.0.len() + + pubkeys.1.len() + + pubkeys.2.0.len() + + pubkeys.2.1.len() + + pubkeys.2.2.len(); + + let mut seq = serializer.serialize_seq(Some(total_len))?; + + fn push_pk(seq: &mut S, pk: &::PublicKey) -> Result<(), S::Error> + where + S: SerializeSeq, + W: Wots, + { + // pk: AsRef<[[u8; 20]]> + let digits = pk.as_ref(); + + debug_assert_eq!(digits.len(), W::TOTAL_DIGIT_LEN as usize); + + let out: Vec> = digits.iter().map(|d| d.to_vec()).collect(); + seq.serialize_element(&out) + } + + for pk in pubkeys.0.iter() { + push_pk::<_, Wots32>(&mut seq, pk)?; } - for pk in pubkeys.1 { - let v: Vec> = pk.iter().map(|x| x.to_vec()).collect(); - pubkeys_map.insert(index, v); - index += 1; + for pk in pubkeys.1.iter() { + push_pk::<_, Wots32>(&mut seq, pk)?; } - // wots pk for groth16 proof - for pk in pubkeys.2.0 { - let v: Vec> = pk.iter().map(|x| x.to_vec()).collect(); - pubkeys_map.insert(index, v); - index += 1; + for pk in pubkeys.2.0.iter() { + push_pk::<_, Wots32>(&mut seq, pk)?; } - for pk in pubkeys.2.1 { - let v: Vec> = pk.iter().map(|x| x.to_vec()).collect(); - pubkeys_map.insert(index, v); - index += 1; + for pk in pubkeys.2.1.iter() { + push_pk::<_, Wots32>(&mut seq, pk)?; } - for pk in pubkeys.2.2 { - let v: Vec> = pk.iter().map(|x| x.to_vec()).collect(); - pubkeys_map.insert(index, v); - index += 1; + for pk in pubkeys.2.2.iter() { + push_pk::<_, Wots16>(&mut seq, pk)?; } - let map_vec = bincode::serialize(&pubkeys_map).map_err(S::Error::custom)?; - serializer.serialize_bytes(&map_vec) + + seq.end() } pub fn deserialize<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { - let map_vec = Vec::::deserialize(deserializer)?; - let pubkeys_map: HashMap>> = - bincode::deserialize(&map_vec).map_err(serde::de::Error::custom)?; + let all: Vec>> = Vec::deserialize(deserializer)?; + let expected = + NUM_GUEST_PUBS_EXTRA + NUM_GUEST_PUBS_ASSERT + NUM_PUBS + NUM_U256 + NUM_HASH; + + if all.len() != expected { + return Err(D::Error::custom(format!( + "Invalid WOTS pubkey count: expected {expected}, got {}", + all.len() + ))); + } + let mut cursor = 0; fn extract_wots_pubkeys( - pubkeys_map: &HashMap>>, - range: std::ops::Range, + src: &[Vec>], + cursor: usize, label: &str, ) -> Result<[::PublicKey; N], E> where W: Wots, - E: serde::de::Error, + E: DeError, { let digit_len = W::TOTAL_DIGIT_LEN as usize; - let mut out = Vec::with_capacity(N); - - for i in range { - let v = pubkeys_map - .get(&i) - .ok_or_else(|| E::custom(format!("Missing {label}[{i}]")))?; + if src.len().checked_sub(cursor).is_none_or(|r| r < N) { + return Err(E::custom(format!( + "{label}: not enough elements: need {N}, have {}", + src.len() - cursor + ))); + } + let slice = &src[cursor..cursor + N]; - if v.len() != digit_len { + let mut out: Vec<::PublicKey> = Vec::with_capacity(N); + for (i, pk) in slice.iter().enumerate() { + if pk.len() != digit_len { return Err(E::custom(format!( - "Invalid {label}[{i}] length (expected {digit_len})" + "{label}[{i}] invalid digit len: expected {digit_len}, got {}", + pk.len() ))); } - let mut res: Vec<[u8; 20]> = Vec::with_capacity(digit_len); - for (j, bytes) in v.iter().enumerate() { - res.push(bytes.as_slice().try_into().map_err(|_| { - E::custom(format!("Invalid 20-byte chunk in {label}[{i}][{j}]")) - })?); + let mut digits: Vec<[u8; 20]> = Vec::with_capacity(digit_len); + for (j, d) in pk.iter().enumerate() { + let arr: [u8; 20] = d.as_slice().try_into().map_err(|_| { + E::custom(format!("{label}[{i}][{j}] invalid hash len (expected 20)")) + })?; + digits.push(arr); } - let res: ::PublicKey = res.try_into().map_err(|_| { - E::custom(format!("{label}[{i}] size mismatch (expected {digit_len})")) - })?; - out.push(res); + let pk: ::PublicKey = digits + .try_into() + .map_err(|_| E::custom(format!("{label}[{i}] size mismatch")))?; + + out.push(pk); } - out.try_into() - .map_err(|_| E::custom(format!("{label} size mismatch (expected {N})"))) + out.try_into().map_err(|_| E::custom(format!("{label}: final size mismatch"))) } - let mut idx = 0u32; - let pk0 = extract_wots_pubkeys::( - &pubkeys_map, - idx..idx + NUM_GUEST_PUBS_EXTRA as u32, + &all, + cursor, "guestpk.extra", )?; - idx += NUM_GUEST_PUBS_EXTRA as u32; + cursor += NUM_GUEST_PUBS_EXTRA; let pk1 = extract_wots_pubkeys::( - &pubkeys_map, - idx..idx + NUM_GUEST_PUBS_ASSERT as u32, + &all, + cursor, "guestpk.assert", )?; - idx += NUM_GUEST_PUBS_ASSERT as u32; + cursor += NUM_GUEST_PUBS_ASSERT; - let pk20 = extract_wots_pubkeys::( - &pubkeys_map, - idx..idx + NUM_PUBS as u32, - "groth16pk.pub", - )?; - idx += NUM_PUBS as u32; + let pk20 = + extract_wots_pubkeys::(&all, cursor, "groth16pk.pub")?; + cursor += NUM_PUBS; let pk21 = extract_wots_pubkeys::( - &pubkeys_map, - idx..idx + NUM_U256 as u32, + &all, + cursor, "groth16pk.wots256", )?; - idx += NUM_U256 as u32; + cursor += NUM_U256; - let pk22 = extract_wots_pubkeys::( - &pubkeys_map, - idx..idx + NUM_HASH as u32, + // FIXME: this is a tricky way to handle Wots16: if we use ? modifier, this will raise SEGV. + #[allow(clippy::question_mark)] + let pk22 = match extract_wots_pubkeys::( + &all, + cursor, "groth16pk.wots_hash", - )?; - + ) { + Err(e) => return Err(e), + Ok(pk) => pk, + }; Ok((pk0, pk1, Box::new((pk20, pk21, pk22)))) } } @@ -630,16 +650,48 @@ pub mod node_serializer { mod tests { use crate::operator::generate_wots_keys; use crate::types::{OperatorWotsPublicKeys, node_serializer}; - use bitcoin::Address; + use bitcoin::{Address, Network, key::PublicKey}; + use rand::rngs::OsRng; + use secp256k1::{Keypair, Secp256k1, SecretKey}; use serde::{Deserialize, Serialize}; use std::fmt::Debug; - use std::str::FromStr; - fn mock_wots_secret_keys() -> WotsKeys { - let (_, pubs) = generate_wots_keys("seed"); - let address = - Address::from_str("1CAGNhS5KPpeoZyL6DDNiKp85hCjZkvyYg").unwrap().assume_checked(); - WotsKeys { pubs, address } + #[derive(Clone, Copy)] + pub enum AddrKind { + P2pkh, + P2wpkh, + P2shWpkh, + P2tr, + } + + fn random_address(network: Network, kind: AddrKind) -> Address { + let secp = Secp256k1::new(); + + match kind { + AddrKind::P2tr => { + let kp = Keypair::new(&secp, &mut OsRng); + let (xonly, _) = kp.x_only_public_key(); + Address::p2tr(&secp, xonly, None, network) + } + _ => { + let sk = SecretKey::new(&mut OsRng); + let pk = PublicKey::new(secp256k1::PublicKey::from_secret_key(&secp, &sk)); + + let privkey = bitcoin::key::PrivateKey { + compressed: true, + network: network.into(), + inner: sk, + }; + let cpk = bitcoin::CompressedPublicKey::from_private_key(&secp, &privkey).unwrap(); + + match kind { + AddrKind::P2pkh => Address::p2pkh(&pk, network), + AddrKind::P2wpkh => Address::p2wpkh(&cpk, network), + AddrKind::P2shWpkh => Address::p2shwpkh(&cpk, network), + AddrKind::P2tr => unreachable!(), + } + } + } } #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -658,15 +710,39 @@ mod tests { } #[test] - fn test_node_serializer() { - let original = mock_wots_secret_keys(); - - let json = serde_json::to_vec(&original).unwrap(); - let parsed: WotsKeys = serde_json::from_slice(&json).unwrap(); - assert_eq!(original, parsed); + fn test_wots_keys_serializer() { + for &network in &[Network::Bitcoin, Network::Testnet, Network::Signet, Network::Regtest] { + for kind in &[AddrKind::P2pkh, AddrKind::P2wpkh, AddrKind::P2shWpkh, AddrKind::P2tr] { + let (_, pubs) = generate_wots_keys("seed"); + let address = random_address(network, *kind); + let original = WotsKeys { pubs, address }; + + let json = serde_json::to_vec(&original).unwrap(); + let parsed: WotsKeys = serde_json::from_slice(&json).unwrap(); + assert_eq!(original, parsed); + + let encoded = bincode::serialize(&original).unwrap(); + let decoded: WotsKeys = bincode::deserialize(&encoded).unwrap(); + assert_eq!(original, decoded); + } + } + } - let encoded = bincode::serialize(&original).unwrap(); - let decoded: WotsKeys = bincode::deserialize(&encoded).unwrap(); - assert_eq!(original, decoded); + #[test] + fn test_address_serializer() { + #[derive(Serialize, Deserialize)] + struct AddressTest { + #[serde(with = "node_serializer::address")] + address: Address, + } + for &network in &[Network::Bitcoin, Network::Testnet, Network::Signet, Network::Regtest] { + for kind in &[AddrKind::P2pkh, AddrKind::P2wpkh, AddrKind::P2shWpkh, AddrKind::P2tr] { + let address = random_address(network, *kind); + let test_instance = AddressTest { address: address.clone() }; + let json = serde_json::to_string(&test_instance).unwrap(); + let parsed: AddressTest = serde_json::from_str(&json).unwrap(); + assert_eq!(address, parsed.address); + } + } } } diff --git a/crates/state-chain/src/cbft.rs b/crates/state-chain/src/cbft.rs index 6428abe3..37f9a915 100644 --- a/crates/state-chain/src/cbft.rs +++ b/crates/state-chain/src/cbft.rs @@ -109,13 +109,6 @@ pub fn verify_sequencer_set(light_block_1: LightBlock, light_block_2: LightBlock &opt, verify_time.unwrap(), ); - println!("cycle-tracker-end: verify"); - - // println!("cycle-tracker-start: public inputs verdict"); - // let verdict_encoded = serde_cbor::to_vec(&verdict).unwrap(); - // zkm_zkvm::io::commit_slice(verdict_encoded.as_slice()); - // println!("cycle-tracker-end: public inputs verdict"); - match verdict { Verdict::Success => { println!("success"); diff --git a/crates/store/src/schema.rs b/crates/store/src/schema.rs index 3a9542f9..5be4d6e7 100644 --- a/crates/store/src/schema.rs +++ b/crates/store/src/schema.rs @@ -519,6 +519,7 @@ pub enum MessageType { SyncGraphRequest, SyncGraph, InstanceDiscarded, + Tick, } #[derive(Clone, Debug, Serialize, Deserialize, Default, Display, EnumString)] diff --git a/node/src/action.rs b/node/src/action.rs index 52f5da18..1521e8c1 100644 --- a/node/src/action.rs +++ b/node/src/action.rs @@ -38,13 +38,13 @@ use store::{GraphStatus, MessageState}; use tracing::warn; use uuid::Uuid; -#[derive(Debug, Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Clone)] pub struct GOATMessage { pub actor: Actor, - pub content: Vec, + pub content: GOATMessageContent, } -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Clone)] pub enum GOATMessageContent { PeginRequest(PeginRequest), CreateGraph(CreateGraph), @@ -79,6 +79,7 @@ pub enum GOATMessageContent { SyncGraphRequest(SyncGraphRequest), SyncGraph(SyncGraph), InstanceDiscarded(InstanceDiscarded), + Tick, } /// Pegin @@ -288,18 +289,27 @@ pub struct InstanceDiscarded { } impl GOATMessage { - pub fn from_typed(actor: Actor, value: &T) -> Result { - let content = serde_json::to_vec(value)?; - Ok(Self { actor, content }) + pub fn new(actor: Actor, content: GOATMessageContent) -> Self { + Self { actor, content } } - pub fn to_typed Deserialize<'de>>(&self) -> Result { - serde_json::from_slice(&self.content) + pub fn content(&self) -> &GOATMessageContent { + &self.content } pub fn default_message_id() -> MessageId { MessageId(b"__inner_message_id__".to_vec()) } + + pub async fn serialize_message(&self) -> Result> { + let cloned = self.clone(); + Ok(tokio::task::spawn_blocking(move || serde_json::to_vec(&cloned)).await??) + } + + pub async fn deserialize_message(message: &[u8]) -> Result { + let cloned = message.to_vec(); + Ok(tokio::task::spawn_blocking(move || serde_json::from_slice(&cloned)).await??) + } } #[allow(clippy::too_many_arguments)] pub async fn handle_self_p2p_msg( @@ -318,11 +328,10 @@ pub async fn handle_self_p2p_msg( tracing::warn!("handle_self_p2p_msg received unexpected message id: {:?}", id); return Ok(()); } - let message: GOATMessage = serde_json::from_slice(message)?; + let message = GOATMessage::deserialize_message(message).await?; tracing::info!( - "Got self p2p message: {}:{} with id: {} from peer: {:?}", + "Got self p2p message: {} with id: {} from peer: {:?}", &message.actor.to_string(), - String::from_utf8_lossy(&message.content), id, from_peer_id ); @@ -398,8 +407,9 @@ pub async fn recv_and_dispatch( // Determine whether the message comes from this node itself to optionally skip validations let is_self_peer = get_local_node_info().peer_id == from_peer_id.to_string(); - let message: GOATMessage = serde_json::from_slice(message)?; - let content: GOATMessageContent = message.to_typed()?; + let message = GOATMessage::deserialize_message(message).await?; + // FIXME: don't clone + let content: GOATMessageContent = message.content().clone(); match (content, actor) { ( GOATMessageContent::PeginRequest(PeginRequest { @@ -518,7 +528,8 @@ pub async fn recv_and_dispatch( graph_nonce: graph.parameters.graph_nonce, graph, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + let msg = GOATMessage::new(Actor::All, message_content); + send_to_peer(swarm, msg).await?; return Ok(()); } // 1. read & check parameters @@ -585,7 +596,7 @@ pub async fn recv_and_dispatch( graph_nonce, graph: graph.to_simplified()?, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } (GOATMessageContent::ConfirmInstance(ConfirmInstance { instance_id }), _) => { // triggered by PeginDeposit tx @@ -663,7 +674,7 @@ pub async fn recv_and_dispatch( pub_nonces: pub_nonces.clone(), nonce_sigs, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; store_committee_pub_nonces_for_graph( local_db, instance_id, @@ -709,7 +720,7 @@ pub async fn recv_and_dispatch( committee_partial_sigs, agg_nonces, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } } ( @@ -838,7 +849,7 @@ pub async fn recv_and_dispatch( committee_partial_sigs: committee_partial_sigs.clone(), agg_nonces, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; store_committee_partial_sigs_for_graph( local_db, instance_id, @@ -866,7 +877,7 @@ pub async fn recv_and_dispatch( committee_sig_for_graph: committee_sig_for_graph.as_bytes().to_vec(), committee_evm_address, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } } } @@ -1068,7 +1079,7 @@ pub async fn recv_and_dispatch( committee_sig_for_graph: committee_sig_for_graph.as_bytes().to_vec(), committee_evm_address, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } } ( @@ -1296,10 +1307,8 @@ pub async fn recv_and_dispatch( pub_nonce: pub_nonce.clone(), nonce_sig, }); - send_to_peer( - swarm, - GOATMessage::from_typed(Actor::Committee, &message_content)?, - )?; + send_to_peer(swarm, GOATMessage::new(Actor::Committee, message_content)) + .await?; store_committee_pub_nonce_for_instance( local_db, instance_id, @@ -1461,7 +1470,7 @@ pub async fn recv_and_dispatch( partial_sig, endorse_sig: endorse_sig.as_bytes().to_vec(), }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::Committee, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::Committee, message_content)).await?; store_committee_partial_sig_for_instance( local_db, instance_id, @@ -3950,8 +3959,8 @@ pub async fn recv_and_dispatch( if let Some(graph) = get_graph(local_db, instance_id, graph_id).await? { let message_content = GOATMessageContent::SyncGraph(SyncGraph { instance_id, graph_id, graph }); - let message = GOATMessage::from_typed(Actor::All, &message_content)?; - send_to_peer(swarm, message)?; + let message = GOATMessage::new(Actor::All, message_content); + send_to_peer(swarm, message).await?; } else { // TODO: if no relayer has the graph, how to recover? tracing::warn!("Graph not found for SyncGraphRequest {instance_id}:{graph_id}"); @@ -3998,7 +4007,7 @@ pub async fn recv_and_dispatch( (GOATMessageContent::RequestNodeInfo(node_info), _) => { save_node_info(local_db, &node_info).await?; let message_content = GOATMessageContent::ResponseNodeInfo(get_local_node_info()); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } (GOATMessageContent::ResponseNodeInfo(node_info), _) => { @@ -4052,17 +4061,23 @@ pub async fn try_finalize_graph( endorse_sigs: endorsements, graph: simplified_graph, }); - send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?)?; + send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await?; } } Ok(()) } -pub fn send_to_peer(swarm: &mut Swarm, message: GOATMessage) -> Result { +pub async fn send_to_peer( + swarm: &mut Swarm, + message: GOATMessage, +) -> Result { let actor = message.actor.to_string(); let topic = crate::middleware::get_topic_name(&actor); let gossipsub_topic = gossipsub::IdentTopic::new(topic); - Ok(swarm.behaviour_mut().gossipsub.publish(gossipsub_topic, serde_json::to_vec(&message)?)?) + Ok(swarm + .behaviour_mut() + .gossipsub + .publish(gossipsub_topic, message.serialize_message().await?)?) } pub async fn push_local_unhandled_messages( @@ -4073,7 +4088,7 @@ pub async fn push_local_unhandled_messages( ) -> Result<()> { let mut storage_processor = local_db.acquire().await?; let actor = message.actor.clone(); - let content: GOATMessageContent = message.to_typed()?; + let content: GOATMessageContent = message.content().clone(); upsert_message( &mut storage_processor, true, @@ -4131,7 +4146,7 @@ pub async fn try_send_sync_graph_request( validate_graph_id_on_goat(goat_client, instance_id, graph_id).await?; let message_content = GOATMessageContent::SyncGraphRequest(SyncGraphRequest { instance_id, graph_id }); - let message = GOATMessage::from_typed(Actor::All, &message_content)?; - send_to_peer(swarm, message)?; + let message = GOATMessage::new(Actor::All, message_content); + send_to_peer(swarm, message).await?; Ok(()) } diff --git a/node/src/bin/db_inject.rs b/node/src/bin/db_inject.rs index ca2f1ffa..9dbc34e2 100644 --- a/node/src/bin/db_inject.rs +++ b/node/src/bin/db_inject.rs @@ -95,6 +95,7 @@ fn infer_business_id(content: &GOATMessageContent) -> Option { v.graph_infos.first().map(|(graph_id, _, _)| *graph_id) } GOATMessageContent::RequestNodeInfo(_) | GOATMessageContent::ResponseNodeInfo(_) => None, + GOATMessageContent::Tick => None, } } diff --git a/node/src/lib.rs b/node/src/lib.rs index f05430c8..7879ac57 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -11,3 +11,187 @@ pub use scheduled_tasks::{run_maintenance_tasks, run_watch_event_task}; mod error; mod vk; + +mod dbg { + #![allow(unused)] + use core::panic; + use std::str::FromStr; + + use crate::action::*; + use crate::utils::*; + use bitcoin::{Address, Amount, Network, Witness}; + use bitvm2_lib::actors::Actor; + use bitvm2_lib::committee::*; + use bitvm2_lib::keys::*; + use bitvm2_lib::operator::*; + use bitvm2_lib::types::*; + use goat::connectors::connector_e::ConnectorE; + use goat::connectors::kickoff_connectors::*; + use goat::contexts::base::generate_n_of_n_public_key; + use goat::disprove_scripts::hash160; + use goat::scripts::p2a_script; + use goat::transactions::base::Input; + use goat::transactions::prekickoff::PrekickoffTransaction; + use secp256k1::{Keypair, Secp256k1, SecretKey, rand}; + use serde::Deserialize; + use serde::Serialize; + use uuid::Uuid; + use zkm_sdk::ZKM_CIRCUIT_VERSION; + + fn dbg_network() -> Network { + Network::Testnet4 + } + fn dbg_keypair() -> Keypair { + let secp = Secp256k1::new(); + Keypair::new(&secp, &mut rand::thread_rng()) + } + fn dbg_input() -> Input { + Input { + outpoint: bitcoin::OutPoint { + txid: bitcoin::Txid::from_str( + "b2b18acfdd358369d9a1e8370cfd9eb4ee123507a0321ad608de500cc54740d8", + ) + .unwrap(), + vout: 0, + }, + amount: Amount::from_sat(500000000), + } + } + fn dbg_address() -> Address { + node_p2wsh_address(dbg_network(), &dbg_keypair().public_key().into()) + } + fn build_dbg_instance_parameters() -> Bitvm2InstanceParameters { + let user_info = UserInfo { + depositor_evm_address: [1u8; 20], + txn_fees: [1000u64; 3], + inputs: vec![dbg_input()], + user_xonly_pubkey: dbg_keypair().public_key().x_only_public_key().0, + user_change_address: dbg_address(), + user_refund_address: dbg_address(), + }; + let committee_pubkeys = + vec![dbg_keypair().public_key().into(), dbg_keypair().public_key().into()]; + let committee_agg_pubkey = generate_n_of_n_public_key(&committee_pubkeys).0; + Bitvm2InstanceParameters { + network: dbg_network(), + instance_id: Uuid::new_v4(), + user_info, + pegin_amount: Amount::from_sat(1000000), + committee_pubkeys, + committee_agg_pubkey, + } + } + fn build_dbg_prekickoff_parameters() -> PrekickoffParameters { + let xonly_pubkey = dbg_keypair().public_key().x_only_public_key().0; + let force_skip_connector = ForceSkipConnector::new(dbg_network(), &xonly_pubkey); + let kickoff_connector = KickoffConnector::new(dbg_network(), &xonly_pubkey); + let prekickoff_connector = PrekickoffConnector::new(dbg_network(), &xonly_pubkey); + let cur_prekickoff_txn = PrekickoffTransaction::new_for_validation( + &prekickoff_connector, + &force_skip_connector, + &kickoff_connector, + &prekickoff_connector, + dbg_input(), + vec![], + vec![], + 1000, + 2, + 50, + ) + .unwrap(); + PrekickoffParameters { + cur_prekickoff_txn, + replenish_fee_inputs: vec![], + replenish_fee_prev_outs: vec![], + fee_amount: 1000, + } + } + fn build_dbg_graph_parameters() -> Bitvm2GraphParameters { + let graph_id = Uuid::new_v4(); + let instance_parameters = build_dbg_instance_parameters(); + let prekickoff_parameters = build_dbg_prekickoff_parameters(); + let operator_master_key = OperatorMasterKey::new(dbg_keypair()); + let operator_master_keypair = operator_master_key.master_keypair(); + let operator_pubkey = operator_master_keypair.public_key().into(); + let operator_wots_pubkeys = operator_master_key.wots_keypair_for_graph(graph_id).1; + let watchtower_pubkeys = vec![ + dbg_keypair().public_key().x_only_public_key().0, + dbg_keypair().public_key().x_only_public_key().0, + ]; + let mut hashlocks = vec![]; + for index in 0..watchtower_pubkeys.len() { + let preimage = b"preimage".to_vec(); + let hashlock = hash160(&preimage); + hashlocks.push(hashlock); + } + let instance_id = instance_parameters.instance_id; + Bitvm2GraphParameters { + instance_parameters, + prekickoff_parameters, + graph_id, + graph_nonce: 1, + challenge_amount: todo_funcs::challenge_amount(), + operator_pubkey, + operator_wots_pubkeys, + operator_receive_address: dbg_address(), + watchtower_pubkeys, + hashlocks, + guest_constant_value: [3u8; 32], + zkm_version: ZKM_CIRCUIT_VERSION.to_string(), + } + } + fn build_dbg_simplified_graph() -> SimplifiedBitvm2Graph { + let disprove_scripts = vec![p2a_script()]; + let graph = generate_bitvm_graph(build_dbg_graph_parameters(), disprove_scripts).unwrap(); + graph.to_simplified().unwrap() + } + + #[tokio::test] + async fn dbg_serde() { + let graph: SimplifiedBitvm2Graph = build_dbg_simplified_graph(); + let message_content = GOATMessageContent::CreateGraph(CreateGraph { + instance_id: graph.parameters.instance_parameters.instance_id, + graph_id: graph.parameters.graph_id, + graph_nonce: graph.parameters.graph_nonce, + graph: graph.clone(), + }); + let msg = GOATMessage::new(Actor::All, message_content); + let msg_se = msg.serialize_message().await.unwrap(); + let msg_de = GOATMessage::deserialize_message(&msg_se).await.unwrap(); + // check graph id + assert_eq!( + graph.parameters.graph_id, + match msg_de.content { + GOATMessageContent::CreateGraph(ref cg) => cg.graph_id, + _ => Uuid::nil(), + } + ); + } + + #[tokio::test] + #[ignore = "requires local db"] + async fn dbg_serde_from_db() { + let dbg_path = "/home/ubuntu/bitvm2-noded-test/operator_0/bitvm2-node.db"; + let instance_id = uuid::Uuid::parse_str("A4DB2DD03EEA43FB9601D60236EBAD90").unwrap(); + let graph_id = uuid::Uuid::parse_str("044285C328EE4D2EAE06718659EFDC34").unwrap(); + let local_db = store::create_local_db(dbg_path).await; + let graph = get_graph(&local_db, instance_id, graph_id).await.unwrap().unwrap(); + let message_content = GOATMessageContent::CreateGraph(CreateGraph { + instance_id: graph.parameters.instance_parameters.instance_id, + graph_id: graph.parameters.graph_id, + graph_nonce: graph.parameters.graph_nonce, + graph, + }); + let msg = GOATMessage::new(Actor::All, message_content); + let msg_se = msg.serialize_message().await.unwrap(); + let msg_de = GOATMessage::deserialize_message(&msg_se).await.unwrap(); + // check graph id + assert_eq!( + graph_id, + match msg_de.content { + GOATMessageContent::CreateGraph(ref cg) => cg.graph_id, + _ => Uuid::nil(), + } + ); + } +} diff --git a/node/src/p2p_msg_handler.rs b/node/src/p2p_msg_handler.rs index 41b46fc6..86feec02 100644 --- a/node/src/p2p_msg_handler.rs +++ b/node/src/p2p_msg_handler.rs @@ -63,10 +63,10 @@ impl P2pMessageHandler for BitvmNodeProcessor { } TickMessageType::RegularlyAction => { tracing::debug!("Handling regular action tick message"); - let tick_data = serde_json::to_vec(&GOATMessage { - actor: actor.clone(), - content: "tick".as_bytes().to_vec(), - })?; + let tick_data = + GOATMessage { actor: actor.clone(), content: GOATMessageContent::Tick } + .serialize_message() + .await?; handle_self_p2p_msg( swarm, @@ -93,7 +93,7 @@ impl P2pMessageHandler for BitvmNodeProcessor { ) -> anyhow::Result<()> { if topic == Actor::All.to_string() { let message_content = GOATMessageContent::RequestNodeInfo(get_local_node_info()); - match send_to_peer(swarm, GOATMessage::from_typed(Actor::All, &message_content)?) { + match send_to_peer(swarm, GOATMessage::new(Actor::All, message_content)).await { Ok(_) => {} Err(e) => { println!("finish_subscribe_topic: send request NodeInfo {e}"); @@ -193,7 +193,7 @@ mod tests { // send to actor let actors = get_rpc_support_actors(); for actor in actors { - match send_to_peer(swarm, GOATMessage::from_typed(actor, &message_content)?) { + match send_to_peer(swarm, GOATMessage::new(actor, message_content.clone())).await { Ok(_) => {} Err(err) => warn!("{err}"), } @@ -214,10 +214,10 @@ mod tests { tracing::info!("recv_and_dispatch receive local message"); return Ok(()); } - let message: GOATMessage = serde_json::from_slice(message)?; - let content: GOATMessageContent = message.to_typed()?; + let message = GOATMessage::deserialize_message(message).await?; + let content: &GOATMessageContent = message.content(); if let (GOATMessageContent::RequestNodeInfo(node_info), _) = (content, actor) { - save_node_info(&self.local_db, &node_info).await.expect("save_node_info"); + save_node_info(&self.local_db, node_info).await.expect("save_node_info"); } Ok(()) } diff --git a/node/src/scheduled_tasks/mod.rs b/node/src/scheduled_tasks/mod.rs index 1fd2cb88..162aae2b 100644 --- a/node/src/scheduled_tasks/mod.rs +++ b/node/src/scheduled_tasks/mod.rs @@ -179,6 +179,7 @@ pub fn get_goat_message_content_type(content: &GOATMessageContent) -> MessageTyp GOATMessageContent::SyncGraphRequest(_) => MessageType::SyncGraphRequest, GOATMessageContent::SyncGraph(_) => MessageType::SyncGraph, GOATMessageContent::InstanceDiscarded(_) => MessageType::InstanceDiscarded, + GOATMessageContent::Tick => MessageType::Tick, } } diff --git a/node/src/utils.rs b/node/src/utils.rs index cb29fa29..41bf7de7 100644 --- a/node/src/utils.rs +++ b/node/src/utils.rs @@ -1181,18 +1181,18 @@ pub(crate) async fn compensate_graph_events( GraphCompensateEventKind::PreKickoffSent => { let prekickoff_sent = PreKickoffSent(crate::action::PreKickoffSent { instance_id, graph_id }); - let message = GOATMessage::from_typed(Actor::All, &prekickoff_sent)?; + let message = GOATMessage::new(Actor::All, prekickoff_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } GraphCompensateEventKind::KickoffSent => { let kickoff_sent = KickoffSent(crate::action::KickoffSent { instance_id, graph_id }); - let message = GOATMessage::from_typed(Actor::All, &kickoff_sent)?; + let message = GOATMessage::new(Actor::All, kickoff_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } GraphCompensateEventKind::Take1Sent => { let take1_sent = Take1Sent(crate::action::Take1Sent { instance_id, graph_id }); - let message = GOATMessage::from_typed(Actor::All, &take1_sent)?; + let message = GOATMessage::new(Actor::All, take1_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } GraphCompensateEventKind::ChallengeSent => { @@ -1218,7 +1218,7 @@ pub(crate) async fn compensate_graph_events( graph_id, challenge_txid, }); - let message = GOATMessage::from_typed(Actor::All, &challenge_sent)?; + let message = GOATMessage::new(Actor::All, challenge_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } } @@ -1343,12 +1343,12 @@ pub(crate) async fn compensate_graph_events( challenge_start_txid, challenge_finish_txid, }); - let message = GOATMessage::from_typed(Actor::All, &disprove_sent)?; + let message = GOATMessage::new(Actor::All, disprove_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } GraphCompensateEventKind::Take2Sent => { let take2_sent = Take2Sent(crate::action::Take2Sent { instance_id, graph_id }); - let message = GOATMessage::from_typed(Actor::All, &take2_sent)?; + let message = GOATMessage::new(Actor::All, take2_sent); push_local_unhandled_messages(local_db, graph_id, &message, 0).await?; } } @@ -3143,7 +3143,7 @@ pub async fn upsert_message( weight: i64, lock_time: i64, ) -> Result<()> { - let message = GOATMessage::from_typed(actor.clone(), &message_content)?; + let message = GOATMessage::new(actor.clone(), message_content.clone()); let msg_type = get_goat_message_content_type(&message_content); let message_id = generate_message_id(business_id, msg_type.to_string().clone(), sub_type); if is_update || storage_processor.find_messages_by_id(&message_id).await?.is_none() { @@ -3164,7 +3164,7 @@ pub async fn upsert_message( actor: actor.to_string(), from_peer, msg_type: msg_type.to_string(), - content: serde_json::to_vec(&message)?, + content: message.serialize_message().await?, weight, lock_time_until: current_time_secs() + lock_time, state: MessageState::Pending.to_string(), @@ -3450,7 +3450,7 @@ pub async fn detect_heart_beat(swarm: &mut Swarm) -> Result<()> { // send to actor let actors = get_rpc_support_actors(); for actor in actors { - match send_to_peer(swarm, GOATMessage::from_typed(actor, &message_content)?) { + match send_to_peer(swarm, GOATMessage::new(actor, message_content.clone())).await { Ok(_) => {} Err(err) => warn!("{err}"), }