-
Notifications
You must be signed in to change notification settings - Fork 570
Add Pico support to the vector pallet. #761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| let updater = Updater::<T>::get(); | ||
| let pico_updater = PicoUpdater::<T>::get(); | ||
| let sp1_updater = Updater::<T>::get(); | ||
| let (updater, _updater_type) = if H256(sender) == pico_updater { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this _updater_type used anywhere?
|
|
||
| let vk_bin = include_bytes!("../pico_vk.bin"); | ||
| let vk = gnark_bn_verifier::vk::Groth16VKey::try_from(vk_bin.as_slice()); | ||
| ensure!(vk.is_ok(), Error::<T>::BadPicoVkKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we could use let..else pattern together with return Error to avoid the unwrap down below.
|
|
||
| let public_inputs = vkh | ||
| .chunks(32) | ||
| .map(|e| Fr::from_slice(e).unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scary unwrap here
| let updater = Updater::<T>::get(); | ||
| let pico_updater = PicoUpdater::<T>::get(); | ||
| let sp1_updater = Updater::<T>::get(); | ||
| let (updater, updater_type) = if H256(sender) == pico_updater { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue but style-wise would a match operator be more elegant in this instance?
| /// Updater that can submit updates | ||
| #[pallet::storage] | ||
| #[pallet::getter(fn pico_updater)] | ||
| pub type PicoUpdater<T: Config> = StorageValue<_, H256, ValueQuery>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue but we should keep on mind that we need to set these storage (PicoUpdater, PicoVerificationKey) once we do the runtime upgrade
| /// Emit new updater. | ||
| NewUpdater { old: H256, new: H256 }, | ||
| /// Emit new updater. | ||
| NewPicoUpdater { old: H256, new: H256 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move the newly created events to the bottom? thank you
| sp1-verifier = { version = "5.0.0", default-features = false } | ||
| alloy-sol-types = { version = "0.8.12", default-features = false } | ||
| hex = { version = "*", default-features = false } | ||
| gnark-bn-verifier = { git = "https://github.com/availproject/gnark-bn-verifier", branch = "no-std", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move all the new dependencies to the main cargo.toml file and here just reference it with { workspace = true, default-features = false }. If you have the will could you do the same for sp1-verifier and alloy-sol-types?
| Weight::zero() | ||
| } | ||
| } | ||
| enum UType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue but style-wise it might make sense to move this type definition to the top of the pallet mod section.
| .collect::<Vec<_>>(); | ||
|
|
||
| let is_valid = groth16_proof.verify(&vk, public_inputs.as_slice()); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scary empty space
Pull Request type
Please add the labels corresponding to the type of changes your PR introduces:
Description
Adding support for Pico verification to Vector pallet. Includes a forked external crate, that may need to be upstreamed.
Related Issues
Testing Performed
The main test was added to test the feature. Some more would probably also need to be added, to cover everything, but this is a good start.
Checklist
cargo test.cargo fmt.cargo build --releaseandcargo build --release --features runtime-benchmarks.cargo clippy.