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(vm): add rpc and eth_getLogs cheats #475

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Vm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ interface VmSafe {
string url;
}

struct EthGetLogs {
address emitter;
bytes32[] topics;
bytes data;
bytes32 blockHash;
uint64 blockNumber;
bytes32 transactionHash;
uint64 transactionIndex;
uint256 logIndex;
bool removed;
}

struct DirEntry {
string errorMessage;
string path;
Expand Down Expand Up @@ -123,6 +135,16 @@ interface VmSafe {
// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
function resumeGasMetering() external;

// -------- RPC Methods --------

/// Gets all the logs according to specified filter.
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
returns (EthGetLogs[] memory logs);

// Performs an Ethereum JSON-RPC request to the current fork URL.
function rpc(string calldata method, string calldata params) external returns (bytes memory data);

// ======== Test Configuration ========

// If the condition is false, discard this run's fuzz inputs and generate new ones.
Expand Down
2 changes: 1 addition & 1 deletion test/Vm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract VmTest is Test {
// inadvertently moved between Vm and VmSafe. This test must be updated each time a function is
// added to or removed from Vm or VmSafe.
function test_interfaceId() public {
assertEq(type(VmSafe).interfaceId, bytes4(0x329f5e71), "VmSafe");
assertEq(type(VmSafe).interfaceId, bytes4(0x1578a242), "VmSafe");
assertEq(type(Vm).interfaceId, bytes4(0x316cedc3), "Vm");
}
}