diff --git a/.github/workflows/nightly-fuzzing.yml b/.github/workflows/nightly-fuzzing.yml new file mode 100644 index 000000000..c54b1581e --- /dev/null +++ b/.github/workflows/nightly-fuzzing.yml @@ -0,0 +1,63 @@ +name: NIGHTLY-FUZZING + +on: + schedule: + - cron: 20 0 * * * + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +permissions: read-all + +jobs: + tests-unit: + runs-on: ubuntu-latest-16-cores + env: + PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10.14 + uses: actions/setup-python@v5 + with: + python-version: 3.10.14 + - name: Load cached Poetry installation + id: cached-poetry + uses: actions/cache@v4 + with: + path: ~/.local + key: poetry-${{ runner.os }} + - name: Install Poetry + if: steps.cached-poetry.outputs.cache-hit != 'true' + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + virtualenvs-path: .venv + installer-parallel: true + - name: Enforce poetry config + run: | + poetry config virtualenvs.in-project true + poetry config virtualenvs.create true + poetry config virtualenvs.path .venv + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v4 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: make setup + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: Run tests + env: + HYPOTHESIS_PROFILE: nightly + run: make test-unit + - name: Upload coverage report to codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + directory: ./coverage/ diff --git a/poetry.lock b/poetry.lock index 3ced7342d..60116a536 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1754,13 +1754,13 @@ test = ["eth-utils (>=2.0.0)", "hypothesis (>=3.44.24,<=6.31.6)", "pytest (>=7.0 [[package]] name = "hypothesis" -version = "6.100.1" +version = "6.112.0" description = "A library for property-based testing" optional = false python-versions = ">=3.8" files = [ - {file = "hypothesis-6.100.1-py3-none-any.whl", hash = "sha256:3dacf6ec90e8d14aaee02cde081ac9a17d5b70105e45e6ac822db72052c0195b"}, - {file = "hypothesis-6.100.1.tar.gz", hash = "sha256:ebff09d7fa4f1fb6a855a812baf17e578b4481b7b70ec6d96496210d1a4c6c35"}, + {file = "hypothesis-6.112.0-py3-none-any.whl", hash = "sha256:1e6adbd9534c0d691690b5006904327ea37c851d4e15262a22094aa77879e84d"}, + {file = "hypothesis-6.112.0.tar.gz", hash = "sha256:06ea8857e1e711a1a6f24154a3c8c4eab04b041993206aaa267f98b859fd6ef5"}, ] [package.dependencies] @@ -1769,10 +1769,10 @@ exceptiongroup = {version = ">=1.0.0", markers = "python_version < \"3.11\""} sortedcontainers = ">=2.1.0,<3.0.0" [package.extras] -all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "crosshair-tool (>=0.0.54)", "django (>=3.2)", "dpcontracts (>=0.4)", "hypothesis-crosshair (>=0.0.2)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.17.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2024.1)"] +all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "crosshair-tool (>=0.0.70)", "django (>=3.2)", "dpcontracts (>=0.4)", "hypothesis-crosshair (>=0.0.13)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.17.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2024.1)"] cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] codemods = ["libcst (>=0.3.16)"] -crosshair = ["crosshair-tool (>=0.0.54)", "hypothesis-crosshair (>=0.0.2)"] +crosshair = ["crosshair-tool (>=0.0.70)", "hypothesis-crosshair (>=0.0.13)"] dateutil = ["python-dateutil (>=1.4)"] django = ["django (>=3.2)"] dpcontracts = ["dpcontracts (>=0.4)"] diff --git a/tests/conftest.py b/tests/conftest.py index 8edaf8fb3..9bf0ed679 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -59,10 +59,16 @@ def seed(request): pytest_plugins = ["tests.fixtures.starknet"] +settings.register_profile( + "nightly", + deadline=None, + max_examples=1500, + phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target], +) settings.register_profile( "ci", deadline=None, - max_examples=1000, + max_examples=100, phases=[Phase.explicit, Phase.reuse, Phase.generate, Phase.target], ) settings.register_profile( diff --git a/tests/src/kakarot/test_kakarot.py b/tests/src/kakarot/test_kakarot.py index 4dd504c23..89757af09 100644 --- a/tests/src/kakarot/test_kakarot.py +++ b/tests/src/kakarot/test_kakarot.py @@ -453,6 +453,7 @@ def test_should_raise_invalid_nonce(self, cairo_run, tx): ) @given(gas_limit=integers(min_value=2**64, max_value=2**248 - 1)) + @SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [34]) def test_raise_gas_limit_too_high(self, cairo_run, gas_limit): tx = { "type": 2, @@ -468,10 +469,7 @@ def test_raise_gas_limit_too_high(self, cairo_run, gas_limit): } tx_data = list(rlp_encode_signed_data(tx)) - with ( - SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [tx["nonce"]]), - cairo_error(message="Gas limit too high"), - ): + with cairo_error(message="Gas limit too high"): cairo_run( "test__eth_send_raw_unsigned_tx", tx_data_len=len(tx_data), @@ -479,6 +477,7 @@ def test_raise_gas_limit_too_high(self, cairo_run, gas_limit): ) @given(maxFeePerGas=integers(min_value=2**128, max_value=2**248 - 1)) + @SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [34]) def test_raise_max_fee_per_gas_too_high(self, cairo_run, maxFeePerGas): tx = { "type": 2, @@ -494,10 +493,7 @@ def test_raise_max_fee_per_gas_too_high(self, cairo_run, maxFeePerGas): } tx_data = list(rlp_encode_signed_data(tx)) - with ( - SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [tx["nonce"]]), - cairo_error(message="Max fee per gas too high"), - ): + with cairo_error(message="Max fee per gas too high"): cairo_run( "test__eth_send_raw_unsigned_tx", tx_data_len=len(tx_data), @@ -543,6 +539,7 @@ def max_priority_fee_too_high(draw): return (max_fee_per_gas, max_priority_fee_per_gas) @SyscallHandler.patch("Kakarot_block_gas_limit", TRANSACTION_GAS_LIMIT) + @SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [34]) @given(max_priority_fee_too_high()) def test_raise_max_priority_fee_too_high( self, cairo_run, max_priority_fee_too_high @@ -561,10 +558,7 @@ def test_raise_max_priority_fee_too_high( } tx_data = list(rlp_encode_signed_data(tx)) - with ( - SyscallHandler.patch("IAccount.get_nonce", lambda _, __: [tx["nonce"]]), - cairo_error(message="Max priority fee greater than max fee per gas"), - ): + with cairo_error(message="Max priority fee greater than max fee per gas"): cairo_run( "test__eth_send_raw_unsigned_tx", tx_data_len=len(tx_data),