Skip to content
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

Use hex-identifiers directly #303

Merged
merged 5 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion contracts/mocks/FeeManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract FeeManagerMock is BaseFeeManager {
}

function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-one-direction")));
return 0xf2aed8f7; // "manages-one-direction"
}

function randomTest(uint256 _count) external view returns (uint256) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/upgradeable_contracts/BaseBridgeValidators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ contract BaseBridgeValidators is Initializable, Ownable {

address public constant F_ADDR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
uint256 internal constant MAX_VALIDATORS = 100;
bytes32 internal constant REQUIRED_SIGNATURES = keccak256(abi.encodePacked("requiredSignatures"));
bytes32 internal constant VALIDATOR_COUNT = keccak256(abi.encodePacked("validatorCount"));
bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // "requiredSignatures"
bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // "validatorCount"

event ValidatorAdded(address indexed validator);
event ValidatorRemoved(address indexed validator);
Expand Down
4 changes: 2 additions & 2 deletions contracts/upgradeable_contracts/BaseFeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ contract BaseFeeManager is EternalStorage, FeeTypes {

// This is not a real fee value but a relative value used to calculate the fee percentage
uint256 internal constant MAX_FEE = 1 ether;
bytes32 internal constant HOME_FEE_STORAGE_KEY = keccak256(abi.encodePacked("homeFee"));
bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = keccak256(abi.encodePacked("foreignFee"));
bytes32 internal constant HOME_FEE_STORAGE_KEY = 0xc3781f3cec62d28f56efe98358f59c2105504b194242dbcb2cc0806850c306e7; // "homeFee"
bytes32 internal constant FOREIGN_FEE_STORAGE_KEY = 0x68c305f6c823f4d2fa4140f9cf28d32a1faccf9b8081ff1c2de11cf32c733efc; // "foreignFee"

function calculateFee(uint256 _value, bool _recover, bytes32 _feeType) public view returns (uint256) {
uint256 fee = _feeType == HOME_FEE ? getHomeFee() : getForeignFee();
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/BaseOverdrawManagement.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contract BaseOverdrawManagement is EternalStorage {
event AmountLimitExceeded(address recipient, uint256 value, bytes32 transactionHash);
event AssetAboveLimitsFixed(bytes32 indexed transactionHash, uint256 value, uint256 remaining);

bytes32 internal constant OUT_OF_LIMIT_AMOUNT = keccak256(abi.encodePacked("outOfLimitAmount"));
bytes32 internal constant OUT_OF_LIMIT_AMOUNT = 0x145286dc85799b6fb9fe322391ba2d95683077b2adf34dd576dedc437e537ba7; // "outOfLimitAmount"

function outOfLimitAmount() public view returns (uint256) {
return uintStorage[OUT_OF_LIMIT_AMOUNT];
Expand Down
4 changes: 2 additions & 2 deletions contracts/upgradeable_contracts/BasicBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ contract BasicBridge is Initializable, Validatable, Ownable, Upgradeable, Claima
event GasPriceChanged(uint256 gasPrice);
event RequiredBlockConfirmationChanged(uint256 requiredBlockConfirmations);

bytes32 internal constant GAS_PRICE = keccak256(abi.encodePacked("gasPrice"));
bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = keccak256(abi.encodePacked("requiredBlockConfirmations"));
bytes32 internal constant GAS_PRICE = 0x55b3774520b5993024893d303890baa4e84b1244a43c60034d1ced2d3cf2b04b; // "gasPrice"
bytes32 internal constant REQUIRED_BLOCK_CONFIRMATIONS = 0x916daedf6915000ff68ced2f0b6773fe6f2582237f92c3c95bb4d79407230071; // "requiredBlockConfirmations"

function setGasPrice(uint256 _gasPrice) external onlyOwner {
require(_gasPrice > 0);
Expand Down
12 changes: 6 additions & 6 deletions contracts/upgradeable_contracts/BasicTokenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ contract BasicTokenBridge is EternalStorage, Ownable {
event DailyLimitChanged(uint256 newLimit);
event ExecutionDailyLimitChanged(uint256 newLimit);

bytes32 internal constant MIN_PER_TX = keccak256(abi.encodePacked("minPerTx"));
bytes32 internal constant MAX_PER_TX = keccak256(abi.encodePacked("maxPerTx"));
bytes32 internal constant DAILY_LIMIT = keccak256(abi.encodePacked("dailyLimit"));
bytes32 internal constant EXECUTION_MAX_PER_TX = keccak256(abi.encodePacked("executionMaxPerTx"));
bytes32 internal constant EXECUTION_DAILY_LIMIT = keccak256(abi.encodePacked("executionDailyLimit"));
bytes32 internal constant DECIMAL_SHIFT = keccak256(abi.encodePacked("decimalShift"));
bytes32 internal constant MIN_PER_TX = 0xbbb088c505d18e049d114c7c91f11724e69c55ad6c5397e2b929e68b41fa05d1; // "minPerTx"
bytes32 internal constant MAX_PER_TX = 0x0f8803acad17c63ee38bf2de71e1888bc7a079a6f73658e274b08018bea4e29c; // "maxPerTx"
bytes32 internal constant DAILY_LIMIT = 0x4a6a899679f26b73530d8cf1001e83b6f7702e04b6fdb98f3c62dc7e47e041a5; // "dailyLimit"
bytes32 internal constant EXECUTION_MAX_PER_TX = 0xc0ed44c192c86d1cc1ba51340b032c2766b4a2b0041031de13c46dd7104888d5; // "executionMaxPerTx"
bytes32 internal constant EXECUTION_DAILY_LIMIT = 0x21dbcab260e413c20dc13c28b7db95e2b423d1135f42bb8b7d5214a92270d237; // "executionDailyLimit"
bytes32 internal constant DECIMAL_SHIFT = 0x1e8ecaafaddea96ed9ac6d2642dcdfe1bebe58a930b1085842d8fc122b371ee5; // "decimalShift"

function totalSpentPerDay(uint256 _day) public view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("totalSpentPerDay", _day))];
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/BlockRewardBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../upgradeability/EternalStorage.sol";
import "openzeppelin-solidity/contracts/AddressUtils.sol";

contract BlockRewardBridge is EternalStorage {
bytes32 internal constant BLOCK_REWARD_CONTRACT = keccak256(abi.encodePacked("blockRewardContract"));
bytes32 internal constant BLOCK_REWARD_CONTRACT = 0x20ae0b8a761b32f3124efb075f427dd6ca669e88ae7747fec9fd1ad688699f32; // "blockRewardContract"
bytes4 internal constant BLOCK_REWARD_CONTRACT_ID = 0x2ee57f8d; // blockRewardContractId()
bytes4 internal constant BRIDGES_ALLOWED_LENGTH = 0x10f2ee7c; // bridgesAllowedLength()

Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol";
import "openzeppelin-solidity/contracts/AddressUtils.sol";

contract ERC20Bridge is EternalStorage {
bytes32 internal constant ERC20_TOKEN = keccak256(abi.encodePacked("erc20token"));
bytes32 internal constant ERC20_TOKEN = 0x15d63b18dbc21bf4438b7972d80076747e1d93c4f87552fe498c90cbde51665e; // "erc20token"

function erc20token() public view returns (ERC20Basic) {
return ERC20Basic(addressStorage[ERC20_TOKEN]);
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/ERC677Storage.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity 0.4.24;

contract ERC677Storage {
bytes32 internal constant ERC677_TOKEN = keccak256(abi.encodePacked("erc677token"));
bytes32 internal constant ERC677_TOKEN = 0xa8b0ade3e2b734f043ce298aca4cc8d19d74270223f34531d0988b7d00cba21d; // "erc677token"
}
4 changes: 2 additions & 2 deletions contracts/upgradeable_contracts/FeeTypes.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity 0.4.24;

contract FeeTypes {
bytes32 internal constant HOME_FEE = keccak256(abi.encodePacked("home-fee"));
bytes32 internal constant FOREIGN_FEE = keccak256(abi.encodePacked("foreign-fee"));
bytes32 internal constant HOME_FEE = 0x89d93e5e92f7e37e490c25f0e50f7f4aad7cc94b308a566553280967be38bcf1; // "home-fee"
bytes32 internal constant FOREIGN_FEE = 0xdeb7f3adca07d6d1f708c1774389db532a2b2f18fd05a62b957e4089f4696ed5; // "foreign-fee"
}
4 changes: 2 additions & 2 deletions contracts/upgradeable_contracts/Initializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity 0.4.24;
import "../upgradeability/EternalStorage.sol";

contract Initializable is EternalStorage {
bytes32 internal constant INITIALIZED = keccak256(abi.encodePacked("isInitialized"));
bytes32 internal constant DEPLOYED_AT_BLOCK = keccak256(abi.encodePacked("deployedAtBlock"));
bytes32 internal constant INITIALIZED = 0x0a6f646cd611241d8073675e00d1a1ff700fbf1b53fcf473de56d1e6e4b714ba; // "isInitialized"
bytes32 internal constant DEPLOYED_AT_BLOCK = 0xb120ceec05576ad0c710bc6e85f1768535e27554458f05dcbb5c65b8c7a749b0; // "deployedAtBlock"

function setInitialize() internal {
boolStorage[INITIALIZED] = true;
Expand Down
6 changes: 4 additions & 2 deletions contracts/upgradeable_contracts/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ contract Ownable is EternalStorage {
_;
}

bytes32 internal constant OWNER = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0; // "owner"

/**
* @dev Tells the address of the owner
* @return the address of the owner
*/
function owner() public view returns (address) {
return addressStorage[keccak256(abi.encodePacked("owner"))];
return addressStorage[OWNER];
}

/**
Expand All @@ -45,6 +47,6 @@ contract Ownable is EternalStorage {
*/
function setOwner(address newOwner) internal {
emit OwnershipTransferred(owner(), newOwner);
addressStorage[keccak256(abi.encodePacked("owner"))] = newOwner;
addressStorage[OWNER] = newOwner;
}
}
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/ReentrancyGuard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.4.24;
import "../upgradeability/EternalStorage.sol";

contract ReentrancyGuard is EternalStorage {
bytes32 internal constant LOCK = keccak256(abi.encodePacked("lock"));
bytes32 internal constant LOCK = 0x6168652c307c1e813ca11cfb3a601f1cf3b22452021a5052d8b05f1f1f8a3e92; // "lock"

function lock() internal returns (bool) {
return boolStorage[LOCK];
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/RewardableBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract RewardableBridge is Ownable, FeeTypes {
event FeeDistributedFromAffirmation(uint256 feeAmount, bytes32 indexed transactionHash);
event FeeDistributedFromSignatures(uint256 feeAmount, bytes32 indexed transactionHash);

bytes32 internal constant FEE_MANAGER_CONTRACT = keccak256(abi.encodePacked("feeManagerContract"));
bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3e2f2516078c38c68a3149787976ee837e5; // "feeManagerContract"
bytes4 internal constant GET_HOME_FEE = 0x94da17cd; // getHomeFee()
bytes4 internal constant GET_FOREIGN_FEE = 0xffd66196; // getForeignFee()
bytes4 internal constant GET_FEE_MANAGER_MODE = 0xf2ba9561; // getFeeManagerMode()
Expand Down
2 changes: 1 addition & 1 deletion contracts/upgradeable_contracts/ValidatorStorage.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pragma solidity 0.4.24;

contract ValidatorStorage {
bytes32 internal constant VALIDATOR_CONTRACT = keccak256(abi.encodePacked("validatorContract"));
bytes32 internal constant VALIDATOR_CONTRACT = 0x5a74bb7e202fb8e4bf311841c7d64ec19df195fee77d7e7ae749b27921b6ddfe; // "validatorContract"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ contract BasicAMBErc677ToErc677 is
{
event FailedMessageFixed(bytes32 indexed dataHash, address recipient, uint256 value);

bytes32 internal constant BRIDGE_CONTRACT = keccak256(abi.encodePacked("bridgeContract"));
bytes32 internal constant MEDIATOR_CONTRACT = keccak256(abi.encodePacked("mediatorContract"));
bytes32 internal constant REQUEST_GAS_LIMIT = keccak256(abi.encodePacked("requestGasLimit"));
bytes32 internal constant NONCE = keccak256(abi.encodePacked("nonce"));
bytes32 internal constant BRIDGE_CONTRACT = 0x811bbb11e8899da471f0e69a3ed55090fc90215227fc5fb1cb0d6e962ea7b74f; // "bridgeContract"
bytes32 internal constant MEDIATOR_CONTRACT = 0x98aa806e31e94a687a31c65769cb99670064dd7f5a87526da075c5fb4eab9880; // "mediatorContract"
bytes32 internal constant REQUEST_GAS_LIMIT = 0x2dfd6c9f781bb6bbb5369c114e949b69ebb440ef3d4dd6b2836225eb1dc3a2be; // "requestGasLimit"
bytes32 internal constant NONCE = 0x7ab1577440dd7bedf920cb6de2f9fc6bf7ba98c78c85a3fa1f8311aac95e1759; // "nonce"

function initialize(
address _bridgeContract,
Expand Down Expand Up @@ -102,7 +102,7 @@ contract BasicAMBErc677ToErc677 is
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("erc-to-erc-amb")));
return 0x76595b56; // "erc-to-erc-amb"
}

function setBridgeContract(address _bridgeContract) external onlyOwner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.4.24;
import "../BasicBridge.sol";

contract BasicAMB is BasicBridge {
bytes32 internal constant MAX_GAS_PER_TX = keccak256(abi.encodePacked("maxGasPerTx"));
bytes32 internal constant MAX_GAS_PER_TX = 0x2670ecc91ec356e32067fd27b36614132d727b84a1e03e08f412a4f2cf075974; // "maxGasPerTx"

function initialize(
address _validatorContract,
Expand Down Expand Up @@ -32,7 +32,7 @@ contract BasicAMB is BasicBridge {
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("arbitrary-message-bridge-core")));
return 0x2544fbb9; // "arbitrary-message-bridge-core"
}

function maxGasPerTx() public view returns (uint256) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "../../upgradeability/EternalStorage.sol";
import "../../libraries/Bytes.sol";

contract MessageProcessor is EternalStorage {
bytes32 internal constant MESSAGE_SENDER = keccak256(abi.encodePacked("messageSender"));
bytes32 internal constant TRANSACTION_HASH = keccak256(abi.encodePacked("transactionHash"));
bytes32 internal constant MESSAGE_SENDER = 0x7b58b2a669d8e0992eae9eaef641092c0f686fd31070e7236865557fa1571b5b; // "messageSender"
bytes32 internal constant TRANSACTION_HASH = 0x7bce44346b9831b0c81437a092605c6fc51612016e2c51e62f21d829e434bcf6; // "transactionHash"

function messageCallStatus(bytes32 _txHash) external view returns (bool) {
return boolStorage[keccak256(abi.encodePacked("messageCallStatus", _txHash))];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract BasicForeignBridgeErcToErc is BasicForeignBridge {
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("erc-to-erc-core")));
return 0xba4690f5; // "erc-to-erc-core"
}

function claimTokens(address _token, address _to) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "../BlockRewardFeeManager.sol";

contract FeeManagerErcToErcPOSDAO is BlockRewardFeeManager {
function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-both-directions")));
return 0xd7de965f; // "manages-both-directions"
}

function blockRewardContract() external view returns (address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract HomeBridgeErcToErc is
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("erc-to-erc-core")));
return 0xba4690f5; // "erc-to-erc-core"
}

function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 txHash) internal returns (bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../BlockRewardBridge.sol";

contract FeeManagerErcToNative is ValidatorsFeeManager, BlockRewardBridge {
function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-both-directions")));
return 0xd7de965f; // "manages-both-directions"
}

function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../BlockRewardFeeManager.sol";

contract FeeManagerErcToNativePOSDAO is BlockRewardFeeManager {
function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-both-directions")));
return 0xd7de965f; // "manages-both-directions"
}

function distributeFeeFromBlockReward(uint256 _fee) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract ForeignBridgeErcToNative is BasicForeignBridge, ERC20Bridge {
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("erc-to-native-core")));
return 0x18762d46; // "erc-to-native-core"
}

function claimTokens(address _token, address _to) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract HomeBridgeErcToNative is
RewardableHomeBridgeErcToNative,
BlockRewardBridge
{
bytes32 internal constant TOTAL_BURNT_COINS = keccak256(abi.encodePacked("totalBurntCoins"));
bytes32 internal constant TOTAL_BURNT_COINS = 0x17f187b2e5d1f8770602b32c1159b85c9600859277fae1eaa9982e9bcf63384c; // "totalBurntCoins"

function() public payable {
nativeTransfer();
Expand Down Expand Up @@ -101,7 +101,7 @@ contract HomeBridgeErcToNative is
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("erc-to-native-core")));
return 0x18762d46; // "erc-to-native-core"
}

function blockRewardContract() public view returns (IBlockReward) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../ERC677Storage.sol";

contract FeeManagerNativeToErc is ValidatorsFeeManager, ERC677Storage {
function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-one-direction")));
return 0xf2aed8f7; // "manages-one-direction"
}

function erc677token() public view returns (IBurnableMintableERC677Token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "../ValidatorsFeeManager.sol";

contract FeeManagerNativeToErcBothDirections is ValidatorsFeeManager {
function getFeeManagerMode() external pure returns (bytes4) {
return bytes4(keccak256(abi.encodePacked("manages-both-directions")));
return 0xd7de965f; // "manages-both-directions"
}

function onAffirmationFeeDistribution(address _rewardAddress, uint256 _fee) internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract ForeignBridgeNativeToErc is
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("native-to-erc-core")));
return 0x92a8d7fe; // "native-to-erc-core"
}

function claimTokensFromErc677(address _token, address _to) external onlyIfUpgradeabilityOwner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicHomeBridge, RewardableHom
}

function getBridgeMode() external pure returns (bytes4 _data) {
return bytes4(keccak256(abi.encodePacked("native-to-erc-core")));
return 0x92a8d7fe; // "native-to-erc-core"
}

function _initialize(
Expand Down