-
Notifications
You must be signed in to change notification settings - Fork 555
Gasless ContractPublisher without chainid in typehash #235
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
Conversation
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
// require(req.chainid == block.chainid, "MinimalForwarder: invalid chainId"); | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
(bool success, bytes memory returndata) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
// Validate that the relayer has sent enough gas for the call. | ||
// See https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
if (gasleft() <= req.gas / 63) { | ||
// We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since | ||
// neither revert or assert consume all gas since Solidity 0.8.0 | ||
// https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require | ||
assembly { | ||
invalid() | ||
} | ||
} | ||
|
||
return (success, returndata); | ||
} |
Check failure
Code scanning / Slither
Functions that send Ether to arbitrary destinations
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, bytes memory result) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
if (!success) { | ||
// Next 5 lines from https://ethereum.stackexchange.com/a/83577 | ||
if (result.length < 68) revert("Transaction reverted silently"); | ||
assembly { | ||
result := add(result, 0x04) | ||
} | ||
revert(abi.decode(result, (string))); | ||
} | ||
// Check gas: https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
assert(gasleft() > req.gas / 63); | ||
return (success, result); | ||
} |
Check failure
Code scanning / Slither
Functions that send Ether to arbitrary destinations
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, bytes memory result) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
if (!success) { | ||
// Next 5 lines from https://ethereum.stackexchange.com/a/83577 | ||
if (result.length < 68) revert("Transaction reverted silently"); | ||
assembly { | ||
result := add(result, 0x04) | ||
} | ||
revert(abi.decode(result, (string))); | ||
} | ||
// Check gas: https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
assert(gasleft() > req.gas / 63); | ||
return (success, result); | ||
8000 | } |
Check warning
Code scanning / Slither
Assembly usage
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
// require(req.chainid == block.chainid, "MinimalForwarder: invalid chainId"); | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
(bool success, bytes memory returndata) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
// Validate that the relayer has sent enough gas for the call. | ||
// See https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
if (gasleft() <= req.gas / 63) { | ||
// We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since | ||
// neither revert or assert consume all gas since Solidity 0.8.0 | ||
// https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require | ||
assembly { | ||
invalid() | ||
} | ||
} | ||
|
||
return (success, returndata); | ||
} |
Check warning
Code scanning / Slither
Assembly usage
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, bytes memory result) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
if (!success) { | ||
// Next 5 lines from https://ethereum.stackexchange.com/a/83577 | ||
if (result.length < 68) revert("Transaction reverted silently"); | ||
assembly { | ||
result := add(result, 0x04) | ||
} | ||
revert(abi.decode(result, (string))); | ||
} | ||
// Check gas: https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
assert(gasleft() > req.gas / 63); | ||
return (success, result); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
function execute(ForwardRequest calldata req, bytes calldata signature) | ||
public | ||
payable | ||
returns (bool, bytes memory) | ||
{ | ||
// require(req.chainid == block.chainid, "MinimalForwarder: invalid chainId"); | ||
require(verify(req, signature), "MinimalForwarder: signature does not match request"); | ||
_nonces[req.from] = req.nonce + 1; | ||
|
||
(bool success, bytes memory returndata) = req.to.call{ gas: req.gas, value: req.value }( | ||
abi.encodePacked(req.data, req.from) | ||
); | ||
|
||
// Validate that the relayer has sent enough gas for the call. | ||
// See https://ronan.eth.link/blog/ethereum-gas-dangers/ | ||
if (gasleft() <= req.gas / 63) { | ||
// We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since | ||
// neither revert or assert consume all gas since Solidity 0.8.0 | ||
// https://docs.soliditylang.org/en/v0.8.0/control-structures.html#panic-via-assert-and-error-via-require | ||
assembly { | ||
invalid() | ||
} | ||
} | ||
|
||
return (success, returndata); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
For chainless we should support https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator |
No description provided.