Skip to content

add 'reserve' variable instead of hard coded gas of 5000 for delegatecall #13

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 13 additions & 1 deletion src/proxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import "ds-note/note.sol";
// i.e. a multisig
contract DSProxy is DSAuth, DSNote {
DSProxyCache public cache; // global cache for contracts
uint128 public reserve = 5000; // reserve gas after delegatecall

function DSProxy(address _cacheAddr) public {
require(setCache(_cacheAddr));
Expand Down Expand Up @@ -61,7 +62,7 @@ contract DSProxy is DSAuth, DSNote {

// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
let succeeded := delegatecall(sub(gas, reserve), _target, add(_data, 0x20), mload(_data), 0, 32)
response := mload(0) // load delegatecall output
switch iszero(succeeded)
case 1 {
Expand All @@ -82,6 +83,17 @@ contract DSProxy is DSAuth, DSNote {
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}

//set the reserve gas for contract after delegatecall
function setReserve(uint128 _gas)
public
auth
note
returns(bool)
{
reserve = _gas;
return true;
}
}

// DSProxyFactory
Expand Down