entropyxyz / programs

Source, toolchain, and examples for using programs on Entropy
https://docs.entropy.xyz/concepts/programs/
GNU Affero General Public License v3.0
19 stars 3 forks source link

Implement default custom hashing to return None #43

Open jakehemmerle opened 9 months ago

jakehemmerle commented 9 months ago

Note, this first requires a refactor in the .wit file

Currently, every program (and every example) not using custom hashes still needs to implement custom_hash and return None. Ideally, we should be able to implement this with a derive procedural macro.

To do this, we should start with rewriting wit/application.wit to generate multiple worlds or something to change custom-hash implementation from

pub struct XYZProgram;

impl Program for XYZProgram {
   fn evaluate ...{
      ...
   }
   fn custom_hash... {
      ...
   }
}

to

pub struct XYZProgram;

impl Program for XYZProgram {
   fn evaluate ...{
      ...
   }
}

impl CustomHash for XYZProgram {
   fn custom_hash... {
      ...
   }
}

which in turn can be simplified to something like

#[derive(NoCustomHash]
pub struct XYZProgram;

impl Program for XYZ Program {
   fn evaluate ...{
      ...
   }
}