Skip to content
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

Add auxiliary data to ProgramInfo #681

Merged
merged 18 commits into from
Mar 29, 2024
Merged

Conversation

JesseAbram
Copy link
Member

This splits up config data and aux data into two seperate slots so it can follow https://json-schema.org/ spec

Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
entropy-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 29, 2024 6:32pm

@JesseAbram JesseAbram marked this pull request as ready for review March 26, 2024 19:18
Copy link
Contributor

@ameba23 ameba23 left a comment

Choose a reason for hiding this comment

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

💯 I like that this does just one thing

hash,
program_info.deployer,
program_info.ref_counter,
program_info.bytecode.len(),
!program_info.interface_description.is_empty(),
!program_info.config_description.is_empty(),
!program_info.aux_description.is_empty(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess if adding this here we should also add a heading in the println! above, eg: 'Has auxiliary?'

@@ -68,14 +73,15 @@ fn set_program() {
"Program gets set to owner"
);
// deposit taken
assert_eq!(Balances::free_balance(PROGRAM_MODIFICATION_ACCOUNT), 85, "Deposit charged");
assert_eq!(Balances::free_balance(PROGRAM_MODIFICATION_ACCOUNT), 80, "Deposit charged");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how or why this ends up being 80, but im guessing its not too important

Copy link
Member Author

Choose a reason for hiding this comment

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

oh ya we charge a deposit based on the size of the program + config and now also + aux data, I added aux data on here so the total size got a little bigger so the deposit amount got bigger

Copy link
Collaborator

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

One question about the flow of using the schema vs. concrete types, but otherwise LGTM

CHANGELOG.md Outdated Show resolved Hide resolved
crates/testing-utils/src/test_client/mod.rs Outdated Show resolved Hide resolved
pallets/programs/src/lib.rs Outdated Show resolved Hide resolved
pallets/programs/src/lib.rs Outdated Show resolved Hide resolved
/// Deployer of the program
pub deployer: AccountId,
/// Accounts that use this program
pub ref_counter: u128,
}

/// Stores the program info for a given program hash.
/// A program hash is a combination of the bytecode and interface_description
/// A program hash is a combination of the bytecode and config_description
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we do the actual hashing we also include the auxiliary data. This comment should probably be updated to reflect that.

Comment on lines 97 to 100
/// An interface description for the program config following https://json-schema.org/ spec
pub config_description: Vec<u8>,
/// An interface description for the program aux data following https://json-schema.org/ spec
pub aux_description: Vec<u8>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not totally following something here.

I guess it makes sense that we'd store the schemas for the config and auxiliary data alongside the program, but where do the "concrete" configuration and auxiliary data JSON objects actually get passed in and used?

Is this something that's being done purely off-chain? In which case the flow would be that, for example, the SDK would pull the program, get the schema, use it to build requests, and then fire those back?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes pretty much exactly the last sentence of this

pallets/programs/src/lib.rs Outdated Show resolved Hide resolved
pallets/programs/src/lib.rs Outdated Show resolved Hide resolved
pallets/programs/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 180 to 181
config_description: Vec<u8>,
aux_description: Vec<u8>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same naming suggestion here. I'd rather be explicit 😄

@HCastano HCastano changed the title Add aux data to program info Add auxiliary data to ProgramInfo Mar 29, 2024
JesseAbram and others added 6 commits March 29, 2024 09:48
@JesseAbram JesseAbram merged commit 5a7f81e into master Mar 29, 2024
11 checks passed
@JesseAbram JesseAbram deleted the add-aux-data-to-program-info branch March 29, 2024 21:31
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