-
Notifications
You must be signed in to change notification settings - Fork 4
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
Oracle data type generation #100
Conversation
); | ||
|
||
// length is 1 if empty and can ignore, scale codec length | ||
let pre = fs::read(oracle_data.clone()).unwrap(); |
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 is pre
here?
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.
will name better but checking if it can be none, non using oracle causes a decoding error.....could probably fix that but using none is better
|
||
// length is 1 if empty and can ignore, scale codec length | ||
let pre = fs::read(oracle_data.clone()).unwrap(); | ||
let oracle_option = if pre.len() == 1 { |
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.
And how come we consider this empty if len == 1
?
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.
because it is scale encoded and scale encoding prefixes the length of the item, so encoding an empty vec![] looks like [0]
@@ -22,13 +23,27 @@ async fn main() -> anyhow::Result<()> { | |||
get_project_root()?.to_string_lossy() | |||
); | |||
|
|||
let oracle_data = format!( | |||
"{}/{{project-name}}_serialized_oracle_data_type.txt", | |||
get_project_root()?.to_string_lossy() |
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.
How come a lossy
conversion is being used here?
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.
mmm idk just copying the ones above
Co-authored-by: Hernando Castano <[email protected]>
Co-authored-by: Hernando Castano <[email protected]>
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.
🥇 All looks good.
Although i haven't actually been through the process of generating a program, generating this type and deploying it - maybe there are some gotchas.
|
||
pub fn generate_types() { | ||
let schema_config = schema_for!(UserConfig); | ||
fs::write( | ||
"./{{project-name}}_serialized_config_type.txt", | ||
"./tests_serialized_config_type.txt", |
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 a bit confused about this bit - does it need to be changed back to "./{{project-name}}_serialized_config_type.txt"
when this generate template is actually used?
|
||
let oracle_data = ORACLE_DATA.iter().map(|x| x.encode()).collect::<Vec<_>>(); | ||
fs::write( | ||
"./tests_serialized_oracle_data_type.txt", |
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 file has a .txt
extension i would expect it to be human readable and valid utf-8 - im not sure if scale encoding a vector adds bytes which are invalid utf-8.
Generates and posts oracle pointer data for programs pairs with entropyxyz/entropy-core#1222, needs to be merged second to update branch in cargo toml back