-
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
Program config storage #593
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
If i've understood right, the idea here is to add the storage logic for program config in this PR, and the actual evaluating a program together with its config will be done separately once entropyxyz/programs#56 is merged.
Anyway this looks great. Personally i would use Option
rather than an empty vector to represent no program config, as in the programs PR evaluate
takes an Option<Vec<u8>>
for the configuration. And generally i think it makes it more explicit - but this works as it is.
Probably more of an issue for Programs
, but it would be nice to have a way to ensure that programs which require a configuration are given a valid configuration at the point of registration / updating, rather than at the point of requesting a signature. I'm not sure if that will be too difficult - as in is there a way that given a ProgramData
, we can tell whether the configuration is valid for the program, without actually evaluating it with a message.
I'm not sure if ProgramData
is the best name, but i don't have a better proposal.
Generally, i think its going be hard for devs to figure out the difference between auxiliary data and configuration, be nice to have names which make it obvious that auxiliary data can vary for each message whereas configuration only varies for each user.
So thumbs up but leaving this as comment for now as not sure if its still WIP, and changelog needs updating.
yup exactly
mmm I debated this, I just went for consistency here, Im ok with either but if so then this and pointer should be like this
I talked about this with jake, it is on the roadmap but a little more complicated and not getting done soon
im sure hernando or jake will come up with something
yeee I mean let's get people using it and then we can tweek, doc etc
|
…ram-config-storage
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.
The big question for me here is the type_definition
in the Programs pallet, and what it's role is
/// The type definition of the program | ||
pub program_type_definition: 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.
What's a type definition in this context? I haven't seen this term used in the issue or in Jake's PR
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.
pretty much it is the serialized json input that the program expects for the config input
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 should be called something like "serialized_config" to corospond to the optional config parameter of evaluate
of type Option<Vec<u8>>
. Programs are not required to have a config, and "type definition" doesn't really make semantic sense
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.
or if this is what describes in JSON what kind of JSON interface a program might take, we should remove this for now as wit-generation from types doesn't exist yet and unlikely going in anytime soon.
I've got a few solutions to check that a JSON config is valid, but the solutions are ugly and they deserve more though first. I suspect there will be a new function on the Program that takes the JSON config as an input string and returns Result<(), Error>
.
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.
Im not sure I understand, we talked about this and about how currently a program owner would self set this option so the front end can know and understand what needs to be set as config when registering (or choosing their program)
pallets/relayer/src/lib.rs
Outdated
@@ -88,12 +88,19 @@ pub mod pallet { | |||
} | |||
pub type ProgramPointers<Hash, MaxProgramHashes> = BoundedVec<Hash, MaxProgramHashes>; | |||
|
|||
#[derive(Clone, Encode, Decode, Eq, PartialEqNoBound, RuntimeDebugNoBound, TypeInfo)] | |||
#[scale_info(skip_type_params(T))] | |||
pub struct ProgramData<T: Config> { |
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 suggest changing this to ProgramInstance
. An instance is made up of code + configuration
.
There can be a separation of responsibilities here too. While the Programs pallet manages and tracks bytecode, and the Relayer (or Registry) pallet manages and tracks instances.
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.
ya that works for me
#[scale_info(skip_type_params(T))] | ||
pub struct ProgramData<T: Config> { | ||
pub program_pointer: T::Hash, | ||
pub program_config: 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.
While I generally I agree with Peg here in that this should be more explicit as an Option
- the Programs pallet already accepts empty programs with just an empty vector, and this kinda matches that API.
Maybe the best people to answer this will actually be on the SDK side. Which of the two options makes their code easier to serialize correctly?
cc @jawndiego @frankiebee ?
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.
yes I also heavily lean towards symmetry on this one as in whatever we decide they both should do it, so no matter what is decided I feel like it should be handled in a follow up PR
pallets/relayer/src/lib.rs
Outdated
/// An account hash changed their program pointers [who, new_programs_data] | ||
ProgramPointerChanged(T::AccountId, BoundedVec<ProgramData<T>, T::MaxProgramHashes>), |
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'll have to be updated to mention instances, or at least the config side of this too
) -> anyhow::Result<<EntropyConfig as Config>::Hash> { | ||
let update_program_tx = entropy::tx().programs().set_program(program); | ||
let update_program_tx = entropy::tx().programs().set_program(program, program_config); |
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.
Yeah so this is defined as type_definition
in the Programs pallet but it's a config
here. So what is it supposed to be?
…ram-config-storage
This adds the storage for program config see.