diff --git a/starknet/src/L1_headers_store/contract.cairo b/starknet/src/L1_headers_store/contract.cairo index 1ef1fd1..b4c29ab 100644 --- a/starknet/src/L1_headers_store/contract.cairo +++ b/starknet/src/L1_headers_store/contract.cairo @@ -235,7 +235,7 @@ pub mod L1HeaderStore { }; let provided_rlp_hash = keccak_words64(header_ints_sequence); - let provided_rlp_hash_u256 = words64_to_u256(provided_rlp_hash.values); + let provided_rlp_hash_u256 = words64_to_u256(provided_rlp_hash.values, provided_rlp_hash.len_bytes); assert!( child_block_parent_hash == provided_rlp_hash_u256, diff --git a/starknet/src/fact_registry/contract.cairo b/starknet/src/fact_registry/contract.cairo index c34bb03..41a8b87 100644 --- a/starknet/src/fact_registry/contract.cairo +++ b/starknet/src/fact_registry/contract.cairo @@ -192,7 +192,7 @@ pub mod FactRegistry { slot: u256, proof_sizes_bytes: Array, proofs_concat: Array, - ) -> felt252 { + ) -> Result { let account_state_root = self.verified_account_storage_hash.read((account, block)); assert!(account_state_root != 0, "FactRegistry: block state root not found"); @@ -205,15 +205,14 @@ pub mod FactRegistry { ); match result { - Result::Err(e) => { e }, + Result::Err(e) => { Result::Err(e) }, Result::Ok(result) => { if !result.is_some() { - 'Result Found No Value' + Result::Err('Result is None') } else { let result_value = words64_to_int(result.unwrap()); self.verified_storage.write((account, block, slot), (true, result_value)); - let res: felt252 = result_value.try_into().unwrap(); - res + Result::Ok(result_value) } } } diff --git a/starknet/src/fact_registry/interface.cairo b/starknet/src/fact_registry/interface.cairo index 25399f4..5368b9e 100644 --- a/starknet/src/fact_registry/interface.cairo +++ b/starknet/src/fact_registry/interface.cairo @@ -17,7 +17,7 @@ pub trait IFactRegistry { slot: u256, proof_sizes_bytes: Array, proofs_concat: Array, - ) -> felt252; + ) -> Result; fn get_storage( ref self: TState, block: u64, account: starknet::EthAddress, slot: u256, ) -> Option; diff --git a/starknet/src/library/rlp_utils.cairo b/starknet/src/library/rlp_utils.cairo index 8d0de43..dee9cb4 100644 --- a/starknet/src/library/rlp_utils.cairo +++ b/starknet/src/library/rlp_utils.cairo @@ -190,12 +190,12 @@ pub fn extract_data(rlp: Words64Sequence, start: usize, size: u64) -> Words64Seq if lastword_right_shift < left_shift { right_part = BitShift::shl( - value_at_end_word, (left_shift - lastword_right_shift).into() * 8 + value_at_end_word, (left_shift - lastword_right_shift + 1).into() * 8 ); } else { right_part = - BitShift::shr( - value_at_end_word, (lastword_right_shift - left_shift).into() * 8 + BitShift::shl( + value_at_end_word, (lastword_right_shift - left_shift + 1).into() * 8 ); } } else { diff --git a/starknet/src/library/words64_utils.cairo b/starknet/src/library/words64_utils.cairo index f35efb2..ab5556d 100644 --- a/starknet/src/library/words64_utils.cairo +++ b/starknet/src/library/words64_utils.cairo @@ -30,7 +30,7 @@ impl U256Words64 of Words64Trait { /// `from_words64` converts a `Words64Sequence` back into an `u256`. fn from_words64(self: Words64Sequence) -> u256 { - words64_to_u256(self.values) + words64_to_u256(self.values, self.len_bytes) } } @@ -67,6 +67,7 @@ impl EthAddressWords64 of Words64Trait { /// /// # Arguments /// * `input` - A `Span` containing up to four 64-bit words to be converted into a `u256`. +/// * `len_bytes` - The length of the `input` in bytes. /// /// # Returns /// * `u256` - A value representing the combination of the input words. @@ -76,18 +77,34 @@ impl EthAddressWords64 of Words64Trait { /// /// This function takes a `Span` representing a `Words64Sequence` i.e sequence of up to four 64-bit words, /// and combines them into a single `u256` value by using the shift and bitwise operator. -pub fn words64_to_u256(input: Span) -> u256 { +pub fn words64_to_u256(input: Span, len_bytes: usize) -> u256 { assert!(input.len() <= 4, "input length must be less than or equal to 4"); if input.len() == 0 { return 0; } - let l0: u256 = BitShift::shl((*input.at(0)).into(), 192_u256); - let l1 = BitShift::shl((*input.at(1)).into(), 128); - let l2 = BitShift::shl((*input.at(2)).into(), 64); - let l3 = (*input.at(3)).into(); + if input.len() == 1 { + return (*input.at(0)).into(); + } else if input.len() == 2 { + let extraBitOffset: u256 = (16 - len_bytes.into()) * 8; + let l0: u256 = BitShift::shl((*input.at(0)).into(), 64_u256 - extraBitOffset); + let l1 = (*input.at(1)).into(); + return BitOr::bitor(l0, l1); + } else if input.len() == 3 { + let extraBitOffset: u256 = (24 - len_bytes.into()) * 8; + let l0: u256 = BitShift::shl((*input.at(0)).into(), 128_u256 - extraBitOffset); + let l1 = BitShift::shl((*input.at(1)).into(), 64 - extraBitOffset); + let l2 = (*input.at(2)).into(); + return BitOr::bitor(BitOr::bitor(l0, l1), l2); + } else { + let extraBitOffset: u256 = (32 - len_bytes.into()) * 8; + let l0: u256 = BitShift::shl((*input.at(0)).into(), 192_u256 - extraBitOffset); + let l1 = BitShift::shl((*input.at(1)).into(), 128 - extraBitOffset); + let l2 = BitShift::shl((*input.at(2)).into(), 64 - extraBitOffset); + let l3 = (*input.at(3)).into(); - return (BitOr::bitor(BitOr::bitor(BitOr::bitor(l0, l1), l2), l3)).into(); + return (BitOr::bitor(BitOr::bitor(BitOr::bitor(l0, l1), l2), l3)).into(); + } } /// Converts a `Words64Sequence` into a `u256` value. @@ -224,15 +241,25 @@ fn words64_to_nibbles_rec(word: u64, nibbles_len: usize, mut acc: Array) -> #[cfg(test)] mod tests { #[test] - fn test_words64_to_u256() { + fn test_words64_to_u256_default_size() { let input = array![ 0xFFFFFFFFFFFFFFFF, 0xAAAAAAAAAAAAAAAA, 0xBBBBBBBBBBBBBBBB, 0xCCCCCCCCCCCCCCCC ]; - let result = super::words64_to_u256(input.span()); + let result = super::words64_to_u256(input.span(), 32); assert_eq!(result, 0xffffffffffffffffaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbcccccccccccccccc); } + #[test] + fn test_words64_to_u256_different_size() { + let input = array![ + 0xFFFFFFFFFFFFFFFF, 0xAAAAAAAAAAAAAAAA, 0xBBBBBBBBBBBBBBBB, 0xCCCCCCCCCCCC + ]; + + let result = super::words64_to_u256(input.span(), 30); + + assert_eq!(result, 0xffffffffffffffffaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbcccccccccccc); + } #[test] fn test_words64_to_nibbles_rec() { diff --git a/starknet/src/testing/proofs/account.cairo b/starknet/src/testing/proofs/account.cairo index fc7aedd..43f22d9 100644 --- a/starknet/src/testing/proofs/account.cairo +++ b/starknet/src/testing/proofs/account.cairo @@ -2305,3 +2305,489 @@ pub fn PROOF_4() -> AccountProof { ] } } + +pub fn PROOF_mainnet_weth() -> AccountProof { + AccountProof { + address: 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2_u256.into(), + balance: 0x2378c831c94842bf20ce3, + code_hash: 0xd0a06b12ac47863b5c7be4185c2deaad1c61557033f56c7d4ea74429cbb25e23, + nonce: 0x1, + storage_hash: 0x4417357b33abc601987a849c678edeadb670c824198aeb000b2d02a47b278b2e, + bytes: array![ + 532, + 532, + 532, + 532, + 532, + 532, + 276, + 83, + 115 + ], + data: array![ + 17942923244466733886, + 1143347056447862615, + 483207580511556251, + 14832636791752721149, + 4657088919268323655, + 16005619128065434373, + 2836871308024574275, + 12298253118188945580, + 15460787361207583719, + 9586431829350304892, + 16603962304786861308, + 538074330429971169, + 8009204375199195266, + 16254513472959853837, + 2617245787521559978, + 13321160999201907314, + 3816236148435735968, + 6466600064936168686, + 11803855190130917607, + 2238137930303903153, + 9146983090506757732, + 11544005538105610806, + 8113312180804097474, + 12789644674463442651, + 15785385315228055297, + 11862632206978965278, + 4087413414268986483, + 6197618085735556060, + 9136116708788913597, + 12890885445535489489, + 2270146567647309383, + 3950934985939632984, + 15836609136266131635, + 8590589492487167324, + 15345590162441370116, + 3843548080099376286, + 4571498972209124173, + 6735558193776949067, + 18304000227704293696, + 8537896457747304614, + 16838094547640634574, + 1542482751001784160, + 18308212110178117985, + 1714688064994103270, + 4997268471152027112, + 14526624518451732675, + 5877135474249972557, + 12417245815039197204, + 8258577399517022031, + 13199293903899945888, + 4094392973217816139, + 17597841640599614639, + 16364864424967241474, + 3456013488942368721, + 11592475463218372886, + 11796677187015612625, + 1161323687235024099, + 35962776160429532, + 8764130135170511823, + 10349453024755977185, + 14270286645599581127, + 2288311512866921347, + 4082689469342374363, + 18369604443170139241, + 8921130777039541507, + 14534127000439790398, + 1931599488, + 17942923245695900470, + 11809864406668696579, + 6766702047181228626, + 18228335912972422939, + 3221896039341678704, + 5420169849240753437, + 10509916871068898387, + 13696553951866932538, + 9175524844960231971, + 15467848336809198458, + 14240593964057589437, + 14402628373498783917, + 17685091648653795441, + 13751507572755987721, + 11131782471574675154, + 10911298102575730357, + 6408155944518220448, + 11951722744725113452, + 4337005495718581342, + 11393803803756081655, + 7112141404060909244, + 11586536891220671279, + 7409524559028803960, + 12317222398477937093, + 1959646032895773276, + 6097944880629187191, + 613508395858279418, + 2584680369092899898, + 6553512091526301163, + 1471164601626930651, + 2488612424123860776, + 16444862168459023242, + 6467627321203623612, + 1631110796527693872, + 3293625274125673721, + 126979398462703177, + 12305999056712918494, + 1663924793352619747, + 9127732517715672403, + 15460946287451600262, + 16557041225319638692, + 12902513674708627247, + 7379355018684130132, + 6084913719150613170, + 5138019203364599291, + 1226510238270398572, + 5557327467463296583, + 4673681596132282409, + 6526262133235204644, + 14936035678825994144, + 8744472530477397751, + 377147735525712649, + 352638661400789980, + 15502960036579178406, + 11566210631023711224, + 18148545282516890771, + 12953870464353206838, + 14982306421010764545, + 11430306769810209824, + 17045750853054225794, + 1105366003318003171, + 11725514451773933708, + 189045974619583826, + 17241164156884849859, + 13757475774464773381, + 2963110631898208672, + 2415400320, + 17942923246055757592, + 17989386363088460095, + 9348998069371538111, + 13548375071090407629, + 7137801560587219864, + 4099118112296046229, + 14751578638501925293, + 6715921526294052005, + 2618126654754532913, + 3153410155232239362, + 13186382206855314525, + 17305364199516038625, + 4873556130175492178, + 3393472284119801891, + 17828579881442310788, + 5857702594655532911, + 7797292605207882400, + 13622779332607232157, + 2313987146461414751, + 6938034205544725527, + 12967317865070013990, + 11535339055156913101, + 5796739283566284476, + 4215581150541336757, + 12269687908533614302, + 4440713325110814361, + 3525235467561728647, + 9275447700637973321, + 4496094321400109478, + 8674391060678783537, + 11287720975446467874, + 2389127980682328975, + 104492419137343347, + 15773780319130642434, + 18390868484425841380, + 7422513391682300199, + 9146516733256750681, + 9076110856650549102, + 14210703510257906061, + 1758691533662906422, + 7540740360610387151, + 17526058494050995857, + 6474016965118558663, + 4435097225114596975, + 1040983976464686500, + 15373132083593650355, + 15115155703119166259, + 4948222151730575153, + 7353209772642225376, + 12733036463196122272, + 8304111331244529516, + 18221252576773058816, + 13715657992765999118, + 11514610725577419659, + 11540011005881618185, + 12120829111323315578, + 5239658931214572602, + 2873365255156346388, + 15393583565927209863, + 8890690063384150993, + 11851245244870164516, + 11753235950611723584, + 12783362101970379840, + 214997671655517645, + 4953844425017601266, + 6801422952021727231, + 3783244672, + 17942923244835656007, + 17935850928160920208, + 1149857788473566297, + 5708728024945690352, + 3109479848802247590, + 9515087640195598204, + 10681447424663607586, + 12983975041127811101, + 16275783689128949576, + 10965605704327571439, + 7434955351170724476, + 2000940098288932166, + 18005482361812983835, + 6721353623640934287, + 10118564283511317439, + 97349289494178888, + 12009063691781920672, + 11139433933725472921, + 13128806567626921821, + 11981447294239488516, + 12761127681706049120, + 11557557530194929038, + 14650638117321933801, + 1974454788273795632, + 5057558288736969612, + 8259742950503354692, + 109291997691928348, + 14945065087888261942, + 11683046811315111273, + 10342129727998515592, + 1813299840576221383, + 11827904651614104780, + 12266557762594821452, + 126871135173309828, + 1586475944357056782, + 9024002534000940572, + 16226644218608922807, + 8933716022022424807, + 3749316920917222721, + 7730984685265422916, + 1597032142116133438, + 13203723576112341714, + 6719202754237907265, + 12028108308590046296, + 3631196263852146394, + 15567748108994912375, + 16015441475485544824, + 5660713854546582257, + 2473964543594673928, + 18436728943387956128, + 13821155065879163558, + 6669609390259375752, + 9742441992511931199, + 17797187752101010925, + 11554467617177570175, + 2853077225369295613, + 13209299524315263948, + 17443260759797533371, + 1774583150144612836, + 5973076662783269288, + 3140682256812054263, + 12359509288266240046, + 11055950429346683726, + 17342464569822820294, + 14194573580907422700, + 5313347316418570469, + 4277671040, + 17942923245995740724, + 13568672643306914495, + 6482706907567490839, + 1328756161885942017, + 90360436657324079, + 15941817423242038002, + 1988623229775240849, + 4306154096416964959, + 17057879658992770267, + 8702967464530494586, + 9615630158461874543, + 2878191974630524509, + 13631056397083385991, + 18311029193689468711, + 13578679088716004991, + 6374355247462415972, + 14895918676691836832, + 17763075964981807934, + 6716552296703449276, + 7221418553133038805, + 2511208740801092174, + 11553343443703912949, + 12088918027404928124, + 18324863904890470216, + 17279059810183320010, + 12006701394606109026, + 3268264182130110982, + 4409172064618231695, + 10998420340261755456, + 12720312411831274221, + 10170745771315607924, + 8502437792453675963, + 10047523358634637372, + 14904948429577100761, + 4468397974459319615, + 982986890919929615, + 12209369860714924741, + 2374941416429969697, + 10622276546620133619, + 4781953349654807917, + 13502895966811738218, + 7517543748497061304, + 16899793499703977053, + 14282412542988502824, + 7803664618690538860, + 12126316574658633786, + 16811679883333265614, + 15121192534326250832, + 3925211887518001064, + 18256608120162195360, + 8536165819025143017, + 9155667461935632144, + 10676305365944047392, + 11150222892397323749, + 11587162808042749428, + 439259894288661533, + 11929768338714373504, + 5762575977978927818, + 621683748313262433, + 6489144268676485544, + 1068723653945125923, + 3976506448728195268, + 18050322692059218461, + 16999827347762024536, + 6328354811894273743, + 12843702436188051942, + 2652046208, + 17942923245665669533, + 15854889532068377410, + 10816231828990707414, + 2591938510163127952, + 7507988240696964793, + 10795353855988242226, + 10457412635052872482, + 8247239035789276650, + 2428216920980326187, + 6950337980934377612, + 17078444432746767735, + 15167443522680258259, + 10857891925746491587, + 13906199307482103165, + 10368732658469690797, + 5282970555465629817, + 14809641775510632608, + 2131377312220566165, + 16580164761713754784, + 13218867911150037112, + 5045117338676639915, + 11534644983101427363, + 3201583958239849729, + 7927059973563515212, + 8791566440379916926, + 16186187303265754049, + 11529875041547072547, + 3397540433125005582, + 16693005685696696216, + 8343095074962212384, + 640644820410441211, + 14567590574450801003, + 17981332209668552228, + 6317724133476139459, + 11427370049438808652, + 17246299400109479364, + 16053737140533522912, + 5038333469410786114, + 3187858135896647555, + 15372429757928689296, + 1880949692346268987, + 5814471260362554336, + 12340018183139461991, + 14917980319047129310, + 16408365800467925277, + 18222047497648709808, + 14265602322077053055, + 5461135768906385820, + 9703815821003251229, + 4319634138961310368, + 9897340411469432250, + 11193130702634069355, + 12317742141045622628, + 2487811571921253630, + 11573896774266150257, + 6506988940290040023, + 12350862428769461316, + 16324076731645818355, + 17771320848041877820, + 15927207202175286888, + 5415084196706066193, + 8780871579684196101, + 3956589189577889993, + 15540823374657198435, + 945633106040380200, + 774429567416318027, + 4180362880, + 17942641772702646964, + 14518929282013346933, + 3079982942922789218, + 16296940619217466588, + 4989406606429278004, + 16147393382316875873, + 8251807515883869592, + 13283657839882818661, + 10716691038954627227, + 14169498033811709734, + 4164011963245329300, + 9536878713167580844, + 12913355840826093440, + 11552399888641636636, + 17861170546117904691, + 7179520253638240208, + 1442246344684871502, + 6233123312083303464, + 2247740788514251002, + 15866604761470816316, + 17795575130005182101, + 15509630351193440416, + 8470132214293737023, + 1329639297811558456, + 11640929532791350089, + 4550727684058008127, + 11539169706713804028, + 8222820627705551394, + 4845440358314160430, + 9702707105243286058, + 2567274513069605969, + 13502304170408551216, + 17094441478980696063, + 8888018635998139248, + 292388992, + 17893224221334907934, + 1134426896199219019, + 1379025013280091964, + 3273304711323044217, + 11053896936040988800, + 9259542123273814176, + 5066897059920650327, + 8204620744634557566, + 7863077354412980010, + 3391101165936999120, + 8421504, + 17902262757329982039, + 7173381874599338888, + 9841628265905562282, + 3225687585136979970, + 13281669794304295479, + 10124967811457217036, + 16402184709355549611, + 14267852746464716686, + 16045681642901346698, + 16933546886858832679, + 10029130238105686700, + 5153872091973687388, + 3308647213660729395, + 17684647613544278475, + 11689507 + ], + } +} \ No newline at end of file diff --git a/starknet/src/testing/proofs/blocks.cairo b/starknet/src/testing/proofs/blocks.cairo index 213196a..c789b1d 100644 --- a/starknet/src/testing/proofs/blocks.cairo +++ b/starknet/src/testing/proofs/blocks.cairo @@ -37,3 +37,10 @@ pub fn BLOCK_4() -> Block { state_root: 0x2045bf4ea5561e88a4d0d9afbc316354e49fe892ac7e961a5e68f1f4b9561158, } } + +pub fn BLOCK_mainnet_weth() -> Block { + Block { + number: 20376807, + state_root: 0x70048fdb62caf4fedbd4f3bd6fd3e57778c0036ecd6b98ae23d05dc8d811fb1f, + } +} \ No newline at end of file diff --git a/starknet/src/testing/proofs/storage.cairo b/starknet/src/testing/proofs/storage.cairo index 7a3a2cf..eba935b 100644 --- a/starknet/src/testing/proofs/storage.cairo +++ b/starknet/src/testing/proofs/storage.cairo @@ -1027,3 +1027,388 @@ pub fn PROOF_2() -> StorageProof { value: 0x07a8f1298f7eaa479401, } } + +pub fn PROOF_mainnet_weth() -> StorageProof { + StorageProof { + key: 0x0, + bytes: array![ + 532, + 532, + 532, + 532, + 532, + 179, + 67 + ], + data: array![ + 17942923245390246106, + 12837577508730496814, + 7000032863229579356, + 10099485054955575929, + 14356819214906382188, + 13281756032476640608, + 10164784402935319277, + 713814894695108046, + 2459739059080150815, + 10657509834563371512, + 6167674051550693100, + 9568848035092404893, + 4663944405137203346, + 6721057345412966975, + 18234935493464459090, + 10265425617602130412, + 2645511674079837600, + 2260784639935651752, + 18306881921317219906, + 14761325104275421197, + 16901856536175749127, + 11587482243449740790, + 14803191045341397963, + 11812518350025201358, + 3940373730757040010, + 14096544996721112536, + 4181811810147548052, + 2088513510160825592, + 10267651149749066379, + 7983932473982656483, + 12559401962483650644, + 2195056293444225697, + 18315709829401576937, + 14446838010294087528, + 17503121024234572990, + 11313227411384627807, + 10478258328642428316, + 14483315055554989161, + 6792067286601642301, + 1101978753879916857, + 7247934035603007544, + 5910808503066300484, + 12182043129225217098, + 7315408080513955723, + 16124790459143096851, + 11593327468062941214, + 171947801571562212, + 4358017608488831003, + 6243644608992051249, + 15185989823784696992, + 10816823274168678304, + 1892867062355566053, + 9673804790683403862, + 8685189853517434080, + 11576819279319040983, + 2204812081920618015, + 13754696856942114548, + 3860732897170713375, + 1126122751734756846, + 17085661507782878885, + 482485832398624337, + 2894232889295253456, + 8032346338709271090, + 5916917277488632719, + 4574479707742554821, + 6255686994555341771, + 4274588800, + 17942923246041438307, + 16210388240141274416, + 13805338146040285462, + 11299765685389235817, + 12163581684026319661, + 11401013563573790852, + 6640905926703321105, + 11684169375016529535, + 8032138384143038322, + 15477337700831097863, + 10118960167438460812, + 1152724371958347962, + 18273456465284669554, + 11498158798779517216, + 16763716387165656932, + 15061164883898977869, + 17189049398837993888, + 5544543512691150647, + 16202380844313566755, + 18075503549307784253, + 13330397648639996030, + 11555396488457633331, + 13215455534425184546, + 15015305107976524414, + 1325681544210001684, + 10925986617808721246, + 14143824967572486819, + 15013447260981810900, + 12158477672047466721, + 5554241211636783592, + 12524643473652365468, + 17822768592536108109, + 13080142077294731117, + 13563529948144749961, + 3380623704972020586, + 3461373277330898066, + 941387399090178633, + 11694532780982926511, + 2041578492971159885, + 11867233272073410028, + 103948128262007947, + 5466237037120119582, + 10443429724623248174, + 4261595969555188475, + 2749207731925489342, + 4328751848444239989, + 7661974948294720625, + 508504588907831739, + 3674041442161960282, + 12583297485374035616, + 15882531132525857233, + 292457139779468120, + 10960995528482569539, + 4894026218416793551, + 11593069325717820940, + 344043732669196975, + 1376188988675366367, + 10321142062253616858, + 12655295182401539469, + 5587080455474225866, + 8914997779665970948, + 11492584271115070309, + 1415151532108848353, + 10710183396641448734, + 11314261742049160878, + 962011466072356556, + 108080000, + 17942923246857937212, + 6730988262610127590, + 4441868612630079387, + 11209596515954146960, + 1501681222625391348, + 11809677849721726956, + 13514541211178065581, + 17209863663563274287, + 17488617945811710667, + 10279257980976248083, + 15021994808187552005, + 10812881056810084133, + 7340611343460507780, + 16817496515666874388, + 16745882076193812371, + 2891698764495633701, + 9325834592894673824, + 1224413193387305405, + 1322519529171570200, + 10905223165759856977, + 17888233374831227908, + 11588447094697411132, + 2699662685961418469, + 16450749920613220215, + 1139462963428025398, + 18275696801720870717, + 4167165466281945512, + 15146050204080338503, + 16225422488040096726, + 13003757986114324034, + 9326911496947770653, + 13179881061696837970, + 3681217732107064857, + 1181619445633196142, + 16827826755777429599, + 17812354951785737525, + 14500675019551838443, + 4874327888364923943, + 9751329391167684016, + 14967745247247819536, + 4146800632591291477, + 5095436235734836849, + 18269605749555787542, + 3200606372790039971, + 9775198171843858806, + 6073669208815870129, + 6860975285854189066, + 9132384769140327309, + 2638595317572526917, + 580657844422909088, + 8906601843397015887, + 17113957601242593067, + 14508431431828619949, + 12501154314671091327, + 11535227427239907583, + 16715899552042098136, + 2056348242273875046, + 15911140026505712438, + 6962806013686122002, + 4940731429389934722, + 11692046571539334932, + 3667942387339012280, + 10272324141439519178, + 15807600570344886174, + 1665566158743606543, + 16031712069526939541, + 187765120, + 17942923246885683789, + 11729014569441459883, + 5826040585411853092, + 8478938184731690811, + 15663875658256358386, + 10363171510090176026, + 6185637524070656438, + 10431693135411050197, + 1152136214273361082, + 12855110058434728132, + 2176224095043180464, + 10695537871650719183, + 5359840502016024780, + 11072480930879891898, + 14028459868438924468, + 9486546258801405193, + 11250033209318512288, + 7653199311058271052, + 10535396042247254202, + 14334956948273917427, + 8934475868126314508, + 11546546605705391398, + 10043483144343270310, + 16612731497336266056, + 9330093791860255756, + 15897983052010311043, + 16638250723309946525, + 2921447924541675571, + 3762826993250895147, + 7189047445932745018, + 9709258852918834121, + 14060244724950566204, + 3892695541392718174, + 17666978815023900071, + 2215331863664719983, + 18197614203733684102, + 6614119547849456006, + 14955425162184936965, + 4118201657347704242, + 12546828719631775416, + 12351503090887912389, + 1384410794420082470, + 4779745633994030363, + 15167866480587369281, + 17663445329260946704, + 6626275474907242559, + 14778476779589775764, + 270098109834589716, + 1386119007868398867, + 10942879784960997280, + 3159145891127690356, + 9783278345293025267, + 7678639951234118185, + 17292026254002948649, + 11546011339891027247, + 17168051059719609336, + 6040415748630491434, + 512752604183552065, + 16185950810867524580, + 13040740121958230535, + 1678540032940608612, + 10229979753979963284, + 12700609183500840201, + 4383608282874542077, + 13875192792877448205, + 17998178211321723199, + 3546286976, + 17942923245997276005, + 13249556084873721902, + 629363402100593355, + 7092174306401863272, + 9017478935239559790, + 12411100239891699101, + 2150395868992115423, + 14625472957281537510, + 17568518153017770824, + 18285054000334270461, + 18085620868485835317, + 6224877744903885655, + 11456733724524454119, + 6121685684356350168, + 6205932658542433623, + 9626573485569968732, + 7468422743316299424, + 10621846087021768798, + 13017587088507800887, + 16566980881084880782, + 15899539926531250638, + 11575616513205751047, + 18216476066232685481, + 10480627785133307647, + 16831355661612613508, + 10925803251837268861, + 12877795134212353684, + 12002765353385344976, + 7321873147822826929, + 4119843979221782219, + 11833789493981250076, + 5460927564943681991, + 13082205478151086625, + 14749122342019379170, + 15171413998649032390, + 8789263899049323801, + 9112776819423996213, + 15853204010014019756, + 12298998399966324017, + 15933135508731800368, + 13017249783967787624, + 15363900618341148270, + 6767257366681721043, + 6788406225758104682, + 17048190106607153422, + 2023253502685323371, + 14004201589078269418, + 7313885268033979286, + 15389743578160179234, + 4007297906768886176, + 12084543123881797843, + 5047653950116434949, + 4245216326906589167, + 8876360462092326313, + 11538636397965320841, + 403488195484510177, + 15485374696118283411, + 15639820979904588838, + 909814511661882772, + 13446325782378123760, + 14896947690660448612, + 10311518958435442366, + 10939701031387543596, + 6705430321787974430, + 8262823899523505024, + 1277498910699136016, + 4249338240, + 17920280590393902535, + 7104376139438737738, + 3974546937849685589, + 10029027476088988336, + 13489140155002082661, + 2078276690833885639, + 32546643332903462, + 2135228304910012997, + 16708809851538538624, + 11552266651040236778, + 17986788599284633311, + 12009599836070451005, + 582969684502042549, + 15672703707382374212, + 2350158611599566022, + 17157183498993915542, + 9851152394054529070, + 16099375261249740972, + 5766701527614283050, + 4186450176405610362, + 15140309251058277804, + 14072807258231367808, + 8421504, + 17888753058814659426, + 12165915041119877231, + 14432812759727489032, + 17741420090849424357, + 7179195578446868592, + 7305999978179618162, + 0, + 0, + 26 + ], + value: 0x577261707065642045746865720000000000000000000000000000000000001a, + } +} \ No newline at end of file diff --git a/starknet/tests/test_fact_registry.cairo b/starknet/tests/test_fact_registry.cairo index 74b2032..e3c7d47 100644 --- a/starknet/tests/test_fact_registry.cairo +++ b/starknet/tests/test_fact_registry.cairo @@ -8,6 +8,63 @@ use fossil::{ use snforge_std::start_cheat_caller_address; use super::test_utils::{setup, OWNER, STARKNET_HANDLER}; +#[test] +fn prove_all_test_success_mainnet_weth() { + let dsp = setup(); + + let block = proofs::blocks::BLOCK_mainnet_weth(); + + start_cheat_caller_address(dsp.store.contract_address, STARKNET_HANDLER()); + dsp.store.store_state_root(block.number, block.state_root); + + let account_proof = proofs::account::PROOF_mainnet_weth(); + + let _output = dsp + .registry + .prove_account( + OptionsSet::All, + account_proof.address, + block.number, + account_proof.bytes, + account_proof.data + ); + + let storage_hash = dsp + .registry + .get_verified_account_storage_hash(account_proof.address, block.number); + assert_eq!(storage_hash, account_proof.storage_hash); + + let code_hash = dsp + .registry + .get_verified_account_code_hash(account_proof.address, block.number); + assert_eq!(code_hash, account_proof.code_hash); + + let balance = dsp.registry.get_verified_account_balance(account_proof.address, block.number); + assert_eq!(balance, account_proof.balance); + + let nonce = dsp.registry.get_verified_account_nonce(account_proof.address, block.number); + assert_eq!(nonce, account_proof.nonce); + + let storage_proof = proofs::storage::PROOF_mainnet_weth(); + + let result = dsp + .registry + .prove_storage( + block.number, + account_proof.address, + storage_proof.key, + storage_proof.bytes, + storage_proof.data + ); + + println!("result: {:?}", result); + + let storage_result = dsp + .registry + .get_storage(block.number, account_proof.address, storage_proof.key); + assert_eq!(result.unwrap(), storage_result.unwrap()); +} + #[test] fn prove_account_test_success_code_hash() { let dsp = setup(); @@ -163,8 +220,7 @@ fn prove_storage_test_success_with_some_data() { let storage_result = dsp .registry .get_storage(block.number, account_proof.address, storage_proof.key); - let result: u256 = result.into(); - assert_eq!(result, storage_result.unwrap()); + assert_eq!(result.unwrap(), storage_result.unwrap()); } #[test] @@ -233,7 +289,7 @@ fn get_storage_test_success_with_no_data() { storage_proof.bytes, storage_proof.data ); - assert!(result == 'Result Found No Value'); + assert!(result == Result::Err('Result is None')); } #[test]