Skip to content

Commit

Permalink
feat(cheatcodes): Record Account and Storage Access Cheatcodes (#6310)
Browse files Browse the repository at this point in the history
* Record storage and account access cheatcodes

Co-authored-by: James Wenzel <wenzel.james.r@gmail.com>

* expand record access cheatcode interface

Adds a couple more fields to recorded account and storage accesses.

* fix small doc comment nit

* fix(cheatcodes): account access doc comment

* fix(cheatcodes): clarify reverted account access status

* fix(cheatcodes): clarify balance doc comments

* fix(cheatcodes): clarify initialized account access field in doc comment

* update Access kind to include Resumed account access

Also rename cheats APIs

* cleanup Resume logic

* fmt

* remove unused Resume access kind

* add chain_id to AccountAccess

* Update crates/cheatcodes/spec/src/vm.rs

Co-authored-by: refcell.eth <abigger87@gmail.com>

* add ChainInfo struct; address PR comments

* avoid old skool ref mut

* tidy code per pr review

* rmeove unused import

* address nits

* selfdesutrct on record ctx check

---------

Co-authored-by: refcell <abigger87@gmail.com>
Co-authored-by: James Wenzel <wenzel.james.r@gmail.com>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent 141bd91 commit c948388
Show file tree
Hide file tree
Showing 9 changed files with 2,170 additions and 10 deletions.
6 changes: 6 additions & 0 deletions crates/abi/abi/HEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ struct DirEntry { string errorMessage; string path; uint64 depth; bool isDir; bo
struct FsMetadata { bool isDir; bool isSymlink; uint256 length; bool readOnly; uint256 modified; uint256 accessed; uint256 created; }
struct Wallet { address addr; uint256 publicKeyX; uint256 publicKeyY; uint256 privateKey; }
struct FfiResult { int32 exitCode; bytes stdout; bytes stderr; }
struct ChainInfo { uint256 forkId; uint256 chainId; }
struct AccountAccess { ChainInfo chainInfo; uint256 kind; address account; address accessor; bool initialized; uint256 oldBalance; uint256 newBalance; bytes deployedCode; uint256 value; bytes data; bool reverted; StorageAccess[] storageAccesses; }
struct StorageAccess { address account; bytes32 slot; bool isWrite; bytes32 previousValue; bytes32 newValue; bool reverted; }

allowCheatcodes(address)

Expand Down Expand Up @@ -84,6 +87,9 @@ record()
accesses(address)(bytes32[], bytes32[])
skip(bool)

startStateDiffRecording()
stopAndReturnStateDiff()(AccountAccess[])

recordLogs()
getRecordedLogs()(Log[])

Expand Down
271 changes: 271 additions & 0 deletions crates/abi/src/bindings/hevm.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c948388

Please sign in to comment.