Skip to content

Commit

Permalink
refactor(erc20_to_native): rn _txHash into _nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
allemanfredi committed Jun 18, 2024
1 parent fd7d5d3 commit acfdfed
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions contracts/upgradeable_contracts/MessageRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pragma solidity 0.4.24;
import "../upgradeability/EternalStorage.sol";

contract MessageRelay is EternalStorage {
function relayedMessages(bytes32 _txHash) public view returns (bool) {
return boolStorage[keccak256(abi.encodePacked("relayedMessages", _txHash))];
function relayedMessages(bytes32 _nonce) public view returns (bool) {
return boolStorage[keccak256(abi.encodePacked("relayedMessages", _nonce))];
}

function setRelayedMessages(bytes32 _txHash, bool _status) internal {
boolStorage[keccak256(abi.encodePacked("relayedMessages", _txHash))] = _status;
function setRelayedMessages(bytes32 _nonce, bool _status) internal {
boolStorage[keccak256(abi.encodePacked("relayedMessages", _nonce))] = _status;
}
}
12 changes: 6 additions & 6 deletions contracts/upgradeable_contracts/RewardableBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,25 @@ contract RewardableBridge is Ownable, FeeTypes {
* @dev Internal function for distributing the fee for collecting sufficient amount of signatures.
* @param _fee amount of fee to distribute.
* @param _feeManager address of the fee manager contract.
* @param _txHash reference transaction hash where the original bridge request happened.
* @param _nonce reference to the nonce generated on the Foreign side.
*/
function distributeFeeFromSignatures(uint256 _fee, address _feeManager, bytes32 _txHash) internal {
function distributeFeeFromSignatures(uint256 _fee, address _feeManager, bytes32 _nonce) internal {
if (_fee > 0) {
require(_feeManager.delegatecall(abi.encodeWithSelector(DISTRIBUTE_FEE_FROM_SIGNATURES, _fee)));
emit FeeDistributedFromSignatures(_fee, _txHash);
emit FeeDistributedFromSignatures(_fee, _nonce);
}
}

/**
* @dev Internal function for distributing the fee for collecting sufficient amount of affirmations.
* @param _fee amount of fee to distribute.
* @param _feeManager address of the fee manager contract.
* @param _txHash reference transaction hash where the original bridge request happened.
* @param _nonce reference to the nonce generated on the Foreign side.
*/
function distributeFeeFromAffirmation(uint256 _fee, address _feeManager, bytes32 _txHash) internal {
function distributeFeeFromAffirmation(uint256 _fee, address _feeManager, bytes32 _nonce) internal {
if (_fee > 0) {
require(_feeManager.delegatecall(abi.encodeWithSelector(DISTRIBUTE_FEE_FROM_AFFIRMATION, _fee)));
emit FeeDistributedFromAffirmation(_fee, _txHash);
emit FeeDistributedFromAffirmation(_fee, _nonce);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract ForeignBridgeErcToNative is ERC20Bridge, OtherSideBridgeStorage {
function onExecuteMessage(
address _recipient,
uint256 _amount,
bytes32 /*_txHash*/
bytes32 /*_nonce*/
) internal returns (bool) {
addTotalExecutedPerDay(getCurrentDay(), _amount);
return erc20token().transfer(_recipient, _unshiftValue(_amount));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ contract HomeBridgeErcToNative is
* Should be called only after enough affirmations from the validators are already collected.
* @param _recipient address of the receiver where the new coins should be minted.
* @param _value amount of coins to mint.
* @param _txHash reference transaction hash on the Foreign side of the bridge which cause this operation.
* @param _nonce reference to the nonce generated on the Foreign side.
* @param _hashMsg unique identifier of the particular bridge operation.
* @return true, if execution completed successfully.
*/
function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 _txHash, bytes32 _hashMsg)
function onExecuteAffirmation(address _recipient, uint256 _value, bytes32 _nonce, bytes32 _hashMsg)
internal
returns (bool)
{
Expand All @@ -185,7 +185,7 @@ contract HomeBridgeErcToNative is
address feeManager = feeManagerContract();
if (feeManager != address(0)) {
uint256 fee = calculateFee(valueToMint, false, feeManager, FOREIGN_FEE);
distributeFeeFromAffirmation(fee, feeManager, _txHash);
distributeFeeFromAffirmation(fee, feeManager, _nonce);
valueToMint = valueToMint.sub(fee);
}
blockReward.addExtraReceiver(valueToMint, _recipient);
Expand Down Expand Up @@ -215,14 +215,14 @@ contract HomeBridgeErcToNative is
* This function saves the bridge operation information for further processing.
* @param _recipient address of the receiver where the new coins should be minted.
* @param _value amount of coins to mint.
* @param _txHash reference transaction hash on the Foreign side of the bridge which cause this operation.
* @param _nonce reference to the nonce generated on the Foreign side.
* @param _hashMsg unique identifier of the particular bridge operation.
*/
function onFailedAffirmation(address _recipient, uint256 _value, bytes32 _txHash, bytes32 _hashMsg) internal {
function onFailedAffirmation(address _recipient, uint256 _value, bytes32 _nonce, bytes32 _hashMsg) internal {
(address recipient, uint256 value) = txAboveLimits(_hashMsg);
require(recipient == address(0) && value == 0);
setOutOfLimitAmount(outOfLimitAmount().add(_value));
setTxAboveLimits(_recipient, _value, _hashMsg);
emit AmountLimitExceeded(_recipient, _value, _txHash, _hashMsg);
emit AmountLimitExceeded(_recipient, _value, _nonce, _hashMsg);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract XDaiForeignBridge is ForeignBridgeErcToNative, SavingsDaiConnector, GSN
function onExecuteMessage(
address _recipient,
uint256 _amount,
bytes32 /*_txHash*/
bytes32 /*_nonce*/
) internal returns (bool) {
addTotalExecutedPerDay(getCurrentDay(), _amount);

Expand Down
2 changes: 1 addition & 1 deletion test/foundry/interfaces/IXDaiForeignBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface IXDaiForeignBridge {
function previewWithdraw(address _token, uint256 _amount) external view returns (uint256);
function refillBridge() external;
function relayTokens(address _receiver, uint256 _amount) external;
function relayedMessages(bytes32 _txHash) external view returns (bool);
function relayedMessages(bytes32 _nonce) external view returns (bool);
function requiredBlockConfirmations() external view returns (uint256);
function requiredSignatures() external view returns (uint256);
function sDaiToken() external pure returns (address);
Expand Down

0 comments on commit acfdfed

Please sign in to comment.