Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: superc20 kontrol tests #36

Merged
merged 50 commits into from
Sep 18, 2024

Conversation

0xDiscotech
Copy link

@0xDiscotech 0xDiscotech commented Aug 29, 2024

Failing proofs:

  • 8: prove_sendERC20ZeroCall
  • 9: prove_relayERC20ZeroCall

0xteddybear and others added 22 commits August 15, 2024 12:37
- used --foundry-compile-all to ensure the test contract under
  `test/properties` is compiled (otherwise it is not compiled and medusa
  crashes when it can't find it's compiled representation)
- set src,test,script to test/properties/medusa to not waste time
  compiling contracts that are not required for the medusa campaign
- used an atomic bridge, which doesnt allow for testing of several of
  the proposed invariants
previously: initial mint, bound on transfer amount: 146625 calls in 200s
now: no initial mint, no bound on transfer amount: 176835 calls in 200s

it doesn't seem to slow the fuzzer down
Chore: setup medusa + 1 basic fuzz scenario
* feat: introduce OptimismSuperchainERC20

* fix: contract fixes

* feat: add snapshots and semver

* test: add supports interface tests

* test: add invariant test

* feat: add parameters to the RelayERC20 event

* fix: typo

* fix: from param description

* fix: event signature and interface pragma

* feat: add initializer

* feat: use unstructured storage and OZ v5

* feat: update superchain erc20 interfaces

* fix: adapt storage to ERC7201

* test: add initializable OZ v5 test

* fix: invariant docs

* fix: ERC165 implementation

* test: improve superc20 invariant (#11)

* fix: gas snapshot

* chore: configure medusa with basic supERC20 self-bridging

- used --foundry-compile-all to ensure the test contract under
  `test/properties` is compiled (otherwise it is not compiled and medusa
  crashes when it can't find it's compiled representation)
- set src,test,script to test/properties/medusa to not waste time
  compiling contracts that are not required for the medusa campaign
- used an atomic bridge, which doesnt allow for testing of several of
  the proposed invariants

* fix: delete dead code

* test: give the fuzzer a head start

* feat: create suite for sybolic tests with halmos

* test: setup and 3 properties with symbolic tests

* chore: remove todo comment

* docs: fix properties order

* test: document & implement assertions 22, 23  and 24

* fix: fixes from self-review

* test: guide the fuzzer a little bit less

previously: initial mint, bound on transfer amount: 146625 calls in 200s
now: no initial mint, no bound on transfer amount: 176835 calls in 200s

it doesn't seem to slow the fuzzer down

* feat: add property for burn

* refactor: remove symbolic address on mint property

* refactor: order the tests based on the property id

* feat: checkpoint

* chore: set xdomain sender on failing test

* chore: enhance mocks

* Revert "Merge branch 'chore/setup-medusa' into feat/halmos-symbolic-tests"

This reverts commit 945d6b6, reversing
changes made to 5dcb3a8.

* refactor: remove symbolic addresses to make all of the test work

* chore: remove console logs

* feat: add properties file

* chore: polish

* refactor: enhance test on property 7 using direct try catch (now works)

* fix: review comments

* refactor: add symbolic addresses on test functions

* feat: create halmos toml

* chore: polish test contract and mock

* chore: update property

* refactor: move symbolic folder into properties one

* feat: create advanced tests helper contract

* refactor: enhance tests using symbolic addresses instead of concrete ones

* chore: remove 0 property natspec

* feat: add halmos profile and just script

* chore: rename symbolic folder to halmos

* feat: add halmos commands to justfile

* chore: reorder assertions on one test

* refactor: complete test property seven

* chore: mark properties as completed

* chore: add halmos-cheatcodes dependency

* chore: rename advancedtest->halmosbase

* chore: minimize mocked messenger

* chore: delete empty halmos file

* chore: revert changes to medusa.json

* docs: update changes to PROPERTIES.md from base branch

* test: sendERC20 destination fix

* chore: natspec fixes

---------

Co-authored-by: agusduha <[email protected]>
Co-authored-by: 0xng <[email protected]>
Co-authored-by: teddy <[email protected]>
* refactor: allow for atomicity on mock messenger

* refactor: cross domain sender logic on mock messenger

* refactor: l2 to l2 caller and messenge sender logic

* chore: remove assumes for removed checks on mock messenger
@0xDiscotech 0xDiscotech self-assigned this Aug 29, 2024
@0xDiscotech 0xDiscotech changed the base branch from feat/add-crosschain-properties to feat/symbolic-testing September 10, 2024 15:08
@0xDiscotech 0xDiscotech marked this pull request as ready for review September 13, 2024 14:53
/// @custom:property-id 14
/// @custom:property Supertoken total supply starts at zero
function prove_totalSupplyStartsAtZero() public {
setUpInlined();
Copy link
Member

Choose a reason for hiding this comment

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

shoudn't we us a "regular" setup for this property tho (ie deploy the contract here, with symb constructor args, instead of the state diff? I don't really see what we'd test here otherwise, this sounds like a single branch)

Copy link
Author

Choose a reason for hiding this comment

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

I don't get which is the difference, if we already rely on the setup for the other properties, why not for this one?
The property says the total supply should start at zero, and I'm testing that after the state diff setup.
I'm open to change my mind ofc

Copy link
Member

Choose a reason for hiding this comment

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

We use these concrete values in the state which is replayed:

abi.encodeCall(OptimismSuperchainERC20.initialize, (remoteToken, name, symbol, decimals))

So this test is solely based on the deployment with concrete value, and only assess one single case -> I agree it shouldn't change much of the underlying logic, but if we want to test the initial state, shouldn't these concrete values be symbolic instead (ie catching a bug where total supply > 0 if decimals is 10**123)?

Copy link
Member

@simon-something simon-something left a comment

Choose a reason for hiding this comment

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

left some comments, rather minors - gg! (not approving to avoid discarded approval circle of hell)

@0xDiscotech 0xDiscotech changed the title feat: checkpoint of superc20 kontrol tests feat: superc20 kontrol tests Sep 18, 2024
@0xDiscotech 0xDiscotech merged commit da66366 into feat/symbolic-testing Sep 18, 2024
3 checks passed
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.

3 participants