flashbots / flashbots/contender

host contracts in contender repo

Open
#252 0 comments 0 reactions 1 assignee Claimed by @zeroXbrock View on GitHub
enhancement
Dominant language
Rust
Stars
141
Forks
57
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

Firstly, contender scenario files use raw bytecode, which is hard to reason about. Additionally, if bytecode is specified without a comment linking to the source, then it's practically impossible to know the exact source code, making debugging difficult.

Most of the scenarios I've written so far have used [high-volume-contract](https://github.com/zeroXbrock/high-volume-contract/tree/main/src) at their core (it contains the `SpamMe` contract). The `fill-block` spam subcommand relies on it as well. We also frequently use include [TestToken](https://github.com/zeroXbrock/testToken/blob/main/src/TestToken.sol) and [Unicheat](https://github.com/zeroXbrock/unicheater/blob/main/src/Unicheat.sol).

It would be nice to have that contract be tightly coupled with contender as we add more subcommands and iterate on the contract.

**Describe the solution you'd like**

We still need our scenarios to use specific bytecode, but we could also use relative file paths, which are easy to read.

We should start by adding support for `.hex` files, but we should also support json files, so the user doesn't have to manually parse the bytecode from their json file into hex.

*for .hex files:*

- we only need the path.
- the contents should be utf8-encoded hex (like [these](https://github.com/flashbots/contender/tree/main/crates/cli/src/default_scenarios/contracts))
- support contents with or without the 0x prefix

*for .json files:*
- we need the path and a filter string to tell us where in the JSON our bytecode is
- filter strings should be interpreted jq-style
- example: the filter string (jq-style) for bytecode from forge builds is `.bytecode.object`
- hardhat's is just `.bytecode`

- make `bytecode` optional in scenario files, add `file` (and `filter` for json)

*add contracts to the contender repo*

- add high-volume-contracts, testToken, unicheater to this repo as submodules
- add a shell script under `scripts/` that checks for the submodules, downloads them if needed, runs `forge build` and writes bytecode from forge artifacts to `crates/cli/src/default_scenarios/contracts/*.hex`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.