-
Notifications
You must be signed in to change notification settings - Fork 228
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
STAKE token mediators #394
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need the deployment scripts for these mediators. Take into account that the deployment must work with pre-defined token contracts on both sides.
For testing purposes consider to use the token contract from https://github.com/xdaichain/stake-token.
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
I have tested the deployment scripts. Everything seems to work fine.
|
@k1rill-fedoseev Could you please measure gas consumption for deploying Foreign contract implementations to ensure the size of the compiled contracts doesn't exceed 24 Kb? (gas cannot exceed ~6 700 000 in this case). |
For the foreign mediator implementation:
For the home mediator, the numbers are similar:
|
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/ForeignStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
contracts/upgradeable_contracts/stake_token_mediators/HomeStakeTokenMediator.sol
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patitonar Gerardo, please take a look at the changes. Since there is no information when we can get the next audit we need to review the changes carefully.
contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignStakeTokenMediator.sol
Show resolved
Hide resolved
contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignStakeTokenMediator.sol
Show resolved
Hide resolved
contracts/upgradeable_contracts/amb_erc677_to_erc677/ForeignStakeTokenMediator.sol
Show resolved
Hide resolved
*/ | ||
function executeActionOnFixedTokens(address _recipient, uint256 _value) internal { | ||
getMintHandler().mint(_recipient, _value); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question regarding executeActionOnFixedTokens
function: as far as I understand, it's used to return tokens back to sender if something is wrong when passing a message from bridge contract to mediator contract. I tried to analyze the following case (please correct me if I'm wrong somewhere):
For example, some sender Bob on Home side uses alternative receiver
feature to send tokens to Alice. He sends his tokens to Home mediator contract, so bridgeSpecificActionsOnTokenTransfer
is triggered (and the tokens are burnt on Home side) and then the message passed to Home bridge contract. Oracle catches the corresponding event, the bridge validators sign the message and request the Foreign bridge contract to pass the message to Foreign mediator contract, but _passMessage
returns false
for some reason.
Then someone calls the requestFailedMessageFix
on the Foreign mediator contract. The Foreign mediator contract in turn through the Foreign bridge contract asks for fixFailedMessage
to be called on Home side. The fixFailedMessage
calls executeActionOnFixedTokens
of the Home mediator contract which mints back the tokens for Alice (but not for Bob) on the Home side.
Is it intended behavior that in case of alternative receiver
feature the failed tokens are returned back to Alice, but not to Bob on Home side?
Should |
contracts/upgradeable_contracts/amb_erc677_to_erc677/HomeStakeTokenMediator.sol
Show resolved
Hide resolved
If I understood your question correctly, you consider the scenario when tokens (not only STAKE tokens) are being sent to a AMB bridge contract. But the AMB token contracts have no |
I mean My understanding is that if we use mediator contract, the mediator contract should accept tokens, but the bridge contract shouldn't (which is between mediator contract and oracle). Am I correct? |
The token contract communicates with the mediator, the mediator contract communicates with the bridge contract. The oracle listens events emitted by the bridge contract. |
OK, so in AMB scheme, what will happen if I send STAKE token to the bridge contract (not to the mediator contract)? Does AMB allow sending STAKE tokens to bridge contract? (not mediator one) |
When we are saying the AMB we mean the bridge contract. The AMB contracts have no |
This PR adds two smart-contracts that are intended to bridge STAKE token through AMB bridge between Mainnet and xDai chains.
From the implementation perspective, the regular
AMB-ERC677-TO-ERC677
can be used, with some slight changes.The STAKE token is supposed to have a dynamic supply in the xDai chain and a non-decreasing supply in the Mainnet chain.
Also, the configured fee will be collected for transfers in the xDai => Mainnet direction.
For that, the following bridging mechanics are being introduced:
AMB-ERC677-TO-ERC677
logic. The tokens are locked on the mediator contract in the Mainnet and then minted in the xDai chain.blockReward.addBridgeTokenRewardReceivers(fee)
is called. The collected fee will be distributed between validators later in the consensus contract.