0xPolygonMiden / miden-vm

STARK-based virtual machine
MIT License
611 stars 148 forks source link

Enable serialization of source locations for `AstSerdeOptions` #1177

Open Dominik1999 opened 7 months ago

Dominik1999 commented 7 months ago

I believe this will serialize note scripts without source locations. Serializing with source locations now is a bit cumbersome - so, maybe we should just create two issues for now:

First issue would be in Miden VM to enable serialization of source locations by simply setting the appropriate property for AstSerdeOptions. For example, here, it should work something like this:

let note_script_bytes = note_script_ast.to_bytes(AstSerdeOptions {
    serialize_imports: true,
    serialize_source_locations: true,
});

The second issue would be here so that we don't forget to come back and fix this once the issue in Miden VM is fixed.

_Originally posted by @bobbinth in https://github.com/0xPolygonMiden/miden-base/pull/339#discussion_r1421689757_

igamigo commented 6 months ago

This should be done for ModuleAst as well. The following tests currently fails because source locations are not being serialized correctly:

    let account = account::mock_account(Some(account_id.into()), Felt::ZERO, None, &assembler);

    let account_module = account.code().module();
    let account_module_bytes = account_module.to_bytes(AstSerdeOptions{serialize_imports:true});

    let reconstructed_ast = ModuleAst::from_bytes(&account_module_bytes).unwrap();

    assert_eq!(*account_module, reconstructed_ast)