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

Add fee manager for erc-to-erc bridge in POSDAO chain #166

Merged

Conversation

patitonar
Copy link
Contributor

Closes #160

@patitonar patitonar requested a review from akolotov April 3, 2019 17:11
@ghost ghost assigned patitonar Apr 3, 2019
@igorbarinov igorbarinov removed the review label Apr 3, 2019
uint256 _foreignDailyLimit,
uint256 _foreignMaxPerTx,
address _owner,
address _blockReward,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in common case the erc20-to-erc20 bridge mode does not require the block reward contract. Reward could be assigned directly by the fee manager. So, I think, we need to have a separate contract like POSDAOHomeBridgeErcToErc which will extend HomeBridgeErcToErc and redefine rewardableInitialize() method with another set of parameters, this contract will also contain blockRewardContract() and setBlockRewardContract().

Another idea is that blockRewardContract and setBlockRewardContract should be implemented in the fee manager since they are related to the fee distribution functionality. In this case the bridge contract should proxy calls to the fee manager contract.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added POSDAOHomeBridgeErcToErc here 8ab76b9.

Another idea is that blockRewardContract and setBlockRewardContract should be implemented in the fee manager since they are related to the fee distribution functionality. In this case the bridge contract should proxy calls to the fee manager contract.

I implemented this approach, it makes sense to manage blockReward logic on fee manager since it is related to this contract functionality.

@ghost ghost added review and removed in progress labels Apr 16, 2019
@ghost ghost added the in progress label Apr 16, 2019
Copy link
Collaborator

@akolotov akolotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding here a part of the Slack chat:

We have three possible case here

  1. Non-rewardable: ordinary bridge contract, ordinary validators contract, ordinary token contract
  2. Rewardable bridge validators: so far it is not implemented yet, so, the corresponding warning could be printed and the script could stop. But in the future it will be: rewardable bridge contract, rewardable validators contract, ordinary token contract, ordinary fee manager (edited)
  3. Reward for network validators: rewardable contract, ordinary validator contract, rewardable token contract (or corresponding configuration), the fee manager working with the block reward contract

It could be differentiated by the following parameters: HOME_REWARDABLE (if it is true, consider the cases 2 or 3) and BLOCK_REWARD_ADDRESS (if it is configured and not zero, consider the case 3).

@ghost ghost removed the in progress label Apr 17, 2019
@patitonar
Copy link
Contributor Author

@akolotov Applied logic on deployment script using HOME_REWARDABLE and BLOCK_REWARD_ADDRESS

REWARD_MANAGEMENT.md Outdated Show resolved Hide resolved
@ghost ghost added the in progress label Apr 18, 2019
@ghost ghost removed the in progress label Apr 22, 2019
if (feeManager != address(0)) {
uint256 fee = calculateFee(valueToMint, false, feeManager, FOREIGN_FEE);
distributeFeeFromAffirmation(fee, feeManager);
emit FeeDistributedFromAffirmation(fee, txHash);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need these event anymore after #176

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Updated logic here 6b25ffb

(recipient, amount, txHash, contractAddress) = Message.parseMessage(_message);
uint256 fee = calculateFee(amount, true, feeManager, HOME_FEE);
distributeFeeFromSignatures(fee, feeManager);
emit FeeDistributedFromSignatures(fee, txHash);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need these event anymore after #176

@ghost ghost added the in progress label Apr 22, 2019
@akolotov akolotov merged commit 7ee814e into 119-Epic-rewards-for-bridge-validators Apr 22, 2019
@ghost ghost removed the in progress label Apr 22, 2019
@akolotov akolotov deleted the 160-fee-erc-erc-posdao-chain branch May 21, 2019 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants