diff --git a/Cargo.lock b/Cargo.lock index 85587a8..1094403 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -701,12 +701,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" -[[package]] -name = "bytemuck" -version = "1.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" - [[package]] name = "byteorder" version = "1.5.0" @@ -2879,15 +2873,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -5196,20 +5181,19 @@ dependencies = [ [[package]] name = "sp1-core" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "anyhow", "arrayref", "bincode", "blake3", - "bytemuck", "cfg-if", "curve25519-dalek", "elf", "elliptic-curve", "generic-array 1.0.0", "hex", - "itertools 0.13.0", + "itertools 0.12.1", "k256", "log", "nohash-hasher", @@ -5233,7 +5217,6 @@ dependencies = [ "p3-symmetric", "p3-uni-stark", "p3-util", - "rand", "rayon-scan", "rrs-lib", "serde", @@ -5256,7 +5239,7 @@ dependencies = [ [[package]] name = "sp1-derive" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "proc-macro2", "quote", @@ -5330,7 +5313,7 @@ dependencies = [ [[package]] name = "sp1-precompiles" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "anyhow", "bincode", @@ -5347,9 +5330,9 @@ dependencies = [ [[package]] name = "sp1-primitives" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ - "itertools 0.13.0", + "itertools 0.12.1", "lazy_static", "p3-baby-bear", "p3-field", @@ -5360,26 +5343,23 @@ dependencies = [ [[package]] name = "sp1-prover" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "anyhow", "backtrace", "bincode", - "bytemuck", "clap", "dirs", "futures", "hex", "indicatif", - "itertools 0.13.0", + "itertools 0.12.1", "num-bigint 0.4.5", "p3-baby-bear", "p3-bn254-fr", "p3-challenger", "p3-commit", "p3-field", - "p3-util", - "rand", "rayon", "reqwest 0.12.5", "serde", @@ -5405,10 +5385,10 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "bincode", - "itertools 0.13.0", + "itertools 0.12.1", "p3-air", "p3-baby-bear", "p3-bn254-fr", @@ -5428,10 +5408,10 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "backtrace", - "itertools 0.13.0", + "itertools 0.12.1", "p3-air", "p3-baby-bear", "p3-bn254-fr", @@ -5452,13 +5432,13 @@ dependencies = [ [[package]] name = "sp1-recursion-core" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "arrayref", "backtrace", "ff 0.13.0", "hashbrown 0.14.5", - "itertools 0.13.0", + "itertools 0.12.1", "p3-air", "p3-baby-bear", "p3-bn254-fr", @@ -5472,7 +5452,6 @@ dependencies = [ "p3-merkle-tree", "p3-poseidon2", "p3-symmetric", - "p3-util", "serde", "serde_with", "sp1-core", @@ -5486,7 +5465,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "proc-macro2", "quote", @@ -5496,24 +5475,18 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ - "anyhow", - "bincode", "bindgen", "cc", "cfg-if", - "hex", "log", "num-bigint 0.4.5", "p3-baby-bear", "p3-field", - "p3-symmetric", "rand", "serde", "serde_json", - "sha2 0.10.8", - "sp1-core", "sp1-recursion-compiler", "tempfile", ] @@ -5521,9 +5494,9 @@ dependencies = [ [[package]] name = "sp1-recursion-program" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ - "itertools 0.13.0", + "itertools 0.12.1", "p3-air", "p3-baby-bear", "p3-challenger", @@ -5548,7 +5521,7 @@ dependencies = [ [[package]] name = "sp1-sdk" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "alloy-sol-types", "anyhow", @@ -5577,7 +5550,6 @@ dependencies = [ "strum", "strum_macros", "tempfile", - "thiserror", "tokio", "tracing", "twirp", @@ -5587,13 +5559,12 @@ dependencies = [ [[package]] name = "sp1-zkvm" version = "0.1.0" -source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.7-testnet#b35be4200e7369bd987d8ba101f70dd7dec3df1a" +source = "git+https://github.com/succinctlabs/sp1.git?tag=v1.0.5-testnet#19ef89a4b8a509b7d765c46ff6e0a1c9a8fcbfb4" dependencies = [ "bincode", "cfg-if", "getrandom", "k256", - "lazy_static", "libm", "once_cell", "rand", diff --git a/Cargo.toml b/Cargo.toml index 873e141..cfcc68a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ authors = ["srdtrk "] [workspace.dependencies] # Used by the programs -sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.7-testnet" } -sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.7-testnet" } +sp1-zkvm = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.5-testnet" } +sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.5-testnet" } sp1-ics07-tendermint-shared = { path = "./packages/shared/" } sp1-ics07-tendermint-update-client = { path = "./programs/update-client/" } @@ -37,7 +37,7 @@ serde_cbor = "0.11.2" serde_json = { version = "1.0", default-features = false, features = ["alloc"] } # Used by the operator -sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.7-testnet" } +sp1-sdk = { git = "https://github.com/succinctlabs/sp1.git", tag = "v1.0.5-testnet", features = ["plonk"] } reqwest = { version = "0.11", features = ["json"] } tokio = { version = "1", features = ["full"] } tendermint = { version = "0.36.0", default-features = false } diff --git a/contracts/fixtures/fixture.json b/contracts/fixtures/fixture.json new file mode 100644 index 000000000..64b710e --- /dev/null +++ b/contracts/fixtures/fixture.json @@ -0,0 +1,9 @@ +{ + "trustedClientState": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c200000000000000000000000000000000000000000000000000044c1ff252000000000000000000000000000000000000000000000000000000044c1ff2520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000", + "trustedConsensusState": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000017db9605c70f5a75000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf0000000000000000000000000000000000000000000000000000000000000020b73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419", + "targetConsensusState": "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000017db962167923e1a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002092a23d699a0d59f2e1b034c129b0051fb711a3d0d1f2e895fce82e933b8e36fd0000000000000000000000000000000000000000000000000000000000000020b73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419", + "targetHeight": 2110668, + "vkey": "0x004ac9cd92d0a05a01903f9f62b3c271ba861e2cd6b615c4c081394cbaf123f3", + "publicValues": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034cc00000000000000000000000000000000000000000000000017db9605c70f5a75000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf0000000000000000000000000000000000000000000000000000000000000020b73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c41900000000000000000000000000000000000000000000000017db962167923e1a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000002092a23d699a0d59f2e1b034c129b0051fb711a3d0d1f2e895fce82e933b8e36fd0000000000000000000000000000000000000000000000000000000000000020b73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c41900000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000044c1ff252000000000000000000000000000000000000000000000000000017dbb9d861d9c38000000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000", + "proof": "0x28192d1ec8d20562142ae5ed4b621a04cf6871187db21b0991e4732d470d7b5a17e6b1c037a5e75fc275e8bae644060d82c70050b6c695bbc4efe534db3f99c62c37e3e49930156a62b2743c054c463a789181b3ade6be54b8108e2afaebc1900f30a937736a0566bda5e72e11ede01e5a9f4cc54e45deb12b5a913415df51c30d5b991991f73942bb25c07444eabf989fe86dcf09874ff7c168a6a52a5d7cf52e46af4a99e227fec9990646781353e3c35a2b6303db59f2dd6c89c6e8b7f61a1e1a5bb75660dd8a914abb6ab7fa24f6ece69b87738b39066a720617707515892dbe014e002a1b859eef8de16ec36b2adfe95d44598853412f9f8c15e6574c732902911a34c720778d381fde493150f3582e412832bc5dfd7c9769a47c6f7c310ecaccac1d8701e743aecff4f8954bda594dc60cd124491bad0b5422abe5f8c60d19b48760f8d8a4243af71ea83c67b56a0c77aa559ff686c493d55a21c83ebb25aba42a65fa9eebde9c6b23b65870cdb0f0b6ed5162042f2f76ff7c63b617861c32723bff3020c91a5a0215d7cc43c59b151909075ddc78ec46895df1c9068f1bb77a4feae837abbbf959af7348b003cd2acbb825cbaf0c1e58db57bb454ddf186666c0a1459c4a578558d46e9b02cb541b173e96e7225e1e91b80c203203001831d51c0423869cefb63f2b346df6b138bd747b1335f48d6e0fe46d6683eda110aa73735e712cc3a921134713d07f839dbd582c2b3174bcc6d2b5b6926447ca190ed214ed8fa55fffb6b850bc6b3eeaa60790c84cfaaf6d31300ed796302e6c2d42eb241dac89b1723e736da9f8c4d897c2da6c2f3b76eda7faf94d4e930d8f1e3ebb0d58ca7c0164e82a7e86724f4a12b6051a5c51d9974d3f1756d1674bd91a1a9c8d5eea30c21cfef32aba24fb9ceb9b2f543871a5855c1c7b7deeed1aac013a6be382d092b3ba9645659e1f9c8d4953e50628a55d6552183a703fca9b330f41c0ce092b8305eea6516531dd98749945178fa5fb0dabe5e6f26a4e7d0a112238b8154ad17fca7edab2c51275d5a0d06496266811912cf9b0fdc2cc14d37924dfc2a17ea46cee7f66cce4883490c7c0abcd51ae339264faf39600bfb256c926620ea8e3d6b8f3babe6ebaee3cc0d48dbbffaf9798ddffdc78cfaa7f07969f141fb667d4790be0b9ef1f503a90c41610f0cc3a6913c69049aa5ab69466dec4" +} \ No newline at end of file diff --git a/contracts/test/SP1ICS07Tendermint.t.sol b/contracts/test/SP1ICS07Tendermint.t.sol index 3ba0e92..36255ab 100644 --- a/contracts/test/SP1ICS07Tendermint.t.sol +++ b/contracts/test/SP1ICS07Tendermint.t.sol @@ -23,13 +23,13 @@ struct SP1ICS07TendermintFixtureJson { contract SP1ICS07TendermintTest is Test { using stdJson for string; - // TODO: Test non-mock ics07Tendermint, once we have a way to generate the fixture. - // SP1ICS07Tendermint public ics07Tendermint; + SP1ICS07Tendermint public ics07Tendermint; SP1ICS07Tendermint public mockIcs07Tendermint; function setUp() public { - /* - SP1TendermintFixtureJson memory fixture = loadFixture("fixture.json"); + SP1ICS07TendermintFixtureJson memory fixture = loadFixture( + "fixture.json" + ); SP1Verifier verifier = new SP1Verifier(); ics07Tendermint = new SP1ICS07Tendermint( fixture.vkey, @@ -37,7 +37,6 @@ contract SP1ICS07TendermintTest is Test { fixture.trustedClientState, fixture.trustedConsensusState ); - */ SP1ICS07TendermintFixtureJson memory mockFixture = loadFixture( "mock_fixture.json" @@ -111,6 +110,46 @@ contract SP1ICS07TendermintTest is Test { return fixture; } + // Confirm that submitting a real proof passes the verifier. + function test_ValidSP1ICS07Tendermint() public { + SP1ICS07TendermintFixtureJson memory fixture = loadFixture( + "fixture.json" + ); + + ics07Tendermint.verifyIcs07UpdateClientProof( + fixture.proof, + fixture.publicValues + ); + + ( + string memory chain_id, + ICS07Tendermint.TrustThreshold memory trust_level, + ICS07Tendermint.Height memory latest_height, + uint64 trusting_period, + uint64 unbonding_period, + bool is_frozen + ) = ics07Tendermint.clientState(); + + assert(keccak256(bytes(chain_id)) == keccak256(bytes("mocha-4"))); + assert(trust_level.numerator == 1); + assert(trust_level.denominator == 3); + assert(latest_height.revision_number == 4); + assert(latest_height.revision_height == 2110668); + assert(trusting_period == 1_209_600_000_000_000); + assert(unbonding_period == 1_209_600_000_000_000); + assert(is_frozen == false); + + ( + uint64 timestamp, + bytes memory root, + bytes memory next_validators_hash + ) = ics07Tendermint.consensusStates(2110668); + + assert(timestamp > 0); + assert(root.length > 0); + assert(next_validators_hash.length > 0); + } + // Confirm that submitting an empty proof passes the mock verifier. function test_ValidMockTendermint() public { SP1ICS07TendermintFixtureJson memory fixture = loadFixture( @@ -151,8 +190,7 @@ contract SP1ICS07TendermintTest is Test { assert(next_validators_hash.length > 0); } - // Confirm that submitting a non-empty proof with the mock verifier fails. This typically - // indicates that the user has passed in a real proof to the mock verifier. + // Confirm that submitting a non-empty proof with the mock verifier fails. function test_Invalid_MockTendermint() public { SP1ICS07TendermintFixtureJson memory fixture = loadFixture( "mock_fixture.json" @@ -160,7 +198,20 @@ contract SP1ICS07TendermintTest is Test { vm.expectRevert(); mockIcs07Tendermint.verifyIcs07UpdateClientProof( - bytes("aa"), + bytes("invalid"), + fixture.publicValues + ); + } + + // Confirm that submitting a random proof with the real verifier fails. + function test_Invalid_SP1ICS07Tendermint() public { + SP1ICS07TendermintFixtureJson memory fixture = loadFixture( + "fixture.json" + ); + + vm.expectRevert(); + ics07Tendermint.verifyIcs07UpdateClientProof( + bytes("invalid"), fixture.publicValues ); } diff --git a/elf/riscv32im-succinct-zkvm-elf b/elf/riscv32im-succinct-zkvm-elf index 590ed89..5c7bb23 100755 Binary files a/elf/riscv32im-succinct-zkvm-elf and b/elf/riscv32im-succinct-zkvm-elf differ diff --git a/justfile b/justfile index d1700f4..856a504 100644 --- a/justfile +++ b/justfile @@ -2,3 +2,7 @@ build-program: cd programs/update-client && cargo prove build @echo "ELF created at 'program/elf/riscv32im-succinct-zkvm-elf'" + +# Run the Solidity tests using `forge test` command +test-foundry: + cd contracts && forge test -vvv