Skip to content

Commit cfef6e4

Browse files
central_systest_blobs: first two bootstrap declares
1 parent 6f48b03 commit cfef6e4

3 files changed

Lines changed: 77 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/central_systest_blobs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ blockifier_test_utils.workspace = true
1818
expect-test.workspace = true
1919
google-cloud-storage.workspace = true
2020
http.workspace = true
21+
mockall.workspace = true
2122
serde_json.workspace = true
2223
starknet_api = { workspace = true, features = ["testing"] }
2324
starknet_committer = { workspace = true, features = ["testing"] }

crates/central_systest_blobs/src/cende_blob_regression_test.rs

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use blockifier::blockifier_versioned_constants::VersionedConstants;
1616
use blockifier::bouncer::BouncerConfig;
1717
use blockifier::context::{BlockContext, ChainInfo};
1818
use blockifier::state::cached_state::StateMaps;
19+
use blockifier::test_utils::contracts::FeatureContractTrait;
1920
use blockifier::test_utils::dict_state_reader::DictStateReader;
2021
use blockifier_test_utils::contracts::FeatureContract;
2122
use expect_test::expect_file;
@@ -25,14 +26,33 @@ use google_cloud_storage::http::objects::download::Range;
2526
use google_cloud_storage::http::objects::get::GetObjectRequest;
2627
use google_cloud_storage::http::objects::upload::{Media, UploadObjectRequest, UploadType};
2728
use google_cloud_storage::http::Error as GcsError;
29+
use mockall::predicate::eq;
2830
use starknet_api::block::{BlockHash, BlockInfo, BlockNumber, BlockTimestamp};
2931
use starknet_api::block_hash::block_hash_calculator::PartialBlockHashComponents;
3032
use starknet_api::consensus_transaction::InternalConsensusTransaction;
3133
use starknet_api::contract_address;
32-
use starknet_api::core::{ChainId, OsChainInfo};
33-
use starknet_api::executable_transaction::AccountTransaction as ExecutableAccountTx;
34+
use starknet_api::contract_class::compiled_class_hash::HashVersion;
35+
use starknet_api::core::{ChainId, Nonce, OsChainInfo};
36+
use starknet_api::data_availability::DataAvailabilityMode;
37+
use starknet_api::executable_transaction::{
38+
AccountTransaction as ExecutableAccountTx,
39+
DeclareTransaction as ExecutableDeclareTransaction,
40+
};
3441
use starknet_api::hash::StateRoots;
42+
use starknet_api::rpc_transaction::{
43+
InternalRpcDeclareTransactionV3,
44+
InternalRpcTransaction,
45+
InternalRpcTransactionWithoutTxHash,
46+
};
3547
use starknet_api::test_utils::TEST_SEQUENCER_ADDRESS;
48+
use starknet_api::transaction::fields::{
49+
AccountDeploymentData,
50+
AllResourceBounds,
51+
PaymasterData,
52+
Tip,
53+
TransactionSignature,
54+
};
55+
use starknet_api::transaction::{DeclareTransaction, TransactionHasher, TransactionVersion};
3656
use starknet_committer::db::facts_db::FactsDb;
3757
use starknet_committer::db::forest_trait::StorageInitializer;
3858
use starknet_patricia_storage::map_storage::MapStorage;
@@ -78,14 +98,12 @@ struct BlockData {
7898

7999
struct BlobFactory {
80100
chain_info: ChainInfo,
81-
#[expect(dead_code)]
82101
class_manager: MockClassManagerClient,
83102

84103
// Finalized blocks.
85104
blocks: Vec<BlockData>,
86105

87106
// Transactions for the next block.
88-
#[expect(dead_code)]
89107
next_txs: Vec<TxPair>,
90108

91109
// Context.
@@ -142,8 +160,59 @@ impl BlobFactory {
142160
// =====================
143161

144162
#[expect(dead_code)]
145-
fn boostrap_declare_tx(&mut self, _contract: FeatureContract) {
146-
unimplemented!()
163+
fn boostrap_declare_tx(&mut self, contract: FeatureContract) {
164+
let sender_address = ExecutableDeclareTransaction::bootstrap_address();
165+
let sierra = contract.get_sierra();
166+
let class_hash = sierra.calculate_class_hash();
167+
let compiled_class_hash = contract.get_compiled_class_hash(&HashVersion::V2);
168+
let resource_bounds = AllResourceBounds::new_unlimited_gas_no_fee_enforcement();
169+
let nonce = Nonce::default();
170+
171+
// Create internal tx.
172+
let internal_declare_without_hash = InternalRpcDeclareTransactionV3 {
173+
sender_address,
174+
nonce,
175+
class_hash,
176+
compiled_class_hash,
177+
resource_bounds,
178+
signature: TransactionSignature::default(),
179+
tip: Tip::default(),
180+
paymaster_data: PaymasterData::default(),
181+
account_deployment_data: AccountDeploymentData::default(),
182+
nonce_data_availability_mode: DataAvailabilityMode::L1,
183+
fee_data_availability_mode: DataAvailabilityMode::L1,
184+
};
185+
let tx_hash = internal_declare_without_hash
186+
.calculate_transaction_hash(&CHAIN_ID, &TransactionVersion::THREE)
187+
.unwrap();
188+
let internal_tx = InternalConsensusTransaction::RpcTransaction(InternalRpcTransaction {
189+
tx: InternalRpcTransactionWithoutTxHash::Declare(internal_declare_without_hash.clone()),
190+
tx_hash,
191+
});
192+
193+
// Create executable tx.
194+
let executable = ExecutableDeclareTransaction::create(
195+
DeclareTransaction::V3(internal_declare_without_hash.into()),
196+
contract.get_class_info(),
197+
&CHAIN_ID,
198+
)
199+
.unwrap();
200+
201+
// Mock the class manager.
202+
// The class manager methods may not be called if a blob is not created with this declare.
203+
self.class_manager
204+
.expect_get_sierra()
205+
.with(eq(class_hash))
206+
.times(..=1)
207+
.returning(move |_| Ok(Some(sierra.clone())));
208+
self.class_manager
209+
.expect_get_executable()
210+
.with(eq(class_hash))
211+
.times(..=1)
212+
.returning(move |_| Ok(Some(contract.get_class())));
213+
214+
// Return the transactions.
215+
self.next_txs.push((executable.into(), internal_tx));
147216
}
148217

149218
// =====================

0 commit comments

Comments
 (0)