Skip to content

Conversation

@0xfluxx
Copy link
Contributor

@0xfluxx 0xfluxx commented Jul 11, 2025

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Feature
  • Bugfix
  • Refactor
  • Format
  • Documentation
  • Testing
  • Other:

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

  • I have performed a self-review of my own code.
  • The tests pass successfully with cargo test.
  • The code was formatted with cargo fmt.
  • The code compiles with no new warnings with cargo build --release and cargo build --release --features runtime-benchmarks.
  • The code has no new warnings when using cargo clippy.
  • If this change affects documented features or needs new documentation, I have created a PR with a documentation update.

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 {
Copy link
Contributor

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);
Copy link
Contributor

@markopoloparadox markopoloparadox Jul 17, 2025

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())
Copy link
Contributor

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 {
Copy link
Contributor

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>;
Copy link
Contributor

@markopoloparadox markopoloparadox Jul 17, 2025

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 },
Copy link
Contributor

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 }
Copy link
Contributor

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 {
Copy link
Contributor

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());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scary empty space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants