Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
imp: aggregated membership proofs (#54)
Browse files Browse the repository at this point in the history
* imp: updated contract defs

* imp: regenerated abi

* imp: updated program and operator

* fix

* deps: removed itertools

* imp: efficiency

* imps

* imp fixtures

* refactor

* more refactors

* rename

* imp tests

* tests passing

* test comment

* test: changed log
  • Loading branch information
srdtrk authored Jul 7, 2024
1 parent c4a17cc commit 5f4dd67
Show file tree
Hide file tree
Showing 34 changed files with 646 additions and 658 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ alloy-contract = "0.1.2"
alloy-node-bindings = "0.1.2"
alloy = "0.1.2"
bincode = "1.3.3"
itertools = "0.12.1"
dotenv = "0.15.0"
subtle-encoding = "0.5.1"
anyhow = "1.0.82"
Expand All @@ -64,6 +63,7 @@ log = "0.4.21"
async-trait = "0.1.80"
hex = "0.4.3"
prost = { version = "0.12", default-features = false }
futures = "0.3"

[patch.crates-io]
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-v0.10.8" }
Expand Down
103 changes: 22 additions & 81 deletions contracts/abi/SP1ICS07Tendermint.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,21 @@
"internalType": "bytes32"
},
{
"name": "key_path",
"type": "string",
"internalType": "string"
},
{
"name": "value",
"type": "bytes",
"internalType": "bytes"
"name": "kv_pairs",
"type": "tuple[]",
"internalType": "struct MembershipProgram.KVPair[]",
"components": [
{
"name": "key",
"type": "string",
"internalType": "string"
},
{
"name": "value",
"type": "bytes",
"internalType": "bytes"
}
]
}
]
},
Expand All @@ -192,37 +199,9 @@
"name": "trustedConsensusStateBz",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "keyPath",
"type": "string",
"internalType": "string"
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct ICS07Tendermint.ConsensusState",
"components": [
{
"name": "timestamp",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "root",
"type": "bytes32",
"internalType": "bytes32"
},
{
"name": "next_validators_hash",
"type": "bytes32",
"internalType": "bytes32"
}
]
}
],
"outputs": [],
"stateMutability": "view"
},
{
Expand Down Expand Up @@ -372,25 +351,7 @@
},
{
"type": "function",
"name": "verifyIcs07UpdateClientProof",
"inputs": [
{
"name": "proof",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "publicValues",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "verifyIcs07VerifyMembershipProof",
"name": "verifyIcs07MembershipProof",
"inputs": [
{
"name": "proof",
Expand All @@ -413,22 +374,17 @@
"internalType": "bytes"
},
{
"name": "keyPath",
"type": "string",
"internalType": "string"
},
{
"name": "value",
"type": "bytes",
"internalType": "bytes"
"name": "kvPairHashes",
"type": "bytes32[]",
"internalType": "bytes32[]"
}
],
"outputs": [],
"stateMutability": "view"
},
{
"type": "function",
"name": "verifyIcs07VerifyNonMembershipProof",
"name": "verifyIcs07UpdateClientProof",
"inputs": [
{
"name": "proof",
Expand All @@ -439,24 +395,9 @@
"name": "publicValues",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "proofHeight",
"type": "uint32",
"internalType": "uint32"
},
{
"name": "trustedConsensusStateBz",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "keyPath",
"type": "string",
"internalType": "string"
}
],
"outputs": [],
"stateMutability": "view"
"stateMutability": "nonpayable"
}
]
11 changes: 11 additions & 0 deletions contracts/fixtures/memberships_fixture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"proofHeight": 2110658,
"trustedClientState": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c200000000000000000000000000000000000000000000000000000000001275000000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000",
"trustedConsensusState": "000000000000000000000000000000000000000000000000000000006677e1da994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bfb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419",
"commitmentRoot": "994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf",
"updateClientVkey": "0x00eb2455c8d14f1f4a2287daa622a411b2e4a764d522fa5172ef9d1a5b8a0f5c",
"membershipVkey": "0x0045c54ed5927a845940a1b05eb768a384189a43f0ce816f2b7b0621600045b1",
"publicValues": "0x0000000000000000000000000000000000000000000000000000000000000020994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000023636c69656e74732f30372d74656e6465726d696e742d302f636c69656e745374617465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b70a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651287010a1174686574612d746573746e65742d3030311204080110031a040880840722040880c60a2a02082832003a0510b7e3c60842190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a107570677261646564494243537461746550015801000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000025636c69656e74732f30372d74656e6465726d696e742d3030312f636c69656e7453746174650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"proof": "0x16b7a55336d5ec7ca39056b6c196e4b9b8064cc1d265bddcf0002ac3f8bc7b110bdbdbc35133b34f43edb6e151383133c12341b436e09135617723e97b8c68291d58db5d9b0dcf7e41b4e32e384c5ac0a36aadf7c5827ec0b753d1905a4fb79d2e406de821e612024ed9ffb8a57b54dcd5d29aa57339d770cdaf8e9ff17539dc2ed822f8f00b7fd68f3be3dcc53d6a4565f3098e6d1e4dbcd6fad4a53759833d089e4ad0409f058af0fd710929ecd472184545c1dc241ecb3aaf81fbbd5a3bd302c45c2ee2deda40dc7a215b48ef29f1ccb8c4f250999cd0c6c813caa1a731f112c5b17e7dba05078de10456edcf97e2722174645ad123ab1b0530ecb9eaa00b20c99b04d82a2bab4d3b38dbb0f17123866f1c6d352d1d7883a4fba21e7b163000b7b79f7c0a30cbad1b94fd813fa903566301412d36540124ae41a9aa63869802f2ae7f0838bc84892cc2a9c2a4e7c90ac94644cc2f596922c0bc3c29491b0f1c237c0dfef0346e55ef6abd1b2ddc22c72642885593a7c7d167b1a92682ad262f6b17de5d09ebc1b902f660da4764240ab1a77143b5796237b80af686c4924815179569b1802d32c6442979c7f77087c5179e1aa375660371f76ab22d7715e607e3d611dcee3a1a004971017ae7189ec43dda4500f8a63dbb69ae8fcb9372aa1cd3f1fed9f2f41b1843630ba313a549c8694f58af1975e61ef3ef4076b8132e058ae7e36d6daea788cdd9d6175e022689e023f48d607d280ccf07b7e6cc54a406eb1c12a9331e14d7836b4fdaa4624ce9a5fb5d16435f6c039fa07af4554b0d0caf56c2e314fbdbf74ae8dde597fee501548db6ef467a0bfc5d7b299eda4d4a139fc47354c40035aa8cbad583aa4991bcf757d702ca50fddf3449e2ee4beb610cf3f82210e65708430a0d97737b9dd0e2364cff88eff26d456ee305d9caab1127e508bae2df774cf3600862152e0403006fd819504d1d7d2b6fe6c0642a7cc61cb30d1f23901e596e03057e6536b42d49ba2143df02497832faf7a24eabedc90893a49eb38b3d6e6fd52031d58b832654b532257e2394f5ffe3f54695f3bbc208fb3c3166672edd08535ae93cf2ef5ece36e52e81c174fe5688bfa14bf065c32590102d6800b82e6d965bf486d1c8779cca6481359fbe0a741ed836400fafb31d6ffaa13804ef0134544b5f835ee72191b9cf4b3806afeba6b6700111926438",
"kvPairs": "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000023636c69656e74732f30372d74656e6465726d696e742d302f636c69656e745374617465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b70a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651287010a1174686574612d746573746e65742d3030311204080110031a040880840722040880c60a2a02082832003a0510b7e3c60842190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a107570677261646564494243537461746550015801000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000025636c69656e74732f30372d74656e6465726d696e742d3030312f636c69656e7453746174650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
11 changes: 11 additions & 0 deletions contracts/fixtures/mock_memberships_fixture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"proofHeight": 2110658,
"trustedClientState": "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c200000000000000000000000000000000000000000000000000000000001275000000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000",
"trustedConsensusState": "000000000000000000000000000000000000000000000000000000006677e1da994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bfb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419",
"commitmentRoot": "994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf",
"updateClientVkey": "0x00eb2455c8d14f1f4a2287daa622a411b2e4a764d522fa5172ef9d1a5b8a0f5c",
"membershipVkey": "0x0045c54ed5927a845940a1b05eb768a384189a43f0ce816f2b7b0621600045b1",
"publicValues": "0x0000000000000000000000000000000000000000000000000000000000000020994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bf00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000023636c69656e74732f30372d74656e6465726d696e742d302f636c69656e745374617465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b70a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651287010a1174686574612d746573746e65742d3030311204080110031a040880840722040880c60a2a02082832003a0510b7e3c60842190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a107570677261646564494243537461746550015801000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000025636c69656e74732f30372d74656e6465726d696e742d3030312f636c69656e7453746174650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"proof": "0x",
"kvPairs": "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000023636c69656e74732f30372d74656e6465726d696e742d302f636c69656e745374617465000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b70a2b2f6962632e6c69676874636c69656e74732e74656e6465726d696e742e76312e436c69656e7453746174651287010a1174686574612d746573746e65742d3030311204080110031a040880840722040880c60a2a02082832003a0510b7e3c60842190a090801180120012a0100120c0a02000110211804200c300142190a090801180120012a0100120c0a02000110201801200130014a07757067726164654a107570677261646564494243537461746550015801000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000025636c69656e74732f30372d74656e6465726d696e742d3030312f636c69656e7453746174650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}
6 changes: 3 additions & 3 deletions contracts/fixtures/mock_update_client_fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"trustedConsensusState": "000000000000000000000000000000000000000000000000000000006677e1da994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bfb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419",
"targetConsensusState": "000000000000000000000000000000000000000000000000000000006677e25092a23d699a0d59f2e1b034c129b0051fb711a3d0d1f2e895fce82e933b8e36fdb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419",
"targetHeight": 2110668,
"updateClientVkey": "0x007249a35f961b3685a282a934413027785080e03426a685b787c7ae6d10fddf",
"verifyMembershipVkey": "0x00daab7c7010120e7df060b4615f623986641fbd9cb1ee5c9120c85a32d1c732",
"publicValues": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000006677e1da994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bfb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419000000000000000000000000000000000000000000000000000000006677e25092a23d699a0d59f2e1b034c129b0051fb711a3d0d1f2e895fce82e933b8e36fdb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c4190000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034cc00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000001275000000000000000000000000000000000000000000000000000000000066882e6e00000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000",
"updateClientVkey": "0x00eb2455c8d14f1f4a2287daa622a411b2e4a764d522fa5172ef9d1a5b8a0f5c",
"membershipVkey": "0x0045c54ed5927a845940a1b05eb768a384189a43f0ce816f2b7b0621600045b1",
"publicValues": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000006677e1da994a2058af458e1a97f19bfa85c99ba5db6534473e8040e671a45431f78651bfb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c419000000000000000000000000000000000000000000000000000000006677e25092a23d699a0d59f2e1b034c129b0051fb711a3d0d1f2e895fce82e933b8e36fdb73058223e788b1b021cd25d9d8b80f1e21f742014d270fc850bacda1e63c4190000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034c2000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000002034cc00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000012750000000000000000000000000000000000000000000000000000000000668a3a9600000000000000000000000000000000000000000000000000000000000000076d6f6368612d3400000000000000000000000000000000000000000000000000",
"proof": "0x"
}
Loading

0 comments on commit 5f4dd67

Please sign in to comment.