Skip to content

Commit

Permalink
Update ClassicEternalStorageProxy fallback method
Browse files Browse the repository at this point in the history
  • Loading branch information
patitonar committed Mar 19, 2019
1 parent 38c694d commit a072da6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 10 additions & 14 deletions contracts/upgradeability/ClassicEternalStorageProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@ import "./EternalStorage.sol";
import "./OwnedUpgradeabilityProxy.sol";


contract ClassicEternalStorageProxy is OwnedUpgradeabilityProxy, EternalStorage {
contract ClassicEternalStorageProxy is EternalStorage, OwnedUpgradeabilityProxy {

function () payable public {
address _impl = implementation();
require(_impl != address(0));
bytes4 sig;
assembly { sig := calldataload(0) }
uint256 len = getSize(sig);
uint256 len = getSize(msg.sig);
assembly {
calldatacopy(0x0, 0x0, calldatasize)
let result := delegatecall(gas, _impl, 0x0, calldatasize, 0, len)
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, _impl, ptr, calldatasize, 0, len)

switch result
case 0 { revert(0, len) }
default { return(0, len) }
}
}

function getSize(bytes4 sig) public pure returns(uint256) {
if (bytes4(sha3("signature(bytes32,uint256)")) == sig) {
return 132;
function getSize(bytes4 sig) public view returns(uint256) {
uint256 ret = uintStorage[keccak256("dataSizes", sig)];
if (ret == 0) {
ret = 32;
}
if (bytes4(sha3("message(bytes32)")) == sig) {
return 210;
}

return 32;
return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicBridge, BasicHomeBridge,
require(_minPerTx > 0 && _maxPerTx > _minPerTx && _dailyLimit > _maxPerTx);
require(_foreignMaxPerTx < _foreignDailyLimit);
require(_owner != address(0));
uintStorage[keccak256("dataSizes", bytes4(sha3("signature(bytes32,uint256)")))] = 132;
uintStorage[keccak256("dataSizes", bytes4(sha3("message(bytes32)")))] = 210;
addressStorage[keccak256("validatorContract")] = _validatorContract;
uintStorage[keccak256("deployedAtBlock")] = block.number;
uintStorage[keccak256("dailyLimit")] = _dailyLimit;
Expand Down

0 comments on commit a072da6

Please sign in to comment.