Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix skip validate #1053

Merged
merged 7 commits into from
Sep 29, 2023
Merged

Fix skip validate #1053

merged 7 commits into from
Sep 29, 2023

Conversation

juanbono
Copy link
Collaborator

@juanbono juanbono commented Sep 29, 2023

Fix skip validate

Description

This PR fixes the skip validate for invoke transactions.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

@juanbono juanbono marked this pull request as draft September 29, 2023 14:20
@codecov-commenter
Copy link

codecov-commenter commented Sep 29, 2023

Codecov Report

Merging #1053 (daf9f18) into main (a1fad26) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1053      +/-   ##
==========================================
- Coverage   89.98%   89.98%   -0.01%     
==========================================
  Files          49       49              
  Lines       13035    13036       +1     
==========================================
  Hits        11730    11730              
- Misses       1305     1306       +1     
Files Coverage Δ
src/transaction/invoke_function.rs 96.31% <100.00%> (-0.09%) ⬇️

@juanbono juanbono marked this pull request as ready for review September 29, 2023 19:02
@juanbono juanbono added this pull request to the merge queue Sep 29, 2023
Merged via the queue into main with commit 9405592 Sep 29, 2023
13 checks passed
fguthmann pushed a commit that referenced this pull request Oct 2, 2023
* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants
Oppen pushed a commit that referenced this pull request Oct 5, 2023
* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants
Oppen pushed a commit that referenced this pull request Oct 17, 2023
* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants
@juanbono juanbono deleted the fix_skip_validate branch October 24, 2023 18:50
toni-calvin added a commit that referenced this pull request Oct 31, 2023
* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>
pefontana pushed a commit that referenced this pull request Nov 13, 2023
* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: Federica <fedemoletta@hotmail.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>
github-merge-queue bot pushed a commit that referenced this pull request Nov 17, 2023
* Unify deprecated and casm contract caches.

* Fix formatting and clippy.

* Remove unused code.

* Unify contract classes in the state traits too.

* Fix typos. Make cache shared.

* Minor fixes.

* Fix testing state generation to make it work with shared caches.

* Fix formatting.

* Add cache diff.

* Add suggestion.

* Fix stuff.

* Implement cache trait. Add a null and a permanent cache. Fix everything that breaks using the permanent cache (should mimic the previous behaviour).

* Add documentation.

* Convert the cache trait into immutable (aka. move the lock into them).

* Remove external cache lock (no longer needed).

* Fix stuff.

* Add LRU cache example.

* Run `cargo fmt`.

* Fix LRU example.

* Fix the other example.

* Fix after merge.

* Add private cache drain method.

* Temporarily disable `max_fee` checks.

* Add comment on `RefCell::get_mut()`.

* Remove `extend` from trait. Remove unused code.

* Fix duplicated `CachedState` issue.

* Add missing comments.

* Update `README.md`.

* Fix after merge.

* Remove obsolete comment.

* Fix test after merge.

* Fix borrows.

* Fix after merge.

* Fix erc20 test.

* Remove unused feature.

* Update `coverage-helper` to support `#[coverage(off)]`.

* Add `coverage` attribute feature on testing.

* Update `README.md` and example.

* Fix `README.md`.

* Improve `README.md`.

* Remove references to `StarknetState` in `README.md`.

* Remove debug print.

* Remove commented block of code.

* Fix after merging.

* Fix formatting.

