All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Bumped Cairo version to
2.7.0
- Max steps in tests (configured by argument
--max-n-steps
) now defaults to 10 million if not provided (changed from 4 million).
- Commands that commit transactions now display links to block explorers. When in human-readable mode,
invoke
,declare
,deploy
,multicall run
,account create
andaccount deploy
will display additional information with an url. A new key in Cast configuration -block-explorer
determines which block explorer service the displayed link leads to. Possible options are:StarkScan
,Voyager
,ViewBlock
,OkLink
,NftScan
.
-
account create
outputs hint about the type of the tokens required to prefund a newly created account with before deployment -
sncast
no longer expects--url
as a common argument. It is now required specifically by commands that utilise it, i.e.account add
,account create
,account delete
,account deploy
,multicall run
,script run
,call
,declare
,deploy
,invoke
,show-config
,tx-status
. Commands that do not require--url
anymore:account list
,multicall new
,script init
,verify
- Fork tests now discover chain ID via provided RPC URL, defaulting to
SN_SEPOLIA
#[fork]
attribute parameters format. Read more here- steps counting
- Block tag changed name from
Latest
tolatest
declare
cheatcode now returnsResult<DeclareResult, Array<felt252>>
Read more here
spy_messages_to_l1()
for listening in on messages to L1 sent by your contracts. Read more here.
- Renamed global cheatcodes listed here - cheatcode invocations affecting the global scope and working indefinitely, already marked with a
_global
suffix, received astart_
prefix
verify
subcommand to verify contract (walnut APIs supported as of this version). Read more here- support for v3 transactions on account deploy, deploy, declare, invoke
- Newest class hash for OpenZeppelin account contracts
account list
subcommand for listing all available accounts Read more here
multicall new
no longer prints generated template to stdout and now requires specifying output path. Read more here
- Updated event testing - read more here on how it now works and here
about updated
spy_events
cheatcode
SyscallResultStringErrorTrait::map_error_to_string
removed in favor of utility function (snforge_std::byte_array::try_deserialize_bytearray_error
)
--class-hash
flag fromaccount deploy
command
tx-status
subcommand to get transaction status. Read more heretx_status
function to cast_std. Read more here- Support for creating argent accounts
- Support for creating braavos accounts
prank
,warp
,roll
,elect
,spoof
cheatcodes in favour ofcheat_execution_info
cheat_execution_info
cheatcode and per variable helpers for it
- New required flag
--type
toaccount add
command
-
SignerTrait::sign
now returnsResult
instead of failing the test -
L1HandlerTrait::execute()
takes source address and payloads as arguments Read more here -
When calling to an address which does not exists, error is forwarded to cairo runtime instead of failing the test
event_name_hash
removal, in favour ofselector!
usage
- the tool now always compiles Sierra contract artifacts to CASM using
USC
- before it used to consume CASM artifacts produced by Scarb if they were present. Setting upcasm = true
inScarb.toml
is no longer recommended - it may slow down the compilation. - The
replace_bytecode
cheatcode now returnsResult
with a possibleReplaceBytecodeError
, since it may cause unexpected errors down the line when not handled properly
- the tool now always compiles Sierra contract artifacts to CASM using
USC
- before it used to consume CASM artifacts produced by Scarb if they were present. Setting upcasm = true
inScarb.toml
is no longer recommended - it may slow down the compilation.
- scripts built with release profile are now properly recognized and ran
deploy
/deploy_at
now additionally return the constructor return data viaSyscallResult<(ContractAddress, Span<felt252>)>
declare
returnsResult<ContractClass, Array<felt252>>
instead ofContractClass
L1HandlerTrait::execute()
returnsSyscallResult<()>
SyscallResultStringErrorTrait::map_string_error
renamed toSyscallResultStringErrorTrait::map_error_to_string
var
now supportsByteArray
with double quoting, and returnsArray<felt252>
instead of a singlefelt252
snforge_std::RevertedTransaction
read_txt
andread_json
now supportsByteArray
- sncast script idempotency feature - every action done by the script that alters the network state will be tracked in state file, and won't be replayed if previously succeeded
- variants of cheatcodes with
CheatSpan
(read more here) - Providing configuration data with env variables DOCS
- Events emitted in cairo 0 contracts are now properly collected
--build-profile
no longer fails silently (compatible withcairo-profiler
0.2.0)
- Default
chain_id
has been changed fromSN_GOERLI
toSN_SEPOLIA
- Supported RPC version is now 0.7.0
- Gas calculation is in sync with starknet 0.13.1 (with EIP 4844 blob usage enabled)
- Resources displayed (steps, builtins) now include OS costs of syscalls
- Support for OpenZeppelin Cairo 1 (or higher) accounts creation, deployment and usage
- Providing configuration data with env variables DOCS
- Supported RPC version is now 0.7.0
- Default class hash in
account create
andaccount deploy
has been changed to cairo2 class hash
replace_bytecode
cheatcode- result of the call to the trace
- added
--build-profile
flag to the--test
command. Saves trace data and then builds profiles of test cases which pass and are not fuzz tests. You need cairo-profiler installed on your system. - dependency on the universal-sierra-compiler binary, which will allow forge to be independent of sierra version
var()
,read_txt()
,read_json()
,FileTrait::new()
,declare()
now use regular strings (ByteArray
) instead of short strings (felt252
)start_mock_call()
,stop_mock_call()
,L1Handler
now use selector (selector!()
) instead of names
declare()
now uses regular strings (ByteArray
) instead of short strings (felt252
)call()
andinvoke()
now require function selector (selector!()
) instead of function name in scripts (sncast_std)
--path-to-scarb-toml
optional flag that allowed to specify the path to theScarb.toml
file--deployed
flag fromaccount add
subcommand
- contract names to call trace
--max-n-steps
argument that allows setting own steps limit
- Unknown entry point error when calling a contract counts as a panic
- Cairo edition set to
2023_11
- Calling Cairo 0 contract no longer cancels cheatcodes in further calls
script init
command to generate a template file structure for deployment scripts- Warning is emitted when executing sncast commands if the node's JSON-RPC version is incompatible
- to run a deployment script it is required to use
script run
subcommand
- fixed a bug where a profile was passed to scarb even when it did not exist
- error handling from inside deployment scripts is now possible (
declare
,deploy
,call
,invoke
now returnResult<T, ScriptCommandError>
)
map_string_error
for use with dispatchers, which automatically converts string errors from the syscall result (read more here)
- Warning in fork testing is emitted, when node JSON-RPC version is incompatible
get_call_trace
library function for retrieving call trace in tests
- Gas estimation is now aligned with the Starknet v0.13
snforge_std::PrintTrait
- useprint!
,println!
macros and / orcore::debug::PrintTrait
instead
- Gas used in constructors and handling of L1 messages is now properly included in total gas cost
- sncast tool configuration is now moved away from
Scarb.toml
tosnfoundry.toml
file. This file must be present in current or any parent directories in order to use profiles.
--package
flag fordeclare
andscript
subcommands, that specifies scarb package to work withDebug
andDisplay
impls for script subcommand responses - useprint!
,println!
macros instead of calling.print()
- Bump to cairo 2.5.0
SafeDispatcher
s usages need to be tagged with#[feature("safe_dispatcher)]
(directly before usage), see the shamans post
--detailed-resources
flag for displaying additional info about used resourcesstore
andload
cheatcodes--save-trace-data
flag tosnforge test
command. Traces can be used for profiling purposes.
available_gas
attribute is now supported (Scarb >= 2.4.4 is required)
- Error message for tests that should panic but pass
- the 'pending' block is used instead of 'latest' as the default when obtaining the nonce
Secp256k1
andSecp256r1
curves support forKeyPair
insnforge_std
- maximum number of computational steps per call set to current Starknet limit (3M)
mean
andstd deviation
fields are displayed for gas usage while running fuzzing tests- Cairo edition in
snforge_std
andsncast_std
set to2023_10
snforge_std::signature
module withstark_curve
,secp256k1_curve
andsecp256r1_curve
submodules
- Safe library dispatchers in test code no longer propagate errors when not intended to
assert_not_emitted
assert to check if an event was not emitted
- fields from
starknet::info::v2::TxInfo
are now part ofTxInfoMock
fromsnforge_std::cheatcodes::tx_info
- consistent latest block numbers for each url are now used across the whole run when testing against forks
- Parsing panic data from call contract result
- add support for sepolia network
--yes
option toaccount delete
command that allows to skip confirmation prompt
- Argument
max-fee
inaccount deploy
is now optional
- Bump cairo to 2.4.0.
- Migrated test compilation and collection to Scarb, snforge should now be compatible with every Scarb version >= 2.4.0 unless breaking changes happen
- print gas usage for each test
- Support for test collector built-in in Scarb with the
--use-scarb-collector
flag. Requires at leastnightly-2023-12-04
version of Scarb.
--wait-timeout
to set timeout for waiting for tx on network using--wait
flag (default 60s)--wait-retry-interval
to adjust the time between consecutive attempts to fetch tx from network using--wait
flag (default 5s)- allow setting nonce in declare, deploy and invoke (using
--nonce
and in deployment scripts) - add
get_nonce
function to cast_std --private-key-file
option toaccount add
command that allows to provide a path to the file holding account private key
elect
cheatcode for mocking the sequencer address. Read more here.--rerun-failed
option to run tests that failed during the last run.
start_warp
andstop_warp
now takeCheatTarget
as the first argument instead ofContractAddress
. Read more here.start_prank
andstop_prank
now takeCheatTarget
as the first argument instead ofContractAddress
. Read more here.start_roll
andstop_roll
now takeCheatTarget
as the first argument instead ofContractAddress
. Read more here.
PS: Credits to @bllu404 for the help with the new interfaces for cheats!
- using unsupported
available_gas
attribute now fails the specific test case instead of the whole runner
- MVP for cairo deployment scripts with declare, deploy, invoke and call
- Bump cairo to 2.3.1
available_gas
attribute, it didn't compute correctly gas usage. Contract functions execution cost would not be included.
- scarb metadata in declare subcommand now takes manifest path from cli if passed instead of looking for it
- forking of the
Pending
block
--color
option to control when colored output is used- when specifying
BlockId::Tag(Latest)
block number of the used block will be printed - printing number of ignored and filtered out tests
- Segment Arena Builtin crashing with
CairoResourcesNotContainedInFeeCosts
when Felt252Dict was used
- account commands now always return valid json when
--json
flag is passed - allow passing multiple calldata argument items without quotes
- display correct error message when account file is invalid
- diagnostic paths referring to
tests
folder - caching
get_class_hash_at
in forking test mode (credits to @jainkunal for catching the bug)
#[ignore]
attribute together with--ignored
andinclude-ignored
flags - read more here- support for
deploy_syscall
directly in the test code (alternative todeploy
) snforge_std::signature
module for performing ecdsa signatures
- updated Cairo version to 2.3.0 - compatible Scarb version is 2.3.0:
- tests in
src
folder now have to be in a module annotated with#[cfg(test)]
- tests in
snforge_std::PrintTrait
will not convert values representing ASCII control characters to strings- separated
snforge
to subcommands:snforge test
,snforge init
andsnforge clean-cache
. Read more here. starknet::get_block_info
now returns correct block info in a forked block
show-config
subcommand to display currently used configurationaccount delete
command for removing accounts from the accounts file--hex-format
flag has been added
-i
short for--int-format
is removed, now have to use the full form--int-format
- Test from different crates are no longer run in parallel
- Test outputs are printed in non-deterministic order
- Test output are printed in real time again
- Bug when application would not wait for tasks to terminate after execution was cancelled
- incorrect caller address bug
- significantly reduced ram usage
#[fuzzer(...)]
attribute allowing to specify a fuzzer configuration for a single test case- Support for
u8
,u16
,u32
,u64
,u128
,u256
types to fuzzer --clean-cache
flag- Changed interface of
L1Handler.execute
andL1Handler
(droppedfee
parameter, added result handling withRevertedTransaction
) - Contract now has associated state, more about it here
- cheatcodes (
prank
,roll
,warp
) now work on forked Cairo 0 contracts
- Spying events interface is updated to enable the use of events defined inside contracts in assertions
- Test are executed in parallel
- Fixed inconsistent pointers bug foundry-rs#659
- Fixed an issue where
deploy_at
would not trigger the constructors foundry-rs#805
- dropped official support for cairo 1 compiled contracts. While they still should be working without any problems, from now on the only officially supported cairo compiler version is 2
var
library function for reading environmental variables
- Using any concrete
block_id
when using forking mode, would lead to crashes
- Support for scarb workspaces
- Initial version of fuzz testing with randomly generated values
#[fork(...)]
attribute allowing testing against a network fork
- Tests are collected only from a package tree (
src/lib.cairo
as an entrypoint) andtests
folder:- If there is a
lib.cairo
file intests
folder, then it is treated as an entrypoint to thetests
package from which tests are collected - Otherwise, all test files matching
tests/*.cairo
regex are treated as modules and added to a single virtuallib.cairo
, which is treated as described above
- If there is a
account add
command for importing accounts to the accounts fileaccount create
command for creating openzeppelin accounts with starkli-style keystoreaccount deploy
command for deploying openzeppelin accounts with starkli-style keystore
--add-profile
no longer accepts-a
for short- allow the
id
property in multicalls to be referenced in the inputs ofdeploy
andinvoke
calls
deploy_at
cheatcode- printing failures summary at the end of an execution
- filtering tests now uses an absolute module tree path — it is possible to filter tests by module names, etc.
- non-zero exit code is returned when any tests fail
- mock_call works with dispatchers if contract does not exists
- support for starkli-style accounts, allowing the use of existing accounts
- fixed misleading error message when there was no scarb in PATH and
--path-to-scarb-toml
was passed - modified
multicall new
command output, to be in line with other commands outputs
- support for
keccak_syscall
syscall. It can be used directly in cairo tests l1_handler_execute
cheatcode- support for
roll
ing/warp
ing/prank
ing the constructor logic (precalculate address, prank, assert pranked state in constructor) spy_events
cheatcode- Functions
read_json
andFileParser<T>::parse_json
to load data from json files and deserialize it
- rename
TxtParser
trait toFileParser
- rename
parse_txt
trait toread_txt
- support for printing in contracts
spoof
cheatcode- snforge command-line flag
--init
- Support for custom networks - accounts created on custom networks are saved in
accounts-file
under network's chain_id accounts-file
field in Scarb.toml profile- Include the class hash of an account contract in the
accounts-file
--network
option together with thenetwork
field in Scarb.toml profile — previously used as a validation factor; now networks are identified by their chain_id
#[should_panic]
attribute support- Documentation to public methods
- Information sections to documentation about importing
snforge_std
- Print support for basic numeric data types
- Functions
parse_txt
andTxtParser<T>::deserialize_txt
to load data from plain text files and serialize it get_class_hash
cheatcodemock_call
cheatcodeprecalculate_address
cheatcode
- Exported
snforge_std
as a Scarb package, now you have to import it explicitly with e.g.use snforge_std::declare
and add it as a dependency to your Scarb.toml
[dependencies]
# ...
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.4.0" }
-
Moved
ForgeConfigFromScarb
toscarb.rs
and renamed toForgeConfig
-
Made private:
print_collected_tests_count
print_running_tests
print_test_result
print_test_summary
TestCaseSummary::from_run_result
TestCaseSummary::skipped
extract_result_data
StarknetArtifacts
StarknetContractArtifactPaths
StarknetContract
-
Split
dependencies_for_package
into separate methods:paths_for_package
corelib_for_package
target_name_for_package
compilation_unit_for_package
-
Fails test when user tries to use syscalls not supported by forge test runner
-
Updated cairo-lang to 2.1.0, starknet-api to 0.4.1 and blockifier to 0.2.0-rc0
- Added
--class-hash
flag to account create/deploy, allowing for custom openzeppelin account contract class hash
warp
cheatcoderoll
cheatcodeprank
cheatcode- Most unsafe libfuncs can now be used in contracts
declare
return type tostarknet::ClassHash
, doesn't return aResult
PreparedContract
class_hash
changed tostarknet::ClassHash
deploy
return type tostarknet::ContractAddress
- Using the same cairo file names as corelib files no longer fails test execution
- multicall as a single transaction
- account creation and deployment
--wait
flag to wait for transaction to be accepted/rejected
- sierra and casm artifacts are now required in Scarb.toml for contract declaration
- improved error messages
class_hash
es calculation- Test collection
- Initial release