Skip to content

Conversation

@ehennenfent
Copy link
Contributor

Previously, contract creation would ignore the consts.oog variable and always check that the caller had the requisite balance. This change checks that we haven't explicitly ignored gas calculations when evaluating whether the transaction has enough balance to proceed.

Eric Hennenfent added 4 commits October 30, 2020 12:31
As I understand it, this is necessary to get the [building secure contracts](https://github.com/crytic/building-secure-contracts) repo passing by default. It's also a frequent first step for real-world EVM analysis, so perhaps it will save some time.

The tests are performing suspiciously well locally. I would have expected some changes to be required. Let's see how GH Actions handles them.
Previously, contract creation would ignore the `consts.oog` variable and always check that the caller had the requisite balance. This change checks that we haven't explicitly ignored gas calculations when evaluating whether the transaction has enough balance to proceed.
Evidently we relied on the gas behavior in some of these tests. Though admittedly, the failure of test_integer_overflow_storageinvariant seems backward to me.

```

_____________ EthBenchmark.test_integer_overflow_storageinvariant ______________
[gw1] linux -- Python 3.6.12 /opt/hostedtoolcache/Python/3.6.12/x64/bin/python

self = <tests.ethereum_bench.test_consensys_benchmark.EthBenchmark testMethod=test_integer_overflow_storageinvariant>

    def test_integer_overflow_storageinvariant(self):
>       self._test("integer_overflow_storageinvariant", set())

tests/ethereum_bench/test_consensys_benchmark.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/ethereum_bench/test_consensys_benchmark.py:57: in _test
    self.assertEqual(expected_findings, actual_findings)
E   AssertionError: Items in the second set but not the first:
E   ('Unsigned integer overflow at ADD instruction', False)
----------------------------- Captured stdout call -----------------
```
@ehennenfent ehennenfent requested review from feliam and montyly November 5, 2020 23:23
@ehennenfent ehennenfent changed the title Extend out-of-gas behavior to cover contract creation Support the examples from the building-secure-contracts repository Nov 6, 2020
@ehennenfent ehennenfent linked an issue Nov 6, 2020 that may be closed by this pull request
except TerminateState as e:
result = str(e)
self.assertEqual(result, "SELFDESTRUCT")
consts.oog = default_gas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possible going to fail if the tests get executed concurrently. Config must go with mcore instance and be frozen and etc etc.
Also there this

Can also be used with a `with-statement context` so it would revert the value, e.g.:
group.var = 100
with group.temp_vals():
group.var = 123
# group.var is 123 for the time of with statement
# group.var is back to 100

Copy link
Contributor

@feliam feliam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need better configuration nobs all around evm.

And also config need to be able to be frzen and to be attached to each mcore instance

@ehennenfent
Copy link
Contributor Author

The building-secure-contracts repo works with #1820, so we don't need the additional gas and timeout changes present in this PR.

@ehennenfent ehennenfent closed this Nov 6, 2020
@dguido dguido deleted the disable-default-gas branch August 21, 2025 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get the building-secure-contracts working out of the box

3 participants