I have an extrinsic in one of my pallets that looks validates a signature over a message, which is separate from the actual extrinsic being submitted.
The code can be simplified to look like the below
#[pallet::call_index(0)]
pub fn do_something(
origin: OriginFor<T>,
msg: SignableMessage,
user_signer: T::AccountId,
user_sig: MultiSignature
) -> DispatchResult {
/* -- snip -- */
let signer_bytes = Self::account_to_bytes(&user_signer)?;
let valid = msg.using_encoded(|encoded| {
let msg = [DOMAIN_SEP_TAG, encoded].concat();
user_sig.verify(msg.as_ref(), &signer_bytes.into())
});
ensure!(valid, <Error<T>>::InvalidSignature);
/* -- snip -- */
}
The code works fine, but benchmarking it is challenging, because benchmarking setup runs in WASM and as such cannot create the signature. The only way I can think of to get around this is basically to create a signature for all messages I benchmark ahead of time, and write their bytes into a static map, then read that out when doing benchmarks.
Is there a better way to do this? Has anyone else run into the same problem?
For this particular usecase, it does not make sense to use the built-in proxy pallets, or something on-chain.