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

feature branch: property testing #28

Closed
wants to merge 59 commits into from
Closed

Conversation

0xteddybear
Copy link

No description provided.

@0xteddybear 0xteddybear force-pushed the feat/invariant-testing branch from 50df837 to dbe0d51 Compare September 10, 2024 20:09
mslipper and others added 27 commits September 12, 2024 17:33
This PR adds a proof-of-concept for `op-deployer`, a CLI tool that allows declarative management of live OP Stack chains. This POC supports initializing the declarative chain config (called an "intent") and deploying the Superchain smart contracts using the OP Stack Manager.

An example intent for a Sepolia chain looks like this:

```toml
l1ChainID = 11155111
useFaultProofs = true
useAltDA = false
fundDevAccounts = true
contractArtifactsURL = "file:///Users/matthewslipper/dev/optimism/packages/contracts-bedrock/forge-artifacts"

[superchainRoles]
  proxyAdminOwner = "0xb9cdf788704088a4c0191d045c151fcbe2db14a4"
  protocolVersionsOwner = "0xb910764be39c84d572ff17713c615b5bfd7df650"
  guardian = "0x8c7e4a51acb17719d225bd17598b8a94b46c8767"
```

When deployed, it produces a state file that looks like this:

```json
{
  "version": 1,
  "appliedIntent": {
    "l1ChainID": 11155111,
    "superchainRoles": {
      "proxyAdminOwner": "0xb9cdf788704088a4c0191d045c151fcbe2db14a4",
      "protocolVersionsOwner": "0xb910764be39c84d572ff17713c615b5bfd7df650",
      "guardian": "0x8c7e4a51acb17719d225bd17598b8a94b46c8767"
    },
    "useFaultProofs": true,
    "useAltDA": false,
    "fundDevAccounts": true,
    "contractArtifactsURL": "file:///Users/matthewslipper/dev/optimism/packages/contracts-bedrock/forge-artifacts",
    "chains": null
  },
  "superchainDeployment": {
    "proxyAdminAddress": "0x54a6088c04a7782e69b5031579a1973a9e3c1a8c",
    "superchainConfigProxyAddress": "0xc969afc4799a9350f9f05b60748bc62f2829b03a",
    "superchainConfigImplAddress": "0x08426b74350e7cba5b52be4909c542d28b6b3962",
    "protocolVersionsProxyAddress": "0x212a023892803c7570eb317c77672c8391bf3dde",
    "protocolVersionsImplAddress": "0x2633ac74edb7ae1f1b5656e042285015f9ee477d"
  }
}
```

To use `op-deployer`, run `op-deployer init --dev --l1-chain-id <chain-id>`. This will initialize a deployment intent using the development keys in the repo. Then, run `op-deployer apply --l1-rpc-url <l1-rpc> --private-key <deployer-private-key>` to apply the deployment.

- The contracts deployment is performed by the local Go/Forge tooling.
- Upgrades of the contracts (i.e. modifying them after deploying the contracts afresh) is not currently supported. This will be supported in the future.
- The rest of the pipeline (i.e., deploying L2s and generating genesis files) is not included in this PR to keep it smaller and allow us to get buy-in on the fundamental concepts behind `op-deployer` before further implementation.
Updates test-heavy-fuzz-modified-tests to skip any files that
don't have any modified fuzz tests.
Tweaks various parameters for the heavy fuzz run tests to prevent
the test from taking too long. We can run a daily super heavy fuzz
run instead to catch any rare flakes.
* discard candidate when ahead

* also discard result.Unsafe for consistency

* remove unnecessary type convertion for FakeGenesis

* Revert "also discard result.Unsafe for consistency"

This reverts commit d2288d4.

* remove type cast
Adds interfaces for the two governance contracts.
Renames the Safe folder (uppercase) to safe (lowercase) in line
with all other folders.
* refactor: remove structs from DeployImplementations

* refactor: remove structs from DeployOPChain

* test: fix tests

* Update packages/contracts-bedrock/test/DeployOPChain.t.sol

Co-authored-by: Blaine Malone <[email protected]>

* Update packages/contracts-bedrock/test/DeployOPChain.t.sol

Co-authored-by: Blaine Malone <[email protected]>

* test: add missing assertions

* fix: update fuzz test timeout

---------

Co-authored-by: Blaine Malone <[email protected]>
Co-authored-by: Kelvin Fichter <[email protected]>
…1885)

* feat: Add channel timeout tests for `op-program`

* typo

* assert error

* fix comment
* feat: Add channel timeout tests for `op-program`

* typo

* assert error

* fix comment

* feat: Add garbage frame tests for `op-program`

* assert error

* fix comment
* contracts-bedrock: add permit functionality to mintable erc20

Adds `permit` functionality to `OptimismMintableERC20` tokens
that are deployed by the `OptimismMintableERC20Factory`.

* feat: max approve permit2 in ERC20Mintable

