-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update pallet-relayer
to use Contraints V2
#433
Conversation
Otherwise this will just fail once we try and write the program to the contraint pallet storage.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This is now scaled on the length of the submitted program
/// Storage: Constraints AllowedToModifyConstraints (r:0 w:1) | ||
/// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) | ||
/// The range of component `c` is `[0, 2]`. | ||
fn confirm_register_registered(_c: u32, ) -> Weight { |
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.
Don't know why c
isn't used here anymore...I didn't touch these benches 🤔
@@ -59,13 +60,15 @@ impl<T: frame_system::Config> pallet_relayer::WeightInfo for WeightInfo<T> { | |||
/// Storage: StakingExtension SigningGroups (r:1 w:0) | |||
/// Proof Skipped: StakingExtension SigningGroups (max_values: None, max_size: None, mode: Measured) | |||
/// The range of component `c` is `[0, 2]`. | |||
fn confirm_register_registering(_c: u32, ) -> Weight { | |||
fn confirm_register_registering(c: u32, ) -> Weight { |
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.
Hmm but c
is used in this bench...ya not sure what's going on here
Jesse suggested this hack...
crypto/server/src/user/tests.rs
Outdated
@@ -461,7 +461,7 @@ async fn test_store_share() { | |||
let alice_account_id: <EntropyConfig as Config>::AccountId = alice.to_account_id().into(); | |||
let registered_query = entropy::storage().relayer().registered(alice_account_id); | |||
for _ in 0..10 { | |||
std::thread::sleep(std::time::Duration::from_millis(500)); | |||
std::thread::sleep(std::time::Duration::from_millis(1000)); |
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.
@JesseAbram lol this actually fixed the CI 🙈
* Remove `is_swapping` field from registration details * Remove related benchmarking code * Update node metadata * Apply same sleep hack as in #433 🙈
(evm_acl_len, btc_acl_len) = ConstraintsPallet::<T>::constraint_weight_values(constraints); | ||
} | ||
<T as Config>::WeightInfo::register(evm_acl_len, btc_acl_len) | ||
<T as Config>::WeightInfo::register(initial_program.len() as u32) | ||
})] | ||
pub fn register( |
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.
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.
this requires we pass an initial program at registration?
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.
Maybe (pending the discussion below), but mostly that there's a change in field names and the type of a program (Option
vs. Vec<u8>
).
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.
This is perfect in a that it achieves exactly what it set out to do, replacing constraints v1 with program bytecode in the relayer pallet.
But it brings up a design decision which we need to be clear on. Is setting a program optional or required?
Previously we allowed Option<Constraints>
and now we require a Vec<u8>
but it may be invalid bytecode, eg: empty vector.
At the point of signing, a valid program is currently required. Our tests pass here even though we set an empty program when registering, because we update it with a valid one before signing.
Personally i think setting a program should be optional, but that we should be explicit and use Option<Vec<u8>>
. If given, it should be a valid program.
I think we should merge this as it is for now though. Maybe i can make an issue about optional vs. required programs.
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.
looks good just the one comment
&constraints, | ||
); | ||
} | ||
ConstraintsPallet::<T>::set_program_unchecked( |
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.
I don't like using set unchecked, as in set program we charge a deposit for length of program, here I believe people can post an arbitrary sized program for free
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.
From what I can tell this doesn't change the previous deposit/weight behaviour for this extrinsic.
So the user calling the register
extrinsic does get charged by program length (before that was being done with the evm_acl
and btc_alc
related functions).
The validators never got charged this deposit since Constraints::set_constraints_unchecked()
doesn't require a deposit, and the confirm_*
weight functions don't account for this either.
If we do want to charge for this some questions come up:
- Who pays for this?
- In the current workflow it would seem like the validators would, although maybe want the
sig_req_account
to
- In the current workflow it would seem like the validators would, although maybe want the
- Which pallet should handle this?
- It should be the
Constraints
pallet imo, but it might make the workflow a bit trickier
- It should be the
And technically the wouldn't be arbitrarily length program, they can only go up to T::MaxV2BytecodeLength
😛
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.
hmmmm ya that does need to be solved, but we can charge them the deposit in the register extrinsic and then ya do set unchecked later on
My understanding here was that an empty program would be equivalent to having a
Can you point me to the checks were we validate a program? Like is an empty program considered invalid?
I thought about changing the type to an
I'm okay discussing it here or in an issue. Maybe we can also get some feedback from @jakehemmerle. |
When reviewing I thought the same as first, but then I thought about it and you write can do the empty program is the same thing makes sense. |
I just tried running the test with an empty program, and it is not a noop. |
@ameba23 can you tell me what test you're trying to run specifically? Maybe this is something that needs to be accounted for upstream in the constraints crate |
|
Programs can be optional; I think it's fine if users can register without requiring one. |
@JesseAbram do you mind if we merge this? I have another PR coming for the storage deposit fixes which I think would be better off standalone instead of being added here. I'll also create an issue about running empty programs (edit: made entropyxyz/programs#36). |
This updates the Relayer pallet to use the new Contraints API.
I split this PR out from #428 since I figured it would be better to ensure
that the new flow was working first and then we could go ahead and get
rid of the old code.