Skip to content

Commit

Permalink
feat: allow disabling account checks so contract's can be pranked (#468)
Browse files Browse the repository at this point in the history
* feat: allow disabling account checks so contract's can be pranked

* update mdbook

* remove medusa.json from version control

* run prettier

---------

Co-authored-by: Anish Naik <[email protected]>
  • Loading branch information
0xalpharush and anishnaik authored Sep 5, 2024
1 parent 3a9b0fa commit 4e56d69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions chain/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type TestChainConfig struct {
// CheatCodeConfig indicates the configuration for EVM cheat codes to use.
CheatCodeConfig CheatCodeConfig `json:"cheatCodes"`

// SkipAccountChecks skips account pre-checks like nonce validation and disallowing non-EOA tx senders (this is done in eth_call, for instance).
SkipAccountChecks bool `json:"skipAccountChecks"`

// ContractAddressOverrides describes contracts that are going to be deployed at deterministic addresses
ContractAddressOverrides map[common.Hash]common.Address `json:"contractAddressOverrides,omitempty"`
}
Expand Down
1 change: 1 addition & 0 deletions chain/config/config_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ func DefaultTestChainConfig() (*TestChainConfig, error) {
CheatCodesEnabled: true,
EnableFFI: false,
},
SkipAccountChecks: true,
}

// Return the generated configuration.
Expand Down
6 changes: 6 additions & 0 deletions docs/src/project_configuration/chain_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ The chain configuration defines the parameters for setting up `medusa`'s underly
- > 🚩 Setting `codeSizeCheckDisabled` to `false` is not recommended since it complicates the fuzz testing process.
- **Default**: `true`

### `skipAccountChecks`

- **Type**: Boolean
- **Description**: If `true`, account-related checks (nonce validation, transaction origin must be an EOA) are disabled in `go-ethereum`.
- **Default**: `true`

## Cheatcode Configuration

### `cheatCodesEnabled`
Expand Down
9 changes: 7 additions & 2 deletions docs/src/static/medusa.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"workerResetLimit": 50,
"timeout": 0,
"testLimit": 0,
"shrinkLimit": 5000,
"callSequenceLength": 100,
"corpusDirectory": "",
"coverageEnabled": true,
"targetContracts": [],
"predeployedContracts": {},
"targetContractsBalances": [],
"constructorArgs": {},
"deployerAddress": "0x30000",
Expand Down Expand Up @@ -45,14 +47,17 @@
"optimizationTesting": {
"enabled": true,
"testPrefixes": ["optimize_"]
}
},
"targetFunctionSignatures": [],
"excludeFunctionSignatures": []
},
"chainConfig": {
"codeSizeCheckDisabled": true,
"cheatCodes": {
"cheatCodesEnabled": true,
"enableFFI": false
}
},
"skipAccountChecks": true
}
},
"compilation": {
Expand Down
4 changes: 4 additions & 0 deletions fuzzing/fuzzer_worker_sequence_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ func (g *CallSequenceGenerator) generateNewElement() (*calls.CallSequenceElement
InputValues: args,
})

if g.worker.fuzzer.config.Fuzzing.TestChainConfig.SkipAccountChecks {
msg.SkipAccountChecks = true
}

// Determine our delay values for this element
blockNumberDelay := uint64(0)
blockTimestampDelay := uint64(0)
Expand Down

0 comments on commit 4e56d69

Please sign in to comment.