This commit max approves permit2 automatically for all holders of the
ERC20 bridge token. This enables all users on OP stack chains to skip an
approval step for actions on protocols utilizing permit2 e.g. Uniswap

* fix: constants first

* semver-lock: update

* snapshots: fix

* contracts: add natspec

* semver-lock: update

* contracts-bedrock: fix nits

* snapshots: update

---------

Co-authored-by: Mark Toda <[email protected]>
Fixes an incorrect import inside of ManageDrippie.s.sol. Seems to
work just fine when forge install is executed but not otherwise.
* op-e2e: Use mt-cannon

Introduces a `USE_MT_CANNON` env to optionally enables MT-Cannon in
op-e2e integration tests

* a couple of fixes

* fix todo
…reum-optimism#11902)

* op-program: Support injecting a Prefetcher creator rather than setting code on the Config object.

* op-program: Use an interface for the Prefetcher instead of requiring a concrete type.
* feat: `op-program` actor test API improvements

* lint

* sort fix

* rebase
Automatically use the correct format if it has been recorded.

Change the default format to directory. Compatibility with op-challenger is preserved because it now uses the automatic format detection, defaulting to file if not specified (e.g for kona-host).
* feat: Scaffolding for DeployAuthSystemInput

* fix: Remove undefined import

* feat: Address feedback
* op-chain-ops/interopgen: OPSM powered interop genesis

* ci: make forge scripts available to op-e2e

* op-chain-ops: address interopgen review comments
…#11911)

* cannon: Handle preimage bounds checks consistently

* cannon: Cleanup stray comment
* feat: Scaffolding for DeployAuthSystemInput

* feat: Scaffolding for DeployAuthSystem Output

* feat: Address feedback and remove comments
* op-e2e: interop test setup (work in progress)

* op-e2e: interop test setup

* organization and comment updates

* refactor creation code into WIP system2

* save secrets per L2

* Add SuperSystem Interface ; Add Users and Transactions

* Further Refactoring ; Fix Test

* Add Supervisor

* Add Supervisor Client

* Comment out Proposer

* Add AddL2RPC to Supervisor Client

* Fully link Supervisor and OP Node in E2E Test

* correct RPC call supervisor_checkBlock

* Make EOF acceptable for backend check

* final structure names

* Change unused functions to _ for linter

* fix import order

* Add Github Issue Numbers to TODOs

* tynes comments: add World Resource as configurable

---------

Co-authored-by: protolambda <[email protected]>
* fix: getting stack underflow error.

* feat: adding proxy infront of OPStackManager.

* fix: PR comments, we're landing on using the initialize function over setRelease.

* fix: rename function.

* fix: nit

* fix: infering proxy admin from superchain config.

* fix: ran command: just pre-pr-no-build

* fix: nits

* fix: using CommonBase in DeployImplementations.s.sol.

* op-chain-ops: pass superchain proxy admin address as input to deployments script

---------

Co-authored-by: Matt Solomon <[email protected]>
Co-authored-by: protolambda <[email protected]>
…11914)

* fix: Additional testing for inferring proxy admin from superchain config.

* Apply suggestions from code review

---------

Co-authored-by: Matt Solomon <[email protected]>
…thereum-optimism#11920)

* op-e2e: Move action test helpers for proofs to a separate package.

* op-e2e: Use helpers package under proofs rather than a completely separate package tree for helpers.
@0xteddybear 0xteddybear force-pushed the feat/invariant-testing branch from 7125c39 to dc346c3 Compare September 16, 2024 12:57
…#11906)

* cannon: Extract RMW op handling from shared logic

* cannon: Add more test cases of LL/SC behavior

* cannon: Cut ll/sc-related logic from common mips code

* cannon: Setup mips helpers to return memory modification info

* cannon: Add new fields to track reserved memory

* cannon: Add a boolean field indicating whether an ll reservation is active

* cannon: Implement ll/sc for MTCannon

* cannon: Add modified sysRead tests for MTCannon

* cannon: Test store operations cleare memory reservations

* cannon: Update SysClockGettime to clear ll memory reservation

* cannon: Fix slither warning - initialize variable

* cannon: Bump MIP2.sol version

* cannon: Run semver, snapshot tasks

* cannon: Cut unused log msg

* cannon: Add new error to MIPS interfaces

* cannon: Cut stale TODO
clabby and others added 12 commits September 16, 2024 22:39
ethereum-optimism#11926)

* feat(op-e2e): Expose `L1Replica` + `L2Engine` + `BlobsStore` endpoints

* mutex

* deterministic blob indexing

* proto review

* lint
* op-e2e: Fix compile error

* ci: Make go-lint a dependency of bedrock-go-tests to prevent merging if it fails.
…mism#11921)

* op-e2e: Move most action tests into a package based on what they test

* op-e2e: Move batch_queue_test.go to derivation package

* op-e2e: Move eip4844_test.go to batcher package

* op-e2e: Move actions helper code to helpers package

* update makefile

* op-e2e: Fix typo

---------