* Update Pr: Make contract caches shared (#1071)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>

* Revert "Update Pr: Make contract caches shared (#1071)" (#1116)

This reverts commit 8a11259.

* Update contract caches (#1117)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: Federica <fedemoletta@hotmail.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>

* Merge

* Fix code

* clippy

* Remove old file

* Remove old file

* Avoid cloning private cache

* Fix locks

* Uncomment metrics

---------

Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>
Co-authored-by: Federica <fedemoletta@hotmail.com>
fguthmann added a commit that referenced this pull request Nov 20, 2023
* Unify deprecated and casm contract caches.

* Fix formatting and clippy.

* Remove unused code.

* Unify contract classes in the state traits too.

* Fix typos. Make cache shared.

* Minor fixes.

* Fix testing state generation to make it work with shared caches.

* Fix formatting.

* Add cache diff.

* Add suggestion.

* Fix stuff.

* Implement cache trait. Add a null and a permanent cache. Fix everything that breaks using the permanent cache (should mimic the previous behaviour).

* Add documentation.

* Convert the cache trait into immutable (aka. move the lock into them).

* Remove external cache lock (no longer needed).

* Fix stuff.

* Add LRU cache example.

* Run `cargo fmt`.

* Fix LRU example.

* Fix the other example.

* Fix after merge.

* Add private cache drain method.

* Temporarily disable `max_fee` checks.

* Add comment on `RefCell::get_mut()`.

* Remove `extend` from trait. Remove unused code.

* Fix duplicated `CachedState` issue.

* Add missing comments.

* Update `README.md`.

* Fix after merge.

* Remove obsolete comment.

* Fix test after merge.

* Fix borrows.

* Fix after merge.

* Fix erc20 test.

* Remove unused feature.

* Update `coverage-helper` to support `#[coverage(off)]`.

* Add `coverage` attribute feature on testing.

* Update `README.md` and example.

* Fix `README.md`.

* Improve `README.md`.

* Remove references to `StarknetState` in `README.md`.

* Remove debug print.

* Remove commented block of code.

* Fix after merging.

* Fix formatting.

* Update Pr: Make contract caches shared (#1071)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>

* Revert "Update Pr: Make contract caches shared (#1071)" (#1116)

This reverts commit 8a11259.

* Update contract caches (#1117)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: Federica <fedemoletta@hotmail.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>

* Merge

* Fix code

* clippy

* Remove old file

* Remove old file

* Avoid cloning private cache

* Fix locks

* Uncomment metrics

---------

Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>
Co-authored-by: Federica <fedemoletta@hotmail.com>
github-merge-queue bot pushed a commit that referenced this pull request Nov 24, 2023
…dule (#884)

* added comments to syscalls/deprecated_business_logic_syscall_handler.rs

* corrected comments

* added informations on system calls

* change comments

* Added Starknet API / Blockifier RPC State Reader (#927)

* initial commit

* add get_class_hash_at

* Added get_nonce_at

* Added get_storage_at

* Remove comments

* Added get block info

* Fixed get_contract_class()

* WIP fixing desearlization

* WIP Fix

* Finished fixing get_contract_class()

* Uncommented tests, new get_contract_class

* Remove file

* WIP Fixing tests

* Finish fixing simple tests

* Fixed transaction trace and block info

* Fix import

* Refactor, fixes, added test

* Fixed warnings, removed tests

* Fixed get_transaction_receipt

* Fixed actual_fee from get_transaction_receipt

* Format Cargo.toml

* Redid BlockValue

* Removed middle response types

* Changed unreachable with unimplemented

* Move import inside fn

* Fix tests

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Deserialize transactions too on the block info for the Rpc Reader SN (#961)

* initial commit

* add get_class_hash_at

* Added get_nonce_at

* Added get_storage_at

* Remove comments

* Added get block info

* Fixed get_contract_class()

* WIP fixing desearlization

* WIP Fix

* Finished fixing get_contract_class()

* Uncommented tests, new get_contract_class

* Remove file

* WIP Fixing tests

* Finish fixing simple tests

* Fixed transaction trace and block info

* Fix import

* Refactor, fixes, added test

* Fixed warnings, removed tests

* deserialize all transactions in the block info too

* docs

* refactor into standalone fn

* get gas from block via RPC SN (#963)

* get gas automatically from block

* cleanup

* fix wrong gas

* unintended change

---------

Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Unify deprecated and casm contract caches. (#937)

* Unify deprecated and casm contract caches.

* Fix formatting and clippy.

* Remove unused code.

* Unify contract classes in the state traits too.

* Restore type alias.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* Update README with Telegram group link and badge (#843)

* Update README.md

* add link to tg group

* From/TryFrom starknet api types (#962)

* From/TryFrom starknet api types

* Add deploy account

* Modify gitignore

* Deploy account and invoke function

* Change into_iter to iter

* Update .gitignore

Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>

* change to try_from

* Move functions to its respective files

* Test

* Delete test

* Fix format

* Fix test

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Fix gas/fee price type consistency (to `u128`). (#987)

* Fix `ExecutionResources::increment_syscall_counter` (#971)

* Fix increment_syscall_counter

* Add test + fix test

* Fix test

* Fix tests

* fmt

* minor code cleanup (#968)

* Added fee transfer storage update into `count_actual_storage_changes()` (#960)

* Add utils fns

* Implemented fix

* Fix some tests

* Fix clippy

* Fix tests

* Fix test

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Remove missing unwrap from codebase. (#1000)

* refactor/ fix TryFrom InvokeTransaction into a standalone method on InvokeFunction (#999)

* refactor and fix TryFrom InvokeTransaction into a standalone method on InvokeFunction

* document

* fix

* Deprecate old RPC StateReader in favor of `starknet_api` compatible one, support SiR execution (#967)

* From/TryFrom starknet api types

* Add deploy account

* Modify gitignore

* Deploy account and invoke function

* Change into_iter to iter

* Update .gitignore

Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>

* change to try_from

* Move functions to its respective files

* WIP Added SIR support to SNRPC

* Implemented state reader for sir

* WIP Transaction

* WIP SiR execution

* Fixed rpc sir execute_tx

* Fix clippy

* Import last version of sn_api

* Formatting

* Test

* Test try from

* Delete test

* Fix format

* Fix test

* Fix clippy

* Replaced try_from with from_invoke_transaction

* infer version

* Fix version

* Changed test_try_from_invoke

* Ignore test_recent_tx

* Refactor tx deser, (un)ignore tests

* Added support for reverted

---------

Co-authored-by: Milton <milton.scuderi@lambdaclass.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: mmsc2 <88055861+mmsc2@users.noreply.github.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* perf: remove clone from compute_sierra_class_hash (#1008)

* fix: Read before writing when executing the deprecated version of `storate_write` syscall (#1006)

* Read before writing

* Add test

* Fix some tests

* Fix test

* Fix test

* Fix test

* Fix test

* Fix tests

* Fix tests

* Fix tests

* BREAKING: `StateReader::get_storage_at` return zero by default (#1011)

* update InMemoryStateReader & CachedState

* Add comments

* Apply changes to State implementation too

* Fix behaviour

* Add test

* BREAKING: `StateReader::get_class_hash_at` return zero by default (#1012)

* Use unwrap_or_default

* return zero by default state reader get_class_hash_at

* Add changes

* clippy

* RPC use test_case with local cache and add more tests (#970)

* From/TryFrom starknet api types

* Add deploy account

* Modify gitignore

* Deploy account and invoke function

* Change into_iter to iter

* Update .gitignore

Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>

* change to try_from

* Move functions to its respective files

* WIP Added SIR support to SNRPC

* Implemented state reader for sir

* WIP Transaction

* WIP SiR execution

* Fixed rpc sir execute_tx

* Fix clippy

* Import last version of sn_api

* Formatting

* Test

* Test try from

* Delete test

* Fix format

* Fix test

* local test cases

* specify block manually

* add test_case for blockifier

* use more recent txs

* dont keep cached responses

* add failing tx on blockifier

* more tests

* Fix clippy

* fix bug

* tests

* Replaced try_from with from_invoke_transaction

* infer version

* Fix version

* Changed test_try_from_invoke

* Ignore test_recent_tx

* ignore failing tests

* Refactor tx deser, (un)ignore tests

* sorted assert and fee threshold

* fixes

---------

Co-authored-by: Milton <milton.scuderi@lambdaclass.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: mmsc2 <88055861+mmsc2@users.noreply.github.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Update cache initial values with write-only accesses in `CachedState::count_actual_storage_changes` (#1009)

* Add update_initial_values_of_write_only_access

* Change name

* Update variable names

* Fix + expand test

* Add band-aid soluction + restore test

* update InMemoryStateReader & CachedState

* Add comments

* Apply changes to State implementation too

* Fix behaviour

* Add test

* Remove band-aid solution

* Use unwrap_or_default

* return zero by default state reader get_class_hash_at

* Add changes

* clippy

* Add initial values to test

* remove duplictaed test

* Refactor new RPC into several files (#1007)

* From/TryFrom starknet api types

* Add deploy account

* Modify gitignore

* Deploy account and invoke function

* Change into_iter to iter

* Update .gitignore

Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>

* change to try_from

* Move functions to its respective files

* WIP Added SIR support to SNRPC

* Implemented state reader for sir

* WIP Transaction

* WIP SiR execution

* Fixed rpc sir execute_tx

* Fix clippy

* Import last version of sn_api

* Formatting

* Test

* Test try from

* Delete test

* Fix format

* Fix test

* local test cases

* specify block manually

* add test_case for blockifier

* use more recent txs

* dont keep cached responses

* add failing tx on blockifier

* more tests

* Fix clippy

* fix bug

* tests

* Replaced try_from with from_invoke_transaction

* infer version

* Fix version

* Changed test_try_from_invoke

* Ignore test_recent_tx

* ignore failing tests

* Refactor tx deser, (un)ignore tests

* sorted assert and fee threshold

* refactor rpc state reader

* fixes

---------

Co-authored-by: Milton <milton.scuderi@lambdaclass.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: mmsc2 <88055861+mmsc2@users.noreply.github.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Fix storage changes count for transactions with fee transfers (#1015)

* Push clean changes

* fmt

* Fix test

* Fix test

* Fix test

* Fix test

* Fix tests

* Fix tests

* Fix tests

* fix estimate fee missing casmclasscache (#916)

Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Mario Rugiero <mrugiero@gmail.com>

* fix: declare v0 requires max_fee=0, consider for simulation (#1017)

* Remove redundant `tx_type` field from transactions. (#1019)

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* remove files and rename the new one (#1020)

* Add contract class cache stats (#958)

* added cache_hit and cahce_misses to count the number of error in our cache, abd a test for it

* wip

* Apply suggestions from code review

* fix: qnd borrow checker

* clippy

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Mario Rugiero <mrugiero@gmail.com>

* add tests and remove ignore on fixed ones (#1021)

* perf: refactor substract_mappings and friends to avoid clones (#1023)

* refactor substract_mappings and friends to avoid clones of the whole hashmap

* another opt

* dont use deref

* fix deref again

* no need for contains_key

* oops

* Fix transactions bypassing the max_fee by introducing new revert logic (#901)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

* Added fee transfer

* Test with invoke

* Added revert logic for invoke

* Modify tests, add fixes

* Add revert error

* Fix test_invoke_tx_account

* Fixed test_invoke_tx_exceeded_max_fee

* Fix test_get_nonce_at

* Rely on another contract

* Introduced transactional state (#917)

* Introduced transactional state

* WIP

* Fixed the rest of tests

* Replaced old revert logic from entrypoint exec

* depl acc revert test

* Remove update writes fix

* WIP Fixed many tests

* fix test

* fix more tests

* more fixes

* fix another test

* fix latest test

* name

* remove comment

* merge

* unignore

* format

* vis

* need to be pub for  tests

* fix test

* format

* use the count_actual_storage_changes impl from cached state

* fix bug

* fix tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* fix get_sorted_events issue (#1024)

* add failing test that reproduce the issue

* fix the bug

* fix test since now 2 events with the same order are ok

* handle multiple events

* fix comments

* cargo fmt

* pin version (#1026)

* update version (#1028)

* Fix coverage control mechanism. (#1035)

* Fix SIR RPC get compiled class hash (#1032)

* update version

* fix get_compiled_hash

* cargo clippy

* remove unneeded added set_compiled_class_hash (#1031)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix missing events (#1034)

* remove unneeded added set_compiled_class_hash

* fix missing events when using deprecated business syscall handler

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fix wrong from_address in deprecated execute_constructor_entry_point (#1041)

* fix wrong from_address in deprecated execute_constructor_entry_point

* fix test

* fix another test

* remove testing, move erc20 test, update fibonacci bin (#1038)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: mmsc2 <88055861+mmsc2@users.noreply.github.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: Milton <milton.scuderi@lambdaclass.com>
Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
Co-authored-by: marioiordanov <mio@shardlabs.io>
github-merge-queue bot pushed a commit that referenced this pull request Dec 22, 2023
…887)

* added comments to syscalls/business_logic_syscall_handler.rs

* added syscall information

* Update src/syscalls/business_logic_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39cd9cdd92f5211930e9f36f3840a978ae9.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Save `SierraProgram` + `ContractEntryPoints` instead of `SierraContractClass` in `CompiledProgram` (#1112)

* Save Program + EntryPoints instead of ContractClass

* clippy

* `get_execution_info`test (#1067)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* Added get_execution_info test

* mend

* fix test + update native latest

* add deleted test

* mend

* delete unused struct

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>
Co-authored-by: toni-calvin <antonio.calvin@lambdaclass.com>

* Cairo native: Implement library_call syscall (#1074)

* cairo-native initial implementation of library call

* rebase

* clippy

* fix

* library call test

* suggestion

* Replace class native (#1105)

* update cairo native to use gas consumed

* implement native replace class syscall

* gas consumed

* add test

* update native rev

* add failing test

* fix gas consumed

* remove comments

* minor changes

* update cairo-native dependency

* improve test

* update latest native version

* use add sierra contract to cache method

* update latest native version

* Replace class contract call native (#1115)

* add last native version

* add failing test

* fix test

* easier merge

* fix test

---------

Co-authored-by: Edgar Luque <git@edgarluque.com>

* `get_block_hash` syscall native (#1048)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* WIP: Implementing get_block_hash syscall

* Fix stuff.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* make get_hash_test syscall work with native and vm

* update readme

* implement get_block_hash on vm

* fmt

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* checout earlier

* fix ci clippy

* test rpc reader execution

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

* implement get_block_hash_native

* remove debug

* add vm execution

* merge

* add less code

* fix syscall

* fmt

* update native to last version

* correctly insert sierra class into cache test

* update latest native version

* remove comments

---------

Co-authored-by: Esteban Dimitroff Hódi <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: toni-calvin <antonio.calvin@lambdaclass.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* Add logging to syscalls (#1111)

* replace println by tracing::debug

* replace MLIR with Cairo Native

* fmt

---------

Co-authored-by: juanbono <juan.bono@lambdaclass.com>

* Add error handling to `RpcState` (#1107)

* Remove explicit and implicit unwraps in RpcCallInfo deserialization

* Handle errors in RpcState::new_infura

* push RpcStateError

* Progress

* Remove all unwraps from rpc code

* Adapt tests

* Clippy

* Unify RpcError & RpcStateError

* Guard potential panicks + fmt

* clippy

* Keccak for Native Syscall Handler (#1055)

* implement keccac (cleanup)

* fix

* fix path

* fix keccak

* oops

* native revision

* update cardo.lock last native version

---------

Co-authored-by: Edgar Luque <git@edgarluque.com>
Co-authored-by: toni-calvin <antonio.calvin@lambdaclass.com>

* Hacky cairo-native compiled program cache (#1091)

* update cairo native

* wip

* wip2

* add cache to call_contract syscall too

* update ref

* add cairo-native as default feature

* cache engine instead

* fix test

* fmt & clippy

* remove cairo_native from default features

* add cairo_native to test targets

* fix features

---------

Co-authored-by: juanbono <juan.bono@lambdaclass.com>

* Update examples to use Cairo 2 + add them to the workspace (#1122)

* Delete old version of contract execution example

* Update example contract to cairo 2

* Make examples/contract_execution a proper crate

* Update contract execution example to use cairo 2 contracts

* Use same chain-id + restore expects

* Adjust values to pass validations

* Remove create_for_simulation

* Remove skip_validate

* Add comments

* fmt + clippy

* Embed aux contracts

* Update contract paths

* fmt

* Fix crate setup

* Add docs for rpc state reader (#1130)

* add more docs to the rpc state reader

* add link

---------

Co-authored-by: juanbono <juan.bono@lambdaclass.com>

* Add benchs (#1129)

* add benchs

* fix bench

* fmt & clippy

* fixed clippy issues

* fix features

* fmt

* add factorial_tr

* remove flag

* add newline in factorial_tr

* add newline to Cargo.toml

* remove dbg

* add usage

* fmt

---------

Co-authored-by: juanbono <juan.bono@lambdaclass.com>

* Add version + validation retdata checks for `InvokeFunction`, `Declare`, `DeclareV2` & `DeployAccount` txs (#1128)

* Check InvokeFuncion tx version

* Remove invalid code

* Add retdata validation

* Check tx version for Declare

* Simplify verify_version

* Check DeclareV2 version

* Unify unsupported version errors

* Reorder checks

* Add retdata validation

* Add retdata validation

* Add version check for DeployAccount

* fmt

* Remove no longer used verify_version function

* Fix tx versions in tests

* Remove test for removed check

* Remove test for removed check

* Remove unreachable case

* Fix test values

* Fix test values

* Fix test values

* Remove unused constants

* Remove old `QUERY_BASE` constant

* Fix test values

* Clippy

* Add back QUERY_VERSION_BASE` constant

* Code cleanup

* Restore

* Add a function to parse query versions

* Add comments

* Restore test

* Fix deploy account version in becnh

* Add tests for version checks

* Remove unwraps (#1137)

* Refactor `InvokeFunction::handle_nonce` to increment the nonce even if `skip_nonce_check` is set (#1134)

* Add test case

* Refactor how skip_nonce_checks affects nonce handling

* Add a separate test for txs that nedd to skip the nonce check

* Clippy

* Improvement

* Replace todo with error handling in `DeprecatedBLSyscallHandler::constructor_entry_points_empty` (#1136)

* Replace todo with error handling

* Clippy

* Add `skip_nonce_check` field to `DeclareV2`, `Declare` & `DeployAccount` txs (#1135)

* Add test case

* Refactor how skip_nonce_checks affects nonce handling

* Add a separate test for txs that nedd to skip the nonce check

* Clippy

* Add `skip_nonce_check` field to all txs

* Add skip_nonce_check for create_for_simulation all txs

* Refactor handle_nonce

* Improvement

* Add skip_nonce_check to execute_tx_configurable for each tx

* fix test + fmt

* Add `check_fee_balance` to `InvokeFunction`, `Declare`, `DeclareV2` & `DeployAccount` txs (#1132)

* Check InvokeFuncion tx version

* Remove invalid code

* Add retdata validation

* Check tx version for Declare

* Simplify verify_version

* Check DeclareV2 version

* Unify unsupported version errors

* Reorder checks

* Add retdata validation

* Add retdata validation

* Add version check for DeployAccount

* fmt

* Remove no longer used verify_version function

* Fix tx versions in tests

* Remove test for removed check

* Remove test for removed check

* Remove unreachable case

* Fix test values

* Fix test values

* Fix test values

* Remove unused constants

* Remove old `QUERY_BASE` constant

* Fix test values

* Clippy

* Add back QUERY_VERSION_BASE` constant

* Code cleanup

* Restore

* Add a function to parse query versions

* Add comments

* Restore test

* Fix deploy account version in becnh

* Use constants for estimated tx steps used in OsResources

* Add estimate_minimal_fee check for InvokeFunction

* Implement get_fee_token_balance for StateReader

* Finish check for InvokeFunction

* Don`t check fee balance for estimate_fee

* Update tests

* Adjust max_fee values

* Add fee balance checks to the other txs

* Update test values

* Refactor account deploy revert test

* fmt

---------

Co-authored-by: juanbono <juanbono94@gmail.com>

* Replace testnet 2 tx in RpcState test with mainnet tx (#1142)

* Remove RpcChain::TestNet2 enum variant

* Use a mainnet tx for RpcState get_transaction_trace test

* Revert "Remove RpcChain::TestNet2 enum variant"

This reverts commit 34c5367081dc61fe53d8b50b42a010286f67c457.

* Add global support for program caches. (#1140)

* Add global support for program caches.

* Update cairo-native dependency and fix stuff.

* Fix compilation errors.

* Refactor class hash  (#1095)

* state with warnings

* fix test

* fix test

* remove unnecessary clone

* clippy

* update latest native version

* mend

* fix import

* Get block hash from rpc (#1124)

* add test rpc vs vm get_block_hash syscall

* set failing branch state

* Revert "set failing branch state"

This reverts commit db722e45f84a7402271646dd879ac19abf03f15c.

* remove unnecessary test

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Make contract caches shared. (#940)

* Unify deprecated and casm contract caches.

* Fix formatting and clippy.

* Remove unused code.

* Unify contract classes in the state traits too.

* Fix typos. Make cache shared.

* Minor fixes.

* Fix testing state generation to make it work with shared caches.

* Fix formatting.

* Add cache diff.

* Add suggestion.

* Fix stuff.

* Implement cache trait. Add a null and a permanent cache. Fix everything that breaks using the permanent cache (should mimic the previous behaviour).

* Add documentation.

* Convert the cache trait into immutable (aka. move the lock into them).

* Remove external cache lock (no longer needed).

* Fix stuff.

* Add LRU cache example.

* Run `cargo fmt`.

* Fix LRU example.

* Fix the other example.

* Fix after merge.

* Add private cache drain method.

* Temporarily disable `max_fee` checks.

* Add comment on `RefCell::get_mut()`.

* Remove `extend` from trait. Remove unused code.

* Fix duplicated `CachedState` issue.

* Add missing comments.

* Update `README.md`.

* Fix after merge.

* Remove obsolete comment.

* Fix test after merge.

* Fix borrows.

* Fix after merge.

* Fix erc20 test.

* Remove unused feature.

* Update `coverage-helper` to support `#[coverage(off)]`.

* Add `coverage` attribute feature on testing.

* Update `README.md` and example.

* Fix `README.md`.

* Improve `README.md`.

* Remove references to `StarknetState` in `README.md`.

* Remove debug print.

* Remove commented block of code.

* Fix after merging.

* Fix formatting.

* Update Pr: Make contract caches shared (#1071)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f341165bb23b473c9231aa68560fb46568.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39cd9cdd92f5211930e9f36f3840a978ae9.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the RpcStateReader (#1096)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* fmt

* Add test cases for `DeployAccount` with popular account contracts using RpcState (#1104)

* Execute `Declare` transactions using the `RpcState` + Various fixes related to `Declare` txs (#1094)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Execute `L1Handler` transactions using the `RpcState`  (#1103)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Fix get_onchain_data_segment_length

* Add StorageChangesCount struct

* Update test values

* Update test values

* fmt

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Add test case with declare

* Deserialize Declare transactions

* Create blockifier Declare transaction

* Fix/Refactor `State::count actual storage changes` (#1086)

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add the ability to execute `DeployAccount` transactions using the `RpcState` (#1089)

* Add test case

* Fix get_onchain_data_segment_length

* Debug setup

* Add StorageChangesCount struct

* Use StorageChangesCount struct in state method

* Fix implicated code

* Update doc

* Update test values

* Rename method for consistency

* Add note comment

* Remove hardcoded contract address

* Remove txt files

* Remove dbg prints

* Remove dbg prints

* Format

* Restore blockifier version

* Restore tests

* Restore newlines

* Restore newlines

* Remove txt file

* fmt

* Fix bug in `From<StarknetRsContractClass> for CompiledClass` implementation (#1090)

* Fix bug in CompiledClass

* Add tests

* fetch class hash from the next block in declare tx

* Return an error if a class_hash is not declared + add tests for declare tx

* Fix error msg

* Add support for DeclareV0-1 in sir_tests

* Make Sierra class optional in declare v2 + other changes

* Add support for DeclareV2

* Uncomment test

* fix

* Use new_with_sierra_class_hash_and_tx_hash

* use CompiledClassHash instead of CompiledClass where applicatble

* Handle nonce in declare v2 + run fmt

* Set casm class before counting state changes in declare v2

* Changes

* Make sierra class hash non-optional

* fix + clippy

* Use state_reader instead of creating a state to fetch the next block s contract classes

* Add removed test

* Update test values

* Make validate_invocation and fee_transfer_info fields optional + add L1_HANDLER transaction RpcState

* Add L1Handler to blockifier_tests::execute_tx

* Add blockifier test case

* Add L1Handler to sir_tests::execute_tx

* Add one more test case

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Added a usage target to makefile (#1069)

* Added a usage target to makefile

* Fixed typo

* Implement `NativeSyscallHandler::deploy` (#1106)

* wip

* Minor improvements + add test

* Improve make clippy

* Clippy + fmt

* Update error messages

* Add failure flag test

* Fix typo

* Apply suggestions + run formatter

* Add llvm setup so we can run clippy with `cairo-native` feature

* Fix

* Remove todo

* Use a proper class_hash

* Fix test assertion

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* update cairo native to use gas consumed (#1102)

* update cairo native to use gas consumed

* gas consumed

* update native rev

* fix gas consumed

* remove comments

* fixes

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix cairo-native feature-gated code

* clippy

---------

Co-authored-by: MrAzteca <azteca1998@users.noreply.github.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>
Co-authored-by: juanbono <juanbono94@gmail.com>
Co-authored-by: Fanny Guthmann <57538139+fguthmann@users.noreply.github.com>
Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Edgar <git@edgarluque.com>
Co-authored-by: ElFantasma <esteban.dimitroff@lambdaclass.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Antonio Calvín García <antonio.calvin@lambdaclass.com>
Co-authored-by: Iñaki Garay <igarai@gmail.com>

* Revert "Update Pr: Make contract caches shared (#1071)" (#1116)

This reverts commit 8a112590e107cc69767bd31c6034c7070ca47c0a.

* Update contract caches (#1117)

* Remove `serde_json_pythonic`. (#1047)

* Remove `serde_json_pythonic`.

* Fix JSON formatter on `deprecated_contract_class.rs`.

* Fix hash JSON formatter (non-ascii support).

* Add unwrap reasoning comment.

* Add debug logging. (#1018)

* Add `tracing` and update dependencies.

* Configure the example to use tracing logging (and make it work again).

* Add tracing logging.

* Add error logging.

* Fix error logging.

* Reduce the amount of spam logged.

* Update `README.md`.

* Fix `Makefile` dependencies.

* Remove `Debug` trait dependency.

* Update `Cargo.lock` after merge.

* Fix warnings.

* Fix formatting.

---------

Co-authored-by: Esteve Soler Arderiu <esteve.soler@lambdaclass.com>

* fmt and improvements

* Fix skip validate (#1053)

* update version

* fix skip validation for invoke txs

* run fmt

* fix clippy suggestion

* simplify a bit the execute_tx function variants

* Add documentation to transaction/fee module (#889)

* added comments to src/transaction/fee.rs

* added return and error comments

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Add comments to origin/Document-transactionl1_handler module (#888)

* added comments to origin/Document-transactionl1_handler-module

* modified comments

* Test multi syscall (#687)

* create multy syscall

* remove the replace syscall, it failed because the contract adress didn't match

* added library call_syscall

* wip

* wip

* wip

* wip

* work in progress

* remove .sjon files from starknet_programs

* finished implemented all the syscalls

* reorder code, create one call to syscall

* fix pull bug

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/multi_syscall_test.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update starknet_programs/cairo1/contract_a.cairo

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update tests/multi_syscall_test.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* added test syscall for deploy

* make format changes

* corrected make clippy error

* get_caller_address and get_contract_address return a adress

* failed of get_contract_address

* failed of get_contract_address

* wip

* modify the selector entrypoint_selector to be function specific

* wip

* wip

* wip

* add input to cairo functions

* coorect format problem

* wip

* wip

* wip

* remove format problem

* Fix sierra class hash calculation (#886)

* reproduce bug

* use pythonic formatter

* rename test

* fix test

* cargo fmt

* Fail with an Err transactions whose calculated fee exceed `max_fee` (#892)

* Make tx fail when actual_fee exceeds max_fee

* Changed test

* Formatting

* Fix logic

* Leave fail only without charging

* Change test

* Fix test broken by better fee calc

* Fixed test fee

* Update fee on test_deploy_account

* Remove comment

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix test_get_nonce_at (#910)

* Fix test_get_nonce_at

* Rely on another contract

* fix get_sorted_events bug (#912)

* fix get_sorted_events bug

* fmt

* fix clippy

---------

Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Added documentations to syscalls/deprecated_syscall_handler module (#883)

* added comments to file syscalls/deprecated_syscall_handler-module'

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* Update src/syscalls/deprecated_syscall_handler.rs

Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>

* wip

* Modify the tests

* fixed clippy errors

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>

* Parse internal calls (#915)

* Added comments to core/contract_address module (#900)

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>

* Add more transaction tests and fee investigation (#914)

* add function for getting tx and refactor tests

* improve imports

* separe tests into 2 groups

* fix test

* add comments

* format

* cargo clippy

* add details to every test

* add fee discrepancy to test doc

* cargo fmt

* improve imports

* added safety element

---------

Co-authored-by: fannyguthmann <fanny.guthmann@post.idc.ac.il>
Co-authored-by: Matías Ignacio González <maigonzalez@fi.uba.ar>
Co-authored-by: SantiagoPittella <pittellasantiago@gmail.com>
Co-authored-by: Juan Bono <juanbono94@gmail.com>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Santiago Pittella <87827390+SantiagoPittella@users.noreply.github.com>

* remove transactionalstatereader as it is not needed as-is (#1054)

* Fix test (or try to)

* Revert "Fix test (or try to)"

This reverts commit 423052f341165bb23b473c9231aa68560fb46568.

* Implement Clone for CachedState

* Fix conflict in Makefile + run clippy-fix

* Remove empty line

* fmt

* Remove unwraps

* Add clone_for_testing

* Remove clones

* Add cairo native (#943)

* Added cairo native flag

* Added cairo_native as dependency

* Partial progress

* Progress

* Partial progress

* Point to newly created branch on cairo native

* Use updated version of cairo native and make test pass

* Run test with storage_write and storage_read with cairo native

* Tidy up code

* Start unhardcoding stuff

* Handle return values

* Tidy up code a little

* Added sierra programs cache

* Add impl for emit_event and send_l1_message

* Fix tests

* Install LLVM on CI

* Test

* Test CI

* Fix lint step

* Save work in progress

* Unhardcode calldata and entry point

* Unhardcode more stuff

* Fix test

* Add basic implementation for call_contract

* Add call to get_name to integration test

* Make call_contract impl compile

* Fix test

* Pass the correct amount of builtins for every function

* Improve test legibility

* Write call_contract test skeleton

* Finish writing test, still bugs to fix

* implement get_execution_info, make increase_allowance work

* More debugging

* Basic test for call_contract working

* More progress on testing ERC20

* More progress on test

* Add caller and callee contracts

* Fix call_contract test after merge

* Fix callee address in tests

* Polish some details

* Remove use_cairo_native from TransactionExecutionContext

* Write test skeleton

* Add test contracts

* Fix tests

* Readd deleted contracts

* Echo contract test passing

* Update cairo compiler to version 2.2.0

* Calling another contract with events test is passing

* Fix failing tests

* Remove internal_calls field TODO in CallInfo returned by native_execute

* Add event_emitter contract

* Add cairo vm execution to the erc20 test for comparison

* Add simple implementation for panics in native execution

* Add some documentation in code

* Assert equality between events, accessed_storage_keys and l1_l2 messages between native and vm runs

* Add event_emitter contract

* Remove print

* Remove comments

* Move native syscall handler to its own file

* Add felt decode to string when program panics

* Make cairo native an optional dependency behind a feature

* Move execution result to cairo native

* Add a README section explaining how to setup cairo native

* Fix some clippy issues

* Fix test compilation

* CI test

* Revert "CI test"

This reverts commit 4631e5e56a46cd0d751ea3a7d10db3541f2fde3d.

* CI test

* Test

* Test

* Address comment about multiple cfgs

* Remove unnecessary clone

* Test

* Test

* Switch to special workflow for native integration tests

* Fix workflow

* Fix stuff after merge.

* Fix clippy warnings.

* Fix after merge.

* Fix comments.

* Fix `Makefile`.

* Remove unused import.

* Use transactional state.

* update cairo native to llvm 17 and remove nightly requirement

* update ci

* upd ci

* try to fix ci

* use ubuntu on native

* try to fix ci

* not needed?

* fix ci

* update cairo native

* fix nightly usage

* try to fix ci

* dont need a transactional state reader, simply clone the state reader

* try to fix ci

* format

* fix again

* fix if

* values

* force rebuild

* make cache track cairo 2 version to trigger rebuilds

* try no restore key

* update readme

* fix tests on ci

* update cairo native commit

* fix more tests on ci

* fix cairo native interface

* try ci without cache

* setup rustup home

* make param passing to cairo native not obscure

* try

* try again

* remove large packages

* remove large dirs

* remove android too

* polly is needed

* needs sudo

* fix cov

* fix test for now

* format

* cleanup ci file

* use pyenv if available

* nightly not needed in readme

* add .sierra as generated to gitattributes

* fix gitattributes

* add casm too

---------

Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
Co-authored-by: Mariano Nicolini <mariano.nicolini.91@gmail.com>
Co-authored-by: Esteve Soler Arderiu <esteve.soler@fratilia.com>
Co-authored-by: Edgar Luque <git@edgarluque.com>

* add test to check cairo 2 account contract deploy panic failing properly (#1045)

* add test for account contract execution with panic

* clippy

* update cairo native to latest revision, u128 gas, mut self (#1082)

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix `get_execution_info` syscall (#1081)

* Mark read-only segments

* Move call

* Remove debug prints

* Remove fn

* Add test case

* Add comment

* Restore newlines

* Add function comment

* Fix test values

* Undo changes to makefile

* Undo changes to makefile

* clippy

* cairo-native: implement testing syscalls (#1084)

* cleanup erc20 test (#1087)

* Fix `get_onchain_data_segment_length` (#1085)

* Fix get_onchain_data_segment_length

* Update test values

* Update test values

* fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Check that running a declare v1 yields a higher fee than simulating it without validation (#1076)

* Reorder DeployAccount::apply

* Revert "Reorder DeployAccount::apply"

This reverts commit 11b0c39cd9cdd92f5211930e9f36f3840a978ae9.

* Add test

* Add test

* clippy + fmt

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* implement display and debug trait for Address (#1080)

* implement display and debug trait for Address

* hexa fmt

* Add recursive calls tests using `library_call` & `call_contract` syscalls (#1072)

* Add recursive library call test

* Add test programs

* Change base changes

* Add recursive test for call_contract

* fmt + clippy

* Add test for 100 contract calls

* clippy + fmt

* Update test values

---------

Co-authored-by: Juan Bono <juanbono94@gmail.com>

* Fix/Refactor State::count actual storage changes + Support `DeployAccount` in the Rpc…
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants