-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: blockifier regression test compile class (#980)
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/starkware-libs/sequencer/980) <!-- Reviewable:end -->
- Loading branch information
1 parent
7427d48
commit 7131378
Showing
8 changed files
with
317 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
crates/blockifier_regression_test/resources/json_objects/deprecated_contract_class.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"abi": [ | ||
{ | ||
"data": [ | ||
{ | ||
"name": "implementation", | ||
"type": "felt" | ||
} | ||
], | ||
"keys": [], | ||
"name": "Upgraded", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "implementation_address", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "initializer_selector", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata_len", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata", | ||
"type": "felt*" | ||
} | ||
], | ||
"name": "constructor", | ||
"outputs": [], | ||
"type": "constructor" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "get_implementation", | ||
"outputs": [ | ||
{ | ||
"name": "implementation", | ||
"type": "felt" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "selector", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata_size", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata", | ||
"type": "felt*" | ||
} | ||
], | ||
"name": "__default__", | ||
"outputs": [ | ||
{ | ||
"name": "retdata_size", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "retdata", | ||
"type": "felt*" | ||
} | ||
], | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ | ||
"name": "selector", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata_size", | ||
"type": "felt" | ||
}, | ||
{ | ||
"name": "calldata", | ||
"type": "felt*" | ||
} | ||
], | ||
"name": "__l1_default__", | ||
"outputs": [], | ||
"type": "l1_handler" | ||
} | ||
], | ||
"entry_points_by_type": { | ||
"CONSTRUCTOR": [ | ||
{ | ||
"offset": "0x91", | ||
"selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194" | ||
} | ||
], | ||
"EXTERNAL": [ | ||
{ | ||
"offset": "0xde", | ||
"selector": "0x0" | ||
}, | ||
{ | ||
"offset": "0xbd", | ||
"selector": "0x21691762da057c1b71f851f9b709e0c143628acf6e0cbc9735411a65663d747" | ||
} | ||
], | ||
"L1_HANDLER": [ | ||
{ | ||
"offset": "0xf7", | ||
"selector": "0x0" | ||
} | ||
] | ||
}, | ||
"program": "H4sIAAAAAAAA/+x9a2/buLb2XzH8aWZ2dsA7pQLzIW09s4s3bedN0jOzT1EIskSnQm3ZW1LaZA/63w90syWLlEhdnHSmAYLEsrjW4uJ6Hi5eRP0530XBRsyfzebg3gKVHwiB2Q+cn83mbpJEwfIuEfH82ez9h7PZPPBFmASrQETppT/njrNxg9Bxzv/lxh+f3wXrJAizL3wRJ0HoJsE2/TyPEzf69MWNxLnnBtH23NtuNtsw/+As83JxTcjZbJ487LK6uOvAjedfz2YHdb9F2/sHqaLIO7/b3UauL+LzdbCM3OihuLtdouP4YuXerRPHKeR628hNtllF38/FfSKi0F2nUiL3ixOEu7uk/LC9S9JPqYN23vz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Nv/5voCeUPX7/+XwAAAP//QZpCgmDPAAA=" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod compile; | ||
#[cfg(test)] | ||
#[cfg(feature = "blockifier_regression_https_testing")] | ||
pub mod rpc_test; | ||
|
105 changes: 105 additions & 0 deletions
105
crates/blockifier_regression_test/src/state_reader/compile.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// This module contains code taken from starknet-replay. | ||
// For more information, see the original repository at: | ||
// `<starknet-replay: https://github.com/lambdaclass/starknet-replay>` | ||
|
||
use std::collections::HashMap; | ||
use std::io::{self, Read}; | ||
use std::sync::Arc; | ||
|
||
use blockifier::execution::contract_class::{ContractClass, ContractClassV0, ContractClassV0Inner}; | ||
use blockifier::state::state_api::StateResult; | ||
use cairo_lang_starknet_classes::contract_class::ContractEntryPoints; | ||
use cairo_lang_utils::bigint::BigUintAsHex; | ||
use cairo_vm::types::program::Program; | ||
use flate2::bufread; | ||
use serde::Deserialize; | ||
use starknet_api::core::EntryPointSelector; | ||
use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}; | ||
use starknet_api::hash::StarkHash; | ||
use starknet_core::types::{ | ||
CompressedLegacyContractClass, | ||
FlattenedSierraClass, | ||
LegacyContractEntryPoint, | ||
LegacyEntryPointsByType, | ||
}; | ||
use starknet_gateway::errors::serde_err_to_state_err; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct MiddleSierraContractClass { | ||
pub sierra_program: Vec<BigUintAsHex>, | ||
pub contract_class_version: String, | ||
pub entry_points_by_type: ContractEntryPoints, | ||
} | ||
|
||
/// Maps `LegacyEntryPointsByType` to a `HashMap` where each `EntryPointType` | ||
/// is associated with a vector of `EntryPoint`. Converts selectors and offsets | ||
/// from legacy format to new `EntryPoint` struct. | ||
pub fn map_entry_points_by_type_legacy( | ||
entry_points_by_type: LegacyEntryPointsByType, | ||
) -> HashMap<EntryPointType, Vec<EntryPoint>> { | ||
let entry_types_to_points = HashMap::from([ | ||
(EntryPointType::Constructor, entry_points_by_type.constructor), | ||
(EntryPointType::External, entry_points_by_type.external), | ||
(EntryPointType::L1Handler, entry_points_by_type.l1_handler), | ||
]); | ||
|
||
let to_contract_entry_point = |entrypoint: &LegacyContractEntryPoint| -> EntryPoint { | ||
let felt: StarkHash = StarkHash::from_bytes_be(&entrypoint.selector.to_bytes_be()); | ||
EntryPoint { | ||
offset: EntryPointOffset(usize::try_from(entrypoint.offset).unwrap()), | ||
selector: EntryPointSelector(felt), | ||
} | ||
}; | ||
|
||
let mut entry_points_by_type_map = HashMap::new(); | ||
for (entry_point_type, entry_points) in entry_types_to_points.into_iter() { | ||
let values = entry_points.iter().map(to_contract_entry_point).collect::<Vec<_>>(); | ||
entry_points_by_type_map.insert(entry_point_type, values); | ||
} | ||
|
||
entry_points_by_type_map | ||
} | ||
|
||
/// Uncompresses a Gz Encoded vector of bytes and returns a string or error | ||
/// Here &[u8] implements BufRead | ||
pub fn decode_reader(bytes: Vec<u8>) -> io::Result<String> { | ||
let mut gz = bufread::GzDecoder::new(&bytes[..]); | ||
let mut s = String::new(); | ||
gz.read_to_string(&mut s)?; | ||
Ok(s) | ||
} | ||
|
||
/// Compile a FlattenedSierraClass to a ContractClass V1 (casm) using cairo_lang_starknet_classes. | ||
pub fn sierra_to_contact_class_v1(sierra: FlattenedSierraClass) -> StateResult<ContractClass> { | ||
let middle_sierra: MiddleSierraContractClass = { | ||
let v = serde_json::to_value(sierra).map_err(serde_err_to_state_err); | ||
serde_json::from_value(v?).map_err(serde_err_to_state_err)? | ||
}; | ||
let sierra = cairo_lang_starknet_classes::contract_class::ContractClass { | ||
sierra_program: middle_sierra.sierra_program, | ||
contract_class_version: middle_sierra.contract_class_version, | ||
entry_points_by_type: middle_sierra.entry_points_by_type, | ||
sierra_program_debug_info: None, | ||
abi: None, | ||
}; | ||
|
||
let casm = | ||
cairo_lang_starknet_classes::casm_contract_class::CasmContractClass::from_contract_class( | ||
sierra, | ||
false, | ||
usize::MAX, | ||
) | ||
.unwrap(); | ||
Ok(ContractClass::V1(casm.try_into().unwrap())) | ||
} | ||
|
||
/// Compile a CompressedLegacyContractClass to a ContractClass V0 using cairo_lang_starknet_classes. | ||
pub fn legacy_to_contract_class_v0( | ||
legacy: CompressedLegacyContractClass, | ||
) -> StateResult<ContractClass> { | ||
let as_str = decode_reader(legacy.program).unwrap(); | ||
let program = Program::from_bytes(as_str.as_bytes(), None).unwrap(); | ||
let entry_points_by_type = map_entry_points_by_type_legacy(legacy.entry_points_by_type); | ||
let inner = Arc::new(ContractClassV0Inner { program, entry_points_by_type }); | ||
Ok(ContractClass::V0(ContractClassV0(inner))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.