Skip to content

Commit 35e9bfe

Browse files
central_systest_blobs: declare the test contract
1 parent 230aacb commit 35e9bfe

3 files changed

Lines changed: 62 additions & 129 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9
1+
10

crates/central_systest_blobs/resources/preconfirmed_block.json

Lines changed: 33 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"block_number": 3,
2+
"block_number": 4,
33
"pre_confirmed_block": {
44
"l1_da_mode": "CALLDATA",
55
"l1_data_gas_price": {
@@ -17,142 +17,73 @@
1717
"sequencer_address": "0x1000",
1818
"starknet_version": "0.14.3",
1919
"status": "PRE_CONFIRMED",
20-
"timestamp": 1003,
20+
"timestamp": 1004,
2121
"transaction_receipts": [
2222
{
23-
"actual_fee": "0x642df9",
23+
"actual_fee": "0x6d1f42b7",
2424
"events": [
2525
{
2626
"data": [
27-
"0x0",
2827
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
29-
"0xffffffffffffffffffffffffffffffff",
28+
"0x1000",
29+
"0x6d1f42b7",
3030
"0x0"
3131
],
3232
"from_address": "0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83",
3333
"keys": [
3434
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
3535
]
36-
},
37-
{
38-
"data": [
39-
"0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846",
40-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
41-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955"
42-
],
43-
"from_address": "0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83",
44-
"keys": [
45-
"0x9d4a59b844ac9d98627ddba326ab3707a7d7e105fd03c777569d0f61a91f1e"
46-
]
47-
},
48-
{
49-
"data": [
50-
"0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846",
51-
"0x0",
52-
"0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846"
53-
],
54-
"from_address": "0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83",
55-
"keys": [
56-
"0x2b23b0c08c7b22209aea4100552de1b7876a49f04ee5a4d94f83ad24bc4ec1c"
57-
]
58-
},
59-
{
60-
"data": [
61-
"0x251e864ca2a080f55bce5da2452e8cfcafdbc951a3e7fff5023d558452ec228",
62-
"0x0",
63-
"0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846"
64-
],
65-
"from_address": "0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83",
66-
"keys": [
67-
"0x2b23b0c08c7b22209aea4100552de1b7876a49f04ee5a4d94f83ad24bc4ec1c"
68-
]
6936
}
7037
],
7138
"execution_resources": {
7239
"builtin_instance_counter": {
7340
"pedersen_builtin": 4,
74-
"poseidon_builtin": 21,
75-
"range_check_builtin": 90
41+
"poseidon_builtin": 15,
42+
"range_check_builtin": 72
7643
},
7744
"data_availability": {
7845
"l1_data_gas": 0,
79-
"l1_gas": 13223,
46+
"l1_gas": 2754,
8047
"l2_gas": 0
8148
},
8249
"n_memory_holes": 0,
83-
"n_steps": 4442,
50+
"n_steps": 3523,
8451
"total_gas_consumed": {
8552
"l1_data_gas": 0,
86-
"l1_gas": 19284,
87-
"l2_gas": 6546085
53+
"l1_gas": 2754,
54+
"l2_gas": 1830762485
8855
}
8956
},
9057
"execution_status": "SUCCEEDED",
9158
"l2_to_l1_messages": [],
92-
"transaction_hash": "0x1d4338e4e7b409a7ebb487b65fdbe6ac72fb5af7c513ac7d1e955445c75526e",
59+
"transaction_hash": "0x5243be6398910bcd98bfbec1271759489364e2e35a73c1f42c0a83482c61aca",
9360
"transaction_index": 0
9461
}
9562
],
9663
"transaction_state_diffs": [
9764
{
98-
"declared_classes": [],
99-
"deployed_contracts": [
65+
"declared_classes": [
10066
{
101-
"address": "0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83",
102-
"class_hash": "0x15b873cb22fcde9b9af95b5e72b0a00219fa73a393467325ff0407e0fa0c7"
67+
"class_hash": "0x4b0dc3014cc21eeeeba97610d8fb3eaf61c428c513a2e9bfcf1b7beb9cb99c0",
68+
"compiled_class_hash": "0x50cb22f072d8c735911ff906272d7f4256b8fa8aea1c8c624f879f343694870"
10369
}
10470
],
71+
"deployed_contracts": [],
10572
"migrated_compiled_classes": [],
10673
"nonces": {
107-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955": "0x2"
74+
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955": "0x3"
10875
},
10976
"old_declared_contracts": [],
11077
"replaced_classes": [],
11178
"storage_diffs": {
11279
"0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83": [
113-
{
114-
"key": "0x3fc801c47df4de8d5835f8bfd4d0b8823ba63e5a3f278086901402d680abfc",
115-
"value": "0xa"
116-
},
117-
{
118-
"key": "0xb6ce5410fca59d078ee9b2a4371a9d684c530d697c64fbef0ae6d5e8f0ac72",
119-
"value": "0x5354524b"
120-
},
121-
{
122-
"key": "0x110e2f729c9c2b988559994a3daccd838cf52faf88e18101373e67dd061455a",
123-
"value": "0xffffffffffffffffffffffffffffffff"
124-
},
125-
{
126-
"key": "0x1390569bb0a3a722eb4228e8700301347da081211d5c2ded2db22ef389551ab",
127-
"value": "0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955"
128-
},
129-
{
130-
"key": "0x1f0d4aa99431d246bac9b8e48c33e888245b15e9678f64f9bdfc8823dc8f979",
131-
"value": "0x12"
132-
},
133-
{
134-
"key": "0x341c1bdfd89f69748aa00b5742b03adbffd79b8e80cab5c50d91cd8c2a79be1",
135-
"value": "0x537461726b4e657420546f6b656e"
136-
},
137-
{
138-
"key": "0x38bb9518f707d6868da0178f4ac498e320441f8f7e11ff8a35ed4ea8286e693",
139-
"value": "0x4cc2702427a1c4fae71487e57751056b882e8ff488e5d0a128e221502e130fd"
140-
},
141-
{
142-
"key": "0x51ff9d8e3b9d9153881c6d021c07e41e820360c3abbff54b127a8bc6d613574",
143-
"value": "0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846"
144-
},
145-
{
146-
"key": "0x67eebb8a37da29031c921351ac6573033c0e3db1d2f205e01a4339afd272a14",
147-
"value": "0x3711c9d994faf6055172091cb841fd4831aa743e6f3315163b06a122c841846"
148-
},
14980
{
15081
"key": "0x6fba6554adab51d0272b896b6f41768bd0491e5ad59c39fab38e65767974793",
151-
"value": "0xffffffffffffffffffffffffffffffff"
82+
"value": "0xffffffffffffffffffffffff92e0bd48"
15283
},
15384
{
154-
"key": "0x7fe3b989a8a0b6382b1cd4c7ff6437964c6d78cbe865f9c6f75678414fba139",
155-
"value": "0x1"
85+
"key": "0x723973208639b7839ce298f7ffea61e3f9533872defd7abdb91023db4658812",
86+
"value": "0x6d1f42b7"
15687
}
15788
]
15889
}
@@ -161,52 +92,34 @@
16192
"transactions": [
16293
{
16394
"account_deployment_data": [],
164-
"calldata": [
165-
"0x1",
166-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
167-
"0x2730079d734ee55315f4f141eaed376bddd8c2133523d223a344c5604e0f7f8",
168-
"0xd",
169-
"0x15b873cb22fcde9b9af95b5e72b0a00219fa73a393467325ff0407e0fa0c7",
170-
"0x0",
171-
"0x9",
172-
"0x537461726b4e657420546f6b656e",
173-
"0x5354524b",
174-
"0x12",
175-
"0xffffffffffffffffffffffffffffffff",
176-
"0x0",
177-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
178-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
179-
"0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
180-
"0xa",
181-
"0x0"
182-
],
95+
"class_hash": "0x4b0dc3014cc21eeeeba97610d8fb3eaf61c428c513a2e9bfcf1b7beb9cb99c0",
96+
"compiled_class_hash": "0x50cb22f072d8c735911ff906272d7f4256b8fa8aea1c8c624f879f343694870",
18397
"fee_data_availability_mode": 0,
184-
"nonce": "0x1",
98+
"nonce": "0x2",
18599
"nonce_data_availability_mode": 0,
186100
"paymaster_data": [],
187-
"proof_facts": [],
188101
"resource_bounds": {
189102
"L1_DATA_GAS": {
190-
"max_amount": "0x0",
191-
"max_price_per_unit": "0x1"
103+
"max_amount": "0x186a0",
104+
"max_price_per_unit": "0x3b9aca00"
192105
},
193106
"L1_GAS": {
194-
"max_amount": "0x0",
195-
"max_price_per_unit": "0x1"
107+
"max_amount": "0x5f5e100",
108+
"max_price_per_unit": "0x174876e800"
196109
},
197110
"L2_GAS": {
198-
"max_amount": "0x2540be400",
199-
"max_price_per_unit": "0x0"
111+
"max_amount": "0x16345785d8a0000",
112+
"max_price_per_unit": "0x3b9aca00"
200113
}
201114
},
202115
"sender_address": "0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
203116
"signature": [
204-
"0x3350c14db6f907c832c5ba9841e154465e577448023b00319ae8547c2d5eef1",
205-
"0x71c8b5707779bd454fd89a7119d36c1d733704badf2cb3624054aaa15c0601f"
117+
"0x147f1b7ec5f3836d7bd3be39af5136cb75f113deebcf7d1962da19ef00d8719",
118+
"0x4d083fb99ab11fb5a577a559c27f9e65c4de397a735054cd6e038716434b53b"
206119
],
207120
"tip": "0x0",
208-
"transaction_hash": "0x1d4338e4e7b409a7ebb487b65fdbe6ac72fb5af7c513ac7d1e955445c75526e",
209-
"type": "INVOKE_FUNCTION",
121+
"transaction_hash": "0x5243be6398910bcd98bfbec1271759489364e2e35a73c1f42c0a83482c61aca",
122+
"type": "DECLARE",
210123
"version": "0x3"
211124
}
212125
]

crates/central_systest_blobs/src/cende_blob_regression_test.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,29 @@ impl BlobFactory {
442442
Calldata(Arc::new([vec![Felt::ONE], single_calldata.0.as_slice().to_vec()].concat()))
443443
}
444444

445-
fn boostrap_declare_tx(&mut self, contract: FeatureContract) {
446-
let sender_address = ExecutableDeclareTx::bootstrap_address();
445+
/// If the sender address is None, create a bootstrap declare tx.
446+
/// Otherwise, create a regular declare tx (with fees).
447+
fn make_declare_tx(&mut self, contract: FeatureContract, sender: Option<ContractAddress>) {
448+
let (bootstrap_mode, sender_address, resource_bounds, nonce) = match sender {
449+
None => (
450+
true,
451+
ExecutableDeclareTx::bootstrap_address(),
452+
AllResourceBounds::new_unlimited_gas_no_fee_enforcement(),
453+
Nonce::default(),
454+
),
455+
Some(sender_address) => (
456+
false,
457+
sender_address,
458+
*NON_TRIVIAL_RESOURCE_BOUNDS,
459+
self.nonce_manager.next(sender_address),
460+
),
461+
};
447462
let sierra = contract.get_sierra();
448463
let class_hash = sierra.calculate_class_hash();
449464
let compiled_class_hash = contract.get_compiled_class_hash(&HashVersion::V2);
450-
let resource_bounds = AllResourceBounds::new_unlimited_gas_no_fee_enforcement();
451-
let nonce = Nonce::default();
452465

453466
// Create internal tx.
454-
let internal_declare_without_hash = InternalRpcDeclareTransactionV3 {
467+
let mut internal_declare_without_hash = InternalRpcDeclareTransactionV3 {
455468
sender_address,
456469
nonce,
457470
class_hash,
@@ -467,6 +480,10 @@ impl BlobFactory {
467480
let tx_hash = internal_declare_without_hash
468481
.calculate_transaction_hash(&CHAIN_ID, &TransactionVersion::THREE)
469482
.unwrap();
483+
// If not bootrap mode, sign the tx.
484+
let signature =
485+
if !bootstrap_mode { Self::sign_tx(tx_hash) } else { TransactionSignature::default() };
486+
internal_declare_without_hash.signature = signature;
470487
let internal_tx = InternalConsensusTransaction::RpcTransaction(InternalRpcTransaction {
471488
tx: InternalRpcTransactionWithoutTxHash::Declare(internal_declare_without_hash.clone()),
472489
tx_hash,
@@ -810,18 +827,19 @@ async fn test_make_data() {
810827
// 3. deploy account (with zero fees).
811828
// 4. deploy ERC20 contract from the account (with zero fees), while minting some tokens to the
812829
// sender account.
813-
// TODO(Dori): the rest of the txs.
814830
// (from this point - all txs include non-zero fees, and no more bootstrap declares)
815831
// 5. declare the test contract.
832+
// TODO(Dori): the rest of the txs.
816833
// 6. deploy the test contract.
817834
// 7. deploy another instance of the test contract.
818835
// 8. invoke the test contract: something with a state change.
819836
// 9. invoke the test contract: test syscalls.
820837
let erc20_contract = FeatureContract::ERC20(CairoVersion::Cairo1(RunnableCairo1::Casm));
821838
let account_with_real_validate = FeatureContract::AccountWithRealValidate(RunnableCairo1::Casm);
822-
blob_factory.boostrap_declare_tx(erc20_contract);
839+
let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm));
840+
blob_factory.make_declare_tx(erc20_contract, None);
823841
blob_factory.close_block().await;
824-
blob_factory.boostrap_declare_tx(account_with_real_validate);
842+
blob_factory.make_declare_tx(account_with_real_validate, None);
825843
blob_factory.close_block().await;
826844
let operator_address = blob_factory.make_free_deploy_account_tx(account_with_real_validate);
827845
EXPECTED_OPERATOR_ADDRESS.assert_eq(&operator_address.to_string());
@@ -842,6 +860,8 @@ async fn test_make_data() {
842860
false, // charge fee
843861
);
844862
EXPECTED_FEE_TOKEN_ADDRESS.assert_eq(&token_address.to_string());
863+
blob_factory.close_block().await;
864+
blob_factory.make_declare_tx(test_contract, Some(*OPERATOR_ADDRESS));
845865

846866
let (blobs, preconfirmed_block) = blob_factory.finalize().await;
847867
expect_file![CHAIN_INFO_PATH].assert_eq(&serde_json::to_string_pretty(&chain_info).unwrap());

0 commit comments

Comments
 (0)