madara icon indicating copy to clipboard operation
madara copied to clipboard

feat: `to_rpc_contract_class` is still returning contracts with a lot of missing data

Open tdelabro opened this issue 1 year ago • 24 comments

/// Returns a [`ContractClass`] from a [`BlockifierContractClass`]
pub fn to_rpc_contract_class(contract_class: BlockifierContractClass) -> Result<ContractClass> {
    match contract_class {
        BlockifierContractClass::V0(contract_class) => {
            let entry_points_by_type = to_legacy_entry_points_by_type(&contract_class.entry_points_by_type)?;
            let compressed_program = compress(&contract_class.program.to_bytes())?;
            Ok(ContractClass::Legacy(CompressedLegacyContractClass {
                program: compressed_program,
                entry_points_by_type,
                // FIXME 723
                abi: None,
            }))
        }
        BlockifierContractClass::V1(_contract_class) => Ok(ContractClass::Sierra(FlattenedSierraClass {
            sierra_program: vec![], // FIXME: https://github.com/keep-starknet-strange/madara/issues/775
            contract_class_version: option_env!("COMPILER_VERSION").unwrap_or("0.11.2").into(),
            entry_points_by_type: EntryPointsByType { constructor: vec![], external: vec![], l1_handler: vec![] }, /* TODO: add entry_points_by_type */
            abi: String::from("{}"), // FIXME: https://github.com/keep-starknet-strange/madara/issues/790
        })),
    }
}

This piece of code is still missing most fields. How to solve this?

Possible solution:

  • store the data lost when passed to the runtime (eg. abi) in a kvStorage in the client, read them back from there when answering get_class rpc request

tdelabro avatar Dec 13 '23 16:12 tdelabro

Hi, would be interested to work on this.

Juul-Mc-Goa avatar Dec 24 '23 11:12 Juul-Mc-Goa

Thanks a lot @Juul-Mc-Goa ! Message me if you don't know how to design things.

tdelabro avatar Dec 26 '23 08:12 tdelabro

Hey @Juul-Mc-Goa, this one had been assigned to you but I don't think you ever worked on it. Do you want to, or can I unassign you?

tdelabro avatar Jan 19 '24 12:01 tdelabro

Hey, sorry got busy with other things. I can start working on it next monday, or you can unassign me if you prefer.

Juul-Mc-Goa avatar Jan 19 '24 14:01 Juul-Mc-Goa

Starting next Monday will be great! Thank you

tdelabro avatar Jan 19 '24 15:01 tdelabro

make sure to read #790 as it is part of what you will be doing

tdelabro avatar Jan 19 '24 15:01 tdelabro

Hey @tdelabro, just to be sure, the kvStorage in the client will not be gossiped to other nodes ? If it has to be gossiped, as said in #775, then I don't know how it should be implemented.

Juul-Mc-Goa avatar Jan 22 '24 14:01 Juul-Mc-Goa

@Juul-Mc-Goa indeed it is not gossiped. We have to find some other way. Starknet does not have the issue coz it is centralized. I think we have to gossip them or make them available one way or another.

Put your work here in hold, and open a discussion so that we can find the best way to do that. List the potential solutions you can think as a starting point for the discussion.

tdelabro avatar Jan 22 '24 17:01 tdelabro

@tdelabro started a discussion there

Juul-Mc-Goa avatar Jan 23 '24 15:01 Juul-Mc-Goa

I'm working on this whole flow. There is a number of task to do first, but I'm on it

tdelabro avatar Jan 27 '24 14:01 tdelabro

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Feb 27 '24 00:02 github-actions[bot]

We now have contract classes stored in the client (since https://github.com/keep-starknet-strange/madara/pull/1409). So I think it reopen the possibility to improve this part

wanna give it a try @Juul-Mc-Goa ?

tdelabro avatar Feb 28 '24 19:02 tdelabro

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Apr 08 '24 00:04 github-actions[bot]

has this been fixed? @tdelabro @Juul-Mc-Goa

elielnfinic avatar Apr 15 '24 15:04 elielnfinic

@elielnfinic nope, still an issue

tdelabro avatar Apr 29 '24 14:04 tdelabro

I will come back to this after completing the other task you just assigned to me. If you don't mind, you can assign this to me too.

elielnfinic avatar Apr 29 '24 14:04 elielnfinic

Has this function been changed to blockifier_to_rpc_contract_class_types in crates/client/rpc-core/src/utils.rs?

elielnfinic avatar Apr 30 '24 19:04 elielnfinic

@elielnfinic yes indeed

tdelabro avatar May 06 '24 05:05 tdelabro

Is conversion from EntryPointV1 to SierraEntryPoint available?

elielnfinic avatar May 08 '24 21:05 elielnfinic

I think, I am able to fix that conversion.

elielnfinic avatar May 09 '24 20:05 elielnfinic

@elielnfinic I think this PR will be fixed by some work I'm doing, storing the casm contract class on the client. It will provide all the data required to fill those missing fields. I don't think you will be able to complete this issue without this

tdelabro avatar May 13 '24 11:05 tdelabro

I can create a draft PR to see if some parts of my code be used.

elielnfinic avatar May 13 '24 11:05 elielnfinic

Sure, but don't spend too much time on that :)

tdelabro avatar May 13 '24 11:05 tdelabro

Hey @tdelabro, please proceed, I will not submit the PR draft.

elielnfinic avatar May 13 '24 19:05 elielnfinic

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Jun 15 '24 00:06 github-actions[bot]

Hey,

Is this issue still relevant ? I would be interested to work on this.

Juul-Mc-Goa avatar Jun 22 '24 17:06 Juul-Mc-Goa

I'm on it #1631

tdelabro avatar Jun 24 '24 07:06 tdelabro

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍 Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Jul 25 '24 00:07 github-actions[bot]

repository archived in favor of https://github.com/madara-alliance/madara

tdelabro avatar Aug 02 '24 18:08 tdelabro