Co-authored-by: clabby <[email protected]>
* feat(op-e2e): Kona FPP actions test adapter

* rebase

* lint

* review

* fix result check
* op-e2e: organize system tests

* op-e2e: update CI make targets

* op-e2e: fix artifacts file paths

* op-e2e: Fix paths.

* op-e2e: Fix paths again

---------

Co-authored-by: Adrian Sutton <[email protected]>
* chore: fix comment

* feat: add assertions

* fix: use method instead of new

* refactor: make salt into an input

* refactor: unify checkOutput function signatures

* chore: update snapshots

* test: fix testContractAuth

* test: fix checkOutput signatures

* fix: update go DeployImplementationsInput struct with salt

* pr feedback

* chore: semver lock
* Disable go patches for cannon MT.

Fix the prestate file list for devnet to use the binary cannon MT prestates.

* Update Makefile

---------

Co-authored-by: Inphi <[email protected]>
* feat: Scaffolding for DeployAuthSystem Script

* feat: Remove redundant documentation

* Update DeployAuthSystem.s.sol
)

* feat: Rewrite FP contract distinctions as table

* feat: clarify handling of non-MCP contracts

* feat: Update pending mcp statuses
@0xteddybear 0xteddybear force-pushed the feat/invariant-testing branch from 9cbd6a9 to da25a61 Compare September 17, 2024 16:34
smartcontracts and others added 12 commits September 17, 2024 17:20
Moves WETH98 over to the universal/ folder where it belongs and
brings DelayedWETH up to the top of the dispute folder since there
is no longer any need for a weth/ subfolder.
- 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
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
fix: fixes after lovely feedback by disco
docs: merge both documents and categorized properties by their milestone
fix: fixes from parti's review
fix: feedback from disco
fix: feedback from doc
refactor: separate state transitions from pure properties
docs: update tested properties
refactor: move all assertions into properties contract
fix: move function without assertions back into handler
test: only use assertion mode
fix: improve justfile recipie for medusa
* 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]>
* test: cross-user fuzzed bridges + actor setup

* test: fuzz properties 8 and 9

* test: properties 7 and 25

* fix: implement doc's feedback

* test: superc20 tob properties (#27)

* chore: add crytic/properties dependency

* test: extend protocol properties so it also covers ToB erc20 properties

* chore: small linter fixes

* docs: update property list

* test: handlers for remaining superc20 state transitions

* fix: disable ToB properties we are not using and guide the fuzzer a bit more

* fix: disable another ToB property not implemented by solady

* chore: remove zero-initializations

* fix: feedback from disco

* chore: separate fuzz campaign tests in guided vs unguided

* test: dont revert on successful unguided relay

* test: add fuzzed calls to burn and mint

* docs: document the separation of fuzz test functions

* chore: move the properties file to its own directory

* chore: consistently use fuzz_ and property_ + camelcase

* chore: fix typo

* chore: camelcase for handlers as well

* fix: revert change that broke halmos campaign compile :D
* test: changed mocked messenger ABI for message sending but kept assertions the same

* docs: add new properties 26&27

* test: queue cross-chain messages and test related properties

* test: relay random messages from queue and check associated invariants

* chore: rename bridge->senderc20 method for consistency with relayerc20

* test: not-yet-deployed supertokens can get funds sent to them

* chore: medusa runs forever by default

doable since it also handles SIGINTs gracefully

* chore: document the reason behind relay zero and send zero inconsistencies

* fix: feedback from doc

* fix: walk around possible medusa issue

I'm getting an 'unknown opcode 0x4e' in ProtocolAtomic constructor when
calling the MockL2ToL2CrossDomainMessenger for the first time

* test: unguided handler for sendERC20

* fix: feedback from disco
* chore: track assertion failures

this is so foundry's invariant contract can check that an assertion
returned false in the handler, while still allowing `fail_on_revert =
false` so we can still take full advantage of medusa's fuzzer & coverage
reports

* fix: explicitly skip duplicate supertoken deployments

* chore: remove duplicated PROPERTIES.md file

* chore: expose data to foundry's external invariant checker

* test: run medusa fuzzing campaign from within foundry

* fix: eagerly check for duplicate deployments

* fix: feedback from doc

* chore: shoehorn medusa campaign into foundry dir structure

* chore: remove PROPERTIES.md file

* chore: delete medusa config

* docs: limited support for subdirectories in test/invariant

* chore: rename contracts to be more sneaky about medusa

* docs: rewrite invariant docs in a way compliant with autogen scripts
* chore: revert modifications from medusa campaign

* docs: extra docs on why ForTest contract is required

* doc: add list of all supertoken properties
@0xteddybear 0xteddybear force-pushed the feat/invariant-testing branch from 485620a to 0ede775 Compare September 17, 2024 18:31
Copy link

github-actions bot commented Oct 2, 2024

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Oct 2, 2024
@0xteddybear
Copy link
Author

closing as this was already merged to upstream repo in ethereum-optimism#11776

@0xteddybear 0xteddybear closed this Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.