lambdaclass / starknet_in_rust

A Rust implementation of Starknet execution logic
Apache License 2.0
171 stars 52 forks source link

Add Sierra program support to RPC State Reader #1173

Closed juanbono closed 9 months ago

juanbono commented 10 months ago

We should be able to retrieve the sierra programs given a class hash from a 0.5.0 RPC full node. That will enable us to use the RPC State Reader to fetch the Sierra needed for compiling to a binary using Cairo Native.

Example call to an RPC endpoint to get the Sierra program:

curl --http1.1 <RPC URL> \
    -X POST \
    -H "Content-Type: application/json" \
    --data '{"jsonrpc": "2.0", "id": 1, "method": "starknet_getClass", "params": ["latest", "0xb8378a3206095057917817e3867b3abc6cbbb3b203e3e3240b3348c960223a"]}'

Important

When that RPC method get called for a Cairo 1 contract, it returns the sierra program by default (with the corresponding casm code, ABI, etc). But when it is called for a Cairo 0 contract it just returns the deprecated contract class. So we should pay attention to error handling when implementing this ticket.

fmoletta commented 9 months ago

Already implemented in main