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

#28 - Ensure _execute and _tryExecute Functions Correctly Handle Calls to EOAs #128

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 22 additions & 5 deletions contracts/base/ExecutionHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,19 @@
assembly {
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)

// Check if the target has code
if iszero(extcodesize(target)) {
mstore(result, 0) // Set result length to 0
mstore(0x40, add(result, 0x20)) // Update free memory pointer

Check warning on line 47 in contracts/base/ExecutionHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/base/ExecutionHelper.sol#L46-L47

Added lines #L46 - L47 were not covered by tests
}

if iszero(call(gas(), target, value, result, callData.length, codesize(), 0x00)) {
// Bubble up the revert if the call reverts.
returndatacopy(result, 0x00, returndatasize())
revert(result, returndatasize())
}

mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
Expand All @@ -64,11 +72,20 @@
assembly {
result := mload(0x40)
calldatacopy(result, callData.offset, callData.length)
success := call(gas(), target, value, result, callData.length, codesize(), 0x00)
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.

// Check if the target has code
if iszero(extcodesize(target)) {
success := 0
mstore(result, 0) // Set result length to 0
mstore(0x40, add(result, 0x20)) // Update free memory pointer

Check warning on line 80 in contracts/base/ExecutionHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/base/ExecutionHelper.sol#L78-L80

Added lines #L78 - L80 were not covered by tests
}
if iszero(success) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

success would already be 0 if it doesn't go to previous block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it will still do this for EOA

success := call(gas(), target, value, result, callData.length, codesize(), 0x00)

success := call(gas(), target, value, result, callData.length, codesize(), 0x00)
mstore(result, returndatasize()) // Store the length.
let o := add(result, 0x20)
returndatacopy(o, 0x00, returndatasize()) // Copy the returndata.
mstore(0x40, add(o, returndatasize())) // Allocate the memory.

Check warning on line 87 in contracts/base/ExecutionHelper.sol

View check run for this annotation

Codecov / codecov/patch

contracts/base/ExecutionHelper.sol#L83-L87

Added lines #L83 - L87 were not covered by tests
}
}
}

Expand Down
Loading