From 2c48caae665b6df8d2f7e0a6be2379d7983f096d Mon Sep 17 00:00:00 2001 From: r001 Date: Fri, 17 Nov 2017 13:38:33 +0100 Subject: [PATCH] add 'reserve' variable instead of hard coded gas of 5000 for delegatecall --- src/proxy.sol | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/proxy.sol b/src/proxy.sol index 2a8b50f..1aa6832 100644 --- a/src/proxy.sol +++ b/src/proxy.sol @@ -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)); @@ -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 { @@ -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