github.com/klaytn/klaytn@v1.12.1/contracts/revertTracer/revertContract.sol (about) 1 pragma solidity ^0.4.0; 2 3 /** 4 * @dev Wrappers over Solidity's arithmetic operations with added overflow 5 * checks. 6 * 7 * Arithmetic operations in Solidity wrap on overflow. This can easily result 8 * in bugs, because programmers usually assume that an overflow raises an 9 * error, which is the standard behavior in high level programming languages. 10 * `SafeMath` restores this intuition by reverting the transaction when an 11 * operation overflows. 12 * 13 * Using this library instead of the unchecked operations eliminates an entire 14 * class of bugs, so it's recommended to use it always. 15 */ 16 library SafeMath { 17 18 /** 19 * @dev Returns the subtraction of two unsigned integers, reverting on 20 * overflow (when the result is negative). 21 * 22 * Counterpart to Solidity's `-` operator. 23 * 24 * Requirements: 25 * - Subtraction cannot overflow. 26 */ 27 function sub(uint256 a, uint256 b) internal pure returns (uint256) { 28 require(b <= a, "SafeMath: subtraction overflow"); 29 uint256 c = a - b; 30 31 return c; 32 } 33 } 34 35 contract ContractC { 36 using SafeMath for uint256; 37 38 function c1(uint256 calllimit) public returns(uint256) { 39 return calllimit.sub(1); 40 } 41 function c2(uint256 calllimit) public returns(uint256) { 42 return calllimit.sub(1); 43 } 44 } 45 46 contract ContractB { 47 using SafeMath for uint256; 48 49 address contractC = address(0xaBBcD5b340c80B5F1C0545C04C987b87310296aC); 50 51 function b1(uint256 calllimit) public returns(uint256) { 52 calllimit = calllimit.sub(1); 53 calllimit = ContractC(0xaBBcD5b340c80B5F1C0545C04C987b87310296aC).c1(calllimit); 54 calllimit = ContractC(0xaBBcD5b340c80B5F1C0545C04C987b87310296aC).c2(calllimit); 55 return calllimit.sub(1); 56 } 57 58 function b2(uint256 calllimit) public returns(uint256) { 59 calllimit = calllimit.sub(1); 60 calllimit = ContractC(0xaBBcD5b340c80B5F1C0545C04C987b87310296aC).c1(calllimit); 61 calllimit = ContractC(0xaBBcD5b340c80B5F1C0545C04C987b87310296aC).c2(calllimit); 62 return calllimit.sub(1); 63 } 64 } 65 66 contract ContractA { 67 using SafeMath for uint256; 68 69 function a1(uint256 calllimit) public { 70 calllimit = calllimit.sub(1); 71 calllimit = ContractB(0xabbcD5b340C80B5F1C0545c04c987b87310296AB).b1(calllimit); 72 calllimit = calllimit.sub(1); 73 } 74 }